u-boot版本:u-boot-2017.05
开发板:vexpress-a9(没办法,目前看到的都是这个开发板,想QEMU调试tiny210,一直没看到怎么修改qemu)
编译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)建立项目:
b)导入项目:
c)配置debug:
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.
调试mmc_init(会在fatload 三秒后不动加载内核时候触发mmc_init)
(gdb)b mmc_init
(gdb)c
最后输出(因为启动命令里面没有mmc配置):
mmc_init: -95, time 28
** Bad device mmc 0 **