فهرست منبع

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 <shubham.kulkarni@espressif.com>
Hassan DRAGA 4 سال پیش
والد
کامیت
b2eb199502
1فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 3 2
      examples/system/ota/native_ota_example/main/native_ota_example.c

+ 3 - 2
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();
     }