Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By jorgele
#88343 Hi all!
I've read that only around 10,000 write cycles are guaranteed for flash memory, although it can be a lot more. But this question arises: if I write 10,000 times to a sector, would only that sector, or all memory be corrupted? Because I need to record a variable around 100,000 times without risk, and I have to because where I am going to use my system, the power supply is unpredictable and if there is a power outage I need to be sure what the last value of the variable was once the system restarts. I think I could change the sector every time I get close to the 10,000 writes limit, but I don't know if that would solve this problem.
(I'm not worried about losing some sectors during the life I estimate for the system.) I appreciate your help.
User avatar
By davydnorris
#88359 Have a look at the little library I wrote that implements a journal style object store - you can allocate as many sectors as you want and then read and write to them. The library will only erase sectors when required and implements wear levelling, which will extend the life of your flash.

https://www.esp8266.com/viewtopic.php?f=166&t=19530