main/updates.c

changeset 74
34da2d2b12d5
parent 53
20c14b06f255
child 78
e03d729aecb8
equal deleted inserted replaced
73:c18d2951e8d7 74:34da2d2b12d5
101 if (update_partition == NULL) { 101 if (update_partition == NULL) {
102 ESP_LOGE(TAG, "No update partition"); 102 ESP_LOGE(TAG, "No update partition");
103 esp_http_client_cleanup(client); 103 esp_http_client_cleanup(client);
104 goto updateerr; 104 goto updateerr;
105 } 105 }
106 ESP_LOGI(TAG, "Update to partition subtype %d at offset 0x%x", update_partition->subtype, update_partition->address); 106 ESP_LOGI(TAG, "Update to partition subtype %d at offset 0x%lu", update_partition->subtype, update_partition->address);
107 107
108 err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle); 108 err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle);
109 if (err != ESP_OK) { 109 if (err != ESP_OK) {
110 ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err)); 110 ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
111 http_cleanup(client); 111 http_cleanup(client);
124 http_cleanup(client); 124 http_cleanup(client);
125 goto updateerr;; 125 goto updateerr;;
126 } else if (data_read > 0) { 126 } else if (data_read > 0) {
127 if (image_header_was_checked == false) { 127 if (image_header_was_checked == false) {
128 esp_app_desc_t new_app_info; 128 esp_app_desc_t new_app_info;
129 if (data_read > sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t)) { 129 if (data_read > (sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t))) {
130 // check current version with downloading 130 // check current version with downloading
131 memcpy(&new_app_info, &ota_write_data[sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t)], sizeof(esp_app_desc_t)); 131 memcpy(&new_app_info, &ota_write_data[sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t)], sizeof(esp_app_desc_t));
132 132
133 esp_app_desc_t running_app_info; 133 esp_app_desc_t running_app_info;
134 if (esp_ota_get_partition_description(running, &running_app_info) == ESP_OK) { 134 if (esp_ota_get_partition_description(running, &running_app_info) == ESP_OK) {

mercurial