feat(bootloader): Support recovery bootloader for ESP32P4/C61

This commit is contained in:
Konstantin Kondrashov
2026-05-13 10:28:58 +03:00
parent 7672d9c125
commit ce467787a9
17 changed files with 109 additions and 74 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -516,6 +516,30 @@ typedef enum {
CANCEL,
} STATUS;
/**
* @brief Returns the offset from which the bootloader image is used to load.
*
* The offset can point to either the PRIMARY or RECOVERY bootloader.
*
* @note The bootloader offset variable in ROM is stored in a memory that will be reclaimed by heap component.
* Read it before the heap is initialized, otherwise it may return an invalid value.
*
* @return The offset of the active bootloader.
*/
uint32_t ets_get_bootloader_offset(void);
/**
* @brief Sets the offset from which the bootloader image is used to load.
*
* The offset can point to either the PRIMARY or RECOVERY bootloader.
*
* @note The bootloader offset variable in ROM is stored in a memory that will be reclaimed by heap component.
* Setting it after the heap is initialized, may corrupt the heap memory.
*
* @param offset The offset value to set for the active bootloader.
*/
void ets_set_bootloader_offset(uint32_t offset);
/**
* @}
*/
+6
View File
@@ -109,11 +109,17 @@ void esp_rom_set_cpu_ticks_per_us(uint32_t ticks_per_us)
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
uint32_t esp_rom_get_bootloader_offset(void)
{
#if CONFIG_IDF_TARGET_ESP32P4 && CONFIG_ESP32P4_REV_MIN_FULL < 300
// For early revisions of ESP32-P4 does not recovery bootloader feature.
// Return the default bootloader offset.
return CONFIG_BOOTLOADER_OFFSET_IN_FLASH;
#else
static uint32_t offset_of_active_bootloader = UINT32_MAX;
if (offset_of_active_bootloader == UINT32_MAX) {
offset_of_active_bootloader = ets_get_bootloader_offset();
}
return offset_of_active_bootloader;
#endif
}
#endif // SOC_RECOVERY_BOOTLOADER_SUPPORTED