How do I enable stlink for a new stm32 chip?

I’m trying to use platformio to program a STM32G071RB over SWD. My only uploader/debugger probe is an st-link v2.

The closest board in platformio is the Nucleo G071RB, so I selected that. But its upload protocol list doesn’t include stlink. I took a chance and edited ~/.platformio/platforms/ststm32/boards/nucleo_g071rb.jso, but then it fails on an assertion error. Looks like some openocd info is missing?

Is there some file somewhere I can edit to add support? How would I go about it?

This is indeed the right first step, but then you also have to give it the correct config file for the board and openOCD needs to have general support for these targets. Which is the whole crux of the thing. This was only introduced recently in openocd, 17 days ago:

Theoretically you can grab the latest openocd version, compile it from source, overwrite your binaries in <home folder>\.platformio\packages\tool-openocd, then set the openocd target to stm32g0 (as seen here) so that it uses the new tcl/target/stm32g0x.cfg config.

Otherwise a new stable version of openocd must and will be integrated into PlatformIO which then enables this support without modifications. Until that, some time could pass.

1 Like