Spark Logic

Debug an STM32Cube project in Eclipse with GNU Arm and J-Link

Build the STM32Cube ELF with GNU Arm and connect an Eclipse GDB session through a SEGGER J-Link.

Build and identify the target ELF

Generate the project for the exact STM32 part with STM32CubeMX. Use an Eclipse ARM embedded project or import the generated project into STM32CubeIDE. Build with the corresponding arm-none-eabi toolchain and keep debug symbols enabled. Check that the startup file and linker script match the selected MCU and boot layout.

Use the same ELF for symbol loading and flashing. For an initial test, place a breakpoint at main and use a debug build where optimization has not inlined the routine you want to inspect.

Connect the J-Link GDB server

Connect target ground, SWDIO, SWCLK and the probe's target reference voltage. Connect reset when available. Select the full MCU name and SWD in SEGGER's GDB server. Set the Eclipse debug configuration to use arm-none-eabi-gdb and the server's reported host and port.

Reset and halt at the start of the session, download the image and let the debugger stop at main. If the probe cannot identify the target, measure the reference voltage, lower the SWD clock and verify the SWD and reset wiring before changing compiler settings.

References