cancel
Showing results for 
Search instead for 
Did you mean: 

Peripheral and settings after changing program execution

Iman Hosseinzadeh
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
T J
Lead

Yes, your code should be independent of the bootloader,

thereby you should reconfigure all registers.

Iman Hosseinzadeh
Associate III

Thanks!:rose: