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
C:\Users\Max.platformio\packages\tool-openocd\bin\
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.