三木社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 719|回复: 0

[教程] Codeblocks+Qemu——在IDE里面实现U-boot指令级调试

[复制链接]

1562

主题

1564

帖子

4904

积分

博士

Rank: 8Rank: 8

积分
4904
发表于 2017-8-16 08:25:35 | 显示全部楼层 |阅读模式
本帖最后由 blake 于 2017-8-16 08:28 编辑

准备:
  1. PC环境:intel x64 cpu, fedora 23 64bit
  2. 软件安装:
  3. sudo dnf install gcc-arm-linux-gnu qemu codeblocks arm-none-eabi-gdb arm-none-eabi-gcc
复制代码
编译:
  1. mkdir ~/qemu
  2. cd ~/qemu
  3. mkdir vexpress-a9
  4. cd vexpress-a9
复制代码

以后,所有基于vexpress-a9板子的实验都会在该目录进行
首先,去ftp://ftp.denx.de/pub/u-boot/下载最新版本U-Boot,u-boot-2015.10.tar.bz2解压:

  1. tar zxvf u-boot-2015.10.tar.bz2
复制代码

由于使用了gcc-arm-linux-gnu编译器,需要在Makefile中指定ARCH及CROSS_COMPILE

  1. vi Makefile

复制代码
  1. ARCH ?= arm
  2. CROSS_COMPILE ?= arm-none-eabi-
复制代码

觉得有必要的话,也可以在config.mk文件下增加-ggdb参数:

  1. PLATFORM_CPPFLAGS := -ggdb
复制代码

保存,然后编译

  1. make vexpress_ca9x4_defconfig
  2. make
复制代码

ls的结果如下:

  1. [llp@llp u-boot-2015.10]$ ls
  2. api        disk      include      MAKEALL   snapshot.commit  u-boot.cfg
  3. arch       doc       Kbuild       Makefile  System.map       u-boot.lds
  4. board      drivers   Kconfig      net       test             u-boot.map
  5. common     dts       lib          post      tools            u-boot.srec
  6. config.mk  examples  Licenses     README    u-boot
  7. configs    fs        MAINTAINERS  scripts   u-boot.bin
复制代码

此时,直接执行这条命令就能跑u-boot了

  1. qemu-system-arm -M vexpress-a9 -m 256M -nographic -kernel u-boot
复制代码

CodeBlocks图形调试环境


首先启动一个支持gdb的qemu机器

  1. qemu-system-arm -M vexpress-a9 -m 256M -nographic -kernel u-boot -s -S
复制代码
  1. 增加的几个参数定义:
  2. -S              freeze CPU at startup (use 'c' to start execution)
  3. -s              shorthand for -gdb tcp::1234
复制代码

然后打开codeblocks,配置settings->compiler(可不配置),指向arm-none-eabi-

配置setting->debuger,指向arm-none-eabi-gdb,另外勾选下do not run the debugee,可以防止程序直接运行

接下来新建一个空的工程,将u-boot目录下所有的.c;.h;.s;.S文件导入(有心情可以把没用的删掉,我是懒得烦了)

右击工程名,打开properties,在debugger标签下,配置下remote connection,填入localhost及1234即可。

这样之后,直接点击调试小图标就可以开始调试uboot了,默认暂停在b reset这儿,可以按F7单步。



三,Relocating之后的处理relocation之后的断点需要重新定位symbols,可以参考http://www.denx.de/wiki/view/DULG/DebuggingUBoot对于这块a9板,可以用这个命令add-symbol-file u-boot 0x6FF83000,然后就能对上relocating之后的代码了。
linux下截图不宜,放两张效果图把











本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

Archiver|手机版|小黑屋|三木电子社区 ( 辽ICP备11000133号-4 )

辽公网安备 21021702000620号

GMT+8, 2025-11-18 19:13 , Processed in 0.030331 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表