The package can be debugged in GDB the standard way if the package symbols are loaded from the package .elf file.
Start the OpenOCD server using the configuration file from the repository:
$ openocd -f openocd.cfgKeep this process running in its own terminal.
An ARM version of GDB is needed, and it needs to have a working Python scripting support.
In a second terminal, change to the refloat repo directory. It contains the .gdbinit file with commands to load the package .elf and for debuging it.
The correct firmware .elf file is needed, it's built along with the firmware binary for the ESC in question:
$ arm-none-eabi-gdb path/to/bldc/build/ESC/ESC.elf -ex 'target extended-remote localhost:3333'Once inside GDB, load the symbols for the package itself:
(gdb) load-package-elf src/package_lib.elfYou can now use package symbols, set breakpoints, decode package frames in stack traces etc. The package has a global data struct, managed and made available through the firmware. The .gdbinit file provides a helper command to access this data easily at any point:
- Type
datato print the contents of the whole struct - Type
data PROPERTYto print any property of the data struct, even nested, e.g.:(gdb) data imu $1 = { pitch = 21.3763847, balance_pitch = 21.2723846, roll = -1.01360452, yaw = 32.8550987, pitch_rate = 0.0440952145, flywheel_pitch_offset = 0, flywheel_roll_offset = 0 } (gdb) data imu.pitch $2 = 21.3763847
Note: A recent enough GCC version is needed for compiling the package, otherwise reading the Data struct in GDB won't work (it doesn't work with GCC 7).