Filesystem - ESP8266 Arduino Core Documentation - Read The Docs

Flash layout

Even though file system is stored on the same flash chip as the program, programming new sketch will not modify file system contents. This allows to use file system to store sketch data, configuration files, or content for Web server.

The following diagram illustrates flash layout used in Arduino environment:

|--------------|-------|---------------|--|--|--|--|--| ^ ^ ^ ^ ^ Sketch OTA update File system EEPROM WiFi config (SDK)

File system size depends on the flash chip size. Depending on the board which is selected in IDE, the following table shows options for flash size.

Another option called Mapping defined by Hardware and Sketch is available. It allows a sketch, not the user, to select FS configuration at boot according to flash chip size.

This option is also enabled with this compilation define: -DFLASH_MAP_SUPPORT=1.

There are three possible configurations:

  • FLASH_MAP_OTA_FS: largest available space for onboard FS, allowing OTA (noted ‘OTA’ in the table)

  • FLASH_MAP_MAX_FS: largest available space for onboard FS (noted ‘MAX’ in the table)

  • FLASH_MAP_NO_FS: no onboard FS

Sketch can invoke a particular configuration by adding this line:

FLASH_MAP_SETUP_CONFIG(FLASH_MAP_OTA_FS) voidsetup(){...} voidloop(){...}

Board

Flash chip size (bytes)

File system size (bytes)

Any

512KBytes

32KB(OTA), 64KB, 128KB(MAX)

Any

1MBytes

64KB(OTA), 128KB, 144KB, 160KB, 192KB, 256KB, 512KB(MAX)

Any

2MBytes

64KB, 128KB, 256KB(OTA), 512KB, 1MB(MAX)

Any

4MBytes

1MB, 2MB(OTA), 3MB(MAX)

Any

8MBytes

6MB(OTA), 7MB(MAX)

Any

16MBytes

14MB(OTA), 15MB(MAX)

Note: to use any of file system functions in the sketch, add the following include to the sketch:

//#include "FS.h" // SPIFFS is declared #include"LittleFS.h" // LittleFS is declared //#include "SDFS.h" // SDFS is declared

Tag » Arduino Littlefs.h No Such File Or Directory