I want to program my bluepill board using a STLink-V2 debug probe (clone).
I have upgraded PIO to the latest version and updated all platform files.
$ pio --version
PlatformIO, version 3.5.2b5
$ pio platform update
Updating tool-scons @ 2.20501.3 [Up-to-date]
Updating tool-unity @ 1.20302.1 [Up-to-date]
Updating contrib-pysite @ 0.1.5 [Up-to-date]
Updating tool-pioplus @ 0.14.1 [Up-to-date]
Platform Manager
================
Platform ST STM32
--------
Updating ststm32 @ 4.0.0 [Up-to-date]
Updating tool-stm32duino @ 1.0.0 [Up-to-date]
Updating framework-arduinoststm32 @ 2.1.180219 [Up-to-date]
Updating toolchain-gccarmnoneeabi @ 1.70201.0 [Up-to-date]
Updating tool-stlink @ 1.10400.0 [Up-to-date]
When I create a new project using pio init -b bluepill_f103c8 --ide=eclipse and add the basic blink sketch, it compiles fine.
platformio.ini
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
At uploading however it fails to find openocd.
$ pio run -t upload
Checking program size
text data bss dec hex filename
6472 1944 344 8760 2238 .pioenvs\bluepill_f103c8\firmware.elf
Configuring upload protocol...
AVAILABLE: blackmagic, jlink, mbed, stlink, stlink
CURRENT: upload_protocol = stlink
openocd -s -f scripts/interface/stlink.cfg -c "transport select hla_swd" -f scripts/target/stm32f1x.cfg -c "program {{.pioenvs\bluepill_f103c8\firmware.elf}} verify reset; shutdown;"
The command "openocd" is either written incorrcetly or couldn't be found. [translated message]
*** [upload] Error 1
When I look at my .platformio/packages/ folder, I donât see a tools-openocd folder in which there might be openocd.exe.
Also, even if openocd would be found in the path, it still selects the wrong file. There is no stlink.cfg in the interface/ folder (here). I would need it to select the stlink-v2.cfg file.
I can however flash the produced firmware using the STM32 ST-LINK Utility just fine, and the firmware works perfectly.
19:23:03 : ST-LINK SN : Old ST-LINK firmware/ST-LINK already used
19:23:03 : ST-LINK Firmware version : V2J17S4 (Need Update)
19:23:03 : Old ST-LINK firmware detected!
Please upgrade it from ST-LINK->'Firmware update' menu.
19:23:03 : Connected via SWD.
19:23:03 : Connection mode : Connect Under Reset.
19:23:03 : Debug in Low Power mode enabled.
19:23:03 : Device ID:0x410
19:23:03 : Device flash Size : 128KBytes
19:23:03 : Device family :STM32F10xx Medium-density
19:23:27 : [firmware.bin] opened successfully.
19:23:27 : [firmware.bin] checksum : 0x001060C5
19:23:53 : Memory programmed in 3s and 438ms.
19:23:53 : Verification...OK
19:23:53 : Programmed memory Checksum: 0x001060C5
So this shouldnât be problem with my STLinkV2 clone.
What am I doing wrong, how can I flash my Bluepill using ST-Link V2 over SWD?