cancel
Showing results for 
Search instead for 
Did you mean: 

How to change boot address on STM32L452

she-peek
Associate II

Hello,

I wrote a program that exchanges the existing bootloader with an attached one.

While this process works, it can be dangerous during the exchange due to power cut-off.

So I would like to implement some safety measures in the code.

Before deleting the existing (old) bootloader, set the boot address to another point in FLASH memory.

After inserting the new bootloader to the address where the old one has been, I would like to change the boot address once more.

I found out that the boot address can be stored in option bytes, at least that's the case for some of the STM32 models.

But as far as I can see, there is not option byte field to write the start address into?

So my question:

Am I overlooking something? Or is there another way to change the start address for the STM32L452?

Best regards

5 REPLIES 5
Bob S
Principal

Programming FLASH (program) memory or programming option bytes - you still have a vulnerability to having the program operation corrupted. Not that I see a "boot address" field in the L4 option bytes, but I didn't look very hard. And if not corrupted by a power failures, what about perhaps a brown out, or noise spike.

The G4 offers dual FLASH banks and the ability to boot from either bank. But you still need to detect when the programming operation to set the boot bank failed due to power failure, etc.

One way around this is to have a primary and secondary bootloader in flash. Only the secondary one ever gets reprogrammed, so the system can always boot into the primary if something goes wrong.

This is exactly the approach for STM32 with dual bank Flash, e.g. with FOTA: you can start the update process from the current bank (current "Golden Image") and run it until the second bank has been successfully updated (CRC, etc).

After that, only the interrupt vector needs to be switched and the updated bank becomes the new Golden Image.

With single bank flash you always have the risk of data loss and can only minimise it by using an external NVM - which amounts to a second, i.e. dual bank Flash.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
she-peek
Associate II

Thank you for your answers!

The dual flash bank approach sounds reasonable, although it might seem like the STM32L452 does not support this system (see datasheet).

Is there any workaround for this?

Best regards

Yes, see my previous email. Without "dual banks" in FLASH the primary and secondary bootloaders just need to be in different FLASH pages so you can erase and program the secondary w/o changing the primary.

she-peek
Associate II

Thank you Bob