2020-01-07 03:58 PM
I am using an STM32F072 MCU in my project and in the development phase, things seem to be working properly. The boot0 pin is pulled low and I can upload firmware via the ST-LINK debugger.
Q1: How do I issue a firmware upgrade without the need to make any changes to the Boot0 pin? My understanding is that I need to write a custom bootloader and place it in the flash memory that can be accessed upon power on since Boot0 will be tied low in the final product.
Q2: I also know that instead of writing my own bootloader, I can jump to system memory directly from the flash memory by reading a register value upon power on. However, I need to disable all the peripherals, clocks, interrupts and generally doing that is difficult and causes unexpected issue. Am I right here?
2020-01-07 05:29 PM
Difficult? It does require that you understand how micro-controllers function and execute code, and what your own code is doing, and might interact with other things.
If you don't have the basics down it is going to be a harder slog. Review the ARM Technical Reference Manuals, review books on how boot loaders and staged loaders function. Review how to split the FLASH into multiple regions and how to put standalone code in each, and then transfer control or jump in/out of them.
You are putting code on the MCU, you control everything happening there. Execution is going to start from a singular point, where it goes from there, and how many sub-applications you run is up to you. In the simplest form you split code such the boot loader starts first, and then you validate and transfer control to the application code, or stay in the boot loader and provide means/methods to update the area used for the application.
Perhaps review the IAP (In Application Programming) examples, and how you can change the vector table location once you have started.