-->
Page 1 of 2

SPIFFS write cycles limit?

PostPosted: Wed Oct 21, 2015 7:31 am
by Fabio
Is there any? I couldn't find.

Is about the same of Arduino? (100.000 write cycles)

I was thinking about using it to store the state of my execution and read after a deep sleep

Thanks in advance

Re: SPIFFS write cycles limit?

PostPosted: Thu Oct 22, 2015 7:34 pm
by mrburnette
Fabio wrote:Is there any? I couldn't find.
Is about the same of Arduino? (100.000 write cycles)
I was thinking about using it to store the state of my execution and read after a deep sleep
Thanks in advance


UPDATED 2015/10/22
https://github.com/pellepl/spiffs/wiki/FAQ
Let's say we have a 1MB flash.
There is only one file.
Each second we open the file, read a number, increment it, and store the file again.

Suppose we divide the flash into 128 bytes pages and 64k blocks. The flash copes with 10000 erases before it fails.

Thus, we will have 1MB / 64k = 16 blocks. Each block has 512 pages, and one file update will consume two pages (metadata + data), meaning we can do 512/2 = 256 file updates before we've used a full block which needs erasing before reuse. Also, spiffs always need two free blocks.

Considering above, after (16-2) * 256 = 3584 file updates the system is full of deleted pages and blocks will need to be erased. Henceforth, after each 256th file update a block must be erased. As we have 16 blocks and have wear leveling, it will take 256 * 16 file updates before same block is erased again. This we can do 10000 times before things fail, so to sum it up we can do 3584 + (256 * 16) * 10000 file updates before the spi flash is worn out, roughly 40960000 times. To play it safe as we haven't considered some extra meta data, we multiply by 0.75 (pretty aggressive) we sum it up to 30,7 million.

Which is 355 days.


Ray

Re: SPIFFS write cycles limit?

PostPosted: Fri Oct 23, 2015 10:11 pm
by Fabio
Thank you!

Re: SPIFFS write cycles limit?

PostPosted: Sat Oct 24, 2015 4:20 pm
by eduperez
Well, 355 days may not seem much; but we are talking here about one update per second. A more reasonable approach, like one update per minute will yield a lifespan of 60 years. Make it one update every five minutes, and we have 300 years.

Not so bad... thanks for the info!