I am new to the STM32 world. I know that all STM32 MCUs come with an internal bootloader. Is it possible to replace it with custom boatloader?


No, it is baked into the chip at manufacture time.

You can however write your own bootloader which you store in the microcontroller's flash and will be executed at power on or reset. There are a number of boot pins which determine where the processor starts executing code from when it's powered on or reset.

  • \$\begingroup\$ Does this 'baked bootloader' can use any of the interface from UART, serial or USB? Is it same across all the STM32 F0 to F7 families? \$\endgroup\$ – scico111 Feb 6 '19 at 3:45
  • \$\begingroup\$ And if i want to flash my custom bootloaded into a MCU, especially STM32F407, then how would i do that.. will it be a single .hex file that has my custom bootloaded as well as my application code OR is it possible to flash (and re-flash ) the bootloader .hex file separately while flash (and update) the app code separately? \$\endgroup\$ – scico111 Feb 6 '19 at 3:54
  • 2
    \$\begingroup\$ Which interface it uses depends on the processor, you need to check in the manual. To flash you would use an st link or jtag programmer. You can create a single binary with your bootloader and application, or flash them separately. \$\endgroup\$ – Colin Feb 6 '19 at 6:32
  • \$\begingroup\$ @scico111: To update the app code separately, make sure that the app exists in different Flash pages from the bootloader. Flash must be erased before it can be overwritten, and it can only be erased an entire page at a time. So keep page boundaries in mind when picking a memory layout, e.g. bootloader, application, and calibration tables should all be aligned to page boundaries. \$\endgroup\$ – Ben Voigt Nov 18 '19 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.