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

Check if board partition table is OTA compatible #19

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 13 additions & 1 deletion src/Arduino_ESP32_OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ Arduino_ESP32_OTA::Error Arduino_ESP32_OTA::begin()

/* ... initialize CRC ... */
_crc32 = 0xFFFFFFFF;

if(!isCapable()) {
DEBUG_ERROR("%s: board is not capable to perform OTA", __FUNCTION__);
return Error::NoOtaStorage;
}

if(!Update.begin(UPDATE_SIZE_UNKNOWN)) {
DEBUG_ERROR("%s: failed to initialize flash update", __FUNCTION__);
Expand Down Expand Up @@ -195,7 +200,7 @@ int Arduino_ESP32_OTA::download(const char * ota_url)
return static_cast<int>(Error::HttpResponse);
}

/* Extract concent length from HTTP header. A typical entry looks like
/* Extract content length from HTTP header. A typical entry looks like
* "Content-Length: 123456"
*/
char const * content_length_ptr = strstr(http_header.c_str(), "Content-Length");
Expand Down Expand Up @@ -279,3 +284,10 @@ void Arduino_ESP32_OTA::reset()
{
ESP.restart();
}

bool Arduino_ESP32_OTA::isCapable()
{
const esp_partition_t * ota_0 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
const esp_partition_t * ota_1 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);
return ((ota_0 != nullptr) && (ota_1 != nullptr));
}
1 change: 1 addition & 0 deletions src/Arduino_ESP32_OTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Arduino_ESP32_OTA
void write_byte_to_flash(uint8_t data);
Arduino_ESP32_OTA::Error update();
void reset();
static bool isCapable();

private:

Expand Down