Replies: 4 comments 13 replies
-
I think each board on esp port can have a partitions CSV that lists everything built internally. |
Beta Was this translation helpful? Give feedback.
-
I would have a try with [esp32.NVS] (https://docs.micropython.org/en/latest/library/esp32.html#esp32.NVS). >>> import esp32
>>> nvs = esp32.NVS('A')
>>> nvs.set_blob('a', b'This is a test')
>>> nvs.set_blob('b', b'We will save this')
>>> nvs.commit()
>>> import machine
>>> machine.reset()
-----------
>>> import esp32
>>> nvs =esp32.NVS('A')
>>> nvs.get_blob('a', buf)
14
>>> buf[:14].decode()
'This is a test'
>>> l = nvs.get_blob('b', buf)
>>> buf[:l].decode()
'We will save this' |
Beta Was this translation helpful? Give feedback.
-
@botos-e Have you considered an external fram for the cycling data? fram has a lifetime in the 10^10 - 10^12 cycle range, so it lives a lot longer than flash. It's much more expensive, but for short-term buffering you might not need a lot. |
Beta Was this translation helpful? Give feedback.
-
You can use the ESP32 RTC SRAM to save small amounts (up to ~3kB) of data. I consider it bad practice to use the flash for (relative) frequent writes, as it is rated for 100k writes only (see the ESP32 datasheets), even when the LFS distributes writes over the whole partition. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Dear community,
I wanted to discuss what the best solution is to deal with a file system corruption error and how to prevent data loss.
The following situation brought me to this topic:
I built a statemachine based uPy custom-firmware for an ESP32-D0WDQ6 based hardware that does some measurements and sends them via mqtt to a broker. For this, it needs to connect WLAN, of course. The WLAN credentials are entered by the user at first use and get stored to the internal filesystem. This is important data I can't afford to lose. I also store measurements in case if temporarily no network is available and do extensive logging with log rotation for debugging purposes. This is less important data which I can afford to lose sometimes. Currently I am testing with 30 boards. Everything works great so far - except that I get filesystem corruption errors once in a while - at roughly 30% of the boards after around 30k cycles.
The error is:
So I was thinking about the following solutions:
1. I write the WIFI credentials to flash outside of the filesystem. In case of a filesystem corruption error I simply recreate the fs with
and accept to lose some measurement data and the logs. That is perfectly acceptable in my use case.
Question 1: How do I know where to write to the flash? And how do I write strings to the flash?
2. I create two partitions and use the first for the important, rarely changing data, e.g. the wifi credentials and use the second partition for the more frequent writes (data and logs). I assume that the first partition won't get corrupted and the second could simply be recreated with the code example from above. In this case I again accept to lose some measurement data and the logs.
Question 2: How do I create multiple partitions instead of one? Also how do I know how many free space is available for my partitions?
3. I create two partitions and use one as a backup partition and the other as "main storage". In this case I have good chances to recover all of my data.
Question 3: How do I check if/which partition is corrupted?
4. I try to recover the data.
Question 4: Is it possible and how is it possible to recover data from a corrupted fs on a running system?
I am looking forward for your answers and/or suggestions.
Beta Was this translation helpful? Give feedback.
All reactions