Flash memory durability (SPIFFS)

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Flash memory durability (SPIFFS)

Postby esp1979 » Mon Jan 10, 2022 7:13 pm

Hello all,

i have a question to the durability of the flash memory:

Is it true that the flash memory of the ESP32 can slowly break after about 100000 write cycles?
And if yes: What exactly means "write cycles"?

Following example:

I want to save 300 measurings a day (e.g. temperature measurings) in a file.
For each day a new file is created named with the current date.

So e.g. for today i would have a file called "2021-01-10.bin"

If i then

open the file
append the new measuring by file.write
close the file

and do this 300 times.
Would that be 300 write cycles?

This would mean that i would have 109500 write cycles a year (300 * 365).
And that would mean, that the flash memory would be defective after about a year.
Is this correct?

Best wishes
Daniel


Thank you for your help and a good healthy new year to everybody!

Daniel

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: Flash memory durability (SPIFFS)

Postby esp1979 » Tue Jan 11, 2022 8:04 pm

Hi,

really no one that can help ;-(

Best wishes
Daniel

ESP_Sprite
Posts: 9606
Joined: Thu Nov 26, 2015 4:08 am

Re: Flash memory durability (SPIFFS)

Postby ESP_Sprite » Wed Jan 12, 2022 1:27 am

Technically, it's 100000 erase cycles per sector, meaning that each (4K large) sector can only be erased up to that amount of times before a flash cell may break. The thing is that flash filesystems like spiffs will do wear leveling, in other words: every time you write a file, it will do that to a different (set of) sector(s). I am not intimately familiar with the workings of spiffs, so my numbers could be off, but as an indication: say you have a spiffs that is 1 megabyte in size, or 256 4K erase sectors. Assuming your file is small, and spiffs only needs to erase one sector per erase/create/write cycle, this means it can do this 100000 times for each erase sector, but it has 256 sectors to spread the load over, which means 25600000 times in total.

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Re: Flash memory durability (SPIFFS)

Postby esp1979 » Wed Jan 12, 2022 8:09 am

OK, that sounds good.
Thank you for your detailed answer.

Best wishes
Daniel

Who is online

Users browsing this forum: No registered users and 36 guests