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.

4 REPLIES 4
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