File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 6
6
static bool sys_update_is_ok = false ; // indicates a successful update
7
7
static Ticker blink;
8
8
9
+ extern " C" uint32_t _FS_start;
10
+ extern " C" uint32_t _FS_end;
11
+
9
12
//
10
13
static void sys_update_finish (ESP8266WebServer &server, bool finish = false )
11
14
{
@@ -89,7 +92,20 @@ void sys_update_register(ESP8266WebServer &server)
89
92
sys_update_is_ok = false ;
90
93
int command = (upload.filename .indexOf (" spiffs.bin" ) != -1 ) ? U_FS : U_FLASH;
91
94
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))
93
109
{
94
110
Serial.println (F (" begin error" ));
95
111
sys_update_finish (server);
You can’t perform that action at this time.
0 commit comments