Skip to content

Commit 83166f9

Browse files
Deprecate SPIFFS, move examples to LittleFS (esp8266#7263)
* Deprecate SPIFFS, move examples to LittleFS SPIFFS has been a great filesystem, but it has significant problems in many cases (and it's also pretty slow). Development seems to have slowed/stopped on the upstream version, and we're not able to provide support or fix the known issues with it as-is. Deprecate SPIFFS variable. Update all examples to use LittleFS instead of SPIFFS. Also, minor cleanup on very old examples which has obsolete delays waiting for the Serial port to come up, or which were stuck at 9600 baud because of their ancient AVR heritage. Fixes esp8266#7095 * Remove leftover debug code * Clean up comments in some examples * Update documentation on SPIFFS deprecation * Fix host tests to avoid deprecation warnings * Fix cut-n-paste error * Restore SpeedTest.ino, adjust to allow custom FSes Co-authored-by: Develo <[email protected]>
1 parent 9845deb commit 83166f9

File tree

40 files changed

+176
-164
lines changed

40 files changed

+176
-164
lines changed

boards.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4960,15 +4960,15 @@ espinotee.menu.baud.3000000.upload.speed=3000000
49604960
wifinfo.name=WifInfo
49614961
wifinfo.build.board=WIFINFO
49624962
wifinfo.build.variant=wifinfo
4963-
wifinfo.menu.ESPModule.ESP07192=ESP07 (1M/192K SPIFFS)
4963+
wifinfo.menu.ESPModule.ESP07192=ESP07 (1M/192K FS)
49644964
wifinfo.menu.ESPModule.ESP07192.build.board=ESP8266_ESP07
49654965
wifinfo.menu.ESPModule.ESP07192.build.flash_ld=eagle.flash.1m192.ld
49664966
wifinfo.menu.ESPModule.ESP07192.build.flash_size=1M
49674967
wifinfo.menu.ESPModule.ESP07192.build.spiffs_blocksize=4096
49684968
wifinfo.menu.ESPModule.ESP07192.build.spiffs_end=0xFB000
49694969
wifinfo.menu.ESPModule.ESP07192.build.spiffs_start=0xCB000
49704970
wifinfo.menu.ESPModule.ESP07192.upload.maximum_size=827376
4971-
wifinfo.menu.ESPModule.ESP12=ESP12 (4M/1M SPIFFS)
4971+
wifinfo.menu.ESPModule.ESP12=ESP12 (4M/1M FS)
49724972
wifinfo.menu.ESPModule.ESP12.build.board=ESP8266_ESP12
49734973
wifinfo.menu.ESPModule.ESP12.build.flash_ld=eagle.flash.4m1m.ld
49744974
wifinfo.menu.ESPModule.ESP12.build.flash_size=4M

cores/esp8266/FS.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ using fs::SPIFFSConfig;
266266
#endif //FS_NO_GLOBALS
267267

268268
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPIFFS)
269-
extern fs::FS SPIFFS;
269+
extern fs::FS SPIFFS __attribute__((deprecated("SPIFFS has been deprecated. Please consider moving to LittleFS or other filesystems.")));
270270
#endif
271271

272272
#endif //FS_H

cores/esp8266/spiffs_api.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst) {
3737
return flash_hal_read(addr, size, dst);
3838
}
3939

40-
41-
40+
#pragma GCC diagnostic push
41+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
4242

4343
namespace spiffs_impl {
4444

@@ -149,6 +149,8 @@ extern "C" void spiffs_request_end(void)
149149
SPIFFS.end();
150150
}
151151

152+
#pragma GCC diagnostic pop
153+
152154
#endif // ARDUINO
153155
#endif // !CORE_MOCK
154156

cores/esp8266/spiffs_api.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class SPIFFSImpl : public FSImpl
171171
return false;
172172
}
173173
_cfg = *static_cast<const SPIFFSConfig *>(&cfg);
174-
return true;
174+
return true;
175175
}
176176

177177
bool begin() override

doc/boards.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Parameters in Arduino IDE:
344344
~~~~~~~~~~~~~~~~~~~~~~~~~~
345345

346346
- Card: "WEMOS D1 Mini Lite"
347-
- Flash Size: "1M (512K SPIFFS)"
347+
- Flash Size: "1M (512K FS)"
348348
- CPU Frequency: "80 Mhz"
349349

350350
Power:

doc/esp8266wifi/bearssl-client-secure-class.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ The web browser you're using to read this document keeps a list of 100s of certi
102102

103103
In many cases your application will know the specific CA it needs to validate web or MQTT servers against (often just a single, self-signing CA private to your institution). Simply load your private CA in a `BearSSL::X509List` and use that as your trust anchor.
104104

105-
However, there are cases where you will not know beforehand which CA you will need (i.e. a user enters a website through a keypad), and you need to keep the list of CAs just like your web browser. In those cases, you need to generate a certificate bundle on the PC while compiling your application, upload the `certs.ar` bundle to SPIFFS or SD when uploading your application binary, and pass it to a `BearSSL::CertStore()` in order to validate TLS peers.
105+
However, there are cases where you will not know beforehand which CA you will need (i.e. a user enters a website through a keypad), and you need to keep the list of CAs just like your web browser. In those cases, you need to generate a certificate bundle on the PC while compiling your application, upload the `certs.ar` bundle to LittleFS or SD when uploading your application binary, and pass it to a `BearSSL::CertStore()` in order to validate TLS peers.
106106

107-
See the `BearSSL_CertStore` example for full details as the `BearSSL::CertStore` requires the creation of a cookie-cutter object for filesystem access (because the SD and SPIFFS filesystems are presently incompatible with each other). At a high level in your `setup()` you will call `BearSSL::initCertStore()` on a global object, and then pass this global certificate store to `client.setCertStore(&gCA)` before every connection attempt to enable it as a validation option.
107+
See the `BearSSL_CertStore` example for full details.
108108

109109
Supported Crypto
110110
~~~~~~~~~~~~~~~~

doc/esp8266wifi/client-secure-class.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,32 @@ Load client certificate from file system.
4242
.. code:: cpp
4343
4444
#include <FS.h>
45+
#include <LittleFS.h>
4546
#include <ESP8266WiFi.h>
4647
#include <WiFiClientSecure.h>
4748
48-
const char* certyficateFile = "/client.cer";
49+
const char* certificateFile = "/client.cer";
4950
5051
*setup() or loop()*
5152

5253
.. code:: cpp
5354
54-
if (!SPIFFS.begin())
55+
if (!LittleFS.begin())
5556
{
5657
Serial.println("Failed to mount the file system");
5758
return;
5859
}
5960
60-
Serial.printf("Opening %s", certyficateFile);
61-
File crtFile = SPIFFS.open(certyficateFile, "r");
61+
Serial.printf("Opening %s", certificateFile);
62+
File crtFile = LittleFS.open(certificateFile, "r");
6263
if (!crtFile)
6364
{
6465
Serial.println(" Failed!");
6566
}
6667
6768
WiFiClientSecure client;
6869
69-
Serial.print("Loading %s", certyficateFile);
70+
Serial.print("Loading %s", certificateFile);
7071
if (!client.loadCertificate(crtFile))
7172
{
7273
Serial.println(" Failed!");

doc/faq/readme.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ perform. It is not listed among libraries verified to work with ESP8266.
7979

8080
`Read more <a03-library-does-not-work.rst>`__.
8181

82-
In the IDE, for ESP-12E that has 4M flash, I can choose 4M (1M SPIFFS) or 4M (3M SPIFFS). No matter what I select, the IDE tells me the maximum code space is about 1M. Where does my flash go?
82+
In the IDE, for ESP-12E that has 4M flash, I can choose 4M (1M FS) or 4M (3M FS). No matter what I select, the IDE tells me the maximum code space is about 1M. Where does my flash go?
8383
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8484

8585
The reason we cannot have more than 1MB of code in flash has to do with
@@ -90,7 +90,7 @@ total, but switching such "banks" on the fly is not easy and efficient,
9090
so we don't bother doing that. Besides, no one has so far complained
9191
about 1MB of code space being insufficient for practical purposes.
9292

93-
The option to choose 3M or 1M SPIFFS is to optimize the upload time.
93+
The option to choose 3M or 1M filesystem is to optimize the upload time.
9494
Uploading 3MB takes a long time so sometimes you can just use 1MB. Other
9595
2MB of flash can still be used with ``ESP.flashRead`` and
9696
``ESP.flashWrite`` APIs if necessary.

doc/filesystem.rst

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ following include to the sketch:
6363
6464
#include "FS.h"
6565
66+
SPIFFS Deprecation Warning
67+
--------------------------
68+
69+
SPIFFS is currently deprecated and may be removed in future releases of
70+
the core. Please consider moving your code to LittleFS. SPIFFS is not
71+
actively supported anymore by the upstream developer, while LittleFS is
72+
under active development, supports real directories, and is many times
73+
faster for most operations.
74+
75+
6676
SPIFFS and LittleFS
6777
-------------------
6878

doc/installing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,6 @@ BeagleBone, CubieBoard).
244244
- `What is PlatformIO? <https://docs.platformio.org/en/latest/what-is-platformio.html?utm_source=arduino-esp8266>`__
245245
- `PlatformIO IDE <https://platformio.org/platformio-ide?utm_source=arduino-esp8266>`__
246246
- `PlatformIO Core <https://docs.platformio.org/en/latest/core.html?utm_source=arduino-esp8266>`__ (command line tool)
247-
- `Advanced usage <https://docs.platformio.org/en/latest/platforms/espressif8266.html?utm_source=arduino-esp8266>`__ - custom settings, uploading to SPIFFS, Over-the-Air (OTA), staging version
247+
- `Advanced usage <https://docs.platformio.org/en/latest/platforms/espressif8266.html?utm_source=arduino-esp8266>`__ - custom settings, uploading to LittleFS, Over-the-Air (OTA), staging version
248248
- `Integration with Cloud and Standalone IDEs <https://docs.platformio.org/en/latest/ide.html?utm_source=arduino-esp8266>`__ - Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM, Visual Studio, and VSCode
249249
- `Project Examples <https://docs.platformio.org/en/latest/platforms/espressif8266.html?utm_source=arduino-esp8266#examples>`__

doc/libraries.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This is a bit different from standard EEPROM class. You need to call ``EEPROM.be
2525

2626
``EEPROM.write`` does not write to flash immediately, instead you must call ``EEPROM.commit()`` whenever you wish to save changes to flash. ``EEPROM.end()`` will also commit, and will release the RAM copy of EEPROM contents.
2727

28-
EEPROM library uses one sector of flash located just after the SPIFFS.
28+
EEPROM library uses one sector of flash located just after the embedded filesystem.
2929

3030
`Three examples <https://github.com/esp8266/Arduino/tree/master/libraries/EEPROM>`__ included.
3131

doc/ota_updates/readme.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ If this is the case, then most likely ESP module has not been reset after initia
360360
The most common causes of OTA failure are as follows:
361361

362362
- not enough physical memory on the chip (e.g. ESP01 with 512K flash memory is not enough for OTA).
363-
- too much memory declared for SPIFFS so new sketch will not fit between existing sketch and SPIFFS – see `Update process - memory view <#update-process-memory-view>`__.
363+
- too much memory declared for the filesystem so new sketch will not fit between existing sketch and the filesystem – see `Update process - memory view <#update-process-memory-view>`__.
364364
- too little memory declared in Arduino IDE for your selected board (i.e. less than physical size).
365365
- not resetting the ESP module after initial upload using serial port.
366366

libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ unsigned int status = WL_IDLE_STATUS;
5656

5757
void setup() {
5858
delay(1000);
59-
Serial.begin(9600);
59+
Serial.begin(115200);
6060
Serial.println();
6161
Serial.println("Configuring access point...");
6262
/* You can remove the password parameter if you want the AP to be open. */

libraries/EEPROM/examples/eeprom_read/eeprom_read.ino

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ byte value;
1515
void setup() {
1616
// initialize serial and wait for port to open:
1717
Serial.begin(115200);
18-
while (!Serial) {
19-
; // wait for serial port to connect. Needed for Leonardo only
20-
}
2118
EEPROM.begin(512);
2219
}
2320

libraries/ESP8266HTTPClient/examples/PostHttpClient/PostHttpClient.ino

+15-17
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include <ESP8266WiFi.h>
99
#include <ESP8266HTTPClient.h>
1010

11-
#define USE_SERIAL Serial
12-
1311
/* this can be run with an emulated server on host:
1412
cd esp8266-core-root-dir
1513
cd tests/host
@@ -27,21 +25,21 @@
2725

2826
void setup() {
2927

30-
USE_SERIAL.begin(115200);
28+
Serial.begin(115200);
3129

32-
USE_SERIAL.println();
33-
USE_SERIAL.println();
34-
USE_SERIAL.println();
30+
Serial.println();
31+
Serial.println();
32+
Serial.println();
3533

3634
WiFi.begin(STASSID, STAPSK);
3735

3836
while (WiFi.status() != WL_CONNECTED) {
3937
delay(500);
40-
USE_SERIAL.print(".");
38+
Serial.print(".");
4139
}
42-
USE_SERIAL.println("");
43-
USE_SERIAL.print("Connected! IP address: ");
44-
USE_SERIAL.println(WiFi.localIP());
40+
Serial.println("");
41+
Serial.print("Connected! IP address: ");
42+
Serial.println(WiFi.localIP());
4543

4644
}
4745

@@ -52,29 +50,29 @@ void loop() {
5250
WiFiClient client;
5351
HTTPClient http;
5452

55-
USE_SERIAL.print("[HTTP] begin...\n");
53+
Serial.print("[HTTP] begin...\n");
5654
// configure traged server and url
5755
http.begin(client, "http://" SERVER_IP "/postplain/"); //HTTP
5856
http.addHeader("Content-Type", "application/json");
5957

60-
USE_SERIAL.print("[HTTP] POST...\n");
58+
Serial.print("[HTTP] POST...\n");
6159
// start connection and send HTTP header and body
6260
int httpCode = http.POST("{\"hello\":\"world\"}");
6361

6462
// httpCode will be negative on error
6563
if (httpCode > 0) {
6664
// HTTP header has been send and Server response header has been handled
67-
USE_SERIAL.printf("[HTTP] POST... code: %d\n", httpCode);
65+
Serial.printf("[HTTP] POST... code: %d\n", httpCode);
6866

6967
// file found at server
7068
if (httpCode == HTTP_CODE_OK) {
7169
const String& payload = http.getString();
72-
USE_SERIAL.println("received payload:\n<<");
73-
USE_SERIAL.println(payload);
74-
USE_SERIAL.println(">>");
70+
Serial.println("received payload:\n<<");
71+
Serial.println(payload);
72+
Serial.println(">>");
7573
}
7674
} else {
77-
USE_SERIAL.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
75+
Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
7876
}
7977

8078
http.end();

libraries/ESP8266WebServer/examples/FSBrowser/FSBrowser.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
// Select the FileSystem by uncommenting one of the lines below
2727

28-
#define USE_SPIFFS
29-
//#define USE_LITTLEFS
28+
//#define USE_SPIFFS
29+
#define USE_LITTLEFS
3030
//#define USE_SDFS
3131

3232
// Uncomment the following line to embed a version of the web page in the code

libraries/ESP8266WebServer/examples/HttpHashCredAuth/HttpHashCredAuth.ino

+13-12
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
1. Creating a secure web server using ESP8266ESP8266WebServerSecure
88
2. Use of HTTP authentication on this secure server
99
3. A simple web interface to allow an authenticated user to change Credentials
10-
4. Persisting those credentials through a reboot of the ESP by saving them to SPIFFS without storing them as plain text
10+
4. Persisting those credentials through a reboot of the ESP by saving them to LittleFS without storing them as plain text
1111
*/
1212

1313
#include <FS.h>
14+
#include <LittleFS.h>
1415
#include <ESP8266WiFi.h>
1516
#include <ESP8266WebServerSecure.h>
1617

@@ -23,8 +24,8 @@
2324
const char* ssid = STASSID;
2425
const char* wifi_pw = STAPSK;
2526

26-
const String file_credentials = R"(/credentials.txt)"; //SPIFFS file name for the saved credentials
27-
const String change_creds = "changecreds"; //address for a credential change
27+
const String file_credentials = R"(/credentials.txt)"; // LittleFS file name for the saved credentials
28+
const String change_creds = "changecreds"; // Address for a credential change
2829

2930
//The ESP8266WebServerSecure requires an encryption certificate and matching key.
3031
//These can generated with the bash script available in the ESP8266 Arduino repository.
@@ -83,7 +84,7 @@ gz5JWYhbD6c38khSzJb0pNXCo3EuYAVa36kDM96k1BtWuhRS10Q1VXk=
8384

8485
ESP8266WebServerSecure server(443);
8586

86-
//These are temporary credentials that will only be used if none are found saved in SPIFFS.
87+
//These are temporary credentials that will only be used if none are found saved in LittleFS.
8788
String login = "admin";
8889
const String realm = "global";
8990
String H1 = "";
@@ -92,9 +93,9 @@ String authentication_failed = "User authentication has failed.";
9293
void setup() {
9394
Serial.begin(115200);
9495

95-
//Initialize SPIFFS to save credentials
96-
if(!SPIFFS.begin()){
97-
Serial.println("SPIFFS initialization error, programmer flash configured?");
96+
//Initialize LittleFS to save credentials
97+
if(!LittleFS.begin()){
98+
Serial.println("LittleFS initialization error, programmer flash configured?");
9899
ESP.restart();
99100
}
100101

@@ -187,16 +188,16 @@ void showcredentialpage(){
187188
server.send(200, "text/html", page);
188189
}
189190

190-
//Saves credentials to SPIFFS
191+
//Saves credentials to LittleFS
191192
void savecredentials(String new_login, String new_password)
192193
{
193194
//Set global variables to new values
194195
login=new_login;
195196
H1=ESP8266WebServer::credentialHash(new_login,realm,new_password);
196197

197-
//Save new values to SPIFFS for loading on next reboot
198+
//Save new values to LittleFS for loading on next reboot
198199
Serial.println("Saving credentials.");
199-
File f=SPIFFS.open(file_credentials,"w"); //open as a brand new file, discard old contents
200+
File f=LittleFS.open(file_credentials,"w"); //open as a brand new file, discard old contents
200201
if(f){
201202
Serial.println("Modifying credentials in file system.");
202203
f.println(login);
@@ -208,12 +209,12 @@ void savecredentials(String new_login, String new_password)
208209
Serial.println("Credentials saved.");
209210
}
210211

211-
//loads credentials from SPIFFS
212+
//loads credentials from LittleFS
212213
void loadcredentials()
213214
{
214215
Serial.println("Searching for credentials.");
215216
File f;
216-
f=SPIFFS.open(file_credentials,"r");
217+
f=LittleFS.open(file_credentials,"r");
217218
if(f){
218219
Serial.println("Loading credentials from file system.");
219220
String mod=f.readString(); //read the file to a String

0 commit comments

Comments
 (0)