How many writes can be made to the mDot's SPI flash?

The filesystem implementation for mDot that we use is called SPIFFS - it can be found on github:

https://github.com/pellepl/spiffs/

The SPIFFS FAQ (https://github.com/pellepl/spiffs/wiki/FAQ) walks through an example and explains how long the flash might last running SPIFFS.

Our SPIFFS configuration uses the entire 2 MB flash and has a block/sector size of 64 KB and a page size of 256 bytes. According to the datasheet, the flash is good for at least 100K write cycles per block/sector. I'm going to copy-paste from the FAQ and change values to match our configuration.

----------------------------------------------------------

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

Considering above, after (32-2) * 128 = 3840 file updates the system is full of deleted pages and blocks will need to be erased. Henceforth, after each 128th file update a block must be erased. As we have 32 blocks and have wear leveling, it will take 128 * 32 file updates before same block is erased again. This we can do 100000 times before things fail, so to sum it up we can do 3840 + (128 * 32) * 100000 file updates before the SPI flash is worn out, roughly 409.6 million 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 307.2 million.

----------------------------------------------------------