Debugging failure almost all Nucleo board - Solution is here

Before reading: I have latestes software (OpenOCD, Eclipse, ARM GNU toolchain …etc)
After spending days, hours to find out why my board never could be debugged. I tried OpenOCD /Eclipse with both Nucleo-L476RG and Nucleo-F207ZG. OpenOCD never could reset, or halt the devices.
I treid Zadig driver, ST origional driver (windows I am talking about). I even tried Linux xbuntu … all failed.
I was suspesious about the delay that could happen during the call of reset, halt. and YES!!!

In my enviroment, My laptop is connected to a laptop-expantion which I have a USB-HUB also connected. I was using the USB-HUB and it was failing all the time.
I tried the NUCLEO-L476RG that I could debug before. Suddenly I couldn’t … I connected again the board DIRECTLY to the laptop without any USB-HUB … and the OpenOCD started again to work …

I tried again the same with Nucleo-F207ZG … but It didn’t work.

I then looked at the OpenOCD\scripts\target\stm32l4x.cfg and OpenOCD\scripts\target\stm32f2x.cfg and compared them in Winmerge… Sure there is a part that is missing in the stm32f2x. the part is as bellow:
# added by mariwan - Start
$_TARGETNAME configure -event reset-init {
# CPU comes out of reset with MSI_ON | MSI_RDY | MSI Range 6 (4 MHz).
# Use MSI 24 MHz clock, compliant even with VOS == 2.
# 3 WS compliant with VOS == 2 and 24 MHz.
mww 0x40022000 0x00000103 ;# FLASH_ACR = PRFTBE | 3(Latency)
mww 0x40021000 0x00000099 ;# RCC_CR = MSI_ON | MSIRGSEL | MSI Range 9
# Boost JTAG frequency
adapter speed 4000
}

$_TARGETNAME configure -event reset-start {
	# Reset clock is MSI (4 MHz)
	adapter speed 500
}
# added by mariwan  - END  

After adding that part to the config file of the Nucleo-F207ZG … Sure the debugger started to work!!!

Days, hours spent on finding this issue. I hope this help you

Think about that, any board, if the OpenOCD cannot rest/halt , you might have a delay issue in your connection. Sure there might be other issues.
I suggested that change to OpenOCD … I hope they fix that file. But there might be a need for adding it to other files also for other boards.
Hope I help you to not face what I faced

1 Like

Thank you for sharing this information with us! I’m sure it will save lot of time and frustration for many of us users. OpenOCD scripts tend to be very tricky an mysterious.

1 Like

I would appreciate if this will be highlighted somewhere … so it is not disappearing from the forum. and will be difficult to reach others.

Since Mbed, specifically MbedStudio, does not support OpenOCD but rather prefers pyOCD, I’m afraid this info won’t be included into the official Mbed documentation. To notify as many users as possible you can try to post this info also in another related and popular threads. For example the following one has been viewed more than 2600 times:

https://forums.mbed.com/t/mbed-studio-cant-debug