Mbed: can't upload to STM32

Using Mbed, when I try to upload I get following output.

  1. I get a failed but the 1. Upload works and the program runs
  2. After them no more upload is possible
  3. It happens with all nucleo boards
platform = ststm32
board = nucleo_f401re
framework = mbed
upload_protocol = stlink

Bildschirmfoto 2021-01-14 um 10.51.32

Bug report to Issues · platformio/platform-ststm32 · GitHub please for @valeros.

See @copperbot-d, he also recently posted about this

Hello @sstaub

This seems to be related to MBED 6.6 and stlink/jlink issue, can you please check this solution ?

After editing your MBED framework, you may need to keep “reset” button pushed on your Nucleo before uploading the new program to get stlink upload protocol working (or switch to upload_protocol = mbed once before working with stlink again).

1 Like

It seems this is not a Mbed problem, I have the same issue when using the Arduino framework. On Mbed Studio I have no upload problem.
It is really annoying that PlatformIO becomes more and more a problem rather than a solution.

Well the question is whether OpenOCD returns a non-zero error code because it failed or if PlatformIO cannot interpret the output or return code directly.

Can you please do a “Verbose Build” and copy the OpenOCD invocation like. Then open a PIO CLI and copy-paste that line, but prefix it with the folder path of the openocd binary. E.g. the output might look something like

openocd -d2 -s C:\Users\Max.platformio\packages\tool-openocd/scripts -f interface/stlink.cfg -c “transport select hla_swd” -f target/stm32f1x.cfg -c “program {.pio\build\genericSTM32F103RC\firmware.elf} verify reset; shutdown;”

And then I would prefix that with


so make it a valid command. For Mac users, the path should look something like /Users/<user>/.platformio/packages/tool-openocd/bin.

Then post that output.