2015/05/12

Play U-Boot on Qemu, 2015 version

Package Installation
  sudo apt-get install qemu-system  gcc-arm-none-eabi
  sudo apt-get -o Dpkg::Options::="--force-overwrite" install gdb-arm-none-eabi


U-Boot Build
Get u-boot source from ftp://ftp.denx.de/pub/u-boot/ , I got version u-boot-2015.01.tar.bz2
Extract the source and on console:
  cd u-boot-2015.01
  make versatileqemu_config ARCH=arm CROSS_COMPILE=arm-none-eabi-
  make all ARCH=arm CROSS_COMPILE=arm-none-eabi-
To print out the actual compile and linker command:
  make all ARCH=arm CROSS_COMPILE=arm-none-eabi- KBUILD_VERBOSE=1


Run the U-Boot in Qemu
  qemu-system-arm -M versatilepb -m 128M -nographic -kernel u-boot.bin
You should see U-Boot prompt "VersatilePB # " on the console
To exit QEMU, press “Ctrl a” and then “x”.


Problem Shooting
Run with logging every instruction exectuted
  qemu-system-arm -M versatilepb -m 128M -nographic -kernel u-boot.bin -d in_asm,cpu -D qemu.log -singlestep

Disassemble U-Boot
  arm-none-eabi-objdump -d u-boot

Check memory map info
  gvim u-boot.map
  nm u-boot

To Clean
  make clean
  make mrproper

To enable debug message
in include/configs/versatial.h
add
#define DEBUG 1


Debug with GDB 
Install the gdb for arm
 sudo apt-get -o Dpkg::Options::="--force-overwrite" install gdb-arm-none-eabi


qemu-system-arm  -m some_machine -m 256M -nographic -kernel some_image.bin -s

on the other terminal

ddd --debugger arm-none-eabi-gdb
(gdb) symbol-file ~/git/lhx/vmlinux
(gdb)
(gdb) target remote :1234
(gdb) break setup_arch
(gdb) c

Reference
https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/
http://infocenter.arm.com/help/topic/com.arm.doc.dui0224i/DUI0224I_realview_platform_baseboard_for_arm926ej_s_ug.pdf
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0183g/DDI0183G_uart_pl011_r1p5_trm.pdf http://git.savannah.gnu.org/cgit/qemu.git/tree/hw/versatilepb.c
https://balau82.wordpress.com/2010/11/30/emulating-arm-pl011-serial-ports/
http://elinux.org/Virtual_Development_Board

No comments:

Post a Comment

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...