Disclaimers
I am sharing what works for me. It may not work for you or it may fail over time. You may suffer data loss or worse. I disclaim all warranties and representations.
Prerequisities
- Xilinx Microprocessor Debugger (XMD)
- GDB capable of understanding the target machine
Debugging the Kernel
When developing a device driver, having access to the linux internals using GDB may be the key to meeting that deadline. On the zedboard, debugging the kernel with GDB is actually very easy with the help of the Xilinx Microprocessor Debugger, or XMD for short.
XMD is included with the Vivado Design Suite from Xilinx. In case you are working with the older ISE Design Suite, the included XMD should work as well.
Start debugging
- Connect the JTAG to the zedboard (or a micro usb to the PROG USB port) and boot it.
- Open a shell and run
xmd
.
1 2 3 4 5 6 7 |
|
- Run
connect arm hw
. This will start a GDB server atlocalhost:1234
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Open a new shell and go to the directory where the kernel sources are located, the ones you used to build the kernel, and run
arm-xilinx-eabi-gdb vmlinux
.In my case I am using
arm-xilinx-eabi-gdb
but any gdb cross-build for arm will do. We are passingvmlinux
to the debugger, so it can read the kernel symbols.
1 2 3 4 5 6 7 8 9 10 |
|
- Then, under the GDB command prompt, enter:
target remote localhost:1234
1 2 3 4 5 |
|
- And now GDB is ready for debugging those kernel hangs. Enter
continue
in the gdb prompt so linux can continue it’s normal operation. You can come back anytime and stop it in order to debug it.
Extras
- Make sure you have enabled the kernel debug symbols in the config file of the
kernel. Enabling
CONFIG_DEBUG_INFO
will do the trick.