Skip to content

Commit

Permalink
OTA Updater better error codes on OOS
Browse files Browse the repository at this point in the history
Fixes #2785.  Thanks @donmsmall!
  • Loading branch information
earlephilhower committed Feb 4, 2025
1 parent b506c01 commit 8633653
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libraries/Updater/src/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,18 @@ bool UpdaterClass::begin(size_t size, int command) {
_md5 = MD5Builder();

if (command == U_FLASH) {
// Basic sanity, if it's larger than entire FS then it can't possibly succeed
if (&_FS_start + size > &_FS_end) {
_setError(UPDATE_ERROR_SPACE);
return false;
}
LittleFS.begin();
_fp = LittleFS.open("firmware.bin", "w+");
if (!_fp) {
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.println(F("[begin] unable to create file"));
#endif
_setError(UPDATE_ERROR_SPACE);
return false;
}
updateStartAddress = 0; // Not used
Expand Down Expand Up @@ -288,6 +294,7 @@ bool UpdaterClass::end(bool evenIfRemaining) {
bool UpdaterClass::_writeBuffer() {
if (_command == U_FLASH) {
if (_bufferLen != _fp.write(_buffer, _bufferLen)) {
_setError(UPDATE_ERROR_SPACE);
return false;
}
} else {
Expand Down

0 comments on commit 8633653

Please sign in to comment.