MCU not available on OpenOCD platformio revision

I’m developing on a really new STM32G4, and I have some trouble using it on platformio.
More detail here :

I’m trying to start debug on my custom board but the platformio version of openOSC is too old and the STM32G4 is not available.

I updated my stlink firmware revision and I found the correct config file stm32g4*.cfg of the new openoCD revision and try to simply paste it into the platformio tool-openocd/target folder.
But I had some strange result :

xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-15:21)
Licensed under GNU GPL v2
For bug reports, read
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 2000 kHz
Info : STLINK V2J23M9 (API v2) VID:PID 0483:374B
Info : Target voltage: 0.012607
Error: target voltage may be too low for reliable debugging
Info : stm32g4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection from pipe
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0xfffffffe msp: 0xffffffd8
Info : device id = 0x20016469
Warn : Cannot identify target as an STM32L4 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
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
.pioinit:13: Error in sourced command file:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout

So I think I will need to get a newer revision of openocd…
I look into cubeIDE and the revision they use is : Open On-Chip Debugger 0.10.0+dev-g5ce997d.

Is there any way to control the openOCD revision used in platformio.ini or board.json?

You’re able to select the available tool-openocd package versions from the officially released ones (Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog) by either declaring it per-project for in the platformio.ini via platform_packages again, or via the platform.json manifest file (version attribute in the package, needs to be listed in the given packageRepositories).

However openocd 0.10.0+dev (2019-07-17-11:25) is the latest version in the PlatformIO repos. So it seems like you have to create your own tool-openocd package again and include it via the one of the ways given above (for the platform.json, you’d need to fork the ststm32 platform and use that in platform = ststm32@..., so it’s more complicated…)

Attempting to identify a STM32G4 as a STM32L4 seems like a red flag. Try getting the openocd binary updated at first, so that then maybe the cfg file works.

I’ve seen that error pop up when some weird (older or newer) gdb version attempts to talk to the openocd-opened gdb server, or when the wrong architecture is used (an x64 gdb vs arm-none-eabi-gdb)

1 Like

Thank’s again @maxgerhardt,

I succeed to make it work following your advices.