Skip to content

Commit 9b0ad39

Browse files
committed
Updater: check boot mode before starting update
ref. #1017
1 parent 22c7d79 commit 9b0ad39

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

cores/esp8266/Updater.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "Arduino.h"
33
#include "eboot_command.h"
44
#include "interrupts.h"
5+
#include "esp8266_peri.h"
56

67
//#define DEBUG_UPDATER Serial
78

@@ -44,6 +45,20 @@ bool UpdaterClass::begin(size_t size, int command) {
4445
return false;
4546
}
4647

48+
/* Check boot mode; if boot mode is 1 (UART download mode),
49+
we will not be able to reset into normal mode once update is done.
50+
Fail early to avoid frustration.
51+
https://github.com/esp8266/Arduino/issues/1017#issuecomment-200605576
52+
*/
53+
int boot_mode = (GPI >> 16) & 0xf;
54+
if (boot_mode == 1) {
55+
_error = UPDATE_ERROR_BOOTSTRAP;
56+
#ifdef DEBUG_UPDATER
57+
printError(DEBUG_UPDATER);
58+
#endif
59+
return false;
60+
}
61+
4762
#ifdef DEBUG_UPDATER
4863
if (command == U_SPIFFS) {
4964
DEBUG_UPDATER.println(F("[begin] Update SPIFFS."));

cores/esp8266/Updater.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define UPDATE_ERROR_FLASH_CONFIG (8)
1717
#define UPDATE_ERROR_NEW_FLASH_CONFIG (9)
1818
#define UPDATE_ERROR_MAGIC_BYTE (10)
19-
19+
#define UPDATE_ERROR_BOOTSTRAP (11)
2020

2121
#define U_FLASH 0
2222
#define U_SPIFFS 100

0 commit comments

Comments
 (0)