MBF and Bootloaders - michael-ring/mbf GitHub Wiki
Some boards come with preinstalled bootloaders and for some people programming a board via bootloader is good enough.
There are several Bootloaders out there,
for STM32F1 and STM32F4 there is:
https://github.com/Serasidis/STM32_HID_Bootloader
or
https://github.com/rogerclarkmelbourne/STM32duino-bootloader
and, especially usefull, most of the Adafruit boards come with a quite nice uf2 bootloader that also allows upload via the filesystem:
https://learn.adafruit.com/bootloader-basics/bootloader-usage
There is also a project of an uf2 bootloader for STM32F103x8 Boards (Bluepill):
https://github.com/mmoskal/uf2-stm32f103
Prebuilt binary:
https://github.com/mmoskal/uf2-stm32f103/releases
All those bootloaders share one common 'problem':
To be able to work they need to run from address 0x08000000 (Flash start) and most of the time collide with the default startaddress of our own code which is also configured to run from the same start address.
To solve this issue we have to tell the linker to link our program to another startaddress.
As an example, for the HID_Bootloader this new Start-Address is 0x08000800, for UF2 Bootloaders Start addresses vary, 0x08002000 (SAMD21) and 0x08004000 (SAMD51 or Bluepill) are often used.
By adding this command:
-k-Ttext=0x08000800
to the custom buildoptions of our lpi file we can make sure that our program plays nice along with the bootloader.
All those bootloaders out there have a different size, so you have to check in bootloader documentation what the size is and adjust the offset to the flash-startaddress accordingly.
To see this in action please check the Blinky-Bluepill example here: