diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index 5d39874fb..2c35597d4 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -298,6 +298,24 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) { } } +/** + * check the Flash settings from IDE against the Real flash size + * @param needsEquals (return only true it equals) + * @return ok or not + */ +bool EspClass::checkFlashConfig(bool needsEquals) { + if(needsEquals) { + if(getFlashChipRealSize() == getFlashChipSize()) { + return true; + } + } else { + if(getFlashChipRealSize() >= getFlashChipSize()) { + return true; + } + } + return false; +} + String EspClass::getResetInfo(void) { if(resetInfo.reason != 0) { char buff[200]; diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index 07e1c093b..4201ec47d 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -117,6 +117,8 @@ class EspClass { FlashMode_t getFlashChipMode(); uint32_t getFlashChipSizeByChipId(); + bool checkFlashConfig(bool needsEquals = false); + bool flashEraseSector(uint32_t sector); bool flashWrite(uint32_t offset, uint32_t *data, size_t size); bool flashRead(uint32_t offset, uint32_t *data, size_t size); diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index ee7fe0b0f..ec2411064 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -57,7 +57,7 @@ bool UpdaterClass::begin(size_t size, int command) { return false; } - if(ESP.getFlashChipRealSize() != ESP.getFlashChipSize()) { + if(ESP.checkFlashConfig(false)) { _error = UPDATE_ERROR_FLASH_CONFIG; #ifdef DEBUG_UPDATER printError(DEBUG_UPDATER);