diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index 2a93d96d7..e01eca0bc 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -86,7 +86,7 @@ bool UpdaterClass::begin(size_t size, int command) { //size of the update rounded to a sector uint32_t roundedSize = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); //address where we will start writing the update - updateStartAddress = updateEndAddress - roundedSize; + updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0; #ifdef DEBUG_UPDATER DEBUG_UPDATER.printf("[begin] roundedSize: 0x%08X (%d)\n", roundedSize, roundedSize); @@ -390,4 +390,4 @@ void UpdaterClass::printError(Print &out){ } } -UpdaterClass Update; \ No newline at end of file +UpdaterClass Update;