cancel
Showing results for 
Search instead for 
Did you mean: 

SWO output not working with VSCode Cortex-Debug

OskarP
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
As far i can see no SWO support (yet at least)
Per release note semihosting is supported but not tracing in real at that
time

View solution in original post

11 REPLIES 11
Nawres GHARBI
ST Employee

@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.

 

https://marketplace.visualstudio.com/items?itemName=stmicroelectronics.stm32-vscode-extension&ssr=false#overview

@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.

Nawres GHARBI
ST Employee

could you share the extension version please ? seems you are using a very old one

@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

Nawres GHARBI
ST Employee

Please update to the latest one on the Marketplace and switch to pre-release version

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

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:

OskarP_0-1759335589497.png

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": ""
        }
    ]
}

@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

Cartu38OpenDev_0-1759346919730.png

 

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 ?

Cartu38OpenDev_1-1759347024616.png

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.

@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.

Bildschirmfoto 2025-10-02 um 07.45.07.png

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",
        },
}