Remote Debugging with GDB
Step through the following procedure in order to start remote debugging of Linux userspace applications with gdbserver:
Download the Yocto toolchain from the Emcraft website.
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
Activate the cross-build environment:
$ source /opt/st/stm32mp1-som/2.4-snapshot/environment-setup-aarch64-poky- linux $ unset CCACHE_PATH
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) ...
It is recommended to rebuild your application (see attached for example) with special GCC options. Use the following options:
Deploy your application binary (app) to the target. For example, you can
scp
it: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:
Run
gdbserver
on the target:Run GDB on the development host:
Specify the
sysroot
directory containing the copies of the target libraries:Establish a connection to the target:
Debug your application using the standard GDB commands. Here is a sample debug session: