u-boot移植问题记录(一)--U_BOOT_CMD区别

我使用的是最新的u-boot版本(2013-10-rc3),你想下载的话可以去u-boot官网下载(http://www.denx.de/wiki/U-Boot/WebHome),推荐使用git下载,这样方便你时刻与最新版本保持更新。

我会时刻记录下在移植中的一些问题和我自己的解决方案,作为参考,我借鉴了2011-03这个版本的u-boot,当然二者之间还是有不同,我也会将这些差异记录下来,方便后来者参考。

U_BOOT_CMD:定义于include/command.h

在2011-03的版本是这么定义:

 

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

#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)


__u_boot_cmd_start = .;
 .u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;

在2013-10-rc3的最新u-boot版本中,对此有改动,我们先看定义(include/command.h)

#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) \
    ll_entry_declare(cmd_tbl_t, _name, cmd) = \
    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 ll_entry_declare(_type, _name, _list) \
     _type _u_boot_list_2_##_list##_2_##_name __aligned(4) \
     __attribute__((unused, \
     section(".u_boot_list_2_"#_list"_2_"#_name)))


看上去挺复杂的,其实就是将cmd放在了u_boot_list这类开头的section里,所以我们只需在u-boot.lds里添加:

. = ALIGN(4);
.u_boot_list : {
 KEEP(*(SORT(.u_boot_list*)));
}

查看下System.map,我们的命令原来长这个样子:

 0541df64 D _u_boot_list_2_cmd_2_bdinfo
 0541df80 D _u_boot_list_2_cmd_2_boot
 0541df9c D _u_boot_list_2_cmd_2_bootd
 0541dfb8 D _u_boot_list_2_cmd_2_bootelf
 0541dfd4 D _u_boot_list_2_cmd_2_bootm
 0541dff0 D _u_boot_list_2_cmd_2_bootp
 0541e00c D _u_boot_list_2_cmd_2_bootvx
 0541e028 D _u_boot_list_2_cmd_2_cmp
 0541e044 D _u_boot_list_2_cmd_2_coninfo
 0541e060 D _u_boot_list_2_cmd_2_cp
 0541e07c D _u_boot_list_2_cmd_2_crc32


这样的话我们输入的命令就能正常被解析识别了,折腾了不少时间,看来还得仔细看看其中的区别。


转载于:https://my.oschina.net/u/2007478/blog/422737

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值