1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

check current flash before starting update, to avoid update problems.

see: #1111
This commit is contained in:
Markus Sattler 2015-12-16 19:45:21 +01:00
parent e75c3d8444
commit b2de8735c8
2 changed files with 19 additions and 7 deletions

View File

@ -57,6 +57,14 @@ bool UpdaterClass::begin(size_t size, int command) {
return false; return false;
} }
if(ESP.getFlashChipRealSize() != ESP.getFlashChipSize()) {
_error = UPDATE_ERROR_FLASH_CONFIG;
#ifdef DEBUG_UPDATER
printError(DEBUG_UPDATER);
#endif
return false;
}
_reset(); _reset();
_error = 0; _error = 0;
@ -278,6 +286,8 @@ void UpdaterClass::printError(Stream &out){
out.println("Stream Read Timeout"); out.println("Stream Read Timeout");
} else if(_error == UPDATE_ERROR_MD5){ } else if(_error == UPDATE_ERROR_MD5){
out.println("MD5 Check Failed"); out.println("MD5 Check Failed");
} else if(_error == UPDATE_ERROR_FLASH_CONFIG){
out.printf("Flash config wrong real: %d IDE: %d\n", ESP.getFlashChipRealSize(), ESP.getFlashChipSize());
} else { } else {
out.println("UNKNOWN"); out.println("UNKNOWN");
} }

View File

@ -5,13 +5,15 @@
#include "flash_utils.h" #include "flash_utils.h"
#include "MD5Builder.h" #include "MD5Builder.h"
#define UPDATE_ERROR_OK 0 #define UPDATE_ERROR_OK (0)
#define UPDATE_ERROR_WRITE 1 #define UPDATE_ERROR_WRITE (1)
#define UPDATE_ERROR_ERASE 2 #define UPDATE_ERROR_ERASE (2)
#define UPDATE_ERROR_SPACE 3 #define UPDATE_ERROR_SPACE (3)
#define UPDATE_ERROR_SIZE 4 #define UPDATE_ERROR_SIZE (4)
#define UPDATE_ERROR_STREAM 5 #define UPDATE_ERROR_STREAM (5)
#define UPDATE_ERROR_MD5 6 #define UPDATE_ERROR_MD5 (6)
#define UPDATE_ERROR_FLASH_CONFIG (7)
#define U_FLASH 0 #define U_FLASH 0
#define U_SPIFFS 100 #define U_SPIFFS 100