Remote Debugging with GDB

Step through the following procedure in order to start remote debugging of Linux userspace applications with gdbserver:

  1. Download the Yocto toolchain from the Emcraft website.

  2. Install the toolchain to your development host. The toolchain can be installed to an arbitrary directory:

    $ sh ./meta-toolchain-qt5-openstlinux-weston-stm32mp1-som-x86_64-toolchain-2.4-snapshot.sh
  3. Activate the cross-build environment:

    $ source /opt/st/stm32mp1-som/2.4-snapshot/environment-setup-aarch64-poky- linux $ unset CCACHE_PATH
  4. Make sure your target board has TCP/IP configured in Linux:

    ~ # ifconfig eth0 Link encap:Ethernet HWaddr 3c:fb:96:77:88:a0 inet addr:172.17.11.163 Bcast:172.17.255.255 Mask:255.255.0.0 inet6 addr: fe80::3efb:96ff:fe77:88a0/64 Scope:Link UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1 RX packets:8407 errors:0 dropped:27 overruns:0 frame:0 TX packets:551 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:831648 (812.1 KiB) TX bytes:247626 (241.8 KiB) ...
  5. It is recommended to rebuild your application (see attached for example) with special GCC options. Use the following options:

  6. Deploy your application binary (app) to the target. For example, you can scp it:

  7. Alternatively, you can configure an NFS server on your development host and export your build directory. To mount the exported directory on the target, run the following commands:

  8. Run gdbserver on the target:

  9. Run GDB on the development host:

  10. Specify the sysroot directory containing the copies of the target libraries:

  11. Establish a connection to the target:

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