STM32F103C8T6 bluepill with HID Bootloader 2.2 problems uploading

Bootloader for STM32F103 and STM32F4xx micro-controllers
No special driver is required. Support for Windows, Linux and Mac Operating System
Post Reply
Doublestm32
Posts: 3
Joined: Mon Jun 07, 2021 1:51 pm

STM32F103C8T6 bluepill with HID Bootloader 2.2 problems uploading

Post by Doublestm32 »

Hi there,

I just installed the HID Bootloader 2.2 onto my bluepill according to https://youtu.be/Myon8H111PQ video and I am using the official corehttps://raw.githubusercontent.com/stm32 ... index.json. Using the serial over USB worked fine in my case and I was also able to use the serial monitor. However, when I set tools>USB support from CDC generic supersede U(S)ART to HID keyboard and mouse, things started behaving unexpectedly.
I want to use the bluepill as an HID device, which is why I set it to that mode. Now, when trying to upload my code, which is for testing purposes just this:

Code: Select all

//Just a minimalistic mouse jiggler

#include <Mouse.h>
void setup() 
{
Mouse.begin();
}

void loop() {
Mouse.move(5,0);
delay(100);
Mouse.move(-5,0);
delay(100);
}
The console at the bottom gives out this error:

Code: Select all

+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [COM1]...
> Toggling DTR...
> Searching for [1209:BEBA] device...
##########
Error - [1209:BEBA] device is not found :(> Searching for [COM1] ...
> [COM1] is found !
> Finish
Der ausgewählte serielle Port > Finish
 ist nicht vorhanden oder das Board ist nicht angeschlossen
(^in English this means: The selected serial port > Finish
is not available or the board is not connected)

I reflashed the bootloader several times and also erased the flash memory and it worked one time but was very inconsistent and when I replugged the bluepill, it wouldn't move the cursor anymore. I can also only select COM1 in the IDE, but I remember that there was one time also shown COM4 which was the actual port, my board was connected to when the upload worked.

I am posting this here, since I was unable to find a solution myself or online and I would appreciate greatly any help :slight_smile: !

Greetings
User avatar
Vassilis
Posts: 23
Joined: Wed Dec 18, 2019 3:04 pm
Location: Thessaloniki, Greece
Contact:

Re: STM32F103C8T6 bluepill with HID Bootloader 2.2 problems uploading

Post by Vassilis »

This is because the usb port is not configured as a composite usb device. A USB Composite Device is a peripheral device that supports more than one device class (source: keil.com). For example, using the usb port as a composite device you can have a usb serial port, mouse and keyboard, all at the same time.

Currently, the HID bootloader does not run as a composite usb device. When running your sketch, only the USB Serial port is available. The Arduino IDE uses the serial port to restart the MCU in HID bootloader mode. If there is no serial port, the loader cannot restart the MCU. When you replace:
USB support from CDC generic supersede U (S) ART
to
HID keyboard and mouse
automatically turn off the serial port needed to restart the MCU in the next programming.
Vassilis Serasidis
https://www.serasidis.gr
Doublestm32
Posts: 3
Joined: Mon Jun 07, 2021 1:51 pm

Re: STM32F103C8T6 bluepill with HID Bootloader 2.2 problems uploading

Post by Doublestm32 »

Thank you very much for your reply, this actually makes a lot of sense especially when I am thinking about how I could program the bluepill just fine when I hadn't changed the setting and only used it to blink an led.
Would it still be possible to use the board as a mouse or keyboard if I uploaded using ST-link?
Greetings

Edit: I got it to work by plugging the USB directly into the bluepill and connecting the ST-link to the swd pins, but I didn't connect the ST-links +3v3 pin. Now, I can upload via swd through the Arduino IDE and still be able to keep HID functionality :)
Post Reply

Return to “STM32 HID bootloader”