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
Filesystem Max Writes - Does MicroPython manage dynamic wearing?
-
- Posts: 10
- Joined: Sat May 29, 2021 5:32 am
Re: Filesystem Max Writes - Does MicroPython manage dynamic wearing?
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,
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,
-
- Posts: 10
- Joined: Sat May 29, 2021 5:32 am
Re: Filesystem Max Writes - Does MicroPython manage dynamic wearing?
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
-
- Posts: 15
- Joined: Mon Jun 14, 2021 12:49 am
Re: Filesystem Max Writes - Does MicroPython manage dynamic wearing?
Yeah, littlefs works better than FAT in the file system. I have worked on it in the Raspberry Pi 4 Project.