cancel
Showing results for 
Search instead for 
Did you mean: 

Any hints on using SWO output from STM32 within VSCode via STLink V3?

brian_schmalz
Associate II

I'm reading various posts about the cortex debug extension supporting SWO output, but maybe not on STLinks, and various ways to enable it for other types of ARMs. Are there any guides to how to set it up for STM32 within VSCode?

5 REPLIES 5

It doesn't work on CM0(+) cores

You'd need to get with VSCode devs to understand exactly what they'd implemented and support in current iterations.

If it works on Segger J-Link's then you might look at the ST-LINK/V2 to J-Link OB firmware conversion. Or look at CMSIS-DAP support

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
brian_schmalz
Associate II

Right - thus my message here. Hopefully some of the ST Devs can weight in and suggest an existing set of instructions or some guidance on how best to set this up with what's in the current version of the extension.

I think VSCode has it's own forums and developer feeds

Perhaps @Nawres GHARBI knows?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jacob WOODRUFF
ST Employee

Hi All,

 

This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.

 

Regards,
Jake

ST Support

Rob.Riggs
Senior III

It works with OpenOCD. This is the stanza I use in my launch.json file:

 

 

        {
            "name": "Build & Debug Microcontroller - OpenOCD",
            "cwd": "${workspaceFolder}",
            "type": "cortex-debug",
            "executable": "${command:cmake.launchTargetPath}",
            // Let CMake extension decide executable: "${command:cmake.launchTargetPath}"
            // Or fixed file path: "${workspaceFolder}/path/to/filename.elf"
            "request": "launch",
            "servertype": "openocd",
            "configFiles": [
                "${workspaceFolder}/stlink.cfg"
            ],
            "device": "STM32L4P5RETx", //MCU used
            "interface": "swd",
            "serialNumber": "",        //Set ST-Link ID if you use multiple at the same time
            "runToEntryPoint": "main",
            "svdFile": "${config:STM32VSCodeExtension.cubeCLT.path}/STMicroelectronics_CMSIS_SVD/STM32L4P5.svd",
            "v1": false,               //Change it depending on ST Link version
            "serverpath": "/usr/bin/openocd",
            "stm32cubeprogrammer":"${config:STM32VSCodeExtension.cubeCLT.path}/STM32CubeProgrammer/bin",
            "stlinkPath": "${config:STM32VSCodeExtension.cubeCLT.path}/STLink-gdb-server/bin/ST-LINK_gdbserver",   
            "armToolchainPath": "${config:STM32VSCodeExtension.cubeCLT.path}/GNU-tools-for-STM32/bin",
            "gdbPath":"${config:STM32VSCodeExtension.cubeCLT.path}/GNU-tools-for-STM32/bin/arm-none-eabi-gdb",            
            "swoConfig": {
                "enabled": true,
                "cpuFrequency": 16000000,
                "swoFrequency":  2000000,
                "source": "probe",
                "decoders": [
                    { 
                        "type": "console",
                        "label": "ITM",
                        "showOnStartup": true,
                        "port": 0,
                        "encoding": "ascii"
                    }
                ]
            },
            "preLaunchTask": "Build project"
            /* If you use external loader, add additional arguments */
            //"serverArgs": ["--extload", "path/to/ext/loader.stldr"],
        },

 

You will need to amend the device, configFiles, and frequency. This will create a SWO terminal with SWO output. You may need to change the path to the OpenOCD binary. You can add multiple decoders, but I have only used it for ASCII output.