Difficulty with getting USB serial [USB CDC] working

I found a solution, thanks too all the above shares, actually.

Working:
DFU Upload
USB Serial
“Serial” automatically routed to USBSerial
TX/RX

Not Working:
After DFU Upload, I have to plug out and reinsert USB in order to see the virtual serial.

Notes:
Its not the regular Blackpill, its a custom board but should work with others having STM32F411xx at least or STM32F4xx hopefully.

[platformio.ini]
[env:genericSTM32F411CC]
platform = ststm32
board = genericSTM32F411CC
board_build.mcu = stm32f411ccu6
board_build.f_cpu = 108000000L
framework = arduino
upload_protocol = dfu
monitor_dtr = 1
monitor_port= COM19 ; needed. Cause after upload, my serial wasn’t getting enumerated untill I replug the USB connector.

build_flags =
-w
; enable USB serial
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-D USBD_PID=0x5740 ;copied from a device built using arduino
-D USBD_VID=0x0483
-D USB_MANUFACTURER=“STMicroelectronics”
-D USB_PRODUCT=“"STM Serial"” ; has no effect, apparantly

1 Like