Using PlatformIO

STM32duino bootloader aka Maple bootloader
Post Reply
Very.Von
Posts: 11
Joined: Mon Jun 26, 2023 12:26 am

Using PlatformIO

Post by Very.Von »

I had a hard time getting PlatformIO working, but finally broke through. YMMV but here's my experience if it could help:

Note that I upload the sketch in Arduino IDE first, and then move to PlatformIO. It's worth doing both to learn the process.

I have a stock blue pill with LED connected to PC13 (I can actually see "PC13" written on the PCB below and to the left of LED) your blue pill might be slightly different. If it is consult the README here to see which bootloader file you need.

Step 1: Load the “generic_boot20_pc13.bin” bootloader onto the device using a FTDI serial breadboard setup and the STM32CubeProgrammer software program (there are many tutorials on how to do this)
Step 2: Load the Maple drivers in windows
Step 3: When you plug the blue pill into your computer it will show as a "Maple Serial" device (make sure both boot jumpers are set to 0 before connecting)
Step 4: Follow this tutorial to setup STM32 within Arduino IDE
Step 5: Use these settings:
Board: Generic STM32F1 series
Port: <your maple serial port in device manager>
Board part number: BluePill F103C6 (32K)
Upload method: Maple DFU Bootloader 2.0
USB Support: CDC (generic 'Serial' supersede U(S)ART)
U(S)ART support: Enabled (generic 'Serial')
Step 6: Compile and Upload the sketch. The "Maple Serial" device will disappear and a new COM port will appear "USB Serial Device" ... this is the USB serial port baked into your sketch.

Now close down Arduino IDE and open PlatformIO. Create a new project, Board F103C8 (Generic), Framework Arduino
Use this platformio.ini:
[env:BLUEPILL_F103C6]
platform = ststm32
board = BLUEPILL_F103C6
framework = arduino
board_build.variant = STM32F1xx\F103C4T_F103C6(T-U)
build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC -DSTM32F1xx -DARDUINO_BLUEPILL_F103C6 -DARDUINO_ARCH_STM32 -DSTM32F103x6 -DUSBCON -DUSBD_VID=0 -DUSBD_PID=0 -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC -DHAL_UART_MODULE_ENABLED -DBL_LEGACY_LEAF -DVECT_TAB_OFFSET=0x2000
upload_protocol = dfu
p.s. those build_flags could be total overkill, I copied them from Arduino IDE. I'll have to experiment to see which are actually needed.

Good luck and god speed. -Von

EDIT: Use BLUEPILL_F103C8, not C6 as the C6 has significantly less memory.
Last edited by Very.Von on Sat Aug 12, 2023 6:03 pm, edited 1 time in total.
cagz
Posts: 6
Joined: Thu Aug 03, 2023 12:26 pm

Re: Using PlatformIO

Post by cagz »

Can I please ask, where in Arduino IDE you found the build flags ?
Very.Von
Posts: 11
Joined: Mon Jun 26, 2023 12:26 am

Re: Using PlatformIO

Post by Very.Von »

cagz wrote: Sat Aug 12, 2023 4:08 pm Can I please ask, where in Arduino IDE you found the build flags ?
In Arduino IDE preferences "show verbose output during compile" and you should see them in the normal output now.
docH0lland4ze
Posts: 1
Joined: Fri Sep 15, 2023 7:00 am

Re: Using PlatformIO

Post by docH0lland4ze »

thank you so much for this. I've spent all week to get the bluepill working with platformio!
Post Reply

Return to “USB bootloader”