Skip to content

Commit

Permalink
add missing error codes for Update.begin()
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSDavidSoft authored Mar 17, 2024
1 parent 9db1d5a commit ef5c856
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.println(F("[begin] already running"));
#endif
_setError(UPDATE_ERROR_RUNNING_ALREADY);
return false;
}

Expand All @@ -86,7 +87,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
_setError(UPDATE_ERROR_BOOTSTRAP);
return false;
}

#ifdef DEBUG_UPDATER
if (command == U_FS) {
DEBUG_UPDATER.println(F("[begin] Update Filesystem."));
Expand Down Expand Up @@ -133,7 +134,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {

//make sure that the size of both sketches is less than the total space (updateEndAddress)
if(updateStartAddress < currentSketchSize) {
_setError(UPDATE_ERROR_SPACE);
_setError(UPDATE_ERROR_SPACE);
return false;
}
}
Expand Down Expand Up @@ -162,6 +163,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.println(F("[begin] Unknown update command."));
#endif
_setError(UPDATE_ERROR_UNKNOWN_COMMAND);
return false;
}

Expand Down Expand Up @@ -404,7 +406,7 @@ bool UpdaterClass::_writeBuffer(){
modifyFlashMode = true;
}
}

if (eraseResult) {
if(!_async) yield();
writeResult = ESP.flashWrite(_currentAddress, _buffer, _bufferLen);
Expand Down Expand Up @@ -488,7 +490,7 @@ bool UpdaterClass::_verifyEnd() {
uint8_t buf[4] __attribute__((aligned(4)));
if(!ESP.flashRead(_startAddress, (uint32_t *) &buf[0], 4)) {
_currentAddress = (_startAddress);
_setError(UPDATE_ERROR_READ);
_setError(UPDATE_ERROR_READ);
return false;
}

Expand All @@ -500,7 +502,7 @@ bool UpdaterClass::_verifyEnd() {
return true;
} else if (buf[0] != 0xE9) {
_currentAddress = (_startAddress);
_setError(UPDATE_ERROR_MAGIC_BYTE);
_setError(UPDATE_ERROR_MAGIC_BYTE);
return false;
}

Expand All @@ -512,7 +514,7 @@ bool UpdaterClass::_verifyEnd() {
// check if new bin fits to SPI flash
if(bin_flash_size > ESP.getFlashChipRealSize()) {
_currentAddress = (_startAddress);
_setError(UPDATE_ERROR_NEW_FLASH_CONFIG);
_setError(UPDATE_ERROR_NEW_FLASH_CONFIG);
return false;
}
#endif
Expand Down

0 comments on commit ef5c856

Please sign in to comment.