Electrical – Why a 4KB (erase block) flash uses too much RAM


I'm using an SST26VF (4KB block erase) flash with elm chan's FAT FS. And when I compiled it for my STM32F103 it is using up too much RAM. But Mr. Chan's application notes that memory usage doesn't on the sector size (which I have set as 4096).
Why would I be using this much RAM? My program worked perfectly fine with an SD card (FAT sector size is 512 bytes). But now when I reconfigured it for SST26VF its RAM usage is more than what the uC offers.

Best Answer

The size of the minimum erase block dictates the size of the RAM buffer required for RMW (read-modify-write) operations, at least in naive implementations. RMW operations are common in filesystem implementations, used for updating data structures such as directories and allocation tables.

It is possible to work around this by writing the updated data to a previously erased block, but keeping track of such relocations can be very tricky. This is usually done as part of a wear-leveling scheme, which is normally a separate layer of software from the filesystem logic.