Platformio and HID bootloader (or any bootloader)
Posted: Sun Sep 13, 2020 11:57 pm
I have an old Blue Pill device, genuine STM32 chip. I used it many times in the past with Arduino and the Libmaple core. So I know that the board is not the problem
I'm now trying to use Platformio with the Libmaple core. I loaded the STM32duino core and the Libmaple one, I manually updated the Libmaple core because I read that some libraries were not updated (I confirmed it was the case using the F1 USB Composite library https://github.com/arpruss/USBComposite_stm32f1).
I first tried Blinky, but if I uploaded it with the SWD protocol (using ST Link), nothing worked: the project gets flashed but doesn't run, and the USB device is not recognized. I suspected a bootloader problem. I flashed the Maple DFU bootloader, but using that protocol I get a Java crash, not sure why
Lastly I decided to try USB HID (https://github.com/Serasidis/STM32_HID_Bootloader). If I use the ST core, everything works with the following settings in Platformio.ini
[env:genericSTM32F103CB]
platform = ststm32
board = genericSTM32F103CB
framework = arduino
upload_protocol = hid
upload_port = COM3
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-D USB_VID=0x0483
-D USB_MANUFACTURER="Unknown"
-D USB_PRODUCT="\"genericSTM32F103CB\""
-D HAL_PCD_MODULE_ENABLED
Code flashes, then reboots and I can see Blinky working as expected. If I reflash, everything works (i.e. HID bootloader is maintained)
But if I add the "use Maple core configuration" as follows
[env:genericSTM32F103CB]
platform = ststm32
board = genericSTM32F103CB
framework = arduino
board_build.core = maple ; Use Maple core
upload_protocol = hid
upload_port = COM3
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-D USB_VID=0x0483
-D USB_MANUFACTURER="Unknown"
-D USB_PRODUCT="\"genericSTM32F103CB\""
-D HAL_PCD_MODULE_ENABLED
The code builds and flashes, but then the BluePill is not recognized as a USB device and Blinky doesn't blink. Just like when using SWD to flash
What is the trick to use a BluePill with Platformio and the Maple/Rogers core?
I'm now trying to use Platformio with the Libmaple core. I loaded the STM32duino core and the Libmaple one, I manually updated the Libmaple core because I read that some libraries were not updated (I confirmed it was the case using the F1 USB Composite library https://github.com/arpruss/USBComposite_stm32f1).
I first tried Blinky, but if I uploaded it with the SWD protocol (using ST Link), nothing worked: the project gets flashed but doesn't run, and the USB device is not recognized. I suspected a bootloader problem. I flashed the Maple DFU bootloader, but using that protocol I get a Java crash, not sure why
Lastly I decided to try USB HID (https://github.com/Serasidis/STM32_HID_Bootloader). If I use the ST core, everything works with the following settings in Platformio.ini
[env:genericSTM32F103CB]
platform = ststm32
board = genericSTM32F103CB
framework = arduino
upload_protocol = hid
upload_port = COM3
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-D USB_VID=0x0483
-D USB_MANUFACTURER="Unknown"
-D USB_PRODUCT="\"genericSTM32F103CB\""
-D HAL_PCD_MODULE_ENABLED
Code flashes, then reboots and I can see Blinky working as expected. If I reflash, everything works (i.e. HID bootloader is maintained)
But if I add the "use Maple core configuration" as follows
[env:genericSTM32F103CB]
platform = ststm32
board = genericSTM32F103CB
framework = arduino
board_build.core = maple ; Use Maple core
upload_protocol = hid
upload_port = COM3
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-D USB_VID=0x0483
-D USB_MANUFACTURER="Unknown"
-D USB_PRODUCT="\"genericSTM32F103CB\""
-D HAL_PCD_MODULE_ENABLED
The code builds and flashes, but then the BluePill is not recognized as a USB device and Blinky doesn't blink. Just like when using SWD to flash
What is the trick to use a BluePill with Platformio and the Maple/Rogers core?