uboot 添加hello命令

简介: <p style="margin-top:0pt; margin-bottom:0pt">平台:MPC8315(POWERPC)</p> <p style="margin-top:0pt; margin-bottom:0pt"><br></p> <p style="margin-top:0pt; margin-bottom:0pt"><span>1.</span><span>在<spa

平台:MPC8315(POWERPC)


1./common/ 目录下创建自己的文件,最好前缀为cmd_. 


 cmd_hello.c

*********************************************************

#include<command.h>

#include<common.h>

#ifdef CONFIG_CMD_HELLO

int do_hello(cmd_tbl_t *cmdtp,int flag,int argc,char *argv)

{

        printf("my test \n");

        return 0;

}

U_BOOT_CMD(

hello,1,0,do_hello,"usage:test\n","help:test\n"

);

#endif

*********************************************************

2.在当前目录下修改Makefile


 在目标变量最后面添加:


#ifdef CONFIG_CMD_HELLO 

COBJS-y += cmd_hello.o

#endif


3.在头文件mpc83xx.h中添加对CONFIG_CMD_HELLO的定义

#define CONFIG_CMD_HELLO


编译下载后,在uboot中运行hello

4.U_BOOT_CMD


它的定义在include/command.h中,

/**********************************************************/

#define Struct_Section  __attribute__((unused, section(".u_boot_cmd"), aligned(4)))


#define U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \

        {#name, maxargs, rep, cmd, usage, _CMD_HELP(help) _CMD_COMPLETE(comp)}


#define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \

        cmd_tbl_t __u_boot_cmd_##name Struct_Section = \

            U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)


#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \

        U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)

/*******************************************************/

展开就是:#define U_BOOT_CMD(hello,1,0,do_hello,"usage:test\n","help:test\n") 

cmd_tbl_t __u_boot_cmd_hello __attribute__((unused, section(".u_boot_cmd"), aligned(4)))

 = {hello, 1, 0, do_hello, "usage:test\n","help:test\n" }


这儿定义了属性,就是所有的命令都存储在.u_boot_cmd节中,可以在连接脚本找到这个节。

相关文章
|
3月前
|
存储 安全 Linux
UBoot怎么跳转到Kernel:uboot与linux的交界
UBoot怎么跳转到Kernel:uboot与linux的交界
50 0
|
C语言 内存技术
PowerPC下uboot命令
PowerPC下uboot命令
93 0
uboot命令添加记录
uboot命令添加记录
91 0
uboot命令添加记录
|
内存技术
判断uboot启动方式:norflash还是nandflash
判断uboot启动方式:norflash还是nandflash
146 0
判断uboot启动方式:norflash还是nandflash
|
存储 Linux 内存技术
uboot环境变量和硬件驱动
uboot环境变量和硬件驱动
380 0
|
Linux 内存技术
uboot设置bootargs启动根文件系统
uboot设置bootargs启动根文件系统
|
开发工具
Hi3516开发笔记(六):通过HiTools使用USB/串口将uboot、kernel、rootfs和userdata按照分区表烧写镜像
Hi3516开发笔记(六):通过HiTools使用USB/串口将uboot、kernel、rootfs和userdata按照分区表烧写镜像
Hi3516开发笔记(六):通过HiTools使用USB/串口将uboot、kernel、rootfs和userdata按照分区表烧写镜像