feat(bootloader): Bootloader OTA update with recovery bootloader feat

This commit is contained in:
Konstantin Kondrashov
2025-06-12 18:47:33 +08:00
committed by BOT
parent 1b7cb43842
commit 3a7c1a2e74
37 changed files with 1023 additions and 384 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -421,6 +421,30 @@ typedef enum {
} STATUS __attribute__((deprecated("Use ETS_STATUS instead")));
#endif
/**
* @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);
/**
* @}
*/
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -421,6 +421,30 @@ typedef enum {
} STATUS __attribute__((deprecated("Use ETS_STATUS instead")));
#endif
/**
* @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);
/**
* @}
*/
+14 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -7,9 +7,11 @@
#pragma once
#include "sdkconfig.h"
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#include <stdarg.h>
#include "soc/reset_reasons.h"
#include "soc/soc_caps.h"
#ifdef __cplusplus
extern "C" {
@@ -151,6 +153,17 @@ uint32_t esp_rom_get_cpu_ticks_per_us(void);
*/
void esp_rom_set_cpu_ticks_per_us(uint32_t ticks_per_us);
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED || __DOXYGEN__
/**
* @brief Returns the offset from which the bootloader image is used to load.
*
* The offset can point to either the PRIMARY or RECOVERY bootloader.
*
* @return The offset of the active bootloader.
*/
uint32_t esp_rom_get_bootloader_offset(void);
#endif // SOC_RECOVERY_BOOTLOADER_SUPPORTED
#ifdef __cplusplus
}
#endif
+12 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -103,3 +103,14 @@ void esp_rom_set_cpu_ticks_per_us(uint32_t ticks_per_us)
#endif
}
#endif // CONFIG_IDF_TARGET_ESP32
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
uint32_t esp_rom_get_bootloader_offset(void)
{
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 // SOC_RECOVERY_BOOTLOADER_SUPPORTED