cancel
Showing results for 
Search instead for 
Did you mean: 

Can't debug STM32H573I-DK board with OpenOCD

CambridgeDev
Associate

I'm trying to debug a Zephyr RTOS application on the STM32H573I Discovery board using the STM fork of openocd and the on-board STLink. I'm running the tools on a Mac M1 machine, and building and flashing the code works fine, using the Zephyr west based toolchain and VSCode.

But when I start openocd with this config (copied from STMCube IDE): 

# This is an genericBoard board with a single STM32H573IIKxQ 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 STM32H573IIKxQ

set BOARDNAME genericBoard

# 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]

it connects:

 Open On-Chip Debugger 0.12.0-00022-gdf4ec6169 (2024-10-04-12:15) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V3J15M7 (API v3) VID:PID 0483:3754
Info : Target voltage: 3.276494
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : clock speed 200 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Info : [STM32H573IIKxQ.cpu] Cortex-M33 r0p4 processor detected
Info : [STM32H573IIKxQ.cpu] target has 8 breakpoints, 4 watchpoints
STM32H573IIKxQ.cpu in Non-Secure state
Warn : DEPRECATED! use 'read_memory' not 'mem2array'
Warn : DEPRECATED! use 'read_memory' not 'mem2array'
Info : gdb port disabled
Info : starting gdb server for STM32H573IIKxQ.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : [STM32H573IIKxQ.cpu] external reset detected

 but when i try to connect to the server with gdb it reports:

Info : accepting 'gdb' connection on tcp/3333
Error: timed out while waiting for target halted
Error executing event gdb-attach on target STM32H573IIKxQ.cpu:

Warn : Cannot identify target as an STM32H5x family device.
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Info : Halt timed out, wake up GDB.

 Is this a bug with the STM openocd, or is my config broken ?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
CambridgeDev
Associate

I managed to work this out after some digging - turns out that the version of opencocd built from the github repo is not the same as the one shipped with the STMCube IDE bundle. The one shipped with the IDE works with the STM32H573, the one from the repo doesn't.

View solution in original post

1 REPLY 1
CambridgeDev
Associate

I managed to work this out after some digging - turns out that the version of opencocd built from the github repo is not the same as the one shipped with the STMCube IDE bundle. The one shipped with the IDE works with the STM32H573, the one from the repo doesn't.