feat(firmware): preserve mini-program BLE recovery

This commit is contained in:
justado committed 2026-08-29 10:36:43 +08:00
1 parent a4cbb02e73
commit 50fd39c144
28 files changed
+441 -23

No files matched your search

@@ -0,0 +1,5 @@
idf_component_register(
SRCS "recovery_boot_hook.c"
PRIV_REQUIRES bootloader_support
PRIV_INCLUDE_DIRS "$ENV{IDF_PATH}/components/bootloader_support/private_include"
)
@@ -0,0 +1,31 @@
// Bootloader hook shared by every AI Passport community firmware derivative.
// Holding the UP-key ADC GPIO low for five seconds boots the factory-installed
// permanent Recovery image. This project never owns or writes that image.
#include "bootloader_common.h"
#include "bootloader_config.h"
#include "bootloader_utility.h"
#include "esp_log.h"
#define RECOVERY_BUTTON_GPIO 0
#define RECOVERY_HOLD_SECONDS 5
#define RECOVERY_OFFSET 0x700000
#define RECOVERY_SIZE 0x100000
void bootloader_hooks_include(void)
{
}
void bootloader_after_init(void)
{
if (bootloader_common_check_long_hold_gpio(
RECOVERY_BUTTON_GPIO, RECOVERY_HOLD_SECONDS) != GPIO_LONG_HOLD) {
return;
}
ESP_LOGI("recovery_boot", "UP held: booting permanent recovery at 0x%x",
RECOVERY_OFFSET);
bootloader_state_t state = { 0 };
state.factory.offset = RECOVERY_OFFSET;
state.factory.size = RECOVERY_SIZE;
bootloader_utility_load_boot_image(&state, FACTORY_INDEX);
}