Skip to content

STM32 Blue / black pill dfu upload and usb serial problems #207

Description

@kloppertje

Some time ago I tried to get a black pill board (STM32F103C8T6) running under platformio. I can upload fine via STLinkV2 (clone). However, if I try to send some data over the emulated USB port, it doesn't work. After plugging in the USB cable, I get a Windows eeror message "unknown usb device (device descriptor request failed)".

Also, when trying to upload using DFU, things go wrong. I can flash the DFU bootloader, and select dfu as upload method in PIO. After flashing the bootloader, a "Maple DFU" device is seen in the category libusb-win32 devices in the device manager on Windows. However, after flashing once from PIO using DFU, the same error as above appears. The fact that the Maple DFU device appears confirms proper operiation of the USB port.

Something seems wrong with the bootloader; I don't know what though. The behaviour is the same for two different black pill boards.

Some more info: apparently, the serial data is visible on PA9 (TX1), when using Serial.print() or Serial1.print(). Might provide some useful info.

platformio.ini:
[env:bluepill_f103c8]
platform = ststm32
; platform = https://github.com/platformio/platform-ststm32.git
board = bluepill_f103c8
; board = genericSTM32F103C8
framework = arduino
; upload_protocol = stlink
upload_protocol = dfu
upload_port = anything

main.cpp:
#include <Arduino.h>

#define LED_PIN PB12

void setup() {
// Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
}

void loop() {
digitalWrite(LED_PIN, 1);
delay(900);
digitalWrite(LED_PIN, 0);
delay(100);
// Serial.println("abc");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions