cancel
Showing results for 
Search instead for 
Did you mean: 

How to know which bank got booted when working with BFB2 bit in STM32L4 MCU's

MDinn
Associate II

Hi,

I'm implementing an OTA system using the L486VG MCU.

This one has the dual bank option and the BFB2 option bit to enable to boot in Bank2.

It works and I can constantly swap the banks and erase and read them.

Only when the BFB2 bit is set and there is no valid firmware in Bank 2 it boots from Bank 1.

The problem is that I need logic in my firmware to know what bank got booted so I can erase the correct bank before writing my new firmware. How could I do this? At the moment I just check the BFB2 bit, but that is no assurance that it's in Bank 2.

Thanks,

Marvin

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Check the SYSCFG_FB_MODE bit to see if it accurately reflects what is mapped.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3

Pretty sure you can read the mapping register. Failing that you can put a unique identifier in each, and perhaps a common boot loader at the front of each bank that forks.​

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

Check the SYSCFG_FB_MODE bit to see if it accurately reflects what is mapped.

If you feel a post has answered your question, please click "Accept as Solution".
MDinn
Associate II

Thanks for the info!

For others searching for more info on this you can read the FB_MODE bit like this:

if(SYSCFG->MEMRMP & 0x00000100)
{
	//bank2 is mapped
}
else
{
	//bank1 is mapped
}