Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Filesystem update via ESP8266HTTPUpdateServer #3732

Merged
merged 34 commits into from
Sep 20, 2019
Merged
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b08d896
Allow SPIFFS update via ESP8266HTTPUpdateServer
sandeen May 11, 2017
8d51a47
Merge remote-tracking branch 'sandeen/spiffs-update' into spiffs-update
Oct 17, 2017
e2fadfe
A simple filter
Oct 17, 2017
1c4440b
Review https://github.com/esp8266/Arduino/pull/3234#pullrequestreview…
Oct 17, 2017
ece2c57
Merge branch 'master' into spiffs-update
caverna Oct 22, 2017
871adc1
Merge branch 'master' into spiffs-update
caverna Nov 5, 2017
8b33311
Merge branch 'master' into spiffs-update
caverna Nov 22, 2017
3cf8a6c
Merge branch 'master' into spiffs-update
caverna Nov 24, 2017
b8e0633
Merge branch 'master' into spiffs-update
caverna Dec 9, 2017
41026b6
Merge branch 'master' into spiffs-update
caverna Dec 13, 2017
a3b5c29
Including suggestions for mobile first #3961
Dec 14, 2017
64ec0d4
Merge branch 'master' into spiffs-update
caverna Dec 16, 2017
80b8ed7
Merge branch 'master' into spiffs-update
caverna Dec 21, 2017
ea2c7d3
Merge remote-tracking branch 'master/master' into spiffs-update
Jan 2, 2018
3e5b179
Merge branch 'master' into spiffs-update
d-a-v Feb 5, 2018
4c0b59e
Merge branch 'master' into spiffs-update
caverna Apr 8, 2018
b51d841
Merge branch 'master' into spiffs-update
caverna May 24, 2018
3cb50d6
Merge branch 'master' into spiffs-update
caverna Jun 14, 2018
9b34a7b
Merge branch 'master' into spiffs-update
caverna Jul 4, 2018
9fc54e5
Merge branch 'master' into spiffs-update
caverna Aug 14, 2018
467ea56
Merge branch 'master' into spiffs-update
caverna Oct 8, 2018
1ec3ca5
Merge branch 'master' into spiffs-update
caverna Nov 5, 2018
a61d7f0
Merge branch 'master' into spiffs-update
d-a-v May 12, 2019
2e5bcd5
Merge branch 'master' into spiffs-update
Sep 12, 2019
d93f71e
SPIFFS rennamed to FS
Sep 14, 2019
db0bbca
Merge branch 'master' into spiffs-update
caverna Sep 14, 2019
303448b
Merge branch 'master' into spiffs-update
caverna Sep 17, 2019
610cba0
including comments from @earlephihower
Sep 17, 2019
6f16022
Merge branch 'spiffs-update' of github.com:caverna/Arduino into spiff…
Sep 17, 2019
7e17463
button renaming
Sep 17, 2019
8fed6be
missing #include for LittleFS
Sep 17, 2019
be5a914
Merge branch 'master' into spiffs-update
caverna Sep 20, 2019
557c733
generic names as suggested by @d-a-v
Sep 20, 2019
c9bccea
Merge branch 'spiffs-update' of github.com:caverna/Arduino into spiff…
Sep 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@
#include <WiFiServer.h>
#include <ESP8266WebServer.h>
#include <WiFiUdp.h>
#include <FS.h>
#include "StreamString.h"
#include "ESP8266HTTPUpdateServer.h"

caverna marked this conversation as resolved.
Show resolved Hide resolved
namespace esp8266httpupdateserver {
using namespace esp8266webserver;

static const char serverIndex[] PROGMEM =
R"(<html><body><form method='POST' action='' enctype='multipart/form-data'>
<input type='file' name='update'>
<input type='submit' value='Update'>
</form>
</body></html>)";
R"(<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'/>
</head>
<body>
<form method='POST' action='' enctype='multipart/form-data'>
Firmware:<br>
<input type='file' accept='.bin' name='firmware'>
<input type='submit' value='Update Firmware'>
</form>
<form method='POST' action='' enctype='multipart/form-data'>
Spiffs:<br>
<input type='file' accept='.bin' name='spiffs'>
caverna marked this conversation as resolved.
Show resolved Hide resolved
<input type='submit' value='Update SPIFFS'>
</form>
</body>
</html>)";
static const char successResponse[] PROGMEM =
"<META http-equiv=\"refresh\" content=\"15;URL=/\">Update Success! Rebooting...";

Expand Down Expand Up @@ -75,9 +90,17 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
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) &_FS_end - (size_t) &_FS_start);
SPIFFS.end();
caverna marked this conversation as resolved.
Show resolved Hide resolved
if (!Update.begin(spiffsSize, U_FS)){//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(".");
Expand Down