PlatformIO Community

How to use USB Serial for STM32F103C8 with default "board_build.core"

Hi All! For the latest platformio (at the moment), if you set board_build.core = maple, then UART via USB works well.

But if nothing is displayed, i.e. use the Arduino_Core_STM32 core, then even with the following flags enabled, SerialUSB.begin() cannot be used;

upload_flags = -c set CPUTAPID 0x2ba01477
build_flags =
    -D USBD_VID=0x0483
    -D USBD_PID=0x5740

My blue pill has the correct D+USB pull-up resistor.
Any help is welcome.

Meaning, a compile error, USB serial is not showing up, or no output on the serial?

No output to serial port via USB.

And with

monitor_dtr = 1

as per here?

1 Like

Thank you very much for pointing it out, but I’ve tried it in various combinations and it didn’t work. UART data is not displayed via USB. Although the COM port appears.

I confirm that your advice is working. To do this, we need any terminal program that supports DTR monitoring. After turning on the DTR-monitoring, YUART via USB begin to be displayed. Of course, this is a bug and needs to be fixed.

Or in loop() you can use SerialUSB.dtr(true) then there is no need for a special program.

I noticed one oddity. If you do not use SerialUSB.dtr(true) or SerialUSB.dtr(false) in the code, then the data is displayed in the Arduino COM port monitor, and if, after starting it, you run it in a regular terminal that does not support DTR control, then in this terminal the data are displayed. But if, immediately after uploading the code, you run it in a regular terminal that does not support DRT, then the COM port data is not displayed.