STM32duino + black pill, usb descriptor failed

Hi there,

I’ve been trying to upload a simple blinking LED sketch, and to send something over the serial port (or rather USB port, emulating a COM port). The board is a “black pill”, containing an STM32f103C8T6. I measured the pull-up resistor located between D+ and VCC, and its value is 1.5 kOhm (this is often an issue with blue pill boards).

The LED blinks successfully. Both upload via STlink (clone) and DFU work (after flashing bootloader). However, after flashing the sketch, the USB device isn’t recognised anymore. An exclamation mark appears next to the device in device manager, stating “unknown usb device (device descriptor request failed)”.

I tested on two boards (from different vendors), and the issue is exactly the same. Can you guys provide me some help here?

The platform.ini file is as follows:
platform = GitHub - platformio/platform-ststm32: ST STM32: development platform for PlatformIO
board = bluepill_f103c8
; board = genericSTM32F103C8
framework = arduino
upload_protocol = stlink
; upload_protocol = dfu
; upload_port = anything

The main.c is very simple:
#include <Arduino.h>

#define LED_PIN PB12

void setup() {

void loop() {
digitalWrite(LED_PIN, 1);
digitalWrite(LED_PIN, 0);

Your real problem is the usb port is sketchy at best. It is terminated incorrectly and you are lucky anything worked up until now. I’m not bashing, but it is a frustrating design.

The solution is to get one of those little cheap st-link devices that connect to the pins at the opposite end of the usb port. It is seamless and you never have to change jumpers. It works in both PlatformIO or ArduinoIDE. No bootloader required.

I am already using an STlink (see first post). I want to use the usb port for serial communication (data logging etc.). Given that the two boards give exactly the same error mode, AND that upload over DFU works ok (i.e. the USB port works), I suspect something is wrong in the software implementation. For completeness, a log from USBview:

[Port1] FailedEnumeration : Unknown USB Device (Device Descriptor Request Failed)

Is Port User Connectable: yes
Is Port Debug Capable: no
Companion Port Number: 5
Companion Hub Symbolic Link Name: USB#ROOT_HUB30#4&1a49b3c3&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
Protocols Supported:
USB 1.1: yes
USB 2.0: yes
USB 3.0: no

   ---===>Device Information<===---

ConnectionStatus: FailedEnumeration
Current Config Value: 0x00 -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address: 0x00
Open Pipes: 0
*!*ERROR: No open pipes!

      ===>Device Descriptor<===

*!*ERROR: bLength of 0 incorrect, should be 18
bLength: 0x00
bDescriptorType: 0x00
bcdUSB: 0x0000
bDeviceClass: 0x00
*!*ERROR: Device enumeration failure

On a hunch, try a different port.

Still the same. Also tried two different USB cables. Edit: also tried two different computers, no difference.

How possible is it that there is no boot loader on the board? Your code may not include any usb initialization code. I believe the bluepill defaults the serial to pa9,10 (or what ever, I don’t remember anymore).

Apparently that’s the case, thanks for the suggestion. If I upload via STlink, the serial data that I expected to be sent over USB appears on PA9.

However, according to, Serial.print commands should print over USB CDC. This isn’t working in my case. Should I manually specify to use some bootloader somehwere in the pio options?

Edit: if I upload via DFU, the LED doesn’t even blink.

Bump. Does anyone have a solution to the problem described above?

I’m having the same problem with PIO. It works fine using the Arduino IDE.

Please file an issue here Issues · platformio/platform-ststm32 · GitHub

Hello, I think I am having this exact issue. Did you ever get it resolved?

What code and platformio.ini do you have, what are the expected and actual results?

I’m new to STM development, so I’m fumbling my way around. Unfortunately, I ended up not saving the project. What happened is I ordered a “BlackPill” From Amazon, RoboDYN with the arduino bootloader. When it first arrived I was able to see it as a Serial device. I used BlackPill 128k as the board. I loaded some generic blink code, uploaded it and it stopped the bootloader from loading / recognizing the device on any computer and lsusb shows nothing. It used to blink the onboard LED when connected and that stopped, I’m assuming some kind of indicator that its accessing serial over USB. For now, I’m using a direct serial connection to program the board.

You know you have to put the board in boot loader mode to be able to program it via USB DFU? The bootloader pins (BOOT0 and BOOT1) control whether the bootlaoder (system memory) is executed, the firmware from Flash or RAM.

Just move the B0 and B1 jumpers respectively on the board

After setting the boot pin you need to push the reset button. Running the firmware requires you to put the jumpers back to 0.

If you want to use the USB serial in your program that’s another story. Are you using that?