H3 使用 128M DDR3启动不了内核问题

问题描述:
平台: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 宏

尝试解决办法:

  1. 关闭 CONFIG_DM_VIDEO
    u-boot-2017.11\arch\arm\mach-sunxi\Kconfig在这里插入图片描述
    default y 改为 default n

  2. 修改 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
 -----------------------------------------------------
root@172:/# 
root@172:/# [   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 的初始化过程有了进一步的了解。

发布了63 篇原创文章 · 获赞 20 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/agave7/article/details/90236414
h3