mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
feat(app_update): OTA update bootloader, partition_table and other partitions
Passive app partition can be used as the staging partition where a new image is loaded. Then copy it to the final partition. Closes: https://github.com/espressif/esp-idf/issues/14195 Closes: https://github.com/espressif/esp-idf/issues/13824
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <esp_http_client.h>
|
||||
#include <bootloader_common.h>
|
||||
#include "esp_app_desc.h"
|
||||
#include "esp_bootloader_desc.h"
|
||||
#include <sdkconfig.h>
|
||||
|
||||
#include "esp_event.h"
|
||||
@@ -26,7 +27,7 @@ ESP_EVENT_DECLARE_BASE(ESP_HTTPS_OTA_EVENT);
|
||||
typedef enum {
|
||||
ESP_HTTPS_OTA_START, /*!< OTA started */
|
||||
ESP_HTTPS_OTA_CONNECTED, /*!< Connected to server */
|
||||
ESP_HTTPS_OTA_GET_IMG_DESC, /*!< Read app description from image header */
|
||||
ESP_HTTPS_OTA_GET_IMG_DESC, /*!< Read app/bootloader description from image header */
|
||||
ESP_HTTPS_OTA_VERIFY_CHIP_ID, /*!< Verify chip id of new image */
|
||||
ESP_HTTPS_OTA_DECRYPT_CB, /*!< Callback to decrypt function */
|
||||
ESP_HTTPS_OTA_WRITE_FLASH, /*!< Flash write operation */
|
||||
@@ -68,6 +69,11 @@ typedef struct {
|
||||
void *decrypt_user_ctx; /*!< User context for external decryption layer */
|
||||
uint16_t enc_img_header_size; /*!< Header size of pre-encrypted ota image header */
|
||||
#endif
|
||||
struct { /*!< Details of staging and final partitions for OTA update */
|
||||
const esp_partition_t *staging; /*!< New image will be downloaded in this staging partition. If NULL then a free app partition (passive app partition) is selected as the staging partition. */
|
||||
const esp_partition_t *final; /*!< Final destination partition. Its type/subtype will be used for verification. If set to NULL, staging partition shall be set as the final partition. */
|
||||
bool finalize_with_copy; /*!< Flag to copy the staging image to the final partition at the end of OTA update */
|
||||
} partition; /*!< Struct containing details about the staging and final partitions for OTA update. */
|
||||
} esp_https_ota_config_t;
|
||||
|
||||
#define ESP_ERR_HTTPS_OTA_BASE (0x9000)
|
||||
@@ -223,6 +229,23 @@ esp_err_t esp_https_ota_abort(esp_https_ota_handle_t https_ota_handle);
|
||||
*/
|
||||
esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, esp_app_desc_t *new_app_info);
|
||||
|
||||
/**
|
||||
* @brief Reads bootloader description from image header. The bootloader description provides information
|
||||
* like the "Bootloader version" of the image.
|
||||
*
|
||||
* @note This API can be called only after esp_https_ota_begin() and before esp_https_ota_perform().
|
||||
* Calling this API is not mandatory.
|
||||
*
|
||||
* @param[in] https_ota_handle pointer to esp_https_ota_handle_t structure
|
||||
* @param[out] new_img_info pointer to an allocated esp_bootloader_desc_t structure
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG: Invalid arguments
|
||||
* - ESP_ERR_INVALID_STATE: Invalid state to call this API. esp_https_ota_begin() not called yet.
|
||||
* - ESP_FAIL: Failed to read image descriptor
|
||||
* - ESP_OK: Successfully read image descriptor
|
||||
*/
|
||||
esp_err_t esp_https_ota_get_bootloader_img_desc(esp_https_ota_handle_t https_ota_handle, esp_bootloader_desc_t *new_img_info);
|
||||
|
||||
/**
|
||||
* @brief This function returns OTA image data read so far.
|
||||
|
Reference in New Issue
Block a user