rogerclarkmelbourne / STM32duino-bootloader

Bootloader for STM32F103 boards, for use with the Arduino_STM32 repo and the Arduino IDE
955 stars 493 forks source link

Document how the bootloader is started #90

Closed matthijskooijman closed 2 years ago

matthijskooijman commented 4 years ago

I just tried this bootloader and found it a bit unclear how it is started exactly. I think I've managed to puzzle it together from various sources, but I might be missing pieces. Here's what I found:

I think it would be valuable to document this somehow. Maybe a little less detailed version for users might be also useful, but these details help Arduino core devs to better understand how this all fits together.

matthijskooijman commented 4 years ago

From writing this, I wonder if it might be a bug that currently all the USB (and other subsystem) initialization happens early in main. Even with fastboot, or the 0x424D magic value, now all kinds of stuff is initialized before jumping to the main application, while it would be cleaner if the main application was started in an as-clean-as-possible scenario (at least when nowait is set, so in fastboot mode or with the 424D value)?

iddq commented 3 years ago

Why is this bootloader needed to program STM32 far as I know STM32 has an internal DFU bootloader?

matthijskooijman commented 3 years ago

You can use the internal bootloader, but not all chips have it (at least not with DFU support, I think), it might not do exactly what you need (maybe it's too slow, or initalizes pins like SPI, UART or I²C in a way that conflicts with other hardware), it does not allow reconfiguring the USB vidpid, to name a few reasons you might want to use a different bootloader.

iddq commented 3 years ago

Thank you. It is interesting this doc says all these chips below have DFU:

STM32F0 Series STM32F1 Series STM32F2 Series STM32F3 Series STM32F4 Series STM32F7 Series STM32G0 Series STM32G4 Series STM32H7 Series STM32L0 Series STM32L1 Series STM32L4 Series STM32L5 Series STM32WB Series

https://www.st.com/resource/en/application_note/cd00264379-usb-dfu-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

https://www.st.com/resource/en/programming_manual/cd00283419-stm32f10xxx-flash-memory-microcontrollers-stmicroelectronics.pdf

rogerclarkmelbourne commented 3 years ago

@iddq

STM32F103 only has Serial UART DFU not USB DFU

I think he others including STM32F0 may all have USB DFU, but unfortunatly the F1 doesn't have USB DFU, hence the need for USB bootloaders for this series of MCU's

This is not the only open source USB DFU for the F1. There are many others, including USB HID, USB Mass storage etc.