From f73cfa5deff1f384f5f5b8f37d494f9890b50bbb Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Mon, 27 Oct 2025 18:44:11 +0530 Subject: [PATCH] fix(hal): Force HUK power up when configuring HUK for ESP32-C5 --- components/hal/esp32c5/include/hal/huk_ll.h | 8 ++++++++ components/hal/esp32p4/include/hal/huk_ll.h | 7 ++++++- components/hal/huk_hal.c | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/hal/esp32c5/include/hal/huk_ll.h b/components/hal/esp32c5/include/hal/huk_ll.h index fb6e4e69f4..d66eed2e41 100644 --- a/components/hal/esp32c5/include/hal/huk_ll.h +++ b/components/hal/esp32c5/include/hal/huk_ll.h @@ -29,6 +29,14 @@ extern "C" { #endif +static inline void huk_ll_power_up(void) +{ + /* huk force_pd MUST be cleared!!! */ + REG_CLR_BIT(LP_AON_MEM_CTRL_REG, LP_AON_HUK_MEM_FORCE_PD); + /* huk force_pu MUST be set!!! */ + REG_SET_BIT(LP_AON_MEM_CTRL_REG, LP_AON_HUK_MEM_FORCE_PU); +} + /* @brief Configure the HUK mode */ static inline void huk_ll_configure_mode(const esp_huk_mode_t huk_mode) { diff --git a/components/hal/esp32p4/include/hal/huk_ll.h b/components/hal/esp32p4/include/hal/huk_ll.h index 6b5a50a64f..dc62489050 100644 --- a/components/hal/esp32p4/include/hal/huk_ll.h +++ b/components/hal/esp32p4/include/hal/huk_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,6 +27,11 @@ extern "C" { #endif +static inline void huk_ll_power_up(void) +{ + +} + /* @brief Configure the HUK mode */ static inline void huk_ll_configure_mode(const esp_huk_mode_t huk_mode) { diff --git a/components/hal/huk_hal.c b/components/hal/huk_hal.c index a274219162..21f1a12959 100644 --- a/components/hal/huk_hal.c +++ b/components/hal/huk_hal.c @@ -30,6 +30,8 @@ static void inline huk_hal_wait_for_state(esp_huk_state_t state) esp_err_t huk_hal_configure(const esp_huk_mode_t huk_mode, uint8_t *huk_info_buf) { + huk_ll_power_up(); + if (esp_rom_km_huk_conf(huk_mode, huk_info_buf) != ETS_OK) { return ESP_FAIL; }