Flash and Serial usb f103

STM32duino bootloader aka Maple bootloader
Post Reply
User avatar
k008
Posts: 7
Joined: Sat Apr 29, 2023 5:19 pm

Flash and Serial usb f103

Post by k008 »

Hello, I just can’t figure it out, I want to load the firmware into stm32f103 via usb, and also have serial on the same usb.
Which bootloader should I use?
ag123
Posts: 1709
Joined: Thu Dec 19, 2019 5:30 am
Answers: 27

Re: Flash and Serial usb f103

Post by ag123 »

for stm32f103 you need either 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

or a usb-uart (3.3v) dongle
for a usb-uart you need to set boot0 to program it

alternatively, get a stm32f401/f411 (e.g. 401 black pill) that one has usb DFU built-in on chip. so you can program with a phone cable
but similarly, you need to set boot0 for that.
User avatar
k008
Posts: 7
Joined: Sat Apr 29, 2023 5:19 pm

Re: Flash and Serial usb f103

Post by k008 »

ST-Link is there, the question is that people flash the bootloader, after which a UART appears on the USB and you can flash the STM using the UART
User avatar
k008
Posts: 7
Joined: Sat Apr 29, 2023 5:19 pm

Re: Flash and Serial usb f103

Post by k008 »

It's strange, with stm32f103C8 64k, Serial did not work, but with stm32f103C8 128k, it worked.
How can you flash using USB?
As I understand it, there is a substitution of concepts. Roger does not have a bootloader, this is an addition to his kernel.
Is there a bootloader that could be used to flash STM?
GonzoG
Posts: 415
Joined: Wed Jan 15, 2020 11:30 am
Answers: 29
Location: Prudnik, Poland

Re: Flash and Serial usb f103

Post by GonzoG »

User avatar
k008
Posts: 7
Joined: Sat Apr 29, 2023 5:19 pm

Re: Flash and Serial usb f103

Post by k008 »

Yes, if you specify the Arduino settings correctly and upload the Roger bootloader, it works. But not on all boards. At some point, Serial is there, but does not want to be attached, the bootloader breaks
User avatar
k008
Posts: 7
Joined: Sat Apr 29, 2023 5:19 pm

Re: Flash and Serial usb f103

Post by k008 »

1. Flash https://github.com/rogerclarkmelbourne/ ... 0_pc13.bin.
I flashed using ST-Link,
BOOT0-0,
BOOT1-0
2. Then flash it through Arduino, only using Maple DFU Bootloader 2.0.

If after step 1 you flash it using ST-Link, then Maple DFU Bootloader 2.0 stops working.

Serial is enabled in Arduino-Tools-
U(S)ART support: "Enable (generic "Serial")" and
USB support (if available): "CDC (generic "Serial supersede U(S)ART)"

P.S.
ST-Link after step 1 stops working, in order to restore operation, I used ST-Link Utility to flash a ready-made binary of any sketch, you need to hold Reset on the stm board, click on “Program...” or “Programm & Verify. ..", release Reset.
Attachments
USB_Serial.jpg
USB_Serial.jpg (48.32 KiB) Viewed 15300 times
ag123
Posts: 1709
Joined: Thu Dec 19, 2019 5:30 am
Answers: 27

Re: Flash and Serial usb f103

Post by ag123 »

if you are using stm32f103c8 blue pill you need to choose
generic_boot20_pc13.bin
https://github.com/rogerclarkmelbourne/ ... 0_pc13.bin
and flash that using st-link (or uart)
if you are in windows use stm32cube programmer to flash that boot loader
https://www.st.com/en/development-tools ... eprog.html
in linux the options varies, including this as well as one of the options.
stm32cube programmer is recommended with the 'official' stm core, it is integrated with arduino IDE including the 2.x versions.

after you have done that, the next time connect your phone usb cable (or press reset) and it should blink quickly, you need to click upload in the next 4-6 seconds to upload your sketch during those blinks
alternatively, click sketch > export compiled binary and the bin file for you sketch should be in the sketch project folder.
you can then flash that using stm32 cube programmer, and during those fast blinks
there may be more configs needed such as to choose alternate 2 for DFU if you use roger's bootloader to upload your sketch using a phone usb cable.

and in stm32cube programmer, do not write protect or copy protect the firmware (check the configs in stm32cube programmer)
if you select any of those options, the next time you if program the board, you need to *connect under reset* which is a special method to bypass the protection and only using st-link that is possible.
Post Reply

Return to “USB bootloader”