X-008-UBOOT-支持命令行(Bubblegum-96平台)
作者:wowo 发布于:2016-7-27 21:41 分类:X Project
1. 前言
经过前面文章的铺垫,u-boot command line的支持已经成了一个顺理成章的事情了。因此,本文没有太多技术细节,仅仅记录支持命令行的实现过程,权当“X Project” “【任务2】启动到u-boot command line”的一个完结。
2. 支持命令行的过程
由“X-007-UBOOT-DDR的初始化(Bubblegum-96平台)”的描述可知,我们已经成功初始化DDR,并将u-boot放到DDR中执行,基于该成果,我们进一步调试命令行功能。
2.1 修改版型的配置头文件,将u-boot的DEBUG功能打开,以便得到更多的打印信息
pengo@ubuntu:~/work/xprj/u-boot$ git diff
diff --git a/include/configs/bubblegum.h b/include/configs/bubblegum.h
index 6ee4227..5f22528 100644
--- a/include/configs/bubblegum.h
+++ b/include/configs/bubblegum.h
@@ -10,7 +10,7 @@
#ifndef __BUBBLEGUM_H
#define __BUBBLEGUM_H
-#define DEBUGX
+#define DEBUG
2.2 根据“X-007-UBOOT-DDR的初始化(Bubblegum-96平台)”所提示的步骤,运行u-boot,得到如下的错误信息。
initcall: 0000000011003180
U-Boot code: 11000000 -> 11014E30 BSS: -> 11014F38
initcall: 0000000011002fc8
initcall: 000000001100321c
DRAM: initcall: 0000000011002834
dram_init
dram_init OK
initcall: 0000000011003484
Monitor len: 00014F38
Ram size: FFFFFFFF80000000
Ram top: FFFFFFFF80000000
initcall: 0000000011002ff8
initcall: 00000000110031b4
TLB table from ffffffff7fff0000 to ffffffff7fff6000
initcall: 000000001100300c
initcall: 0000000011003130
Reserving 83k for U-Boot at: ffffffff7ffdb000
initcall: 00000000110030fc
Reserving 24k for malloc() at: ffffffff7ffd5000
initcall: 0000000011003354
"Synchronous Abort" handler, esr 0x96000040
ELR: 1100b684
LR: 11003384
x0 : ffffffff7ffd4f68 x1 : 0000000000000000
x2 : 0000000000000098 x3 : 0000000000000000
x4 : 0000000000000000 x5 : 0000000000000098
x6 : 0000000000000000 x7 : 0000000000000004
x8 : 0000000000000031 x9 : 0000000000000000
x10: 000000000000000f x11: 000000000007f468
x12: 000000001100d0d8 x13: 000000000000003c
x14: 0000000000000001 x15: 0000000000000008
x16: 0000000000000008 x17: 0000000000000000
x18: 000000000007f990 x19: 0000000011011c70
x20: 0000000011011ba0 x21: 0000000000000000
x22: 0000000011011286 x23: 000000001101185b
x24: 0000000011011293 x25: 0000000080000000
x26: 0000000000000010 x27: 0000002000000000
x28: 000000000000000c x29: 000000000007f930
Resetting CPU ...
resetting ...
2.3 分析错误信息
由上面黄色位置的信息可以推测,应该是reserve_malloc后面的那个init call出问题了,查一下代码:
#ifndef CONFIG_SPL_BUILD
reserve_malloc,
reserve_board,
#endif
reserve_malloc后面的函数是reserve_board:
/* (permanently) allocate a Board Info struct */
static int reserve_board(void)
{
if (!gd->bd) {
gd->start_addr_sp -= sizeof(bd_t);
gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
memset(gd->bd, '\0', sizeof(bd_t));
debug("Reserving %zu Bytes for Board Info at: %08lx\n",
sizeof(bd_t), gd->start_addr_sp);
}
return 0;
}
start_addr_sp不对?再看一下上面的日志输出:
Ram size: FFFFFFFF80000000
Ram top: FFFFFFFF80000000
RAM size不对?回忆一下编译过程,有个编译错误:
/home/pengo/work/xprj/u-boot/board/actions/bubblegum/board.c:136:33: warning: integer overflow in expression [-Woverflow]
代码136行对ram_size的赋值如下:
gd->ram_size = 2 * 1024 * 1024 * 1024; /* 2GB, TODO */
会溢出?先不纠结,先把这个问题修复再说。
2.4 修改ram_size的赋值,避免溢出
diff --git a/board/actions/bubblegum/board.c b/board/actions/bubblegum/board.c
index 81472a4..ea6fddc 100755
--- a/board/actions/bubblegum/board.c
+++ b/board/actions/bubblegum/board.c
@@ -133,7 +133,7 @@ int dram_init(void)
/* no need do dram init in here, we have done it in SPL */
- gd->ram_size = 2 * 1024 * 1024 * 1024; /* 2GB, TODO */
+ gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
printf("dram_init OK\n");
return 0;
diff --git a/include/configs/bubblegum.h b/include/configs/bubblegum.h
/*
* u-boot SPL definitions, which is resided in SRAM
@@ -33,6 +33,8 @@
#define CONFIG_SYS_SDRAM_BASE 0x0
#define CONFIG_NR_DRAM_BANKS 1
+#define CONFIG_SYS_SDRAM_SIZE 0x3FFFFFFF
+
暂时使用一个安全的值,后面再完善。编译重新运行后,出现如下的输出:
…
Initial value for argc=3
Final value for argc=3
initcall: 00000000110024c4 (relocated to 000000003ffdd4c4)
initcall: 00000000110035d0 (relocated to 000000003ffde5d0)
initcall: 00000000110035c0 (relocated to 000000003ffde5c0)
fdtdec_get_config_string: bootcmd
fdtdec_get_config_int: bootsecure
## U-Boot command line is disabled. Please enable CONFIG_CMDLINE
No CLI available
resetting ...
OK,一切正常了,只不过由于没有定义CONFIG_CMDLINE,无法进入命令行。打开相应的配置即可。
2.5 配置命令行功能
配置u-boot,开启命令行有关的配置项包括:
Command line interface --->
[*] Support U-Boot commands
([xprj]# ) Shell prompt
Info commands --->
[*] bdinfo
[*] coninfo
修改后的配置文件为:
pengo@ubuntu:~/work/xprj/u-boot$ git diff configs/bubblegum_defconfig
diff --git a/configs/bubblegum_defconfig b/configs/bubblegum_defconfig
index 85a488d..bc0c5f7 100644
--- a/configs/bubblegum_defconfig
+++ b/configs/bubblegum_defconfig
@@ -198,8 +198,9 @@ CONFIG_BOOTSTAGE_STASH_SIZE=4096
#
# Command line interface
#
-# CONFIG_CMDLINE is not set
-CONFIG_SYS_PROMPT="=> "
+CONFIG_CMDLINE=y
+# CONFIG_HUSH_PARSER is not set
+CONFIG_SYS_PROMPT="[xprj]# "
#
# Autoboot options
@@ -213,8 +214,8 @@ CONFIG_SYS_PROMPT="=> "
#
# Info commands
#
-# CONFIG_CMD_BDI is not set
-# CONFIG_CMD_CONSOLE is not set
+CONFIG_CMD_BDI=y
+CONFIG_CMD_CONSOLE=y
# CONFIG_CMD_CPU is not set
# CONFIG_CMD_LICENSE is not set
再次编译并运行u-boot,OK了,如下:
[xprj]# help
? - alias for 'help'
bdinfo - print Board Info structure
coninfo - print console devices and information
dm - Driver model low level access
env - environment handling commands
help - print command description/usage
printenv- print environment variables
reset - Perform RESET of the CPU
setenv - set environment variables
version - print monitor, compiler and linker version
[xprj]# bdinfo
arch_number = 0x00000000
boot_params = 0x00000000
DRAM bank = 0x00000000
-> start = 0x00000000
-> size = 0x3FFFFFFF
baudrate = 115200 bps
TLB addr = 0x3FFF0000
relocaddr = 0x3FFD8000
reloc off = 0x2EFD8000
irq_sp = 0x3FFD0BD0
sp start = 0x3FFD0BD0
以上改动,可参考如下patch:
https://github.com/wowotechX/u-boot/commit/7cc2bd4716bb095925eb6e2c3e43cef157cf40d4
原创文章,转发请注明出处。蜗窝科技,www.wowotech.net。

评论:
2018-09-13 22:11
2018-09-13 13:49
功能
最新评论
- wangjing
写得太好了 - wangjing
写得太好了! - DRAM
圖面都沒辦法顯示出來好像掛點了。 - Simbr
bus至少是不是还有个subsystem? - troy
@testtest:只要ldrex-modify-strex... - gh
Linux 内核在 sparse 内存模型基础上实现了vme...
文章分类
随机文章
文章存档
- 2025年4月(5)
- 2024年2月(1)
- 2023年5月(1)
- 2022年10月(1)
- 2022年8月(1)
- 2022年6月(1)
- 2022年5月(1)
- 2022年4月(2)
- 2022年2月(2)
- 2021年12月(1)
- 2021年11月(5)
- 2021年7月(1)
- 2021年6月(1)
- 2021年5月(3)
- 2020年3月(3)
- 2020年2月(2)
- 2020年1月(3)
- 2019年12月(3)
- 2019年5月(4)
- 2019年3月(1)
- 2019年1月(3)
- 2018年12月(2)
- 2018年11月(1)
- 2018年10月(2)
- 2018年8月(1)
- 2018年6月(1)
- 2018年5月(1)
- 2018年4月(7)
- 2018年2月(4)
- 2018年1月(5)
- 2017年12月(2)
- 2017年11月(2)
- 2017年10月(1)
- 2017年9月(5)
- 2017年8月(4)
- 2017年7月(4)
- 2017年6月(3)
- 2017年5月(3)
- 2017年4月(1)
- 2017年3月(8)
- 2017年2月(6)
- 2017年1月(5)
- 2016年12月(6)
- 2016年11月(11)
- 2016年10月(9)
- 2016年9月(6)
- 2016年8月(9)
- 2016年7月(5)
- 2016年6月(8)
- 2016年5月(8)
- 2016年4月(7)
- 2016年3月(5)
- 2016年2月(5)
- 2016年1月(6)
- 2015年12月(6)
- 2015年11月(9)
- 2015年10月(9)
- 2015年9月(4)
- 2015年8月(3)
- 2015年7月(7)
- 2015年6月(3)
- 2015年5月(6)
- 2015年4月(9)
- 2015年3月(9)
- 2015年2月(6)
- 2015年1月(6)
- 2014年12月(17)
- 2014年11月(8)
- 2014年10月(9)
- 2014年9月(7)
- 2014年8月(12)
- 2014年7月(6)
- 2014年6月(6)
- 2014年5月(9)
- 2014年4月(9)
- 2014年3月(7)
- 2014年2月(3)
- 2014年1月(4)
2018-09-16 19:14