Merge branch 'feature/recovery_bootloader_support_v6.0' into 'release/v6.0'

feat(bootloader): Support recovery bootloader for ESP32P4 (v6.0)

See merge request espressif/esp-idf!48468
This commit is contained in:
Mahavir Jain
2026-05-15 09:52:49 +05:30
22 changed files with 117 additions and 75 deletions
@@ -90,3 +90,7 @@ config ESP_ROM_HAS_OUTPUT_PUTC_FUNC
config ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY
bool
default y
config ESP_ROM_BOOTLOADER_OFFSET_FLASH
hex
default 0x2000
@@ -28,3 +28,4 @@
#define ESP_ROM_CLIC_INT_TYPE_PATCH (1) // ROM api esprv_intc_int_set_type configuring edge type interrupt (old revisions)
#define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart)
#define ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY (1) // ROM mem/str functions are not optimized well for misaligned memory access.
#define ESP_ROM_BOOTLOADER_OFFSET_FLASH (0x2000) // Bootloader offset in flash determined by the ROM bootloader
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -508,6 +508,30 @@ void intr_matrix_set(int cpu_no, uint32_t model_num, uint32_t intr_num);
#define ETS_MEM_BAR() asm volatile ( "" : : : "memory" )
/**
* @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 ESP_ROM_BOOTLOADER_OFFSET_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