歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

u-boot中的version命令

[u-boot: v2013.04]

[Author: Bo Shen [email protected]]

1. Source Code

<common/cmd_version.c>

2. Usage

U-Boot > help version

version - print monitor version

U-boot > version

U-Boot 2013.04-00085-g5ed6f44

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}" ; \
                ) > [email protected]
                @( printf '#define CC_VERSION_STRING "%s"\n' \
                '$(shell $(CC) --version | head -n 1)' )>>  [email protected]
                @( printf '#define LD_VERSION_STRING "%s"\n' \
                '$(shell $(LD) -v | head -n 1)' )>>  [email protected]
                @cmp -s $@ [email protected] && rm -f [email protected] || mv -f [email protected] $@

Copyright © Linux教程網 All Rights Reserved