Debugging Linux Kernel using QEMU

In this article we will learn to setting up and Debugging Embedded Linux Kernel using Qemu.

Requirements:
1. zImage
2. Rootfs
3. dtb file

Above images and rootfs can be compiled and built from these Tutorial

In 1st terminal execute below command:

qemu-system-arm -M vexpress-a9 -dtb linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -kernel linux/arch/arm/boot/zImage -append "root=/dev/nfs nfsroot=10.0.2.2:/rootfs_ES rw ip=10.0.2.15::10.0.2.1:255.255.255.0 init=/linuxrc console=ttyAMA0" -serial stdio -s -S

 

Using the “-s” option: makes qemu listen on port tcp::1234, which you can connect to as localhost:1234 if you are on the same machine.

Qemu’s “-S”option: makes Qemu stop execution until you give the continue command.

Open one more terminal i.e in 2nd terminal execute below command as shown in image

arm-none-linux-gnueabi-gdb path to vmlinux

arm-none-linux-gnueabi-gdb linux/vmlinux
target remote :1234
b start_kernel

cmd

gdb

For more options and debugging please refer online gdb tutorial.

Happy debugging

 

Reference:

https://stackoverflow.com/questions/36621505/debugging-linux-kernel-using-gdb-in-qemu-unable-to-hit-function-or-given-adress

 

Advertisements

About VinayMahadev

I am passionate about Embedded Linux systems . I believe in "If you want to learn something, read about it. If you want to understand something, write about it. If you want to master something, teach it". Here I am just trying to connect the Dots.
Gallery | This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s