2019-10-21 09:26 AM
in some cases that we encountered, 2 types of failure occur.
1- when powering up, ALL sectors of flash, are Erased. we guess ESD makes all sectors erased. with additional protection in power circuit, this problem solved.
2- after powering up, we realized that 2 sectors which used as eeprom, are Erased. (not all sectors containing program). in other words, program works properly but saved data does not exist anymore.
As I saw in mentioned Application Note at above, section 3.3 "Page header recovery in case of power loss" according table 2, "three of which are invalid" . with refer to "eeprom.c" in ST's Example (we use this APIs), I understood according to this document, in this 3 states 2 flash sectors that used as eeprom, will format.
"/* Invalid state -> format eeprom */"
can anyone says how to handle this problem. should we use POR or PDR? HOW?
and about my first question? Is there any advices ?
thanks.
2019-10-22 07:22 AM
I'm not an advocate of EEPROM Emulation, but as asked to respond, here are my thoughts.
Don't use EEPROM Emulation, understand how the underlying FLASH works, and how to hold and partition your data better.
For permanent/semi-permanent stuff use OTP and FLASH areas separate from your other data.
Have Workable Defaults.
Do not unlock the flash to read the data.
Push your data in a structure, in one place, avoid having a million global variables, and copying them individual.
Journal the structure across multiple sectors/pages.
Have a checksum/crc on the data, and a sequence number.
Copy the whole structure to RAM, and work on RAM copy.
Only erase when all memory is close to being consumed, and always erase the least recently used sector.
Plan when memory is getting low, don't make it occur under critical conditions.
Don't rush to unlock/erase at startup, do it when you are reasonably sure things are stable.
Perhaps schedule for two minutes after power-up.