From 5a2658edb40108888eafe43d130280aafd5770fa Mon Sep 17 00:00:00 2001 From: gaoxu Date: Wed, 5 Aug 2026 14:43:24 +0800 Subject: [PATCH] fix(rng): fix esp_random failed beacuse do not enable RNG clock --- components/hal/esp32s31/include/hal/rng_ll.h | 4 ++-- components/soc/esp32s31/include/soc/Kconfig.soc_caps.in | 4 ++++ components/soc/esp32s31/include/soc/soc_caps.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/hal/esp32s31/include/hal/rng_ll.h b/components/hal/esp32s31/include/hal/rng_ll.h index 2d87f796eb2..5d4513b97ac 100644 --- a/components/hal/esp32s31/include/hal/rng_ll.h +++ b/components/hal/esp32s31/include/hal/rng_ll.h @@ -77,8 +77,8 @@ static inline void rng_ll_enable_noise_crc(bool enable) static inline void rng_ll_enable(void) { rng_ll_enable_bus_clock(true); - rng_ll_reset(); rng_ll_enable_clock(true); + rng_ll_reset(); rng_ll_enable_sample(true); rng_ll_enable_noise_crc(true); } @@ -90,8 +90,8 @@ static inline void rng_ll_enable(void) */ static inline void rng_ll_disable(void) { - rng_ll_enable_sample(false); rng_ll_enable_noise_crc(false); + rng_ll_enable_sample(false); rng_ll_enable_clock(false); rng_ll_enable_bus_clock(false); } diff --git a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in index 3a0b8d5b8b7..293a375f073 100644 --- a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in @@ -1363,6 +1363,10 @@ config SOC_MODEM_CLOCK_WIFI_BB_80X1_AS_APB bool default y +config SOC_RNG_CLOCK_IS_INDEPENDENT + bool + default y + config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION bool default y diff --git a/components/soc/esp32s31/include/soc/soc_caps.h b/components/soc/esp32s31/include/soc/soc_caps.h index a2496e6aa19..5343e5092a6 100644 --- a/components/soc/esp32s31/include/soc/soc_caps.h +++ b/components/soc/esp32s31/include/soc/soc_caps.h @@ -509,6 +509,7 @@ #define SOC_MODEM_APB_CLOCK_IS_INDEPENDENT (1) #define SOC_MODEM_CLOCK_SOC_PLL_SOURCE_CG_SUPPORTED (1) #define SOC_MODEM_CLOCK_WIFI_BB_80X1_AS_APB (1) +#define SOC_RNG_CLOCK_IS_INDEPENDENT (1) #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1)