Chinaunix首页 | 论坛 | 博客
  • 博客访问: 80897
  • 博文数量: 19
  • 博客积分: 575
  • 博客等级: 中士
  • 技术积分: 203
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-03 20:06
个人简介

好好学习,天天向上

文章分类

全部博文(19)

分类: LINUX

2011-03-17 13:15:22

添加新命令的方法:
(1)定义命令。在include/cmd_confdefs.h中定义新命令的标志位,注意不要和别的命令重复了。

#define CFG_CMD_MYTEST 0x8000000000000000ULL


(2)实现命令的操作函数,保存在common目录下面,以cmd_开头,如下cmd_test.c
#include
#include
#if (CONFIG_COMMANDS & CFG_CMD_CACHE)

int do_mytest ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{    
printf("just a test\n");
return 0;
}
……
U_Boot_CMD( //通过宏定义命令
    mytest,   1,   0,     do_mytest,  //命令为mytest,命令执行函数为do_mytest()
    "mytest",   //帮助信息
    "mytest\n"
);
#endif

(3)在板子支持包中添加定义,比如在include/configs/orign.h里

#define CONFIG_COMMANDS \
                 (CONFIG_CMD_DFL  | \
                 CFG_CMD_CACHE     | \
                 CFG_CMD_REGINFO    | \
                 CFG_CMD_DATE      | \
                 CFG_CMD_ELF | CFG_CMD_MYTEST)

按照这3步,就能添加新的U-Boot命令。
阅读(2191) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~