The application discloses a kind of based on SPI Flash's embedded
file system implementation method, comprising: initialization reads superblock, establishes the state mapping table of
file record item and data sector;When opening file,
record item is quickly matched by file name
metadata, and new item is allocated if it fails;When reading and writing,
aggregate data through write cache, asynchronously update to
flash memory and refresh mapping table;When closing file, if change occurs, then allocate new space and mark original space as invalid, avoid real-time erasing;Finally,
garbage collection and fragmentation are arranged in
system idle period.This method reduces direct access to SPI Flash through
memory mapping table, reduces the frequency of erasing and writing by using write cache and asynchronous mechanism, moves time-consuming erasing operation to the background, significantly improves the
processing efficiency of file operation and
system real-time, while prolonging the service life of storage medium.