Hello everyone,
I am planning to implement a function to read from and write to the flash.
While searching through the ESP documentation, I found direct APIs such as esp_flash_write and esp_flash_read.
I am not sure if these APIs support wear leveling. Any feedback would be appreciated.
P.S. I have found other APIs that support wear leveling, but I would like to know if these APIs also support it.
writing and readting to/from Flash memory
-
- Posts: 2045
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
-
- Posts: 18
- Joined: Thu Jun 22, 2023 2:58 pm
Re: writing and readting to/from Flash memory
ESP's esp_flash_write and esp_flash_read APIs provide direct access to flash memory but do not inherently handle wear leveling. To enable wear leveling, you can use LittleFS or FatFS with the wear-leveling enabled on top of the flash storage. Hope this helps!
Re: writing and readting to/from Flash memory
Thank you ! That helped a lot. Any recommendation to store data from a ringbuffer to the flash. New data should overwrite the existed data considering wear leveling ? I don't need a filesystem, I would like to store the data without a filesystemRathiSonika wrote: ↑Mon Feb 10, 2025 12:03 pmESP's esp_flash_write and esp_flash_read APIs provide direct access to flash memory but do not inherently handle wear leveling. To enable wear leveling, you can use LittleFS or FatFS with the wear-leveling enabled on top of the flash storage. Hope this helps!
-
- Posts: 18
- Joined: Thu Jun 22, 2023 2:58 pm
Re: writing and readting to/from Flash memory
Please refer to the Wear Leveling APIs here https://docs.espressif.com/projects/esp ... lling.html. You can try these steps: load the partition using esp_partition_find_first(), mount Wear Leveling using wl_mount(), and then use wl_write() and wl_read() to write and read from flash memory (refer to the documentation for details). This should solve your problem. Let me know if you face any issues!
Re: writing and readting to/from Flash memory
erasing flash for every new writing seems to me not the best solution. How about nvs ? I have read that nvs supports wear leveling automatically. Can I use a BLOB to store big data i.e. data from a ringbuffer ? About 1024 bytes ?RathiSonika wrote: ↑Mon Feb 10, 2025 12:56 pmPlease refer to the Wear Leveling APIs here https://docs.espressif.com/projects/esp ... lling.html. You can try these steps: load the partition using esp_partition_find_first(), mount Wear Leveling using wl_mount(), and then use wl_write() and wl_read() to write and read from flash memory (refer to the documentation for details). This should solve your problem. Let me know if you face any issues!
-
- Posts: 18
- Joined: Thu Jun 22, 2023 2:58 pm
Re: writing and readting to/from Flash memory
Yes, NVS supports wear leveling. NVS is useful for applications that manage multiple key-value pairs, such as system configuration. You can refer to this https://docs.espressif.com/projects/esp ... vs-library for more details on NVS.
Who is online
Users browsing this forum: No registered users and 99 guests