mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
esp_https_ota: change erase to incremental during flash write
This commit is contained in:
@@ -30,6 +30,7 @@ typedef esp_err_t(*http_client_init_cb_t)(esp_http_client_handle_t);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
const esp_http_client_config_t *http_config; /*!< ESP HTTP client configuration */
|
const esp_http_client_config_t *http_config; /*!< ESP HTTP client configuration */
|
||||||
http_client_init_cb_t http_client_init_cb; /*!< Callback after ESP HTTP client is initialised */
|
http_client_init_cb_t http_client_init_cb; /*!< Callback after ESP HTTP client is initialised */
|
||||||
|
bool bulk_flash_erase; /*!< Erase entire flash partition during initialization. By default flash partition is erased during write operation and in chunk of 4K sector size */
|
||||||
} esp_https_ota_config_t;
|
} esp_https_ota_config_t;
|
||||||
|
|
||||||
#define ESP_ERR_HTTPS_OTA_BASE (0x9000)
|
#define ESP_ERR_HTTPS_OTA_BASE (0x9000)
|
||||||
|
@@ -39,6 +39,7 @@ struct esp_https_ota_handle {
|
|||||||
size_t ota_upgrade_buf_size;
|
size_t ota_upgrade_buf_size;
|
||||||
int binary_file_len;
|
int binary_file_len;
|
||||||
esp_https_ota_state state;
|
esp_https_ota_state state;
|
||||||
|
bool bulk_flash_erase;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct esp_https_ota_handle esp_https_ota_t;
|
typedef struct esp_https_ota_handle esp_https_ota_t;
|
||||||
@@ -207,7 +208,7 @@ esp_err_t esp_https_ota_begin(esp_https_ota_config_t *ota_config, esp_https_ota_
|
|||||||
goto http_cleanup;
|
goto http_cleanup;
|
||||||
}
|
}
|
||||||
https_ota_handle->ota_upgrade_buf_size = alloc_size;
|
https_ota_handle->ota_upgrade_buf_size = alloc_size;
|
||||||
|
https_ota_handle->bulk_flash_erase = ota_config->bulk_flash_erase;
|
||||||
https_ota_handle->binary_file_len = 0;
|
https_ota_handle->binary_file_len = 0;
|
||||||
*handle = (esp_https_ota_handle_t)https_ota_handle;
|
*handle = (esp_https_ota_handle_t)https_ota_handle;
|
||||||
https_ota_handle->state = ESP_HTTPS_OTA_BEGIN;
|
https_ota_handle->state = ESP_HTTPS_OTA_BEGIN;
|
||||||
@@ -280,9 +281,10 @@ esp_err_t esp_https_ota_perform(esp_https_ota_handle_t https_ota_handle)
|
|||||||
|
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
int data_read;
|
int data_read;
|
||||||
|
const int erase_size = handle->bulk_flash_erase ? OTA_SIZE_UNKNOWN : OTA_WITH_SEQUENTIAL_WRITES;
|
||||||
switch (handle->state) {
|
switch (handle->state) {
|
||||||
case ESP_HTTPS_OTA_BEGIN:
|
case ESP_HTTPS_OTA_BEGIN:
|
||||||
err = esp_ota_begin(handle->update_partition, OTA_SIZE_UNKNOWN, &handle->update_handle);
|
err = esp_ota_begin(handle->update_partition, erase_size, &handle->update_handle);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
|
ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
|
||||||
return err;
|
return err;
|
||||||
|
@@ -183,7 +183,7 @@ static void ota_example_task(void *pvParameter)
|
|||||||
|
|
||||||
image_header_was_checked = true;
|
image_header_was_checked = true;
|
||||||
|
|
||||||
err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle);
|
err = esp_ota_begin(update_partition, OTA_WITH_SEQUENTIAL_WRITES, &update_handle);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
|
ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
|
||||||
http_cleanup(client);
|
http_cleanup(client);
|
||||||
|
Reference in New Issue
Block a user