From 941eb4e61e511cadd0cbffc6b373a324afdb1592 Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Mon, 3 Jul 2023 16:04:05 +0530 Subject: [PATCH] feat: Made read_otadata() API public Updated the read_otadata() API name to bootloader_common_read_otadata() and made the API public. Closes https://github.com/espressif/esp-idf/issues/11603 --- .../include/bootloader_common.h | 15 ++++++++++++++- .../bootloader_support/src/bootloader_utility.c | 5 ++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/bootloader_support/include/bootloader_common.h b/components/bootloader_support/include/bootloader_common.h index b74acf560c..75d10ad482 100644 --- a/components/bootloader_support/include/bootloader_common.h +++ b/components/bootloader_support/include/bootloader_common.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -24,6 +24,19 @@ typedef enum { ESP_IMAGE_APPLICATION } esp_image_type; +/** + * @brief Read ota_info partition and fill array from two otadata structures. + * + * @param[in] ota_info It is a pointer to the OTA data partition. + * The "otadata" partition (Type = "data" and SubType = "ota") + * is defined in the CSV partition table. + * @param[out] two_otadata Pointer to array of OTA selection structure. + * @return - ESP_OK: On success + * - ESP_ERR_NOT_FOUND: Partition table does not have otadata partition + * - ESP_FAIL: On failure + */ +esp_err_t bootloader_common_read_otadata(const esp_partition_pos_t *ota_info, esp_ota_select_entry_t *two_otadata); + /** * @brief Calculate crc for the OTA data select. * diff --git a/components/bootloader_support/src/bootloader_utility.c b/components/bootloader_support/src/bootloader_utility.c index 715ef610a3..4ee0bf11fc 100644 --- a/components/bootloader_support/src/bootloader_utility.c +++ b/components/bootloader_support/src/bootloader_utility.c @@ -100,8 +100,7 @@ static void set_cache_and_start_app(uint32_t drom_addr, uint32_t irom_size, uint32_t entry_addr); -// Read ota_info partition and fill array from two otadata structures. -static esp_err_t read_otadata(const esp_partition_pos_t *ota_info, esp_ota_select_entry_t *two_otadata) +esp_err_t bootloader_common_read_otadata(const esp_partition_pos_t *ota_info, esp_ota_select_entry_t *two_otadata) { const esp_ota_select_entry_t *ota_select_map; if (ota_info->offset == 0) { @@ -361,7 +360,7 @@ int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs) return FACTORY_INDEX; } - if (read_otadata(&bs->ota_info, otadata) != ESP_OK) { + if (bootloader_common_read_otadata(&bs->ota_info, otadata) != ESP_OK) { return INVALID_INDEX; } ota_has_initial_contents = false;