on 2026-02-17 2:38 AM
This article details the configuration options for debugging STM32 projects in VS Code using the STM32CubeIDE extension.
These are the three main debug configurations that you may need with STM32CubeIDE for VS Code extension.
Type: "stlinkgdbtarget"
Key parameters:
| Parameter | Type | Description |
|---|---|---|
| type | string | Must be "stlinkgdbtarget". Specifies the debugger type. |
| request | string | "launch" to start a new debug session, or "attach" to connect to a running target. |
| name | string | User-friendly configuration name |
| cwd | string | Working directory for the debug session. |
| preBuild | string | Command to run before starting the debug session (for example, build task). |
| runEntry | string | Entry point symbol to run to after reset (for example, "main"). |
| serverExtLoader | array | List of external loader objects for external flash (see below for object structure). |
| imagesAndSymbols | array | List of objects specifying images (binaries) and their symbols to load (see below). |
| device | string | STM32 device part number (optional, for example, "STM32H7R3ZI"). |
| interface | string | Debug interface, typically "swd" or "jtag" (optional). |
| stopAtEntry | boolean | If true, stops at the entry point after reset (optional). |
| svdFile | string | Path to SVD file for peripheral register view (optional). |
| serverArgs | array | Additional arguments to pass to the STLINK GDB server (optional). |
| gdbPath | string | Path to the GDB executable (optional). |
| gdbArgs | array | Additional arguments for GDB (optional). |
| postRestartCmds | array | GDB commands to execute after restart (optional). |
| postAttachCmds | array | GDB commands to execute after attach (optional). |
serverExtLoader object:
| Field | Type | Description |
|---|---|---|
| loader | string | Path to the external loader file (.stldr). |
| initialize | boolean | Whether to initialize the loader at session start. |
imagesAndSymbols object:
| Field | Type | Description |
|---|---|---|
| imageFileName | string | Path to the binary/ELF file to load. |
| symbolsFileName | string | Path to the symbols file (optional, if separate from image). |
Type: "openocdtarget"
Key parameters:
| Parameter | Type | Description |
|---|---|---|
| type | string | Must be "openocdtarget". Specifies the debugger type. |
| request | string | "launch" or "attach". |
| name | string | User-friendly configuration name. |
| cwd | string | Working directory for the debug session. |
| preBuild | string | Command to run before starting the debug session. |
| openOCDConfigFiles | array | List of OpenOCD config files (for example, interface, target, board). |
| openOCDSearchDirs | array | Directories to search for OpenOCD scripts. |
| runEntry | string | Entry point symbol to run to after reset (for example, "main"). |
| imagesAndSymbols | array | List of objects specifying images (binaries) and their symbols to load. |
| device | string | STM32 device part number (optional). |
| interface | string | Debug interface, typically "swd" or "jtag" (optional). |
| stopAtEntry | boolean | If true, stops at the entry point after reset (optional). |
| svdFile | string | Path to SVD file for peripheral register view (optional). |
| serverArgs | array | Additional arguments to pass to OpenOCD (optional). |
| gdbPath | string | Path to the GDB executable (optional). |
| gdbArgs | array | Additional arguments for GDB (optional). |
| postRestartCmds | array | GDB commands to execute after restart (optional). |
| postAttachCmds | array | GDB commands to execute after attach (optional). |
Type: "jlinkgdbtarget"
Key Parameters:
| Parameter | Type | Description |
|---|---|---|
| type | string | Must be "jlinkgdbtarget". Specifies the debugger type. |
| request | string | "launch" or "attach". |
| name | string | User-friendly configuration name. |
| cwd | string | Working directory for the debug session. |
| preBuild | string | Command to run before starting the debug session. |
| jlinkDevice | string | Device name for J-Link (for example, "STM32H7R3ZI"). |
| interface | string | Debug interface, typically "swd" or "jtag". |
| runEntry | string | Entry point symbol to run to after reset (for example, "main"). |
| imagesAndSymbols | array | List of objects specifying images (binaries) and their symbols to load. |
| stopAtEntry | boolean | If true, stops at the entry point after reset (optional). |
| svdFile | string | Path to SVD file for peripheral register view (optional). |
| serverArgs | array | Additional arguments to pass to the J-Link GDB server (optional). |
| gdbPath | string | Path to the GDB executable (optional). |
| gdbArgs | array | Additional arguments for GDB (optional). |
| postRestartCmds | array | GDB commands to execute after restart (optional). |
| postAttachCmds | array | GDB commands to execute after attach (optional). |
"type" field determines the debug server: "stlinkgdbtarget", "openocdtarget", "jlinkgdbtarget"or other type."serverExtLoader" for external flash loaders if needed."imagesAndSymbols" allows specifying multiple binaries or symbol files."preBuild", "cwd", and other fields as needed for your project.{
"type": "stlinkgdbtarget",
"request": "launch",
"name": "STM32Cube: STM32 Launch ST-Link GDB Server",
"cwd": "${workspaceFolder}",
"preBuild": "${command:st-stm32-ide-debug-launch.build}",
"runEntry": "main",
"serverExtLoader": [
{
"loader": "C:/Users/gharbin/AppData/Local/stm32cube/bundles/programmer/2.21.0-a10/bin/ExternalLoader/MX25UW25645G_NUCLEO-H7S3L8.stldr",
"initialize": false
}
],
"imagesAndSymbols": [
{
"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
},
{
"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context2}"
}
],
"device": "STM32H7R3ZI",
"interface": "swd",
"stopAtEntry": false,
"svdFile": "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32H7RSxx/Include/STM32H7R3.svd"
}{
"type": "jlinkgdbtarget",
"request": "launch",
"name": "STM32Cube: STM32 Launch J-Link GDB Server",
"cwd": "${workspaceFolder}",
"preBuild": "${command:st-stm32-ide-debug-launch.build}",
"jlinkDevice": "STM32H7R3ZI",
"interface": "swd",
"runEntry": "main",
"imagesAndSymbols": [
{
"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
}
],
"stopAtEntry": false,
"svdFile": "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32H7RSxx/Include/STM32H7R3.svd"
}{
"type": "openocdtarget",
"request": "launch",
"name": "STM32Cube: STM32 Launch OpenOCD",
"cwd": "${workspaceFolder}",
"preBuild": "${command:st-stm32-ide-debug-launch.build}",
"openOCDConfigFiles": [
"interface/stlink.cfg",
"target/stm32h7x.cfg"
],
"openOCDSearchDirs": [
"C:/OpenOCD/scripts"
],
"runEntry": "main",
"imagesAndSymbols": [
{
"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
}
],
"device": "STM32H7R3ZI",
"interface": "swd",
"stopAtEntry": false,
"svdFile": "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32H7RSxx/Include/STM32H7R3.svd"
}
This configuration is dedicated to the CM7 core.
Let us create a new configuration for the CM4 core.
The order of debug launch will be:
Reset mode “none”
ImageAndSymbols: only SymbolFileName"serverReset": "Connect under reset","serverSemihosting": {
"enabled": true,
"mode": "console",
"port": "61260" },"liveWatch": {
"enabled": true,
"samplesPerSecond": "4" },"preBuild": "${command:st-stm32-ide-debug-launch.build}","serverRtos": {
"enabled": true,
"port":"60000",
"driver": "freertos" }For support, visit our VS Code product forums:
STM32CubeIDE for Visual Studio Code product forums.