u-boot 分析(2)-在QEMU环境下的调试

好文推荐:

https://www.jianshu.com/p/91baa4d140a2

qemu-system-arm仿真vexpress-a9踩坑记

 

 

通过走读代码来熟悉uboot,对于新手比较困难。

若能通过调试环境,一步一步的跟踪代码运行,就能很好的理解u-boot的实现流程,及主要的功能模块。

在QEMU环境下,有两种方法可以进行调试

首先安装QEMU。简单点,直接使用sudo apt-get install qemu

 

 

1)无界面GDB调试方式

首先在u-boot-2017.05下,执行

sudo qemu-system-arm -M vexpress-a9 -kernel u-boot -nographic -m 512M -S -s

启动uboot


在另一个终端里,执行

arm-linux-gnueabi-gdb

(gdb)  file u-boot     //加载调试文件
(gdb)  target remote:1234     //连接仿真目标

(gdb) file u-boot
Reading symbols from u-boot...done.
(gdb) target remote:1234
Remote debugging using :1234
warning: remote target does not support file transfer, attempting to access files from local filesystem.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
_start () at arch/arm/lib/vectors.S:54
54        b    reset  
(gdb) s               //单步执行
reset () at arch/arm/cpu/armv7/start.S:40
40        b    save_boot_params
(gdb) s
save_boot_params () at arch/arm/cpu/armv7/start.S:116
116        b    save_boot_params_ret        @ back to my caller
(gdb) s
save_boot_params_ret () at arch/arm/cpu/armv7/start.S:56
56        mrs    r0, cpsr
(gdb) 
 

详细的GDB调试命令请参考相关文档
 

2)使用DDD,在图形界面下调试U-BOOT

上面的方式虽然也可以调试。但是使用图形界面,通过鼠标操作,更是我们程序的最爱。

下面隆重推荐  DDD调试器。参考下面链接的资料,了解DDD

https://blog.csdn.net/yangzm/article/details/51793023

ddd 调试器配置

 

首先在u-boot-2017.05下,执行

sudo qemu-system-arm -M vexpress-a9 -kernel u-boot -nographic -m 512M -S -s

启动uboot

 

在另一终端里,使用ddd --debugger arm-linux-gnueabi-gdb,启动调试界面。

注意,要配置debugger为编译uboot工具链里的gdb

通过FILE,加载u-boot

在命令行连接调试目标

target remote:1234

之后,参考DDD的资料,就能很方面的进行调试和跟踪了。

 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值