自己添加命令:
step1:添加宏定义即命令标志位,在include文件夹下的config_cmd_all.h和
config_cmd_default.h中加入一行#define CONFIG_CMD_TEST。
step2:编写自己的命令,如下:在common文件夹中新建my_test.c,内容为:
#include <common.h>
#include <command.h>
#if defined(CONFIG_CMD_TEST)
static int do_myTest(void)
{
printf("I'm do_myTest\n");
return 0;
}
U_BOOT_CMD(
myTest, 2, 1, do_myTest,
"myTest -have a test of add CMD\n",
"[on off]\n"
" -test of it\n"
);
#endif
保存。
step3:修改common下的Makefile添加要编译的目标文件,如下加入:COBJS-
$(CONFIG_CMD_TEST) += cmd_test.o
step4:最后就是编译了,在编译前一定要make distclean一下否则出错!
启动进入u-boot用help即可看见自己的命令了。
myTest -have a test of add CMD
输入help myTest:
[bootloader@u-boot] # help myTest
myTest [on off]
-test of it
运行:myTest:
[bootloader@u-boot] # myTest
I'm do_myTest
ok!结束。。。