Trouble with STM32F103 USB Communication on Arduino – Need Hel

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
blouseadjoining
Posts: 1
Joined: Fri Jan 10, 2025 3:01 am
Location: https://retrobowlonline.co/

Trouble with STM32F103 USB Communication on Arduino – Need Hel

Post by blouseadjoining »

I’m currently working with an STM32F103 board and trying to get USB communication working through the Arduino IDE. I’ve followed all the setup instructions, but I’m running into an issue where my board doesn’t seem to register as a USB device when connected to my PC.

I’ve installed the STM32 core and selected the correct board in the IDE, but when I try to upload a sketch or use the USB serial communication, I get an error stating that the USB device isn’t recognized. I've checked the connections and tried multiple cables, so I’m fairly sure it’s not a hardware issue.

Has anyone else experienced this problem with the STM32F103 or have suggestions on how to troubleshoot the USB connection? I’m wondering if I might be missing a specific driver or if there’s something I need to configure in the IDE.

Any help or guidance would be greatly appreciated!

Thanks!
ag123
Posts: 1881
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: Trouble with STM32F103 USB Communication on Arduino – Need Hel

Post by ag123 »

to program a stm32f103 board you need

one of 2 ways:
- st-link - if you have a st-link v2 programmer e.g.
https://www.adafruit.com/product/2548
https://www.st.com/en/development-tools/st-link-v2.html
https://octopart.com/search?autosugg_id ... SD&specs=0
this should connect the relevant pins at the 'bottom' (opposite usb) edge with 4 pins for that purpose (SWD).
Accordingly, normally pressing boot0 isn't necessary for this
if you have the SWD pins from st-link connected properly to the pins for st-link on the board.
you could use an app like stm32cubeprogrammer to flash the 'bin' file into the device
https://www.st.com/en/development-tools ... eprog.html

(to get your 'bin' file in Arduino IDE, run sketch > export compiled binary, and you should find it in your project folder in some sub-directory e.g. build)

- usb-uart serial dongle
this requires properly connecting a usb-uart dongle (get 3.3v ones) at pins PA9 (for TX on stm chip side) and PA10 (for RX on stm chip side)
so at the uart side TX should goto RX on stm, and RX side on uart should goto TX on stm. and then GND to GND
and you need to keep the bluepill board powered e.g. on a usb A (or C?) cable

next this requires setting boot0 jumper or if they give you a button, the button dance is
- press both reset and boot0
- hold boot0 release reset
- release reset 2 sec later
then you can use that same stm32cube programmer app to flash the "bin" file to the chip similarly


I'm more a fan of STM32F4xx chips, I commented a little here
viewtopic.php?p=15142#p15142
e.g. stm32f401 and or stm32f411 has a USB DFU boot loader built-in
it can be programmed with the standard phone USB C (some A) cables and that stm32cube programmer
this needs setting/pressing boot0 as above but it works over a standard phone USB C cable.
it STM32F401/F411 is faster (much) more performant than stm32f103 for the same Hz (has FPU, and ART Accelerator (on chip cache), has more memory, more flash and normally cost a little more. e.g.
https://github.com/WeActStudio/WeActStu ... iSTM32F4x1

'official' stm core is here
https://github.com/stm32duino/Arduino_Core_STM32
the wiki is here
https://github.com/stm32duino/Arduino_Core_STM32/wiki

there are similar discussion here as well
viewtopic.php?p=15171

note, for novices avoid using custom bootloaders unless you know what you are doing
the 'official' on chip built-in supported programming methods are either usb-uart dongle or st-link for stm32f1 devices
GonzoG
Posts: 481
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: Trouble with STM32F103 USB Communication on Arduino – Need Hel

Post by GonzoG »

First of all, STM32F1 do not have native USB bootloader (DFU). You need to flash software bootloader (eg. HID bootloader https://github.com/Serasidis/STM32_HID_Bootloader).
Without you can use only UART or ST-link to upload firmware.

Next, to use USB as a Serial output, you need to enable USB in CDC mode (supersede UART) in Tools menu.
Post Reply

Return to “General discussion”