tech_log: u-boot in qemu

Tuesday, November 3, 2009

u-boot in qemu

1) make versatile_config
2) Start u-boot.bin in qemu :
$ qemu-system-arm -M versatileab -nographic -m 256 -kernel u-boot.bin

3) Debugging:
$ qemu-system-arm -M versatileab -nographic -m 256 -kernel u-boot.bin -s -S
$ drasko@Marx:~/qemu-arm/u-boot-2009.03$ arm-linux-gnu-gdb u-boot
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i486-linux-gnu --target=arm-linux-gnu"...
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
[New Thread 1]
0x00000000 in ?? ()
(gdb)



Explanation :

Debugging with the moxie qemu simulator

I’ve finally cracked the gdb+qemu puzzle, so now we can debug code running on the qemu moxie simulator!

The last little gotcha was that the simulated $pc wasn’t being updated after single-stepping. This will get you nowhere fast! But it’s all fixed now, and here’s how it works…

$ qemu-system-moxie -s -S -kernel hello.x

This tells qemu to load our hello world program, hello.x. The “-s” option tells it to wait for a connection from GDB on port 1234. The -S option tells it to freeze on startup, and wait for a “continue” command from the debugger.

Now, in a different terminal, fire up moxie-elf-gdb on hello.x and connect to qemu like so:

(gdb) target remote localhost:1234

GDB and qemu should be talking now, and the debugger will report that the sim is waiting on __start, the entry point to our hello.x ELF file. Put a breakpoint on main, and hit ‘c’ to continue. You should be debugging as usual now. I normally run moxie-elf-gdb within emacs in order to get a nice UI, but invoking it from ddd or Eclipse should work just as well.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home