Skip to main content
Visitor II
December 11, 2023
Solved

Nucleo STM32H5 debugging OpenOCD

  • December 11, 2023
  • 3 replies
  • 12110 views

Hi all,

I recently got a Nucleo STM32H563ZI board to start doing development with the STM32H5x family of microcontrollers but I'm having issues trying to setup a debug session in VSCode. I've download the STM32 OpenOCD version and compiled it as it seems to have support for STM32h5x.

 

Has anyone successfully launched a debug session in VSCode? 

I'm using Cortex-Debug and have tried different configurations with openocd but no luck. 

Thanks!

martin

    This topic has been closed for replies.
    Best answer by margce

    This can now be closed, I saw the file STM32H5_Nucleo Debug.cfg which I have generated from CubeMX code example.

    3 replies

    margceAuthorAnswer
    Visitor II
    December 11, 2023

    This can now be closed, I saw the file STM32H5_Nucleo Debug.cfg which I have generated from CubeMX code example.

    Visitor II
    February 6, 2024

    I'm facing the same issue for STM32H503xx.

    Can you please share the cortex-debug configuration in VS code?

    Thanks in advance.

    margceAuthor
    Visitor II
    February 7, 2024

    Hi 

    The configuration I'm using for cortex-debug is as follows, note that I define the "serverpath" variable to the version of openocd that I've download and compiled locally as the latest version of openOcd that I've installed in the system from homebrew does not support STM32H5 targets yet

    This is the system openocd 

    (base) ➜ ~ which openocd
    /opt/homebrew/bin/openocd
    (base) ➜ ~ openocd --verion
    Open On-Chip Debugger 0.12.0
    Licensed under GNU GPL v2
    For bug reports, read
    	http://openocd.org/doc/doxygen/bugs.html
    openocd: unrecognized option `--verion'

     This is the ST version that adds support for H5

    (base) ➜ ~/tools/bin pwd
    /Users/tinno/tools/bin
    (base) ➜ ~/tools/bin ./openocd --version
    Open On-Chip Debugger 0.12.0-00017-g26301c4dd-dirty (2023-12-11-10:38) [https://github.com/STMicroelectronics/OpenOCD]
    Licensed under GNU GPL v2
    For bug reports, read
    	http://openocd.org/doc/doxygen/bugs.html

    The cortex-debug config looks like this

    {
     "executable": "${workspaceFolder}/port/NUCLEO_STM32H563/Output/App.elf",
     "cwd": "${workspaceRoot}",
     "name": "APP-OPENOCD",
     "request": "launch",
     "type": "cortex-debug",
     "servertype": "openocd",
     "serverpath": "/Users/tinno/tools/bin/openocd",
     "runToEntryPoint": "application_main",
     "serverArgs": [
     ],
     "osx": {
     "configFiles": ["port/NUCLEO_STM32H563/debugOpenOcd.cfg"],
     "armToolchainPath": "/Applications/ARM/bin/",
     "executable": "${workspaceFolder}/port/NUCLEO_STM32H563/Output/App.elf",
     },
     "preLaunchCommands": [
     "symbol-file port/NUCLEO_STM32H563/Output/App.elf",
     "monitor reset halt",
     "break application_main",
     ], 
     "postLaunchCommands": [
     "continue"
     ]
     ,"preRestartCommands": [
     ],
     "svdFile": "${workspaceFolder}/port/NUCLEO_STM32H563/STM32H563.svd",
     "liveWatch": {
     "enabled": false,
     "samplesPerSecond": 1
     }
    }

    The file with debugOpenOcd.cfg is the one I copied from STM32 as shown in my previous comments

     

    Visitor II
    December 11, 2023

    Hi all. 

    I have the same problem with stm32h563zi using Clion as IDE. In order to debug I was seeking for stm32h563xx.cfg in the official OPENOCD repository (https://sourceforge.net/p/openocd/code/ci/master/tree/) but found 3 main conf files to be combined (h563zi.cfg, stm32h5x.cfg, stm32x5x_common.cfg). However I couldn't make.

    I would like to try the solution above but I couldn't generate the file STM32H5_Nucleo Debug.cfg. Can anyone help?

    Thank you

    margceAuthor
    Visitor II
    December 12, 2023

    Hi Marc

    On the last stable OpenOCD version I have installed on my Macbook which is v0.12.0 there is no support for stm32h5x so what I did that download the STM32 OpenOcd and compile the source. Clone the repo and follow the instruction for to configure and compile for your system. ST custom version has support for stm32h5 the config file i'm using looks like this

    # This is an NUCLEO-H563ZI board with a single STM32H563ZITx chip
    #
    # Generated by STM32CubeIDE
    # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
    
    source [find interface/stlink-dap.cfg]
    
    set WORKAREASIZE 0x8000
    
    transport select "dapdirect_swd"
    
    set CHIPNAME STM32H563ZITx
    set BOARDNAME NUCLEO-H563ZI
    
    # Enable debug when in low power modes
    set ENABLE_LOW_POWER 1
    
    # Stop Watchdog counters when halt
    set STOP_WATCHDOG 1
    
    # STlink Debug clock frequency
    set CLOCK_FREQ 8000
    
    # Reset configuration
    # use hardware reset, connect under reset
    # connect_assert_srst needed if low power mode application running (WFI...)
    reset_config srst_only srst_nogate connect_assert_srst
    set CONNECT_UNDER_RESET 1
    set CORE_RESET 0
    
    # ACCESS PORT NUMBER
    set AP_NUM 1
    # GDB PORT
    set GDB_PORT 3333
    
    # BCTM CPU variables
    source [find target/stm32h5x.cfg]

     

    Explorer
    January 23, 2024

    Hi

    I am facing the same issue. Can you please share the compile steps for to compile the STM32 Openocd for windows if known. 

    Thanks

    SSing

    Graduate
    February 26, 2024

    Thanks! Will take a look at and get back to you if I need anything.