問題描述:
平台:H3
SDK: OpenWRT
u-boot 版本 :u-boot-2017.11
u-boot 加載核心時卡在了 Starting kernel …
HDMI present but not probed
No active display present
## Transferring control to Linux (at address 40008000)...
Starting kernel ...
排查過程:
1.更換大容量DDR 可正常啟動,初步懷疑是記憶體不夠。
2.mtest 測試記憶體讀寫
=> mtest 40000000 41f00000
Testing 40000000 ... 41f00000:
Iteration: 1
Pattern 00000000 Writing... Reading...Iteration: 2
=> mtest 41f00000 48000000
Testing 41f00000 ... 48000000:
Iteration: 1
Pattern 00000000 Writing...
發現 41f00000 以上的記憶體位址不能正常讀寫。意味着隻有0x1f00000 (31 MB) 記憶體可用。顯然不夠核心使用。為什麼會這樣呢?總共不是128MB 嗎?剩下的96MB用來幹嘛了呢?
3.開啟DEBUG 宏,打開調試列印。
U-Boot 2017.11 (Aug 16 2018 - 07:51:15 +0000) Allwinner Technology
initcall: 4a00b889
U-Boot code: 4A000000 -> 4A050A48 BSS: -> 4A08E49C
initcall: 4a001625
CPU: Allwinner H3 (SUN8I 1680)
initcall: 4a00bc85
Model: H3-DB-V1
initcall: 4a00b985
DRAM: initcall: 4a001c3d
initcall: 4a00ba5d
Monitor len: 0008E49C
Ram size: 08000000
Ram top: 48000000
initcall: 4a00b715
initcall: 4a00b749
TLB table from 47ff0000 to 47ff4000
initcall: 4a00b965
video_reserve: Reserving 1ff0000 bytes at 46000000 for video device 'sunxi_de2'
Video frame buffers from 46000000 to 47ff0000
initcall: 4a00b729
initcall: 4a00b849
Reserving 569k for U-Boot at: 45f71000
initcall: 4a00b81d
Reserving 65596k for malloc() at: 41f62000
initcall: 4a00b92d
Reserving 80 Bytes for Board Info at: 41f61fb0
initcall: 4a00b9cb
initcall: 4a00b7f5
Reserving 208 Bytes for Global Data at: 41f61ee0
initcall: 4a00b7a5
Reserving 16736 Bytes for FDT at: 41f5dd80
initcall: 4a00b9cf
initcall: 4a00b9db
initcall: 4a00bab9
initcall: 4a00b72d
initcall: 4a00b9e5
RAM Configuration:
Bank #0: 40000000 128 MiB
DRAM: 128 MiB
initcall: 4a00b791
New Stack Pointer is: 41f5dd60
...

發現 uboot 保留記憶體裡 給vedio 和 malloc 保留了比較大的記憶體空間 vedio 31M malloc 64M 。
跟蹤代碼:
在u-boot-2017.11\common\board_f.c 裡
取消 reserve_video 隻要關閉 CONFIG_DM_VIDEO
減少 reserve_malloc 需要修改 CONFIG_SYS_MALLOC_LEN 宏
嘗試解決辦法:
-
關閉 CONFIG_DM_VIDEO
u-boot-2017.11\arch\arm\mach-sunxi\Kconfig
default y 改為 default nH3 使用 128M DDR3啟動不了核心問題 -
修改 CONFIG_SYS_MALLOC_LEN 宏
u-boot-2017.11\include\configs\sunxi-common.h
#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (2 << 20))
重新編譯u-boot, 燒錄後啟動。
仍然卡在 Starting kernel …
仍然卡在 Starting kernel …
仍然卡在 Starting kernel …
問題沒有解決!
說明原因沒找對!
## device tree at 40000000 ... 4000416a (len=29035 [0x716B])
Loading Device Tree to 49ff8000, end 49fff16a ... OK
Initial value for argc=3
Final value for argc=3
Setting up simplefb
HDMI present but not probed
No active display present
## Transferring control to Linux (at address 40008000)...
Starting kernel ...
繼續找原因
注意到一行列印資訊 Loading Device Tree to 49ff8000, end 49fff16a … OK
49ff8000 已經超出了 48000000 上限!
跟蹤代碼發現 env_get_bootm_size 裡面讀取 bootm_size 值等于 0xa000000。
u-boot-2017.11\common\image.c
u-boot-2017.11\include\configs\sunxi-common.h
sunxi-common.h 中定義了 預設 bootm_size=0xa000000 ;
解決辦法,把bootm_size 改為 = 0x8000000
或者 删除 bootm_size 環境變量,這樣 bootm_size 會等于 ramsize。
驗證:OK
BusyBox v1.28.3 () built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 18.06.1, r7258-5eb055306f
-----------------------------------------------------
[email protected]:/#
[email protected]:/# [ 75.667798] random: crng init done
[ 75.671220] random: 4 urandom warning(s) missed due to ratelimiting
總結
H3 使用128M DDR3 核心啟動卡在Starting kernel …
原因是因為環境變量 預設 bootm_size=0xa000000 超出 0x8000000
解決辦法是删掉 bootm_size 環境變量 。
最開始懷疑記憶體不夠引起,費了半天勁去修改了保留記憶體大小,雖然走了彎路,但還是有所收獲,對uboot 中 DDR 的初始化過程有了進一步的了解。