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
- constchar__weakversion_string[]=U_BOOT_VERSION_STRING;
- staticintdo_version(cmd_tbl_t*cmdtp,intflag,intargc,char*constargv[])
- {
- printf(”
%s
“,version_string); - #ifdefCC_VERSION_STRING
- puts(CC_VERSION_STRING”
“); - #endif
- #ifdefLD_VERSION_STRING
- puts(LD_VERSION_STRING”
“); - #endif
- #ifdefCONFIG_SYS_COREBOOT
- printf(“coreboot-%s(%s)
“,lib_sysinfo.version,lib_sysinfo.build); - #endif
- return0;
- }
其中,U_BOOT_VERSION_STRING在include/version.h定义:
- #defineU_BOOT_VERSION_STRINGU_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’#definePLAIN_VERSION”%s%s”
’ - “$(U_BOOT_VERSION)”“$${localvers}”;
- printf’#defineU_BOOT_VERSION”U-Boot%s%s”
’ - “$(U_BOOT_VERSION)”“$${localvers}”;
- )$@.tmp
- @(printf’#defineCC_VERSION_STRING”%s”
’ - ’$(shell$(CC)–version|head-n1)’)$@.tmp
- @(printf’#defineLD_VERSION_STRING”%s”
’ - ’$(shell$(LD)-v|head-n1)’)$@.tmp
- @cmp-s$@$@.tmprm-f$@.tmp||mv-f$@.tmp$@