-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Fix HTTPUpdate flash size check and add SPIFFS size check #2161
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5668927
Fix error in PR #2048: if ::available() is called before ::connect() …
cf9175b
Fixed flash size check and added SPIFFS size check
572b013
Merge branch 'master' into bugfix/HTTPUpdate2
9e629e7
Rewriting ESP.getFreeSketchSpace(), moving code from HTTPUpdate.cpp
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,8 @@ String HTTPUpdate::getLastErrorString(void) | |
return "Verify Bin Header Failed"; | ||
case HTTP_UE_BIN_FOR_WRONG_FLASH: | ||
return "New Binary Does Not Fit Flash Size"; | ||
case HTTP_UE_NO_PARTITION: | ||
return "Partition Could Not be Found"; | ||
} | ||
|
||
return String(); | ||
|
@@ -229,14 +231,25 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren | |
if(len > 0) { | ||
bool startUpdate = true; | ||
if(spiffs) { | ||
// To do size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start); | ||
// To do if(len > (int) spiffsSize) { | ||
// To do log_e("spiffsSize to low (%d) needed: %d\n", spiffsSize, len); | ||
// To do startUpdate = false; | ||
// To do } | ||
const esp_partition_t* _partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL); | ||
if(!_partition){ | ||
_lastError = HTTP_UE_NO_PARTITION; | ||
return HTTP_UPDATE_FAILED; | ||
} | ||
|
||
if(len > _partition->size) { | ||
log_e("spiffsSize to low (%d) needed: %d\n", _partition->size, len); | ||
startUpdate = false; | ||
} | ||
} else { | ||
if(len > (int) ESP.getFreeSketchSpace()) { | ||
log_e("FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len); | ||
const esp_partition_t* _partition = esp_ota_get_next_update_partition(NULL); | ||
if(!_partition){ | ||
_lastError = HTTP_UE_NO_PARTITION; | ||
return HTTP_UPDATE_FAILED; | ||
} | ||
|
||
if(len > _partition->size) { | ||
log_e("FreeSketchSpace to low (%d) needed: %d\n", _partition->size, len); | ||
startUpdate = false; | ||
} | ||
} | ||
|
@@ -366,6 +379,10 @@ bool HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int command) | |
} | ||
} | ||
|
||
// To do: the SHA256 could be checked if the server sends it | ||
|
||
delay(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing... |
||
|
||
if(Update.writeStream(in) != size) { | ||
_lastError = Update.getError(); | ||
Update.printError(error); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this logic to Esp.cpp and replace the one in
ESP.getFreeSketchSpace
. What is currently there makes no sense for any use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to ESP.cpp, replacing getFreeSketchSpace() with new code, in HTTUpdate.cpp calling getFreeSketchSpace() again.