How to use with PlatformIO?

Bootloader for STM32F103 and STM32F4xx micro-controllers
No special driver is required. Support for Windows, Linux and Mac Operating System
Post Reply
Kenjutsu
Posts: 27
Joined: Tue Apr 07, 2020 10:58 am
Answers: 2

How to use with PlatformIO?

Post by Kenjutsu »

Good day

How do I use this bootloader with PlatformIO?

It works perfectly under Arduino without fail, so thank you so much for your hard work on this. Under macOS, I have found that only Serial upload worked perfectly each time. Now I can add the STM32 HID bootloader to this list ;)

TIA
by Kenjutsu » Mon May 25, 2020 8:35 am
Thank you for your reply. I started working on a custom uploader, which was able to find the PB and started uploading, but the blink program never executed and the serial port was missing after the upload. I knew it had to do with some build flags, but I had no idea which ones, so I put it on ice.

By chance, I read this post stm32 shows up on dmesg but not in arduino ide #34 which lead me to Notes on using STM32F103C8T6 Blue Pill. I watched the video How to Install the STM32 USB Bootloader - Tutorial Video. Towards the end was info on how to get the HID bootloader working in PlatformIO. I modified my platformio.ini file accordingly, but the upload failed with sh: hid-flash: command not found

A quick Google led me to [sh: hid-flash: command not found] Error when using hid upload protocol with stm32 bluepill. The fix is to copy the appropriate hid-flash program to the appropriate folder. I do not have framework-arduinoststm32-maple so I downloaded and copied hid-flash from STM32_HID_Bootloader

Now, everything works fine ;) 8-)
Go to full post
Pieter

OSX: 11.6.8
Arduino IDE: 1.8.19
PlatformIO: 6.1.4
STM32 Core: 2.3.0
Get a $5 off coupon on your first purchase at Kaiweets
Kaiweets Affordable & Smart Electrical Testing Tools
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: How to use with PlatformIO?

Post by stas2z »

With platformio you can define your own custom uploader
https://docs.platformio.org/en/latest/p ... pload-tool
Kenjutsu
Posts: 27
Joined: Tue Apr 07, 2020 10:58 am
Answers: 2

Re: How to use with PlatformIO?

Post by Kenjutsu »

Thank you for your reply. I started working on a custom uploader, which was able to find the PB and started uploading, but the blink program never executed and the serial port was missing after the upload. I knew it had to do with some build flags, but I had no idea which ones, so I put it on ice.

By chance, I read this post stm32 shows up on dmesg but not in arduino ide #34 which lead me to Notes on using STM32F103C8T6 Blue Pill. I watched the video How to Install the STM32 USB Bootloader - Tutorial Video. Towards the end was info on how to get the HID bootloader working in PlatformIO. I modified my platformio.ini file accordingly, but the upload failed with sh: hid-flash: command not found

A quick Google led me to [sh: hid-flash: command not found] Error when using hid upload protocol with stm32 bluepill. The fix is to copy the appropriate hid-flash program to the appropriate folder. I do not have framework-arduinoststm32-maple so I downloaded and copied hid-flash from STM32_HID_Bootloader

Now, everything works fine ;) 8-)
Pieter

OSX: 11.6.8
Arduino IDE: 1.8.19
PlatformIO: 6.1.4
STM32 Core: 2.3.0
Get a $5 off coupon on your first purchase at Kaiweets
Kaiweets Affordable & Smart Electrical Testing Tools
Riffer
Posts: 3
Joined: Sat Aug 08, 2020 7:11 pm

Re: How to use with PlatformIO?

Post by Riffer »

Thanks for your valuable input. I experienced the same: the hid-flash tool of PlatformIO is outdated and can not cope with the 2.2.1 bootloader.

After copying the executable into the platform-IO tools directory, the upload works.

But I had to use a slightly changed environment I want to share:

Code: Select all

[env:bluepill_f103c8_128k]
platform = ststm32
board = bluepill_f103c8_128k
framework = arduino
upload_protocol = hid
upload_port = COM8
build_flags = 
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D USBCON
    -D USB_VID=0x0483
    -D USB_MANUFACTURER="Unknown"
    -D USB_PRODUCT="\"BLUEPILL_F103C8\""
    -D HAL_PCD_MODULE_ENABLED
lib_extra_dirs = ~/Documents/Arduino/libraries
Please be aware of "USB_VID"! That key was more or less a good guess after looking into the log files.
The upload_port depended on the port Windows (in my case) set up the device as 'STM Device'.
neo_nmik
Posts: 20
Joined: Thu Feb 04, 2021 7:09 pm
Answers: 2

Re: How to use with PlatformIO?

Post by neo_nmik »

Just incase anyone finds this and is still struggling...

I'm using a Mac, and moving from the Arduino IDE, and I already had this Bootloader working for the Bluepill under the Arduino IDE...
Kenjutsu wrote: Mon May 25, 2020 8:35 am By chance, I read this post stm32 shows up on dmesg but not in arduino ide #34 which lead me to Notes on using STM32F103C8T6 Blue Pill. I watched the video How to Install the STM32 USB Bootloader - Tutorial Video. Towards the end was info on how to get the HID bootloader working in PlatformIO. I modified my platformio.ini file accordingly, but the upload failed with sh: hid-flash: command not found

A quick Google led me to [sh: hid-flash: command not found] Error when using hid upload protocol with stm32 bluepill. The fix is to copy the appropriate hid-flash program to the appropriate folder. I do not have framework-arduinoststm32-maple so I downloaded and copied hid-flash from STM32_HID_Bootloader
For clarification, as I also didn't have a framework-arduinoststm32-maple folder, I ended up copying HID-Flash from my Arduino packages folder:
/Users/**yourusername**/Library/Arduino15/packages/STM32/tools/STM32tools/**versionnumber**/macosx/hid-flash
Straight into:
/Users/** yourusername**/.platformio/packages/tool-stm32duino

This made the HID-flash available in PlatformIO, but still failed to upload, and spat out this in the terminal:

Code: Select all

Error - [1209:BEBA] device is not found :(> Searching for [COM17] ...
error, counldn't open [/dev/COM17]
So I then copied the address from an Arduino IDE Upload (cu.usbmodem024EB5C953471) to the platform.ini file:

Code: Select all

upload_port = cu.usbmodem024EB5C953471
I'm pretty sure I'd have to change this if I changed USB port or the Board, but you could always figure it from the Arduino IDE on your machine.
Post Reply

Return to “STM32 HID bootloader”