u-boot添加一个hello命令

1、在common目录下建立一个cmd_hello.c文件

2、仿照/common/cmd_bootm.c文件修改,把cmd_bootm.c头文件复制过来

3、再复制do_bootm、U_BOOT_CMD函数过来

4、代码如下:

#include <common.h>
#include <watchdog.h>
#include <command.h>
#include <image.h>
#include <malloc.h>
#include <zlib.h>
#include <bzlib.h>
#include <environment.h>
#include <asm/byteorder.h>

int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{

    int i;

    printf("hello,world!,%d ",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 - just for test ",

 "hello ,long help............................ "
);

5、修改common目录下的Makefile文件,添加cmd_hello.o

原文地址:https://www.cnblogs.com/yihujiu/p/5452070.html