-
Notifications
You must be signed in to change notification settings - Fork 410
FAQ
Mail me or post an issue on github if you want answers here.
###Why is spiffs so slow?#
Apart from the underlying hardware (CPU and SPI flash), it is mainly because spiffs uses little memory. Spiffs does not build any file-trees in ram or such, it is really more of a brute-force file system. One may enable caches and stuff, but it will probably still be pretty slow. The slowest part of spiffs is the file system integrity check, SPIFFS_check
. This is because checking must cross-reference huge parts of information using just a handful of bytes. Hence, it runs several scans over the full file system. That said, a lot of effort has been put into optimizing spiffs, it should not be slower than it must to be.
###How does spiffs handle powerlosses?# There is a scheme for updating data: when modifying a page the old page is first marked as being modified, then the new page is written with the updated (and possibly not updated) data. Then the old page is removed, and finally the new page is marked as finalized. In event of a power loss somewhere, there might be two pages with same id, but the status of these pages will indicate which one is valid. There also are certain integrity tests that always are tested when accessing files. If the problem can be mended, there will be an attempt to do this if possible. In the early days of spiffs, a full integrity check was made at mount time, but I removed this as it took so long time. It must now be invoked by user. This integrity check will remove such duplicate pages mentioned before and try to fix a bunch of other problems that might arise from power losses.
###How does the cache work?#
If build time configuration SPIFFS_CACHE
is enabled, spiffs will keep mirrors of the flash in ram used when reading stuff. If build time configuration SPIFFS_CACHE_WR
is disabled, all writes are write through. If SPIFFS_CACHE_WR
is enabled, also writes are cached. The write cache (if there is one) for a file is flushed when calling SPIFFS_fflush
, SPIFFS_close
, SPIFFS_read
, SPIFFS_fstat
, SPIFFS_lseek
. All files are flushed when calling SPIFFS_unmount
.
This means that e.g. SPIFFS_read
might give errors concerning write operations.
###Can spiffs run on an i2c eeprom?# Nope. At least none of the i2c eeproms I've come across. Spiffs uses the nor flash way of writing extensively, where a written byte is sort of AND-written. E.g. say you have a byte on your flash being erased, i.e. is 0xFF. If you first write 0xFE and then 0x7F to this same byte, spiffs expects this byte to be read as 0x7E. Of course, one could write a hal for spiffs that first reads what is supposed to be written, then AND writes in memory, and finally stores this ANDed data to the i2c eeprom. Considering i2c bus speeds, the performance would be horrible.
###Why does half the tests fail when running make test
?#
Because of a missing folder. Run make all
first.