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 (GitHub - rogerclarkmelbourne/STM32duino-bootloader: Bootloader for STM32F103 boards, for use with the Arduino_STM32 repo and the Arduino IDE).

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
1 Like

Can you show your Arduino IDE board manager which exact STM32 core you have installed? GitHub - rogerclarkmelbourne/Arduino_STM32: Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards or GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino?

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
1 Like

When trying to upload a sketch via the USB port I get the following error message:

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=3092, tid=0x0000000000002c48

Does anyone knows a fix for this? Thanks a lot in advance.