From b08d896a6c8eb01c8b206df9c490f7f0ca6ce5ac Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Thu, 11 May 2017 16:50:43 -0500 Subject: [PATCH 1/9] Allow SPIFFS update via ESP8266HTTPUpdateServer This adds capability to update the SPIFFS image via the same mechansism as firmware in the ESP8266HTTPUpdateServer. It does not provide any dependency or linkage between firmware and spiffs image updating; they are each taken on their own, each followed by a reboot. (I wrote this before seeing the other PR for similar functionality; I like this a bit better, becaue it uses the available SPIFFS size, and does not hide magic numbers (U_SPIFFS) in the html...) (It also cleans up a stray \n from commit ace0622) --- .../src/ESP8266HTTPUpdateServer.cpp | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp index 1223596cf8..7f4b17ffa6 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp @@ -6,13 +6,22 @@ #include "StreamString.h" #include "ESP8266HTTPUpdateServer.h" +extern "C" uint32_t _SPIFFS_start; +extern "C" uint32_t _SPIFFS_end; static const char serverIndex[] PROGMEM = - R"(
- - + R"( + + Firmware:
+ +
- \n)"; +
+ Spiffs:
+ + +
+ )"; static const char successResponse[] PROGMEM = "Update Success! Rebooting...\n"; @@ -71,9 +80,16 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path, WiFiUDP::stopAll(); if (_serial_output) Serial.printf("Update: %s\n", upload.filename.c_str()); - uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; - if(!Update.begin(maxSketchSpace)){//start with max available size - _setUpdaterError(); + if (upload.name == "spiffs") { + size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start); + if (!Update.begin(spiffsSize, U_SPIFFS)){//start with max available size + if (_serial_output) Update.printError(Serial); + } + } else { + uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; + if (!Update.begin(maxSketchSpace, U_FLASH)){//start with max available size + _setUpdaterError(); + } } } else if(_authenticated && upload.status == UPLOAD_FILE_WRITE && !_updaterError.length()){ if (_serial_output) Serial.printf("."); From e2fadfe4bf87552e1131fb0de44519a50c366884 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Nunes Date: Tue, 17 Oct 2017 16:15:10 -0200 Subject: [PATCH 2/9] A simple filter --- .../ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp index 409df6d0f6..3261e1697d 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp @@ -13,12 +13,12 @@ static const char serverIndex[] PROGMEM = R"(
Firmware:
- +
Spiffs:
- +
)"; From 1c4440be0700ea19028a782a6e387e0a7b4e4e4b Mon Sep 17 00:00:00 2001 From: Carlos Alberto Nunes Date: Tue, 17 Oct 2017 16:18:03 -0200 Subject: [PATCH 3/9] Review https://github.com/esp8266/Arduino/pull/3234#pullrequestreview-37773153 --- .../ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp index 3261e1697d..9fbc3b9aca 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "StreamString.h" #include "ESP8266HTTPUpdateServer.h" @@ -82,6 +83,7 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path, Serial.printf("Update: %s\n", upload.filename.c_str()); if (upload.name == "spiffs") { size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start); + SPIFFS.end(); if (!Update.begin(spiffsSize, U_SPIFFS)){//start with max available size if (_serial_output) Update.printError(Serial); } From a3b5c295fb51eaa5845752e241514076e6906ae4 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Nunes Date: Thu, 14 Dec 2017 07:40:05 -0200 Subject: [PATCH 4/9] Including suggestions for mobile first #3961 --- .../src/ESP8266HTTPUpdateServer.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp index 9fbc3b9aca..65cbefe743 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp @@ -11,18 +11,25 @@ extern "C" uint32_t _SPIFFS_start; extern "C" uint32_t _SPIFFS_end; static const char serverIndex[] PROGMEM = - R"( + R"( + + + + + +
- Firmware:
- - -
+ Firmware:
+ + +
- Spiffs:
- - -
- )"; + Spiffs:
+ + + + + )"; static const char successResponse[] PROGMEM = "Update Success! Rebooting...\n"; From d93f71eb77381e63e247739a2f915492ffdddaec Mon Sep 17 00:00:00 2001 From: Carlos Nunes Date: Sat, 14 Sep 2019 09:54:44 +0200 Subject: [PATCH 5/9] SPIFFS rennamed to FS --- .../src/ESP8266HTTPUpdateServer-impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index 2284412c95..72c7d26f49 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -91,9 +91,9 @@ void ESP8266HTTPUpdateServerTemplate::setup(ESP8266WebServerTemplate if (_serial_output) Serial.printf("Update: %s\n", upload.filename.c_str()); if (upload.name == "spiffs") { - size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start); + size_t spiffsSize = ((size_t) &_FS_end - (size_t) &_FS_start); SPIFFS.end(); - if (!Update.begin(spiffsSize, U_SPIFFS)){//start with max available size + if (!Update.begin(spiffsSize, U_FS)){//start with max available size if (_serial_output) Update.printError(Serial); } } else { From 610cba00c326cd5941a382731da3281c6b3dcf2f Mon Sep 17 00:00:00 2001 From: Carlos Nunes Date: Tue, 17 Sep 2019 16:07:30 +0200 Subject: [PATCH 6/9] including comments from @earlephihower --- .../src/ESP8266HTTPUpdateServer-impl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index 72c7d26f49..41a5738cb5 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "StreamString.h" #include "ESP8266HTTPUpdateServer.h" @@ -24,7 +25,7 @@ static const char serverIndex[] PROGMEM =
- Spiffs:
+ FileSystem:
@@ -93,6 +94,7 @@ void ESP8266HTTPUpdateServerTemplate::setup(ESP8266WebServerTemplate if (upload.name == "spiffs") { size_t spiffsSize = ((size_t) &_FS_end - (size_t) &_FS_start); SPIFFS.end(); + LittleFS.end(); if (!Update.begin(spiffsSize, U_FS)){//start with max available size if (_serial_output) Update.printError(Serial); } From 7e17463fcf8c939d5f2f9a321bcebac141132242 Mon Sep 17 00:00:00 2001 From: Carlos Nunes Date: Tue, 17 Sep 2019 16:14:08 +0200 Subject: [PATCH 7/9] button renaming --- .../ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index 41a5738cb5..adb18cce38 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -27,7 +27,7 @@ static const char serverIndex[] PROGMEM =
FileSystem:
- +
)"; From 8fed6be0bff9168c5b747e5d8274d61ca16a36ba Mon Sep 17 00:00:00 2001 From: Carlos Nunes Date: Tue, 17 Sep 2019 16:31:55 +0200 Subject: [PATCH 8/9] missing #include for LittleFS --- .../ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index adb18cce38..0304594aa2 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -3,8 +3,9 @@ #include #include #include -#include #include +#include +#include #include "StreamString.h" #include "ESP8266HTTPUpdateServer.h" From 557c733ca0ebb87192e386b242685bfd817b24ac Mon Sep 17 00:00:00 2001 From: Carlos Nunes Date: Fri, 20 Sep 2019 08:41:57 +0200 Subject: [PATCH 9/9] generic names as suggested by @d-a-v --- .../src/ESP8266HTTPUpdateServer-impl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index 0304594aa2..6761177a0a 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -27,7 +27,7 @@ static const char serverIndex[] PROGMEM =
FileSystem:
- +
@@ -92,11 +92,11 @@ void ESP8266HTTPUpdateServerTemplate::setup(ESP8266WebServerTemplate WiFiUDP::stopAll(); if (_serial_output) Serial.printf("Update: %s\n", upload.filename.c_str()); - if (upload.name == "spiffs") { - size_t spiffsSize = ((size_t) &_FS_end - (size_t) &_FS_start); + if (upload.name == "filesystem") { + size_t fsSize = ((size_t) &_FS_end - (size_t) &_FS_start); SPIFFS.end(); LittleFS.end(); - if (!Update.begin(spiffsSize, U_FS)){//start with max available size + if (!Update.begin(fsSize, U_FS)){//start with max available size if (_serial_output) Update.printError(Serial); } } else {