cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R5ZI - Is it possible to erase a page and write a double word in Flash ?

KVenk.1
Associate III

Hi,

I am using STM32L4R5ZI MCU (Nucleo kit). My application demands non-volatile storage of few configuration parameters. I am using 2 banks mode. I want to store a double word at location 0x8100000 which is first page of bank 2. I tried the STM32L4R5ZI_NUCLEO_FLASH_EraseProgram example code that was available from ST webpage. But am getting unpredictable results. Sometimes It works. But most of the times, Erase operation was not successful. All I was trying is, ensure the double word is properly saved at first page of the 2nd bank everytime i write with new value. Why there is inconsistency in erasing the flash memory ?

8 REPLIES 8

>>Why there is inconsistency in erasing the flash memory ?

Hard to know, guessing implementation or power stability

Saving / updating configuration structure in FLASH on the L4R5 here, also doing firmware updating, not sure why your implementation fails.

Supply on NUCLEO should be fine.

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

I observed that, controller boots from System memory whenever there is erase failure. I got this by noticing controller not stopping at the breakpoint during debug. When i hit pause, ide flags "Break at address 0x1ffffxxxx with no debug information available, or outside of program code" . This confirms that controller is not booting from the flash memory. I verified the BOOT0 pin voltage level and it is as expected 0V. Then I verified the OPTR register value for nBoot1 and nBoot0 bit status. I could see nBoot1 bit is set, but in SFRs view, I couldnt see nBoot0 value. Why the controller is booting from system memory occassionally ? This is not happening everytime. When I recompile and again debug, it boots from flash memory.

TZARDI
Associate III

​Hello,

Verify the value of nSWBOOT0 if it's set, with the BOOT0 is 0 and when the flash is empty the system will boot from the system memory. You can check table 4 Boot modes of the reference manual  to see the different boot possibilities.

Br,0693W000003R9feQAC.png

Yes, nSWBOOT0 is set. But how it considers Flash empty, because am just modifying the configuration value that needs to be written on Page 1/Bank2.

TZARDI
Associate III

​Hello,

Can you share the configuration of the FLASH_OPTR register and your main if it's possible? I want to check if the bit BFB2 is set or not.

Br,

HI,

Pls find snapshot of the FLASH register below , taken in debug mode: BFB2 is RESET, so dual bank boot disabled.

0693W000003RA9dQAG.jpg

TZARDI
Associate III

Hello,

Can you maybe share your main? I tried the example but i couldn't see the problem you're facing.

Br,