mirror of https://github.com/arendst/Tasmota.git
Merge pull request #15610 from s-hadinger/esp32_upload_size_check
Esp32 upload file checked done against OTA partitionsize
This commit is contained in:
commit
7ca954fa4f
|
@ -36,6 +36,7 @@ default_envs =
|
||||||
; tasmota32solo1
|
; tasmota32solo1
|
||||||
; tasmota32c3
|
; tasmota32c3
|
||||||
; tasmota32s2
|
; tasmota32s2
|
||||||
|
; tasmota32s3
|
||||||
; tasmota32-odroidgo
|
; tasmota32-odroidgo
|
||||||
; tasmota32-core2
|
; tasmota32-core2
|
||||||
|
|
||||||
|
@ -90,8 +91,8 @@ lib_extra_dirs = ${library.lib_extra_dirs}
|
||||||
|
|
||||||
[env:tasmota32_base]
|
[env:tasmota32_base]
|
||||||
; *** Uncomment next lines ";" to enable development Tasmota Arduino version ESP32
|
; *** Uncomment next lines ";" to enable development Tasmota Arduino version ESP32
|
||||||
;platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.3rc1/platform-espressif32-2.0.3new.zip
|
;platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-v.2.0.3.zip
|
||||||
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/825/framework-arduinoespressif32-v4.4_work-c4b83228a5.tar.gz
|
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/837/framework-arduinoespressif32-v4.4_dev-6fa4526c0d.tar.gz
|
||||||
build_unflags = ${esp32_defaults.build_unflags}
|
build_unflags = ${esp32_defaults.build_unflags}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
build_flags = ${esp32_defaults.build_flags}
|
||||||
|
|
||||||
|
|
|
@ -353,18 +353,22 @@ const char HTTP_FORM_UPG[] PROGMEM =
|
||||||
"</fieldset><br><br>"
|
"</fieldset><br><br>"
|
||||||
"<fieldset><legend><b> " D_UPGRADE_BY_FILE_UPLOAD " </b></legend>";
|
"<fieldset><legend><b> " D_UPGRADE_BY_FILE_UPLOAD " </b></legend>";
|
||||||
const char HTTP_FORM_RST_UPG[] PROGMEM =
|
const char HTTP_FORM_RST_UPG[] PROGMEM =
|
||||||
"<form method='post' action='u2' enctype='multipart/form-data'>"
|
"<form method='post' action='u2?fsz=' enctype='multipart/form-data'>"
|
||||||
"<br><input type='file' name='u2'><br>"
|
"<br><input type='file' name='u2'><br>"
|
||||||
"<br><button type='submit' onclick='eb(\"f1\").style.display=\"none\";eb(\"f2\").style.display=\"block\";this.form.submit();'>" D_START " %s</button></form>"
|
"<br><button type='submit' "
|
||||||
|
"onclick='eb(\"f1\").style.display=\"none\";eb(\"f2\").style.display=\"block\";this.form.action+=this.form[\"u2\"].files[0].size;this.form.submit();'"
|
||||||
|
">" D_START " %s</button></form>"
|
||||||
"</fieldset>"
|
"</fieldset>"
|
||||||
"</div>"
|
"</div>"
|
||||||
"<div id='f2' style='display:none;text-align:center;'><b>" D_UPLOAD_STARTED "...</b></div>";
|
"<div id='f2' style='display:none;text-align:center;'><b>" D_UPLOAD_STARTED "...</b></div>";
|
||||||
|
|
||||||
// upload via factory partition
|
// upload via factory partition
|
||||||
const char HTTP_FORM_RST_UPG_FCT[] PROGMEM =
|
const char HTTP_FORM_RST_UPG_FCT[] PROGMEM =
|
||||||
"<form method='post' action='u2' enctype='multipart/form-data'>"
|
"<form method='post' action='u2?fsz=' enctype='multipart/form-data'>"
|
||||||
"<br><input type='file' name='u2'><br>"
|
"<br><input type='file' name='u2'><br>"
|
||||||
"<br><button type='submit' onclick='eb(\"f1\").style.display=\"none\";eb(\"f3\").style.display=\"block\";return upl(this);'>" D_START " %s</button></form>"
|
"<br><button type='submit' "
|
||||||
|
"onclick='eb(\"f1\").style.display=\"none\";eb(\"f3\").style.display=\"block\";this.form.action+=this.form[\"u2\"].files[0].size;return upl(this);'"
|
||||||
|
">" D_START " %s</button></form>"
|
||||||
"</fieldset>"
|
"</fieldset>"
|
||||||
"</div>"
|
"</div>"
|
||||||
"<div id='f3' style='display:none;text-align:center;'><b>" D_UPLOAD_FACTORY "...</b></div>"
|
"<div id='f3' style='display:none;text-align:center;'><b>" D_UPLOAD_FACTORY "...</b></div>"
|
||||||
|
@ -436,6 +440,7 @@ ESP8266WebServer *Webserver;
|
||||||
|
|
||||||
struct WEB {
|
struct WEB {
|
||||||
String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE
|
String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE
|
||||||
|
uint32_t upload_size = 0;
|
||||||
uint16_t upload_error = 0;
|
uint16_t upload_error = 0;
|
||||||
uint8_t state = HTTP_OFF;
|
uint8_t state = HTTP_OFF;
|
||||||
uint8_t upload_file_type;
|
uint8_t upload_file_type;
|
||||||
|
@ -2775,11 +2780,15 @@ void HandleUploadLoop(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (0xE9 == upload.buf[0]) {
|
if (0xE9 == upload.buf[0]) {
|
||||||
uint32_t bin_flash_size = ESP.magicFlashChipSize((upload.buf[3] & 0xf0) >> 4);
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
uint32_t bin_flash_size = ESP.magicFlashChipSize((upload.buf[3] & 0xf0) >> 4);
|
||||||
if (bin_flash_size > ESP.getFlashChipRealSize()) {
|
if (bin_flash_size > ESP.getFlashChipRealSize()) {
|
||||||
#else
|
#else
|
||||||
if (bin_flash_size > ESP.getFlashChipSize()) { // TODO revisit this test
|
char tmp[16];
|
||||||
|
WebGetArg("fsz", tmp, sizeof(tmp)); // filesize
|
||||||
|
uint32_t upload_size = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, D_LOG_UPLOAD "freespace=%i filesize=%i", ESP.getFreeSketchSpace(), upload_size);
|
||||||
|
if (upload_size > ESP.getFreeSketchSpace()) { // TODO revisit this test
|
||||||
#endif
|
#endif
|
||||||
Web.upload_error = 4; // Program flash size is larger than real flash size
|
Web.upload_error = 4; // Program flash size is larger than real flash size
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue