I am running the Parallella board in the headless mode, normally I’ll just start a VNC session and connect to the board. However, debugging programs running on Parallella board with GDB in a terminal window is really painful.
I tried installing and using DDD in the VNC session, but failed to get it working. It’s always stuck at a stage complaining that GDB is busy. That’s why I was forced to use GDBserver, instead.
Now, in order to debug an ARM program the DDD on host would need access to the binary image of the built ARM program. There are two convenient ways to make the image accessible by DDD.
The first method is to cross-build for Parallella on host and install the binaries to a directory on host. The next step would be to export that directory as an NFS share, so that the Parallela board can mount that NFS share and run the program. However, this method does not work for now since the Parallella SDK right now does not support cross-building nicely.
This leaves the second method as the only good one I can think of. The program is built native on Parallella, and the directory that contain the source tree is exported. The host mounts the directory and then has access to the images. Note that the default kernel in the Ubuntu image provided by Adapteva does not have NFS support so a customary kernel would need to be built. The detailed information on building a kernel for Parallella can be found on the forum.
I am running 32-bit Fedora as my host OS. Initially, I thought that I have to install the
arm-none-eabi-gdb package as the inferior debugger under DDD. However, that’s always causing a protocol error. Until one time I inadvertently supplied the native GDB as the inferior debugger, everything suddenly works. I am still scratching my head on this. But it looks like the natively-built GDB on x86 can recognized binaries built for ARM and communicate with ARM targets correctly. Now I don’t get why the
arm-none-eabi-gdb package is needed at all.
Once we can mount exported share of Parallella on the host, we are ready to kick start debugging process:
- On the host, mount the exported share first:
$sudo mount -t nfs parallella:/home/linaro/Work ~/parallella
- On the Parallella, we can start the program to be debugged like the example below:
$gdbserver localhost:65432 ffmpeg_g -f hevc -i str.bin -f rawvideo decoded.yuv
- On the host, change directory to where the binary image resides, and start DDD:
Once inside the debugger console of DDD, we can connect to the GDB server running on Parallella:
(gdb) target remote parallella:65432
Once the connection is established, we can use DDD as usual. Once we complete the debugging session, we can detach from the server:
If there is communication issue between the GDB client and the server, here are two links for understanding the root cause of the issue: