Skip to content

Commit 9b06df8

Browse files
committed
problème de taille...
1 parent c934511 commit 9b06df8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/update.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
static bool sys_update_is_ok = false; // indicates a successful update
77
static Ticker blink;
88

9+
extern "C" uint32_t _FS_start;
10+
extern "C" uint32_t _FS_end;
11+
912
//
1013
static void sys_update_finish(ESP8266WebServer &server, bool finish = false)
1114
{
@@ -89,7 +92,20 @@ void sys_update_register(ESP8266WebServer &server)
8992
sys_update_is_ok = false;
9093
int command = (upload.filename.indexOf("spiffs.bin") != -1) ? U_FS : U_FLASH;
9194

92-
if (!Update.begin(1024000, command))
95+
// upload.contentLength is NOT the real upload size
96+
uint32_t max_size;
97+
if (command == U_FS)
98+
{
99+
// contentLength is a little above the authorized length
100+
max_size = (uint32_t)&_FS_end - (uint32_t)&_FS_start;
101+
}
102+
else
103+
{
104+
// should be always ok
105+
max_size = upload.contentLength;
106+
}
107+
108+
if (!Update.begin(max_size, command))
93109
{
94110
Serial.println(F("begin error"));
95111
sys_update_finish(server);

0 commit comments

Comments
 (0)