diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index 37de5c301..3ea10a6d1 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -2,6 +2,7 @@ #include "Arduino.h" #include "eboot_command.h" #include "interrupts.h" +#include "esp8266_peri.h" //#define DEBUG_UPDATER Serial @@ -44,6 +45,20 @@ bool UpdaterClass::begin(size_t size, int command) { return false; } + /* Check boot mode; if boot mode is 1 (UART download mode), + we will not be able to reset into normal mode once update is done. + Fail early to avoid frustration. + https://github.com/esp8266/Arduino/issues/1017#issuecomment-200605576 + */ + int boot_mode = (GPI >> 16) & 0xf; + if (boot_mode == 1) { + _error = UPDATE_ERROR_BOOTSTRAP; +#ifdef DEBUG_UPDATER + printError(DEBUG_UPDATER); +#endif + return false; + } + #ifdef DEBUG_UPDATER if (command == U_SPIFFS) { DEBUG_UPDATER.println(F("[begin] Update SPIFFS.")); diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index 046ff1667..1f9454202 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -16,7 +16,7 @@ #define UPDATE_ERROR_FLASH_CONFIG (8) #define UPDATE_ERROR_NEW_FLASH_CONFIG (9) #define UPDATE_ERROR_MAGIC_BYTE (10) - +#define UPDATE_ERROR_BOOTSTRAP (11) #define U_FLASH 0 #define U_SPIFFS 100