Skip to content

How to debug

Debugging an STM32 Arduino sketch requires a debug probe, a firmware image with debug symbols, and a debugger configuration that matches the target MCU. The Arduino IDE 2 workflow is the recommended and officially supported option; the other sections describe community or tool-specific alternatives.

Before starting, verify that:

  • The board is powered and the debug probe is connected to the SWD pins. ST-LINK/V2 and ST-LINK/V3 are supported by the recommended workflow.
  • The selected board and upload/debug interface are supported by the tool being used.
  • The sketch is compiled with debug information. In Arduino IDE 2, select Optimize for debugging; in other tools, use the equivalent -g or Debug build option.
  • You know where the generated ELF file is located. GDB needs the ELF file to resolve symbols, even when the board was programmed with a BIN or HEX file.

Warning

Only the Arduino IDE 2 is officially supported.

Note

Requires a ST-Link/V2 or ST-Link/V3 device connected to the PC over USB and to the board via the SWD interface.

  1. If not already done, Getting Started

  2. Configure the IDE to the desired board. Here the Nucleo L476RG which already includes a ST-Link.

See Getting Started

  1. Open the Blink sketch from the "File> Examples > 01.Basics > Blink".

  2. Select the "Optimize for debugging" in the "Sketch" menu:

Optimize for debugging

  1. Click the upload button

See Getting Started to change the upload method.

Upload

  1. Click the start debugging button:

Start debugging

Debugging session

Tip

Refer to official documentation to see how Using the Debugger.