u-boot版本:u-boot-2017.05
开发板:vexpress-a9(没办法,目前看到的都是这个开发板,想QEMU调试tiny210,一直没看到怎么修改qemu)
参考:https://blog.51cto.com/u_15076234/3961317?articleABtest=1
编译u-boot:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- vexpress_ca9x4_defconfig
启动gdb-multiarch:
qemu-system-arm -M vexpress-a9 -m 1024M -nographic -kernel u-boot -s -S
配置eclipse:
a)建立项目:
![](https://img-blog.csdnimg.cn/img_convert/0ed4d0c1cdab5c375ba2d8085e2a9e1d.png)
b)导入项目:
![](https://img-blog.csdnimg.cn/img_convert/aad2313d65ffef5295a7b1fb5697b525.png)
c)配置debug:
![](https://img-blog.csdnimg.cn/img_convert/e9c4d03768985b7cb1fc1b3759ecee53.png)
![](https://img-blog.csdnimg.cn/img_convert/646e679c97424263174916e50e444b06.png)
![](https://img-blog.csdnimg.cn/img_convert/2d4618d098a32628de7c827689402422.png)
d)进入调试:
(gdb) file u-boot
获取重定位之后uboot在内存中的地址,先跳到relocate_code,查看r0 的值,就知道从定位后地址,然后从新设置符号表,设置之后的断点b board_init_r
(gdb) b relocate_code
Breakpoint 1 at 0x60800b34: file arch/arm/lib/relocate.S, line 81.
(gdb) c
Continuing.
(gdb) info register r0
r0 0x7ff7d000 2146947072
(gdb) symbol-file //删除符号表
(gdb) add-symbol-file u-boot 0x7ff7d000 //从新设置符号表
add symbol table from file "u-boot" at
.text_addr = 0x7ff7d000
(y or n) y
(gdb) b board_init_r
Breakpoint 2 at 0x7ff89054: file common/board_r.c, line 947.
(gdb) c
Continuing.
![](https://img-blog.csdnimg.cn/img_convert/c0323e4171969d3d41063f966a552e23.png)
调试mmc_init(会在fatload 三秒后不动加载内核时候触发mmc_init)
(gdb)b mmc_init
(gdb)c
![](https://img-blog.csdnimg.cn/img_convert/3b5a7c229b8b4314c7b2394d9400afa8.png)
最后输出(因为启动命令里面没有mmc配置):
mmc_init: -95, time 28
** Bad device mmc 0 **