spiffs.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. SPIFFS Filesystem
  2. =================
  3. Overview
  4. --------
  5. SPIFFS is a file system intended for SPI NOR flash devices on embedded targets.
  6. It supports wear leveling, file system consistency checks and more.
  7. Notes
  8. -----
  9. - Presently, spiffs does not support directories. It produces a flat structure. If SPIFFS is mounted under ``/spiffs`` creating a file with path ``/spiffs/tmp/myfile.txt`` will create a file called ``/tmp/myfile.txt`` in SPIFFS, instead of ``myfile.txt`` under directory ``/spiffs/tmp``.
  10. - It is not a realtime stack. One write operation might last much longer than another.
  11. - Presently, it does not detect or handle bad blocks.
  12. Tools
  13. -----
  14. Host-Side tools for creating SPIFS partition images exist and one such tool is `mkspiffs <https://github.com/igrr/mkspiffs>`_.
  15. You can use it to create image from a given folder and then flash that image with ``esptool.py``
  16. To do that you need to obtain some parameters:
  17. - Block Size: 4096 (standard for SPI Flash)
  18. - Page Size: 256 (standard for SPI Flash)
  19. - Image Size: Size of the partition in bytes (can be obtained from partition table)
  20. - Partition Offset: Starting address of the partition (can be obtained from partition table)
  21. To pack a folder into 1 Megabyte image::
  22. mkspiffs -c [src_folder] -b 4096 -p 256 -s 0x100000 spiffs.bin
  23. To flash the image to ESP32 at offset 0x110000::
  24. python esptool.py --chip esp32 --port [port] --baud [baud] write_flash -z 0x110000 spiffs.bin
  25. See also
  26. --------
  27. - :doc:`Partition Table documentation <../../api-guides/partition-tables>`
  28. Application Example
  29. -------------------
  30. An example for using SPIFFS is provided in :example:`storage/spiffs` directory. This example initializes and mounts SPIFFS partition, and writes and reads data from it using POSIX and C library APIs. See README.md file in the example directory for more information.
  31. High level API Reference
  32. ------------------------
  33. * :component_file:`spiffs/include/esp_spiffs.h`
  34. .. include:: /_build/inc/esp_spiffs.inc