Skip to content

Commit 1584fd8

Browse files
committed
OTA: esp8266 fix for gzipped fw image
Signed-off-by: Emil Muratov <[email protected]>
1 parent 208e6ec commit 1584fd8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

EmbUI/EmbUI.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@
1919
#define SECONDARY_PERIOD 300U // second handler timer, ms
2020

2121
// Update defs
22-
#define FW_MAGIC 0xe9
22+
#ifndef ESP_IMAGE_HEADER_MAGIC
23+
#define ESP_IMAGE_HEADER_MAGIC 0xE9
24+
#endif
25+
26+
#ifndef GZ_HEADER
27+
#define GZ_HEADER 0x1F
28+
#endif
29+
30+
2331
#ifdef ESP32
2432
#define U_FS U_SPIFFS
2533
#endif
@@ -305,14 +313,14 @@ void EmbUI::begin(){
305313
}
306314
},[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
307315
if (!index) {
308-
int type = (data[0] == FW_MAGIC)? U_FLASH : U_FS;
309-
310316
#ifdef ESP8266
317+
int type = (data[0] == ESP_IMAGE_HEADER_MAGIC || data[0] == GZ_HEADER)? U_FLASH : U_FS;
311318
Update.runAsync(true);
312319
// TODO: разобраться почему под littlefs образ генерится чуть больше чем размер доступной памяти по константам
313320
size_t size = (type == U_FLASH)? request->contentLength() : (uintptr_t)&_FS_end - (uintptr_t)&_FS_start;
314321
#endif
315322
#ifdef ESP32
323+
int type = (data[0] == ESP_IMAGE_HEADER_MAGIC)? U_FLASH : U_FS;
316324
size_t size = (type == U_FLASH)? request->contentLength() : UPDATE_SIZE_UNKNOWN;
317325
#endif
318326
LOG(printf_P, PSTR("Updating %s, file size:%u\n"), (type == U_FLASH)? F("Firmware") : F("Filesystem"), request->contentLength());

0 commit comments

Comments
 (0)