Skip to main content
Visitor II
August 25, 2020
Solved

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

  • August 25, 2020
  • 3 replies
  • 1104 views

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

    This topic has been closed for replies.
    Best answer by TDK

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

    3 replies

    Graduate II
    August 25, 2020

    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.​

    TDKAnswer
    Super User
    August 25, 2020

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

    MDinnAuthor
    Visitor II
    August 25, 2020

    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
    }