Skip to content

Commit 03b45eb

Browse files
bryceschoberfpistm
authored andcommitted
Document debugging with VSCode + STM32CubeCLT + cortex-debug extension
1 parent c82617e commit 03b45eb

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

_dev/How-to-debug.md

+77
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,83 @@ This [tutorial](https://visualgdb.com/tutorials/arduino/stm32/) shows how to dev
232232

233233
See the Visual Studio Code extension for Arduino [README.md](https://github.com/microsoft/vscode-arduino/blob/main/README.md).
234234

235+
# Visual Studio Code + STM32CubeCLT + `cortex-debug` extension
236+
237+
These settings were extracted by using the [new STM32 VS Code extension](https://marketplace.visualstudio.com/items?itemName=stmicroelectronics.stm32-vscode-extension)'s generated launch configuration. That extension currently only supports `CMake` projects, so using it for development isn't yet appropriate for all use cases (i.e. [STM32duino](https://github.com/stm32duino/Arduino_Core_STM32)).
238+
239+
## Prerequisites
240+
241+
1. Download and install the latest STM32CubeCLT installer from <https://www.st.com/en/development-tools/stm32cubeclt.html>
242+
2. Restart Windows in order to reload your system environment variables.
243+
244+
On Linux, you might need to manually define the appropriate environment variable yourself, something like this, but making sure you have the correct installation path:
245+
246+
```shell
247+
echo "export STM32CLT_PATH=/opt/st/stm32cubeclt_1.16.0" >> ~/.bashrc
248+
```
249+
250+
## Debug Launch settings
251+
252+
See the embedded comments below for pointers to places you might need or want to modify for your
253+
application.
254+
255+
```jsonc
256+
"launch": {
257+
"version": "0.2.0",
258+
"configurations": [
259+
{
260+
"name": "Debug w/ ST-Link",
261+
"cwd": "${workspaceFolder}",
262+
"type": "cortex-debug",
263+
"executable": "myproject.elf", // Change to your .elf executable
264+
"request": "launch",
265+
"servertype": "stlink",
266+
"device": "STM32H563ZITx", // Change to your MCU used
267+
"interface": "swd",
268+
"serialNumber": "", // Set ST-Link ID if you use multiple at the same time
269+
"runToEntryPoint": "main",
270+
"svdFile": "${env:STM32CLT_PATH}/STMicroelectronics_CMSIS_SVD/STM32H563.svd", // Change based your MCU used
271+
"v1": false, // Change it depending on ST Link version
272+
"serverpath": "${env:STM32CLT_PATH}/STLink-gdb-server/bin/ST-LINK_gdbserver",
273+
"stm32cubeprogrammer": "${env:STM32CLT_PATH}/STM32CubeProgrammer/bin",
274+
"stlinkPath": "${env:STM32CLT_PATH}/STLink-gdb-server/bin/ST-LINK_gdbserver",
275+
"armToolchainPath": "${env:STM32CLT_PATH}/GNU-tools-for-STM32/bin",
276+
"gdbPath": "${env:STM32CLT_PATH}/GNU-tools-for-STM32/bin/arm-none-eabi-gdb",
277+
"serverArgs": [
278+
"-m",
279+
"1",
280+
],
281+
//"preLaunchTask": "Build + Flash"
282+
},
283+
{
284+
"name": "Attach w/ ST-Link",
285+
"cwd": "${workspaceFolder}",
286+
"type": "cortex-debug",
287+
"executable": "myproject.elf", // Change to your .elf executable
288+
// Let CMake extension decide executable: "${command:cmake.launchTargetPath}"
289+
// Or fixed file path: "${workspaceFolder}/path/to/filename.elf"
290+
"request": "attach",
291+
"servertype": "stlink",
292+
"device": "STM32H563ZITx", // Change to your MCU used
293+
"interface": "swd",
294+
"serialNumber": "", // Set ST-Link ID if you use multiple at the same time
295+
"runToEntryPoint": "main",
296+
"svdFile": "${env:STM32CLT_PATH}/STMicroelectronics_CMSIS_SVD/STM32H563.svd", // Change based your MCU used
297+
"v1": false, // Change it depending on ST Link version
298+
"serverpath": "${env:STM32CLT_PATH}/STLink-gdb-server/bin/ST-LINK_gdbserver",
299+
"stm32cubeprogrammer": "${env:STM32CLT_PATH}/STM32CubeProgrammer/bin",
300+
"stlinkPath": "${env:STM32CLT_PATH}/STLink-gdb-server/bin/ST-LINK_gdbserver",
301+
"armToolchainPath": "${env:STM32CLT_PATH}/GNU-tools-for-STM32/bin",
302+
"gdbPath": "${env:STM32CLT_PATH}/GNU-tools-for-STM32/bin/arm-none-eabi-gdb",
303+
"serverArgs": [
304+
"-m",
305+
"1",
306+
],
307+
}
308+
]
309+
}
310+
```
311+
235312
# Command Line GDB
236313

237314
## 1. Command Line GDB

0 commit comments

Comments
 (0)