GDB SWD 调试
This page documents how to connect the hardware target using GDB (from a terminal). To use an IDE instead, see the instructions for Eclipse or VSCode.
For the wiring interface setup, please see this detailed information.
Using Dronecode probe / Blackmagic probe
To use a Dronecode probe with GDB, start GDB with the exact ELF file that is currently flashed on the autopilot:
Then, you have to select the Dronecode probe interface, on Linux this is e.g.:
Then you scan for the target:
And you should see something like:
Note that for some autopilots it shows 0.0V but the subsequent steps work nevertheless.
You can now attach to that target:
And now you should be connected.
Using JLink
To use the JLink debugger, you first need to install the JLink software containing the JLink GDB server.
The JLink installer should install the JLink GDB server to /usr/bin/
. Once installed, you can start the server using:
It might then prompt you to update the JLink which is recommended, and then to specify which device it is communicating with. Check the docs of your autopilot for the specific device.
Once that's done, the GDB server should be start listening on port 2331
, e.g. like so:
You can now start GDB with the exact elf file that is currently flashed on the autopilot (in a separate terminal):
And connect to the GDB server:
And now you should be connected.
GDB Quickstart
Once connected, you can use the usual GDB commands such as:
continue
to continue program executionrun
to start from the beginningbacktrace
to see the backtracebreak somewhere.cpp:123
to set a breakpointdelete somewhere.cpp:123
to remove it againinfo locals
to print local variablesinfo registers
to print the registers
And much more, just use your favorite resource to learn more about GDB.
To avoid having to type all commands to connect in GDB each time, you can write them into ~/.gdbinit
.
Last updated