AnsweredAssumed Answered

Bug (possible data loss) in STM32F4xx_EEPROM_Emulation (AN3969)

Question asked by wiredancer on Jun 18, 2014
Latest reply on Jul 27, 2015 by wiredancer
Regarding downloaded from the ST website.

In the file /STM32F4xx_AN3969_V1.0.0/Project/STM32F4xx_EEPROM_Emulation/src/eeprom.c, lines 138 and 229, there is a possibility that the system remains in an invalid state if power loss occurs right after the execution of these lines.
On the next power up, when EE_Init() is called the next time, this invalid state will be treated by "formatting" both flash sectors involved, thereby deleting all contained data. This is of course not desirable.

The fix seems easy enough in this case: at both of the mentioned lines, the order should be swapped to 1) erase the old page, 2) mark the new page as VALID_PAGE.