Hi,
i have an esp32 that is plugged into a device from wich he get current and comunicate with it with serial interface.
My problem is that when the device lose current and then the esp32 turn on again, sometimes, the filesystem become corrupted.
In production this scenario makes it unusable for the user and does not allow to restore the application.
Is there a way to creare a separate partition to restore from it the entire flash memory?
Thanks in advance for the help.
ESP32 broken filesystem
Re: ESP32 broken filesystem
Usually, this kind of problem arises when the file is open at the time of the power outage.
Sofware solution
So you can close the file every time you end writing a file. This will limit the risk of filesystem corruption. But don't suppress them of course.
Hardware solution
You can put a supercap between the power supply and your ESP32. And detect when the power supply is down so that you have time to cleanly halt the software. You shall put a diode between the power supply and supercap so that the supercap won't discharge into the power supply
Sofware solution
So you can close the file every time you end writing a file. This will limit the risk of filesystem corruption. But don't suppress them of course.
Hardware solution
You can put a supercap between the power supply and your ESP32. And detect when the power supply is down so that you have time to cleanly halt the software. You shall put a diode between the power supply and supercap so that the supercap won't discharge into the power supply
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: ESP32 broken filesystem
Lots opf ESP32 devices have problems with rebooting due to dips in current. This is caused by the 2.4GHz radio. On the datasheet it shows that recommended caps but many manufactures don't put the recommended caps on and this is why there is problems with it rebooting.
The most common cap that manufactures r leaving out is the the 100nf on the EN(enable) line. If the EN pin dips even for a fraction of a sec the ESP32 reboots.
The most common cap that manufactures r leaving out is the the 100nf on the EN(enable) line. If the EN pin dips even for a fraction of a sec the ESP32 reboots.
Re: ESP32 broken filesystem
Using SPIFFS or LittleFS for internal file system may help as they are both more resilient to power loss (by design) than FatFS.
Re: ESP32 broken filesystem
Thanks guys for the quick reply.
Unfortunately the host device has been already in production so we can't change the hardware and file is currently closed at the end of each operation and this did not solve the problem.
The file is currently in json format, if I avoid writing a file and treat this data as bytes directly on the flash, would I have the possibility to write that part of the corrupted sector avoiding to completely reset the filesystem?
Unfortunately the host device has been already in production so we can't change the hardware and file is currently closed at the end of each operation and this did not solve the problem.
The file is currently in json format, if I avoid writing a file and treat this data as bytes directly on the flash, would I have the possibility to write that part of the corrupted sector avoiding to completely reset the filesystem?