u-boot中的version命令

[u-boot: v2013.04]

[Author: Bo Shen <voice.shen@gmail.com>]


1. Source Code

     <common/cmd_version.c>


2. Usage

U-Boot > help version

version - print monitor version

U-boot > version

U-Boot 2013.04 (May 11 2013 - 18:08:59)
arm-none-linux-gnueabi-gcc (Sourcery CodeBench Lite 2012.09-64) 4.7.2
GNU ld (Sourcery CodeBench Lite 2012.09-64) 2.23.51.20120829


3. Source code go through

const char __weak version_string[] = U_BOOT_VERSION_STRING;

static int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	printf("\n%s\n", version_string);
#ifdef CC_VERSION_STRING
	puts(CC_VERSION_STRING "\n");
#endif
#ifdef LD_VERSION_STRING
	puts(LD_VERSION_STRING "\n");
#endif
#ifdef CONFIG_SYS_COREBOOT
	printf("coreboot-%s (%s)\n", lib_sysinfo.version, lib_sysinfo.build);
#endif
	return 0;
}
其中, U_BOOT_VERSION_STRING在< include/version.h>定义:

#define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
        U_BOOT_TIME ")" CONFIG_IDENT_STRING
U_BOOT_VERSION, CC_VERSION_STRING, LD_VERSION_STRING: 定义在< include/generated/version_autogenerated.h>此文件通过名字可以看出是自动生成的。其具体生成代码在顶层目录中的Makefile里面。代码如下:

$(VERSION_FILE):
                @mkdir -p $(dir $(VERSION_FILE))
                @( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
                   printf '#define PLAIN_VERSION "%s%s"\n' \
                        "$(U_BOOT_VERSION)" "$${localvers}" ; \
                   printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
                        "$(U_BOOT_VERSION)" "$${localvers}" ; \
                ) > $@.tmp
                @( printf '#define CC_VERSION_STRING "%s"\n' \
                 '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp
                @( printf '#define LD_VERSION_STRING "%s"\n' \
                 '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp
                @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值