2025-09-08 11:29 AM
Hello,
I am trying to get SWO output working in VSCode using the Cortex-Debug plugin (v1.12.1).
My setup:
Debugger: STLink V3-MINIE
MCU: STM32H747IIT6
IDE: VSCode with Cortex-Debug
GDB Server: OpenOCD
Debug config: Trace Asynchronous SW enabled in CubeMX
When I run the project in STM32CubeIDE, the SWO output works as expected.
However, in VSCode I don’t see any SWO output in the terminal.
I overrode the write function like this:
int _write(int file, char *ptr, int len) {
int dataIdx;
for (dataIdx = 0; dataIdx < len; dataIdx++) {
ITM_SendChar(*ptr++);
}
return len;
}
My launch.json:
{
"name": "CM7 SWO",
"cwd": "${workspaceRoot}/CM7",
"type": "cortex-debug",
"executable": "build/Printf_CM7.elf",
"request": "launch",
"servertype": "openocd",
"gdbPath": "/opt/ST/STM32CubeCLT_1.19.0/GNU-tools-for-STM32/bin/arm-none-eabi-gdb",
"device": "STM32H747IITx",
"svdFile": "/opt/ST/STM32CubeCLT_1.19.0/STMicroelectronics_CMSIS_SVD/STM32H747_CM7.svd",
"configFiles": [
"interface/stlink.cfg",
"target/stm32h7x.cfg"
],
"runToEntryPoint": "main",
"preLaunchTask": "Build All Debug",
"showDevDebugOutput": "raw",
"swoConfig": {
"enabled": true,
"source": "socket",
"swoFrequency": 2000000,
"cpuFrequency": 480000000,
"decoders": [
{
"port": 0,
"type": "console"
}
]
}
}
When I launch debugging, I get this error message from the GDB server:
marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl:
Error: Could not find TPIU/SWO names. Perhaps it hasn't been created?
Does anyone know what I might be missing in the launch.json or OpenOCD configuration to get SWO working with Cortex-Debug and STLink V3-MINIE?
Thanks in advance!
Best regards
OskarP.
Solved! Go to Solution.
2025-10-03 3:44 AM
2025-09-15 12:49 AM
@OskarP Thanks for contributing to this forum—it’s the right place to get answers!
The best way to start is by installing STM32Cube for Visual Studio Code.
2025-09-15 11:53 PM
@Nawres GHARBI Thanks for your reply, Nawres!
I already have STM32Cube for VS Code installed. The actual issue is that the cortex-debug extension, which STM32Cube also relies on, unfortunately does not support SWO when using the STLink server. Therefore, I switched to OpenOCD to get SWO capabilities.
2025-09-16 3:18 AM
could you share the extension version please ? seems you are using a very old one
2025-09-16 4:42 AM
@Nawres GHARBI Sure. I'm using the following versions:
- STM32Cube for Visual Studio Code Core Version 0.17.1
- STMCubeMX 6.15
- STMCubeCLT 1.19.0
2025-09-23 1:16 AM
Please update to the latest one on the Marketplace and switch to pre-release version
2025-09-29 11:11 PM
Hello Nawres,
sorry for the late reply. I have updated STM32Cube for Visual Studio Code to Core Version 1.0.3.
Could you please provide me with an example of a working launch configuration with SWO for the STM32H747IIT6?
Thank you very much for your help.
Best regards,
Oskar
2025-10-01 9:23 AM
Hello Nawres,
I’ve made some more progress. After installing STM32CubeIDE Version 3.6.3 and following the linked guide, it seems that the Cortex-Debug extension is no longer needed. However, when I try to debug with the basic configuration provided in the guide, I get the following error:
I can add a "deviceCore" entry to the config, but I’m not sure which argument I need for the M7 core of my STM32H747IIT6 microcontroller.
I’m looking forward to your reply.
Thank you very much for your help.
Best regards,
Oskar
{
"version": "0.2.0",
"configurations": [
{
"type": "stlinkgdbtarget",
"request": "launch",
"name": "STM32Cube: STM32 Launch ST-Link GDB Server",
"origin": "snippet",
"cwd": "${workspaceFolder}",
"preBuild": "${command:st-stm32-ide-debug-launch.build}",
"runEntry": "main",
"imagesAndSymbols": [
{
"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
}
],
"deviceCore": ""
}
]
}
2025-10-01 12:33 PM
@OskarP
About core setup I bet on CMSIS pack schema definition this STM32CubeIDE for Visual Studio Code is relying on: https://raw.githubusercontent.com/Open-CMSIS-Pack/Open-CMSIS-Pack-Spec/refs/heads/main/schema/PACK.xsd
Such said I would try first to get a chance automation to help me. Have you got a try about "Setup STM32Cube project(s)" key action ?
Per my understanding it has as a result to add couple of metadata enriching your CMake project improving couple of common actions like debug launch.
In theory adding Cmake project to your workspace is triggering some stuff ending with a notification asking you to initiate this process. Missing it, this key action is allowing you to trigger on demand.
2025-10-01 11:01 PM
@Cartu38 OpenDevThank you for your reply.
As you correctly pointed out, the core setup indeed relies on the Open-CMSIS-Pack definition. I configured my project using the "Setup STM32Cube project" option, but this did not create a launch.json file in my setup. After reviewing the user guide, I believe this is intentional, as it states that you have to add it yourself and provides a basic configuration there.
I have since created a new empty project in STM32CubeMX. The debug option is set to "Trace Asynchronous Sw," and I have added the overwrite for the _write function to enable printf output over SWO.
/* USER CODE BEGIN 4 */
int _write(int file, char *ptr, int len) {
int dataIDX;
for (dataIDX = 0; dataIDX < len; dataIDX++){
ITM_SendChar(*ptr++);
}
return len;
}
/* USER CODE END 4 */
Is there anything specific I need to add to the launch configuration to get the SWO output to appear in the console?
Thank you very much for your help.
Best regards
Oskar
{
"version": "0.2.0",
"configurations": [
{
"type": "stlinkgdbtarget",
"request": "launch",
"name": "STM32Cube: STM32 Launch ST-Link GDB Server",
"origin": "snippet",
"cwd": "${workspaceFolder}",
"preBuild": "${command:st-stm32-ide-debug-launch.build}",
"runEntry": "main",
"imagesAndSymbols": [
{
"imageFileName": "${command:st-stm32-ide-debug-launch.get-projects-binary-from-context1}"
}
],
"deviceName": "STM32H747IIT6",
"deviceCore": "Cortex-M7",
},
}