Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing update error codes #9104

Merged
merged 4 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions cores/esp8266/Updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define UPDATE_ERROR_SIGN (12)
#define UPDATE_ERROR_NO_DATA (13)
#define UPDATE_ERROR_OOM (14)
#define UPDATE_ERROR_RUNNING_ALREADY (15)
#define UPDATE_ERROR_UNKNOWN_COMMAND (16)

#define U_FLASH 0
#define U_FS 100
Expand Down