cancel
Showing results for 
Search instead for 
Did you mean: 

Flash mass erase: are MER1/MER2 bits swapped when flash banks are swapped?

mhaun
Associate II
Posted on March 03, 2016 at 23:36

On STM32L4 (and some other parts), the FB_MODE bit in SYSCFG->MEMRMP is used to swap the mapping of flash banks 1 and 2.  This is how the factory bootloader implements ''boot from bank 2'' (BFB2) in the flash option bytes.

The flash controller provides two bits in FLASH->CR, MER1 and MER2, which allow for erasing a single bank or both banks (if both MER1=MER2=1).  This raises an obvious question: Does MER1 always refer to bank 1?  Or does it refer to whichever bank is currently mapped into the lower address range (0x0800 0000 on my 1-MB part)?

2 REPLIES 2
Posted on March 04, 2016 at 00:58

I would expect only the memory mapping of the array to be swapped, and the flash banks and controllers remain as they are physically defined.

Sort of thing you could quickly validate with simple experiments.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mhaun
Associate II
Posted on March 16, 2016 at 00:30

Confirmed.  For MER1/MER2 purposes, ''bank 1'' always refers to the same bank and ''bank 2'' always refers to the same bank.