uboot命令的实现
1->输入字符串(name)
2->这些字符串就会产生动作,根据不同的名字,产生不同的动作(函数)
最简单的办法是做一个结构体,有名字和对应的处理函数:
cmd_tabl_t 结构体
typedef struct cmd_tbl_s cmd_tbl_t;
在uboot上增加命令实践
1)eg:增加命令 ,新建文件cmd_hello.c仿照cmd_boom.c,头文件照用 ==》 在uboot的common目录里面
int do_hello(cmd_tbl_t *cmdtp ,int flag,int argc,char *argv[])
{
int i;
print(“hello,word!,%d\n”,argc);
for(i=0;i<argc;i++)
{
printf("argv[%d]; %s\n ",i,argv[i]);
}
return 0;
}
U_BOOT_CMD(
hello,CFG_MAXARGS, 1, do_hello,
“hello -jus for test \n”,
“helloo,long help …\n”
)
2)在 COMMON里面的Makefile 上增加cmd_hello.o,
3)make ,增加新文件不需要make disclean也可以