From b2eb199502a1dcdadf9d4558c4792117529e4a1a Mon Sep 17 00:00:00 2001 From: Hassan DRAGA Date: Fri, 26 Feb 2021 17:40:06 -0400 Subject: [PATCH] Update native_ota_example.c * assert(update_partition) should be before trying to use update_partition in ESP_LOGI(). * if we show detailed description about the error ESP_ERR_OTA_VALIDATE_FAILED, why show it again using esp_err_to_name() ? Merges https://github.com/espressif/esp-idf/pull/6623 Signed-off-by: Shubham Kulkarni --- .../system/ota/native_ota_example/main/native_ota_example.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/system/ota/native_ota_example/main/native_ota_example.c b/examples/system/ota/native_ota_example/main/native_ota_example.c index 0df3f5f105..5e1d0f51d2 100644 --- a/examples/system/ota/native_ota_example/main/native_ota_example.c +++ b/examples/system/ota/native_ota_example/main/native_ota_example.c @@ -132,9 +132,9 @@ static void ota_example_task(void *pvParameter) esp_http_client_fetch_headers(client); update_partition = esp_ota_get_next_update_partition(NULL); + assert(update_partition != NULL); ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%x", update_partition->subtype, update_partition->address); - assert(update_partition != NULL); int binary_file_length = 0; /*deal with all receive packet*/ @@ -234,8 +234,9 @@ static void ota_example_task(void *pvParameter) if (err != ESP_OK) { if (err == ESP_ERR_OTA_VALIDATE_FAILED) { ESP_LOGE(TAG, "Image validation failed, image is corrupted"); + } else { + ESP_LOGE(TAG, "esp_ota_end failed (%s)!", esp_err_to_name(err)); } - ESP_LOGE(TAG, "esp_ota_end failed (%s)!", esp_err_to_name(err)); http_cleanup(client); task_fatal_error(); }