-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow SPIFFS update via ESP8266HTTPUpdateServer #3234
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"(<html><body><form method='POST' action='' enctype='multipart/form-data'> | ||
<input type='file' name='update'> | ||
<input type='submit' value='Update'> | ||
R"(<html><body> | ||
<form method='POST' action='' enctype='multipart/form-data'> | ||
Firmware:<br> | ||
<input type='file' name='firmware'> | ||
<input type='submit' value='Update Firmware'> | ||
</form> | ||
</body></html>\n)"; | ||
<form method='POST' action='' enctype='multipart/form-data'> | ||
Spiffs:<br> | ||
<input type='file' name='spiffs'> | ||
<input type='submit' value='Update SPIFFS'> | ||
</form> | ||
</body></html>)"; | ||
static const char successResponse[] PROGMEM = | ||
"<META http-equiv=\"refresh\" content=\"15;URL=\">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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, interesting. The README does say Use this method before updating SPIFFS using OTA. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
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("."); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about to include
accept='.bin'
in both fields to filter a little?