Remote Debugging with GDB

Step through the following procedure in order to start remote debugging with gdbserver:

  1. Go to the top of your Linux Cortex-M installation and activate a Linux Cortex-M development session:

    $ . ./ACTIVATE.sh
  2. Make sure your target board has TCP/IP configured and up in Linux:

    / # ifconfig eth0 eth0 Link encap:Ethernet HWaddr AA:BB:CC:DD:EE:F0 inet addr:192.168.1.82 Bcast:192.168.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3014 errors:0 dropped:11 overruns:0 frame:0 TX packets:344 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:248079 (242.2 KiB) TX bytes:402628 (393.1 KiB)
  3. It is recommended to rebuild your application on the development host with special GCC options. Use the following options:

    ${CROSS_COMPILE_APPS}gcc -g -o app app.c
  4. Make your application binary (app) and the gdbserver binary (${TOOLS_DIR}/debug-root/usr/bin/gdbserver) accessible from the target. You can NFS-mount some host directory from the target for that purpose or put these binaries to the initramfs list of your kernel image. The gdbserver binary (${TOOLS_DIR}/debug-root/usr/bin/gdbserver) is already included the initramfs file.

  5. Run gdbserver on the target (assuming /mnt/nfs is NFS-mounted to the host):

  6. Run GDB on the development host:

  7. Establish a connection to the target:

  8. Debug your application using the standard GDB commands. Here is a sample debug session:

Â