2015/07/01

Debug Linux Versatile Build on Qemu

How to debug Linux4.0 ARM Versatile build on Qemu
Below is tested on Ubuntu 14.04
 
Install toolchain
sudo apt-get install gcc-arm-linux-gnueabi


Install Qemu for ARM
sudo apt-get install qemu-system-arm


Install GDB for ARM
sudo apt-get -o Dpkg::Options::="--force-overwrite" install gdb-arm-none-eabi
Some error happens without force overwrite option


Build Kernel with Device Tree Support
cd Linux4.0
make versatile_defconfig
make xconfig
  On the GUI xconfig window, find below configs (by Ctrl+F) and
    check on CONFIG_USE_OF
    check on CONFIG_MACH_VERSATILE_DT
    check on CONFIG_MACH_DEBUG_INFO
  Save the config
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make -j9


Run On Qemu
qemu-system-arm -M versatileab -nographic -dtb ./arch/arm/boot/dts/versatile-ab.dtb -kernel arch/arm/boot/zImage -append “console=ttyAMA0″
or
qemu-system-arm -M versatileab -nographic -dtb ./arch/arm/boot/dts/versatile-ab.dtb -kernel arch/arm/boot/zImage -append “console=ttyAMA0″ -s -S

The second command will cause the Qemu to pause at start before any gdb client is connected


Debug with GDB
cd Linux4.0
ddd --debugger arm-none-eabi-gdb
On ddd command console
  target remote :1234
  file vmlinx
  b  setup_arch
  c
  ....






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:...