File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,16 @@ size_t UpdaterClass::writeStream(Stream &data) {
252
252
if (hasError () || !isRunning ())
253
253
return 0 ;
254
254
255
+ // check for valid first magic byte (is always 0xE9)
256
+ if (data.peek () != 0xE9 ) {
257
+ _error = UPDATE_ERROR_MAGIC_BYTE;
258
+ _currentAddress = (_startAddress + _size);
259
+ #ifdef DEBUG_UPDATER
260
+ printError (DEBUG_UPDATER);
261
+ #endif
262
+ return 0 ;
263
+ }
264
+
255
265
while (remaining ()) {
256
266
toRead = data.readBytes (_buffer + _bufferLen, (FLASH_SECTOR_SIZE - _bufferLen));
257
267
if (toRead == 0 ) { // Timeout
@@ -293,6 +303,8 @@ void UpdaterClass::printError(Stream &out){
293
303
out.println (" MD5 Check Failed" );
294
304
} else if (_error == UPDATE_ERROR_FLASH_CONFIG){
295
305
out.printf (" Flash config wrong real: %d IDE: %d\n " , ESP.getFlashChipRealSize (), ESP.getFlashChipSize ());
306
+ } else if (_error == UPDATE_ERROR_MAGIC_BYTE){
307
+ out.println (" Magic byte is wrong, not 0xE9" );
296
308
} else {
297
309
out.println (" UNKNOWN" );
298
310
}
Original file line number Diff line number Diff line change 13
13
#define UPDATE_ERROR_STREAM (5 )
14
14
#define UPDATE_ERROR_MD5 (6 )
15
15
#define UPDATE_ERROR_FLASH_CONFIG (7 )
16
+ #define UPDATE_ERROR_MAGIC_BYTE (8 )
16
17
17
18
18
19
#define U_FLASH 0
You can’t perform that action at this time.
0 commit comments