cancel
Showing results for 
Search instead for 
Did you mean: 

Reason of being flash corruption in STM32G0

TSola.1
Associate II

Hello,

So in our project we are saving some of out parameters on last page of our controller and reads that during startup.

We are able to read and write content properly.

Issue we are facing is that when a power on/off cycle is happening multiple times in a day at random instance during this process the data being read at startup is not correct and we get different values.

This issue is not happening at every power on/off cycle, this happens just randomly at any moment like once or twice in a day.

It would be grateful if someone can help regarding this.

Regards,

Tirthraj Solanki

2 REPLIES 2
Bob S
Principal

If power drops while writing to flash, all bets are off. The write may or may not have happened, or happened fully. The ST "EEPROM Emulation" package has lots of code to try and deal with that, but at the end of the day, nothing can guarantee the data will be stored correctly.

The usual way to deal with this is have a low power input to the CPU that detects when the power supply is dropping, and to have enough capacitance on the CPU to run the CPU long enough for a write sequence to finish. Only start a write operation is the power supply is "OK".

Journal content, and use checksums/CRC to check validity, find most recent valid entry on startup.

Use two pages so you can erase one without loosing recent valid content.

Likely minimum write size of 64-bits (8-bytes)

Use NVRAM as a secondary store

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