Stumbling at the first connection...

Post here first, or if you can't find a relevant section!
Post Reply
ullix
Posts: 3
Joined: Fri Apr 26, 2024 3:59 pm

Stumbling at the first connection...

Post by ullix »

I have long experience with the ESP family, but I am newbie to STM32. I got several of STM32F103C8T6 board modules like https://www.amazon.de/dp/B07Y83Q2HP, and with each got the same problem that the USB connection failed, both on Linux and Windows11. Dmesg is reporting:

Code: Select all

[284283.729630] usb 3-1: new full-speed USB device number 77 using xhci_hcd
[284283.729744] usb 3-1: Device not responding to setup address.
At the end no USB connection exists.

I can't believe that each module is defect, so what am I missing? How do I need to start up?

There are these two Mini-Jumpers on the board, plus a button. Do they need to be is a specific position to get the boards USB-connected?
I am missing something like a "STM32 - 101". Can you point me to one?
ag123
Posts: 1678
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Stumbling at the first connection...

Post by ag123 »

usually this indicates a bad usb cable
GonzoG
Posts: 407
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Stumbling at the first connection...

Post by GonzoG »

F103 does not have hardware USB bootloader. If there is no firmware with USB support there won't be a connection.
I recommend flashing HID bootloader, but you need USB-TTL adapter or ST-Link.
ag123
Posts: 1678
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Stumbling at the first connection...

Post by ag123 »

if you want to program a stm32f103 e.g. those 'blue pill' style boards.
get a st-link v2
https://www.adafruit.com/product/2548
https://www.st.com/en/development-tools/st-link-v2.html
https://octopart.com/search?q=st-link+v2
for 'blue pill' style boards, i think they put the headers for that at the 'bottom' conveniently so it is unlikely to get it incorrectly.

or slightly more complicated
a (3.3v) usb-uart dongle (connect to pa9, pa10, gnd)
using usb-uart requires setting the boot0 jumper and pressing reset to get into programming mode
ullix
Posts: 3
Joined: Fri Apr 26, 2024 3:59 pm

Re: Stumbling at the first connection...

Post by ullix »

Aaah, a missing bootloader! The disadvantage when USB is integrated on the chip, but needs code for activation (unlike in the ESP family, where USB is a separate chip).

Now, I got an ST-LINK V2 and by using the ST-tools on my Linux box and st-flash I was able to write and read some bin data to and from the Blue Pill. Appears to be working!

Which bootloader should I now use and where do I find it? Is it correct to write this bootloader to the Blue Pill also by st-flash?

The Arduino IDE seems to offer multiple ways to upload code. Which one do I need, and does it depend on the bootloader chosen?

P.S. I am new in this forum and expected I would get an email when a new post is made, but this did not happen. Impossible? Or what do I need to do to activate the email notification feature?
ag123
Posts: 1678
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Stumbling at the first connection...

Post by ag123 »

custom bootloaders are 3rd party developed
back in the 'old days' there is leaflabs maple, that is the first popular *duino running on stm32f103, the old forum which hosted this made improvements originally hosted by 'roger'
https://github.com/rogerclarkmelbourne/Arduino_STM32
https://github.com/rogerclarkmelbourne/ ... bootloader
that is the 'old' libmaple core. The boot loader is a DFU boot loader which install your sketch at 0x8002000

then that there are HID bootloaders which is developed later
viewforum.php?f=58

and again all 'custom' developed.

for stm32 mcus, the most native ways to program them remains as either using st-link v2 or a usb-uart (at uart1 pa9, pa10), requires setting boot0 to use that. This is there in all stm32 mcus and is stm32 native, it is there in every chip without any additional firmware.

if you get a stm32f4xx series (e.g. for boards as like the stm32f401 'black pill' etc, https://stm32-base.org/boards/STM32F401 ... -V1.2.html) or stm32g4xx series, and many more, those has DFU built-in native
more details about which has DFU is in this document.
https://www.st.com/resource/en/applicat ... ronics.pdf
with those, you can simply connect a usb (phone) cable set boot0 (on stm32f401 black pil, that is a button) press reset, and it should restart into the DFU bootloader mode (native, built-in to stm32) and you can simply program away.

for 'beginners', I'd recommend going 'straight' to stm32f401 / f411, benefits:
- more sram often have like 32k sram and even much higher
- more flash often have like 128k, 256k and even 512k (i think stm32f411ce has it 512k flash)
- fast (it has that 'ART accelerator' on chip cache), which in theory for the same mhz 'others' (e.g. stm32f103 or lower) runs from flash say like at least 3 -4 or more wait states, 'ART accelerate' if it is in the cache, reduce that to *zero* wait state immediate run
- fast (it has 32bit FPU, floating point calcs between stm32f4xx vs stm32f1xx is literally 'worlds apart', stm32f4xx is like a 'race car' where you can measure the wheatstone benchmark in MFLOPS, it would be 'embarrasing' to try the same on stm32f1xx or lower)
viewtopic.php?p=939#p939
- fast - often more mhz vs stm32f1xx or lower.

I 'switched' to stm32f401, practically didn't look back. I still have stm32f103 for 'simple' apps.
ullix
Posts: 3
Joined: Fri Apr 26, 2024 3:59 pm

Re: Stumbling at the first connection...

Post by ullix »

@ag123: Thanks for some more insight!

The only thing firm in this moment is that I have to use chip STM32F103C8, no matter how much better others may be :-(

I managed to install the bootloader generic_boot20_pc13.bin. On connecting dmesg said:

Code: Select all

ullix@urkam:~$ dmesg -W
[512460.235425] usb 3-2: new full-speed USB device number 112 using xhci_hcd
[512460.384710] usb 3-2: New USB device found, idVendor=1eaf, idProduct=0004, bcdDevice= 2.00
[512460.384723] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[512460.384729] usb 3-2: Product: Maple
[512460.384733] usb 3-2: Manufacturer: LeafLabs
[512460.388058] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
Looks like it was working, and I took note of 'Maple' and 'LeafLabs'.

In the Arduino IDE I Programmed a small Blink-sketch, selected Board, Port, and Upload Method 'Maple DFU Bootloader 2.0' and clicked upload. It compiled but failed to upload with this message:

Code: Select all

Sketch uses 10960 bytes (8%) of program storage space. Maximum is 131072 bytes.
Global variables use 1132 bytes (5%) of dynamic memory, leaving 19348 bytes for local variables. Maximum is 20480 bytes.
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
dfu-util: No DFU capable USB device available
Trying 4 more time(s)
dfu-util 0.8
I tried all other upload methods, but all failed.

I then tried bootloader generic_boot20_pc13_fastboot.bin. Same result; all uploads failed.

So, now what? What alternative to Arduino IDE can be used for uploading?
My Arduino-IDE is: arduino-ide_2.3.2_Linux_64bit.AppImage
ag123
Posts: 1678
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Stumbling at the first connection...

Post by ag123 »

for this maple DFU boot loader, after you press reset, it should blink fast for like 6 times, you need to click upload or run dfu-util within about 4-5 seconds when it blinks
there is a 'perpetual' mode, and I think the setting is 'boot1' jumper
this is from the good old days
http://static.leaflabs.com/pub/leaflabs ... oader-mode
https://www.youtube.com/watch?v=rvNIeKuXsxM
those leaflabs documentations are still relevant for libmaple (roger's) core.

I think this DFU boot loader works in the 'official' stm core as well.
But choose the correct upload method when you compile your sketch, as the config needs to be compiled to install at 0x8002000.
For normal installs it is always at 0x8000000 - this is the start of flash on practically all stm32 devices, normally when you install via st-link or usb-uart
or stm32's own in chip DFU bootloader.

if you use dfu-util in linux,
after you have installed dfu-util, you need to run

Code: Select all

dfu-util -l
during the fast blinks, then it would list the available options.

I think the normal way to install a bin file is

Code: Select all

dfu-util -a 2 -RD sketch.bin
btw arduino ide 2 and above normally won't work with (roger's) libmaple core. it doesn't have the new board manager configs.

to get your 'bin' file, normally it is sketch > export compiled binary. that'd leave that 'bin' file in your project folder.
you can then manually flash that using dfu-util
Post Reply

Return to “General discussion”