FATFS sector size and wear levelling

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

FATFS sector size and wear levelling

Postby PeterR » Wed Oct 16, 2019 12:06 pm

I have a small configuration file to store in onboard flash. The configuration file is writen on each setting change. As some settings are exposed in an API then I need wear leveling.

The NVS system does not seem to support wear levelling.
I tried FATFS. The manual says:
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.
and that
.allocation_unit_size ... Must be a power of 2, between sector size and 128 * sector size.
Which is obviously won't fit in an ESP32.
I can set sector size to 512 to create a more reasonable size, however:
It is not clear how sector size works with respect to wear leveling. If sector size is telling the wear leveler that the hardware sector is 512 bytes then the wear leveler may simply move to the next block. With a small file size this may just result in the true (4096) sector being writen twice.
Does the wear leveler do something like always move forward and then wrap?

Q) Will a small file be properly 'leveled' when sector size = 512 but hardware sector is 4096?
Q) Why must allocated size be > sector size e.g. the default requires 4096*4096 bytes which is 16M?

Or pehaps I am muddled?
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: No registered users and 99 guests