本帖最后由 blake 于 2017-8-16 08:28 编辑
准备:
- PC环境:intel x64 cpu, fedora 23 64bit
- 软件安装:
- sudo dnf install gcc-arm-linux-gnu qemu codeblocks arm-none-eabi-gdb arm-none-eabi-gcc
复制代码 编译:
- mkdir ~/qemu
- cd ~/qemu
- mkdir vexpress-a9
- cd vexpress-a9
复制代码以后,所有基于vexpress-a9板子的实验都会在该目录进行
首先,去ftp://ftp.denx.de/pub/u-boot/下载最新版本U-Boot,u-boot-2015.10.tar.bz2解压: - tar zxvf u-boot-2015.10.tar.bz2
复制代码由于使用了gcc-arm-linux-gnu编译器,需要在Makefile中指定ARCH及CROSS_COMPILE - ARCH ?= arm
- CROSS_COMPILE ?= arm-none-eabi-
复制代码觉得有必要的话,也可以在config.mk文件下增加-ggdb参数: - PLATFORM_CPPFLAGS := -ggdb
复制代码保存,然后编译 - make vexpress_ca9x4_defconfig
- make
复制代码
ls的结果如下: - [llp@llp u-boot-2015.10]$ ls
- api disk include MAKEALL snapshot.commit u-boot.cfg
- arch doc Kbuild Makefile System.map u-boot.lds
- board drivers Kconfig net test u-boot.map
- common dts lib post tools u-boot.srec
- config.mk examples Licenses README u-boot
- configs fs MAINTAINERS scripts u-boot.bin
复制代码此时,直接执行这条命令就能跑u-boot了 - qemu-system-arm -M vexpress-a9 -m 256M -nographic -kernel u-boot
复制代码
CodeBlocks图形调试环境
首先启动一个支持gdb的qemu机器 - qemu-system-arm -M vexpress-a9 -m 256M -nographic -kernel u-boot -s -S
复制代码- 增加的几个参数定义:
- -S freeze CPU at startup (use 'c' to start execution)
- -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下截图不宜,放两张效果图把
|