From 47ab3735c2e6ae0c1bba8d30f2bc8dbe43437b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neboj=C5=A1a=20Cvetkovi=C4=87?= Date: Thu, 18 Dec 2025 11:24:33 +0000 Subject: [PATCH 1/2] feat(app_update): esp_ota_set_boot_partition_without_validate() --- components/app_update/esp_ota_ops.c | 9 +++++++++ components/app_update/include/esp_ota_ops.h | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/components/app_update/esp_ota_ops.c b/components/app_update/esp_ota_ops.c index 0e9575be109..90c53d63a11 100644 --- a/components/app_update/esp_ota_ops.c +++ b/components/app_update/esp_ota_ops.c @@ -682,6 +682,15 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition) return ESP_ERR_OTA_VALIDATE_FAILED; } + return esp_ota_set_boot_partition_without_validate(partition); +} + +esp_err_t esp_ota_set_boot_partition_without_validate(const esp_partition_t* partition) +{ + if (partition == NULL) { + return ESP_ERR_INVALID_ARG; + } + // if set boot partition to factory bin ,just format ota info partition if (partition->type == ESP_PARTITION_TYPE_APP) { if (partition->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) { diff --git a/components/app_update/include/esp_ota_ops.h b/components/app_update/include/esp_ota_ops.h index 029a7db4734..fc358a4c39d 100644 --- a/components/app_update/include/esp_ota_ops.h +++ b/components/app_update/include/esp_ota_ops.h @@ -209,6 +209,8 @@ esp_err_t esp_ota_abort(esp_ota_handle_t handle); /** * @brief Configure OTA data for a new boot partition * + * Equivalent to esp_image_verify() followed by esp_ota_set_boot_partition_without_validate(). + * * @note If this function returns ESP_OK, calling esp_restart() will boot the newly configured app partition. * * @param partition Pointer to info for partition containing app image to boot. @@ -222,6 +224,21 @@ esp_err_t esp_ota_abort(esp_ota_handle_t handle); */ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition); +/** + * @brief Configure OTA data for a new boot partition without validating the image + * + * @note If this function returns ESP_OK, calling esp_restart() will boot the newly configured app partition. + * + * @param partition Pointer to info for partition containing app image to boot. + * + * @return + * - ESP_OK: OTA data updated, next reboot will use specified partition. + * - ESP_ERR_INVALID_ARG: partition argument was NULL or didn't point to a valid OTA partition of type "app". + * - ESP_ERR_NOT_FOUND: OTA data partition not found. + * - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash erase or write failed. + */ +esp_err_t esp_ota_set_boot_partition_without_validate(const esp_partition_t* partition); + /** * @brief Get partition info of currently configured boot app * From ab97927dabd011a4535e3ad271439d05529dbc7d Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Fri, 30 Jan 2026 14:32:31 +0530 Subject: [PATCH 2/2] feat(app_update): misc cleanup and rename API for clarity --- components/app_update/esp_ota_ops.c | 43 ++++++++++++--------- components/app_update/include/esp_ota_ops.h | 4 +- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/components/app_update/esp_ota_ops.c b/components/app_update/esp_ota_ops.c index 90c53d63a11..636b01d121f 100644 --- a/components/app_update/esp_ota_ops.c +++ b/components/app_update/esp_ota_ops.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -672,25 +672,8 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype) return rewrite_ota_seq(otadata, new_seq, next_otadata, otadata_partition); } -esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition) +static esp_err_t esp_ota_set_boot_partition_internal(const esp_partition_t* partition) { - if (partition == NULL) { - return ESP_ERR_INVALID_ARG; - } - - if (image_validate(partition, ESP_IMAGE_VERIFY) != ESP_OK) { - return ESP_ERR_OTA_VALIDATE_FAILED; - } - - return esp_ota_set_boot_partition_without_validate(partition); -} - -esp_err_t esp_ota_set_boot_partition_without_validate(const esp_partition_t* partition) -{ - if (partition == NULL) { - return ESP_ERR_INVALID_ARG; - } - // if set boot partition to factory bin ,just format ota info partition if (partition->type == ESP_PARTITION_TYPE_APP) { if (partition->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) { @@ -724,6 +707,28 @@ esp_err_t esp_ota_set_boot_partition_without_validate(const esp_partition_t* par } } +esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition) +{ + if (partition == NULL) { + return ESP_ERR_INVALID_ARG; + } + + if (image_validate(partition, ESP_IMAGE_VERIFY) != ESP_OK) { + return ESP_ERR_OTA_VALIDATE_FAILED; + } + + return esp_ota_set_boot_partition_internal(partition); +} + +esp_err_t esp_ota_set_boot_partition_skip_validate(const esp_partition_t *partition) +{ + if (partition == NULL) { + return ESP_ERR_INVALID_ARG; + } + + return esp_ota_set_boot_partition_internal(partition); +} + static const esp_partition_t *find_default_boot_partition(void) { // This logic matches the logic of bootloader get_selected_boot_partition() & load_boot_image(). diff --git a/components/app_update/include/esp_ota_ops.h b/components/app_update/include/esp_ota_ops.h index fc358a4c39d..b451465ec7b 100644 --- a/components/app_update/include/esp_ota_ops.h +++ b/components/app_update/include/esp_ota_ops.h @@ -209,7 +209,7 @@ esp_err_t esp_ota_abort(esp_ota_handle_t handle); /** * @brief Configure OTA data for a new boot partition * - * Equivalent to esp_image_verify() followed by esp_ota_set_boot_partition_without_validate(). + * Equivalent to esp_image_verify() followed by esp_ota_set_boot_partition_skip_validate(). * * @note If this function returns ESP_OK, calling esp_restart() will boot the newly configured app partition. * @@ -237,7 +237,7 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition); * - ESP_ERR_NOT_FOUND: OTA data partition not found. * - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash erase or write failed. */ -esp_err_t esp_ota_set_boot_partition_without_validate(const esp_partition_t* partition); +esp_err_t esp_ota_set_boot_partition_skip_validate(const esp_partition_t* partition); /** * @brief Get partition info of currently configured boot app