Hi there,
I have used MicroPython before for a few projects and I really liked how easy is to write powerful apps with such an ease.
But the problem that I very often run into is damaging the file system. For example, if the code run into a problem, I programmed to perform restart of the board or if that doesn't help then I set up the small circuit that will cut power of the board if a capacitor is not discharged. And this caused a lot of problems on my projects. I didn't have a time to protect my code from nulls, wrong format of a data, so I added this hardware failover system to ensure that the board can perform tasks in 90% of the time.
I didn't use MicroPython for a while, so can you guys tell me is the file system improved? Is it more robust? Do you know a good way of preventing this problem? Can you give me some advice regarding the problem?
thanks,
Lazar
How robust is MicroPython file system?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How robust is MicroPython file system?
You haven't told us what hardware you're using. If it's a Pyboard you may be hitting this issue. On other platforms the problem is most likely to be electrical power related. Although code which fails leaving files open can corrupt any filesystem: use Python context managers to ensure this doesn't occur.
In general, properly handled, the MicroPython filesystem is very robust.
In general, properly handled, the MicroPython filesystem is very robust.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How robust is MicroPython file system?
Hello and thanks for response.pythoncoder wrote: ↑Sun Dec 06, 2020 12:12 pmYou haven't told us what hardware you're using. If it's a Pyboard you may be hitting this issue. On other platforms the problem is most likely to be electrical power related. Although code which fails leaving files open can corrupt any filesystem: use Python context managers to ensure this doesn't occur.
In general, properly handled, the MicroPython filesystem is very robust.
I've used esp8266 and esp32 and found the issue.
Since I don't know how to debug microcontroller in real time, the only solution I got is to wire any error into a file and later to read it.
Leaving file open is a problem and I think that I never run into that problem.
However, thanks for the answer
cheers!
Re: How robust is MicroPython file system?
MicroPython currently supports two filesystems, FAT32 and LittleFS (there are also a couple of hybrid options for the STM32 and ESP32). FAT32 is not particularly resilient and can easily be corrupted in the event of a power failure. LittleFS has been designed to be robust even in the face of power failures.
Although it's still possible to corrupt a LittleFS filesystem it's significantly more robust than FAT32 and I'd strongly recommend using LittleFS for all but experimental projects. My experience with a project that had unreliable power is that I often had corruption using FAT32 but never with LittleFS.
The filesystem documentation covers how to manage the filesystems reasonably well. Damien also gave a Talk on LittleFS at the November 2019 Melbourne MicroPython Meetup.
One (the only?) benefit of FAT32 is that it's effectively required for ports that support mounting the filesystem over USB mass storage. Given you're using ESP32/8266 this won't affect you but, for others, there's a choice to be made: the convenience of editing files over USB or the robustness of LittleFS.
Although it's still possible to corrupt a LittleFS filesystem it's significantly more robust than FAT32 and I'd strongly recommend using LittleFS for all but experimental projects. My experience with a project that had unreliable power is that I often had corruption using FAT32 but never with LittleFS.
The filesystem documentation covers how to manage the filesystems reasonably well. Damien also gave a Talk on LittleFS at the November 2019 Melbourne MicroPython Meetup.
One (the only?) benefit of FAT32 is that it's effectively required for ports that support mounting the filesystem over USB mass storage. Given you're using ESP32/8266 this won't affect you but, for others, there's a choice to be made: the convenience of editing files over USB or the robustness of LittleFS.
Re: How robust is MicroPython file system?
Thanks, I remember that FAT32 I used for my projects and that these power interrupts were causing the issue.mattyt wrote: ↑Mon Dec 07, 2020 3:27 amMicroPython currently supports two filesystems, FAT32 and LittleFS (there are also a couple of hybrid options for the STM32 and ESP32). FAT32 is not particularly resilient and can easily be corrupted in the event of a power failure. LittleFS has been designed to be robust even in the face of power failures.
Although it's still possible to corrupt a LittleFS filesystem it's significantly more robust than FAT32 and I'd strongly recommend using LittleFS for all but experimental projects. My experience with a project that had unreliable power is that I often had corruption using FAT32 but never with LittleFS.
The filesystem documentation covers how to manage the filesystems reasonably well. Damien also gave a Talk on LittleFS at the November 2019 Melbourne MicroPython Meetup.
One (the only?) benefit of FAT32 is that it's effectively required for ports that support mounting the filesystem over USB mass storage. Given you're using ESP32/8266 this won't affect you but, for others, there's a choice to be made: the convenience of editing files over USB or the robustness of LittleFS.
Thanks for the explanation and links.