Question
Bug (possible data loss) in STM32F4xx_EEPROM_Emulation (AN3969)
Posted on June 18, 2014 at 17:57
Regarding stsw-stm32066.zip 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, whenEE_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. #eeprom-emulation #an3969 #eeprom-flash-emulation