PlatformIO Community

PlatformIO on VSCode for STM32 (STM32F103 bluepill) with the Arduino Framework cannot upload via USB (DFU bootloader)

I’m using VS Code with PlatformIO for the “ST STM32” platform with the “Arduino Framework” and I am trying to upload firmware to an STM32F103 bluepill that has probably been flashed with the default STM32duino / Maple bootloader (https://github.com/rogerclarkmelbourne/STM32duino-bootloader).

With the Arduino IDE everything works, i.e. VCP shows up and can upload firmware (I need to reset the board manually ocasionally).

With VSCode and PlatformIO, I first got a “java” not found error. I was able to “bend” the VSCode batch files to use the java version supplied with the Arduino IDE to eliminate that error (other Java versions cause an access violation).
Then uploading to the microcontroller worked once, and afterwards no COM port is shown but a “Maple 003” device, resulting in

Looking for upload port...
Error: Please specify `upload_port` for environment or use global 
`--upload-port` option.

What is the issue here, is there a fix?
Is there documentation on the “dfu” upload protocol for the “arduino” platform anywhere?
What is the recommended way to use PlatformIO with the bluepill and the Arduino framework?

platformio.ini:

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_protocol = dfu
#upload_port=COM20

Can you show your Arduino IDE board manager which exact STM32 core you have installed? https://github.com/rogerclarkmelbourne/Arduino_STM32 or https://github.com/stm32duino/Arduino_Core_STM32?

Arduino:
STM32 Cores by STMicroelectronics V 1.9.0
https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json

possibly related:

  • http s://community.platformio.org/t/can-not-upload-to-blue-pill-using-dfu/6431/7
  • http s://community.platformio.org/t/error-uploading-bluepill-stm32-arduino/12131/5
  • http s://community.platformio.org/t/help-stm32-bluepill-f103c8-and-maple-librarys/10048
  • http s://community.platformio.org/t/stm32f1-blue-pill-stuck-in-dfu-mode-after-upload/6853

This works:

[env:bluepill_f103c8]

platform = ststm32

board = bluepill_f103c8

framework = arduino

board_build.core = maple

upload_protocol = dfu