PlatformIO’s build script for activating USB serial support seems really broken right now. It’s missnig needed flags like USBD_VID, USB_MANUFACTURER, USB_PRODUCT, USBCON and HAL_PCD_MODULE_ENABLED.
Regarding high-speed (HS) mode: The bluepill only supports the lesser Full-Speeed (FS) standard. Activating PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED will cause it to try HS which it doesn’t have, and PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED_FULLMODE will cause it to put its HS peripheral into FS mode, which it doesn’t even have in the first place, so both macros must be omitted.
Can you test on your bluepill if this works? Baud rate for the CDC should be 115200.
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
build_flags =
; enable USB serial
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
; QUIRK: without setting this, no
; data will be received on the serial USB port
; https://github.com/stm32duino/Arduino_Core_STM32/issues/1193
monitor_dtr = 1
; optional: set COM port to monitor here if there are multiple
;monitor_port= COM27
EDIT October 2020: Added USBD_PID. Also: Using the dev-platform is not required anymore, you can write platform = ststm32 instead.
The same problem seem to appear when using the original “Roger Melbourne” (derived from leaflabs)-core.
When using this in platformio.ini:
board_build.core = maple
the same thing seems to happen. The bluepill’s USB does not change from “bootloader” to “serial port”.
A funny detail: if you disable the libUSB device (maple 003) in the device manager and reactivate it after that, then the board activates the virtual serial port.
Hi,
thank you, the solution is working. However, there is still a problem.
I am programming a bluepill, and stlink for upload and debug.
If I upload the code, the usb virtual serial port is working.
If I start a debug session, no serial port in the Device Manager, but an unknown usb device instead. So the serial monitor is not working.
I suspect it’s because the debugger stops the uC before proper enumeration.
A workaround:
start running the code in the debugger
disconnect the board’s usb, and reconnect it, now the virtual usb port appears in the Device Manager
restart the serial monitor in PIO
stop the uC with a breakpoint
now both debugging and serial is working
While it’s working, not really comfortable. Is there a better way?
Great
I really struggled to make the USB serial monitor work on my BLACKPILL_F411CE work.
I was able to restore the serial monitor by slightly modifying the platformio.ini as follows:
However, as the saying goes, “Don’t give me a fish, but rather teach me how to fish”,
How do we go about finding the solution to this problem? which documentation if any shall we refer to?
Notice that I am using F401cc board configuration for the F411ce, and that is because the Blackpill_411 board is not yet available in the platformio boards list.
How do we know whether platformio is working on the Bloackpill_F411 board?
Hi , i have some problem with PIO USB serial Programming . after change boot loader i can just programing with Arduino IDE , here is my board configuration . and all the time i have some error
I started recently to use stm32duino and platformio for fast prototyping on small projects.
This solution allowed me add USB/serial support on my devices.
IMPORTANT NOTE: To receive data on PC I needed to enable DTR signal (Data Terminal Ready). Handshaking (flow control) does not need to be activated.
Hi there, I’m trying to get serial monitor communication with blackpill stm32f411 via the USB cable, but I don’t know how to proceed, is there a ‘how to’ guide for that?
this is my current platformio.ini:
Thanks a lot, just tried that,
after uploading I click on the platformio serial monitor icon and I get this:
> Executing task: platformio device monitor <
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Available ports:
--- 1: /dev/cu.Bluetooth-Incoming-Port 'n/a'
--- 2: /dev/cu.MacBookProdeManuelDiego 'n/a'
--- 3: /dev/cu.serial0 'n/a'
--- Enter port index or full name: 3
--- forcing DTR active
--- Miniterm on /dev/cu.serial0 9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
I selected option 3, don’t see any message there. I have this in the loop: