From: Supreet Deshpande Date: Mon, 10 Dec 2018 11:46:38 +0000 (+0530) Subject: bugfix/ota_magic_byte_issue: Fixes OTA magic byte error X-Git-Tag: v3.2-beta3~57^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30e01847adeabb71b321727cdf91aea204575689;p=esp-idf bugfix/ota_magic_byte_issue: Fixes OTA magic byte error On enabling flash encryption, OTA fails with magic byte error in the second chunk if the http data is split into two or more chunks and first chunk is less than 16. --- diff --git a/components/app_update/esp_ota_ops.c b/components/app_update/esp_ota_ops.c index 6416b5d93f..74cf1a193b 100644 --- a/components/app_update/esp_ota_ops.c +++ b/components/app_update/esp_ota_ops.c @@ -145,8 +145,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size) if (it->handle == handle) { // must erase the partition before writing to it assert(it->erased_size > 0 && "must erase the partition before writing to it"); - - if(it->wrote_size == 0 && size > 0 && data_bytes[0] != 0xE9) { + if(it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != 0xE9) { ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]); return ESP_ERR_OTA_VALIDATE_FAILED; }