Skip to content

Commit b2de873

Browse files
committed
check current flash before starting update, to avoid update problems.
see: esp8266#1111
1 parent e75c3d8 commit b2de873

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

cores/esp8266/Updater.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ bool UpdaterClass::begin(size_t size, int command) {
5757
return false;
5858
}
5959

60+
if(ESP.getFlashChipRealSize() != ESP.getFlashChipSize()) {
61+
_error = UPDATE_ERROR_FLASH_CONFIG;
62+
#ifdef DEBUG_UPDATER
63+
printError(DEBUG_UPDATER);
64+
#endif
65+
return false;
66+
}
67+
6068
_reset();
6169
_error = 0;
6270

@@ -278,6 +286,8 @@ void UpdaterClass::printError(Stream &out){
278286
out.println("Stream Read Timeout");
279287
} else if(_error == UPDATE_ERROR_MD5){
280288
out.println("MD5 Check Failed");
289+
} else if(_error == UPDATE_ERROR_FLASH_CONFIG){
290+
out.printf("Flash config wrong real: %d IDE: %d\n", ESP.getFlashChipRealSize(), ESP.getFlashChipSize());
281291
} else {
282292
out.println("UNKNOWN");
283293
}

cores/esp8266/Updater.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
#include "flash_utils.h"
66
#include "MD5Builder.h"
77

8-
#define UPDATE_ERROR_OK 0
9-
#define UPDATE_ERROR_WRITE 1
10-
#define UPDATE_ERROR_ERASE 2
11-
#define UPDATE_ERROR_SPACE 3
12-
#define UPDATE_ERROR_SIZE 4
13-
#define UPDATE_ERROR_STREAM 5
14-
#define UPDATE_ERROR_MD5 6
8+
#define UPDATE_ERROR_OK (0)
9+
#define UPDATE_ERROR_WRITE (1)
10+
#define UPDATE_ERROR_ERASE (2)
11+
#define UPDATE_ERROR_SPACE (3)
12+
#define UPDATE_ERROR_SIZE (4)
13+
#define UPDATE_ERROR_STREAM (5)
14+
#define UPDATE_ERROR_MD5 (6)
15+
#define UPDATE_ERROR_FLASH_CONFIG (7)
16+
1517

1618
#define U_FLASH 0
1719
#define U_SPIFFS 100

0 commit comments

Comments
 (0)