3
votes

I have been asked to help out on an embedded firmware project where they are trying to mount a file system on an SPI flash chip (Cypress S25FL512S) with a 256KB (Kilo Byte) Erase sector size.

My past experience with file systems is that the file system has a block size upto 4Kbytes which is mapped onto erase sectors of 512bytes to 4Kbytes

The embedded controller is a small NXP device running at 180MHz with 512KBytes of RAM so I cannot even cache an erase sector. I note that the chip family does have pin compatible devices with smaller erase sectors.

My general question is how do you mount a file system with a block/cluster size that is smaller than the flash erase sector size? I've not been able to find any articles addressing this.

1
I agree with what you alluded to: the erase sector size is too large for this application - 256K is quite large, 4K is typical. Also, your last paragraph seems to be backwards.Jonathon Reinhart
@JonathonReinhart. I've edited the last paragraph thanks.Tim
@JonathonReinhart 4k erase block size is not typical in large storage non-volatile chips. They're typically 128KB or 256KB for the larger storage devices. If it's smaller (like on SD cards), then there's a controller inside that's doing a translation layer and managing the physical hardware while presenting a virtual erase block to the interface.Russ Schultz
Did you found a solution ? I have the same problemransh
@ransh The accepted answer below confirmed my suspicions that the large erase sector could not be easily accommodated in the small MCU to use as a traditional file system. We were looking to use the flash chip for Logging events so in the end we hand built a simple journaling type logging module that simply hard allocated N sectors, wrote the next event entry to the end of the log, and rotated round the sectors erasing the next sector when the current one was full. We then reproduced this a number of times to fit our needs. Not the answer to my original question but an adequate work aroundTim

1 Answers

1
votes

You can't do this in any sensible way. Your specification needs to be modified.

Possible solutions are:

  • Pick a flash/eeprom circuit with smaller erase size.
  • Pick a flash/eeprom with more memory and multiple segments, so that you can back-up the data in one segment while programming another.
  • Add a second flash circuit which mirrors the first one, erase one at a time and overwrite with contents of the other.
  • Pick a MCU with more RAM.
  • Backup the flash inside MCU flash (very slow and likely defeats the purpose of having external flash to begin with).