I am trying to understand all the nuances of the FatFS and Wear Leveling components of the library. To quote the documentation (https://docs.espressif.com/projects/esp ... lling.html):
I have a couple of doubts about this paragraph:The wear levelling component, together with the FAT FS component, uses FAT FS sectors of 4096 bytes, which is a standard size for flash memory. With this size, the component shows the best performance but needs additional memory in RAM.
To save internal memory, the component has two additional modes which both use sectors of 512 bytes:
- Performance mode. Erase sector operation data is stored in RAM, the sector is erased, and then data is copied back to flash memory. However, if a device is powered off for any reason, all 4096 bytes of data is lost.
- Safety mode. The data is first saved to flash memory, and after the sector is erased, the data is saved back. If a device is powered off, the data can be recovered as soon as the device boots up.
- When using a sector size of 512B there are two different modes, performance and safety; what is the case when using 4096B? Do I get the best performance AND safety? What happens if a poweroff occurs during the write operation?
- In safety mode the data is written in flash before erasing the sector, so "the data can be recovered as soon as the device boots up" in case of interruption. Is this recovery automatic or should I implement it? If so, how?