/
Remote Debugging with GDB

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. Develop source files for whatever application user would like to debug on the uClinux target. For instance:

    $ vi app.c #include <stdio.h> int func(int a, int b) { int c = (a+b)/2; printf("%s: (%d + %d)/2 = %d\n", __func__, a, b, c); return c; } int main() { int a, b, ret; a = 10; b = 20; ret = func(a,b); printf("%s: got result %d\n", __func__, ret); return 0; }
  4. It is recommended to rebuild your application on the development host with special GCC options. Use the following options:

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

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

  7. Run GDB on the development host:

  8. Establish a connection to the target:

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

 

Related content

Remote Debugging with GDB (uClinux)
Remote Debugging with GDB (uClinux)
More like this
Remote Debugging with GDB
Remote Debugging with GDB
More like this
STM32MP1-Old-Kits: Remote Debugging with GDB
STM32MP1-Old-Kits: Remote Debugging with GDB
More like this
Debugging with Eclipse
Debugging with Eclipse
More like this
Loading Application Files via UART
Loading Application Files via UART
More like this
Loading Application Files via UART (uClinux)
Loading Application Files via UART (uClinux)
More like this