1. 使能base命令
通过定义:CONFIG_CMD_MEMORY, 就可以使能base命令。
注:由于在include/config_cmd_default.h里面已经有此定义,在板子相关的configure文件中(位于include/configs/),默认情况下,都会include此文件。所以,u-boot默认会包含此命令。
源代码:common/cmd_mem.c
2. Usage
base – print or set address offset
例:
2.1 print address offset
U-Boot base
Base Address: 0x00000000
2.2 set address offset
U-Boot base 0x20000000
Base Address: 0x20000000
U-Boot base
Base Address: 0x20000000
注:此命令会对md命令进行影响,具体参见md命令。
3.源代码分析
do_mem_base
|– if (argc 1) // set new base address
|– base_address = simple_strtoul(argv[1], NULL, 16); // 注:base_address是全局变量:static ulong base_address = 0;
|– printf(“Base Address: 0x%08lx
“, base_address);
|– return 0;
4. QA: