使用 QEMU 测试 U-BOOT

来源:互联网 发布:网络买卖 编辑:程序博客网 时间:2024/06/15 17:47

还是模拟 VEXPRESS-A9.

起初,我用的还是qemu官网里的最新代码编出的qemu程序。

u-boot从下面的网址获得:

http://ftp.denx.de/pub/u-boot/

取得是最新的代码。解压后,配置,编译:

make vexpress_ca9x4_configexport ARCH=armexport CROSS_COMPILE=arm-linux-gnueabi-make vexpress_ca9x4_configmake

然后,用  qemu运行 u-boot:

qemu-system-arm -M vexpress-a9  -serial stdio -kernel u-boot
结果,qemu的窗口出来了,但却没有任何输出,程序好像是deadlock 在某一个地方了。
根据http://balau82.wordpress.com/2012/03/31/compile-linux-kernel-3-2-for-arm-and-emulate-with-qemu/

建议的方法调试如下:

1. 先运行

qemu-system-arm -M vexpress-a9  -serial stdio -kernel u-boot -s -S
然后,在另一个虚拟终端窗口执行:

arm-linux-gnueabi-gdb u-boot...(gdb) target remote localhost:1234
最终发现,程序执行了下面的汇编执行后就 stuck 那里了
mcrp15, 0, r0, c12, c0, 0@Set VBAR
(在文件  u-boot-2013.10/arch/arm/cpu/armv7/start.S里)
现在对arm的汇编还不熟悉,这个错误不知道如何解决。。

所以,就换了另一个对arm支持较好的qemu版本: qemu-linaro。可以用git拿到源码。

git clone git://git.linaro.org/qemu/qemu-linaro.git
用编译 qemu一样的方法编译 qemu-linaro.

然后,再尝试运行u-boot:

~/code/u-boot-2013.10$ qemu-system-arm -M vexpress-a9  -serial stdio -kernel u-bootoss: Could not initialize DACoss: Failed to open `/dev/dsp'oss: Reason: No such file or directoryoss: Could not initialize DACoss: Failed to open `/dev/dsp'oss: Reason: No such file or directoryaudio: Failed to create voice `lm4549.out'U-Boot 2013.10 (Oct 24 2013 - 00:04:17)DRAM:  128 MiBWARNING: Caches not enabledFlash: 128 MiBMMC:   MMC: 0*** Warning - bad CRC, using default environmentIn:    serialOut:   serialErr:   serialNet:   smc911x-0Warning: smc911x-0 using MAC address from net deviceHit any key to stop autoboot:  0 Wrong Image Format for bootm commandERROR: can't get kernel image!VExpress# VExpress# VExpress# help?       - alias for 'help'base    - print or set address offsetbdinfo  - print Board Info structurebootelf - Boot from an ELF image in memorybootm   - boot application image from memorybootp   - boot image via network using BOOTP/TFTP protocolbootvx  - Boot vxWorks from an ELF imagebootz   - boot Linux zImage image from memorycmp     - memory comparecp      - memory copy

这次能看到u-boot的输出了。看来还是  linaro的qemu对arm的支持比较好啊。