U-boot中怎么添加命令选项

简介:

在command.h中分析命令结构


/* 这是定义一个结构的属性,将其放在.u_boot_cmd这个段当中,相当于.data/.bss这些段 */
#define Struct_Section  __attribute__ ((unused,section (".u_boot_cmd")))   
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help)
 cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
这样一来,凡通过U_BOOT_CMD定义的cmd_tbl_t变量会全部被放在.u_boot_cmd段当中(可以看UBOOT的链接脚本xxx.lds),具体怎么放是链接器的工作。
name :  命令的名字
maxargs:最大的参数
rep:是否可重复发命令
usage:短帮助信息
help:长帮助信息


增加一个hello命令,具体格式如下:把这个hello_common.c放在commoc文件夹下面
/*参考cmd_bootm.c文件*/
#include <common.h>
#include <watchdog.h>
#include <command.h>
#include <image.h>
#include <malloc.h>
#include <u-boot/zlib.h>
#include <bzlib.h>
#include <environment.h>
#include <lmb.h>
#include <linux/ctype.h>
#include <asm/byteorder.h>


int do_hello (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
  printf("hello world!\n");
  return 0;
}


U_BOOT_CMD(
hello,CONFIG_SYS_MAXARGS,1,do_hello,
"just for test"
"boot application image from memory",
);
目录
相关文章
|
9月前
|
Java 数据库连接 Spring
Spring Boot命令行启动添加参数
Spring Boot命令行启动添加参数
310 0
|
3月前
|
Web App开发 存储
测试使用选项
Playwright 测试使用选项
34 1
|
7月前
|
Linux
Linux02---命令基础 Linux命令基础, ls命令入门,ls命令参数和选项,命令行是一种以纯字符操作系统的方式,command命令本身,options命令的细节行为,parameter命令的
Linux02---命令基础 Linux命令基础, ls命令入门,ls命令参数和选项,命令行是一种以纯字符操作系统的方式,command命令本身,options命令的细节行为,parameter命令的
|
9月前
|
存储
201403-3 命令行选项
201403-3 命令行选项
|
9月前
|
Java Shell API
通用Shell脚本执行Spring Boot项目Jar包
通用Shell脚本执行Spring Boot项目Jar包
|
9月前
|
存储 Linux
U-Boot 命令解析(二)
U-Boot 命令解析(二)
130 0
|
9月前
|
Linux 内存技术
U-Boot 命令解析(一)
U-Boot 命令解析(一)
153 0
|
9月前
|
Ubuntu Linux 开发工具
U-Boot 中使用 nfs 命令加载文件报错指南
U-Boot 中使用 nfs 命令加载文件报错指南
392 0
|
9月前
|
Shell Linux C语言
【Shell 命令集合 系统设置 内建命令】Linux 启用或禁用指定的shell内建命令 enable命令 使用指南
【Shell 命令集合 系统设置 内建命令】Linux 启用或禁用指定的shell内建命令 enable命令 使用指南
112 0
|
存储 缓存 监控
启动选项和系统变量
启动选项和系统变量
169 0