cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo H503 Debugging with VSCode

Calamity1911
Associate

Hello all,

I recently purchased a Nucleo H503 board to experiment with. The board itself works just fine, but I've been having trouble getting it to work with the VSCode STM32/cortex-debug plugin.

I just want to emphasize that using CubeProgrammer, I can connect to the board just fine and I was able to flash my test firmware that way. I also tried an ST-LINK V3SET that I borrowed from work, which also functioned just fine using CubeProgrammer.

When I try to debug the board using VSCode, I just get an error about not being able to connect to the target. Below is the launch.json I created for my project.

 

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceFolder}",
            "executable": "./build/h503dk.elf",
            "request": "launch",
            "type": "cortex-debug",
            "runToEntryPoint": "main",
            "servertype": "stlink",
            "gdbPath": "C:/arm-toolchain/bin/arm-none-eabi-gdb.exe",
            "serverpath": "C:/ST/STM32CubeCLT_1.16.0/STLink-gdb-server/bin/ST-LINK_gdbserver.exe",
            "svdFile": "C:/ST/STM32CubeCLT_1.16.0/STMicroelectronics_CMSIS_SVD/STM32H503.svd"
        }
    ]
}

 

 

When attempting to debug, the following error appears in the command line. Note that this is the same exact error between the on-board ST-LINK and the V3SET. I did also make sure to fit JP1 on the board to disable the on-board ST-LINK when using the V3SET.

 

"C:/ST/STM32CubeCLT_1.16.0/STLink-gdb-server/bin/ST-LINK_gdbserver.exe" -p 50000 -cp "C:\\Program Files\\STMicroelectronics\\STM32Cube\\STM32CubeProgrammer\\bin" --swd --halt


STMicroelectronics ST-LINK GDB server. Version 7.8.0
Copyright (c) 2024, STMicroelectronics. All rights reserved.

Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 31
        Listen Port Number         : 50000
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled

COM frequency = 24000 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
COM frequency = 8000 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
COM frequency = 3300 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
COM frequency = 1000 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
COM frequency = 200 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
COM frequency = 50 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
COM frequency = 5 kHz
Target connection mode: Default
Target connection failed. Try connecting under reset
Target connection failed
Target unknown error 32

Error in initializing ST-LINK device.
Reason: Unknown. Please check power and cabling to target.

 

 

Again, I can verify that CubeProgrammer is able to communicate with the target. I also used CubeProgrammer to check if somehow the debug authentication feature of the processor was enabled, and to the best of my knowledge, it looks like there shouldn't be any because the product state option byte is still marked as "open." I also attached the .ioc generated by CubeMX. SWD is enabled, so I don't think that's the issue.

My thought is that this could potentially be a bug with the CubeProgrammer CLI application, but the GUI works just fine so I am uncertain as to the cause of the problem. Any advice would be appreciated.

 

 

2 REPLIES 2
Pavel A.
Evangelist III

It prints several times: "Try connecting under reset". Doesn't this give some clue?

Yes, it does give some insight, but my interpretation is that the software failed to do a hot plug connection, so it then tries to connect under reset.

I guess I could manually try holding the reset button while the GDB Server tries to connect but I have a feeling that would cause a different error.

Plus, like I mentioned, CubeProgrammer itself can connect to the target just fine, either set to Hot Plug connection mode or Under Reset.