Page 1 of 1

Filesystem Max Writes - Does MicroPython manage dynamic wearing?

Posted: Mon Jun 21, 2021 3:34 am
by Curly Tale Games
I'm doing some data logging to the filesystem on a ESP32 running MicroPython and I have some concerns about destroying the flash storage.

I've read that the ESP32 can support 100,000 writes before it starts to degrade blocks of flash storage. I looked at the different filesystems that MicroPython supports on the ESP32: FAT and littlefs v2

https://docs.micropython.org/en/latest/ ... ystem.html

From the Readme of littlefs v2 it looks like it doesn't overwrite the same blocks over and over again to move evenly wear the storage on the chip, they call it Dynamic Wear Leveling.

https://github.com/littlefs-project/littlefs

What filesystem does Micropython use by default on the ESP32?

Does FAT provide any Dynamic Wear Leveling? What if I keep creating new log files and then delete the oldest logs after space fills up? Will it wear evenly then?

Thanks!
-Ben

Re: Filesystem Max Writes - Does MicroPython manage dynamic wearing?

Posted: Mon Jun 21, 2021 5:49 am
by Roberthh
The default file system for ESP32 is littlefs V2. You can change that to FAT by creating the file system as FAT. But FAT has indeed no wear leveling. Playing tricks with files will not help much with FAT. The critical area is the File Allocation Table (FAT) and the root directory, which are at fixed places. Littlefs use dynamic block assignment too for file management, at the cost of speed. I did a test once with a ESP32 creating files 10 Million times. Using Littlefs that worked fine.

Note 1: The wear leveling is only effective if there is sufficient room on the file system.
Note 2: FAT is faster in that Littlefs in handling files and reading directories, not nexcessary in writing to files. It did not measure the difference, but it is obvious,

Re: Filesystem Max Writes - Does MicroPython manage dynamic wearing?

Posted: Fri Jun 25, 2021 12:49 am
by Curly Tale Games
Thank you so much! I think I'll stick with littlefs V2 for logging files then since I don't want to kill my ESP32's storage :)

Re: Filesystem Max Writes - Does MicroPython manage dynamic wearing?

Posted: Tue Jun 29, 2021 1:11 pm
by katesimon123
Yeah, littlefs works better than FAT in the file system. I have worked on it in the Raspberry Pi 4 Project.