2018-08-14 04:33 AM
Hi All,
I have implemented a bootloader on STM32L152RC device. The bootloader is located on 0x8000000 flash address and checks if a new version of firmware is available. If not, it jumps to the flash address 0x8004000, so the previous version of firmware will run.
My question is: What happens to the registers that have been initialized in the bootloader program? For example, I use SPI3 and GPIOB in the bootloader. Should I reinitialize them after jumping to the new program address?
Thanks in advance.
Solved! Go to Solution.
2018-08-14 04:50 AM
Depends on what you want to do.
The contract between the Loader-App can have the loader initialize the clocks/peripherals and the application uses them as-is, or the application can reinitialize them. The latter might be more appealing with the HAL implementations as the peripherals have a large data structure/object that follows them around.
For speed, initializing the system clocks and PLLs once makes a lot of sense. Either way suggest you document/comment in your loader and app sources what the expectations of each are so that when you or someone else edits them in the future they understand what is being done where.
2018-08-14 04:50 AM
Depends on what you want to do.
The contract between the Loader-App can have the loader initialize the clocks/peripherals and the application uses them as-is, or the application can reinitialize them. The latter might be more appealing with the HAL implementations as the peripherals have a large data structure/object that follows them around.
For speed, initializing the system clocks and PLLs once makes a lot of sense. Either way suggest you document/comment in your loader and app sources what the expectations of each are so that when you or someone else edits them in the future they understand what is being done where.
2018-08-14 01:21 PM
Yes, your code should be independent of the bootloader,
thereby you should reconfigure all registers.
2018-08-14 10:10 PM
Thanks!:rose: