From d0766f2a7f5be8fb396eaa2217624e8b5bcf9fe2 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Thu, 7 May 2026 20:58:55 +0800 Subject: [PATCH] fix(esp_hw_support): fix core1 branch predictor access ext mem after cache disabled by core0 --- components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c | 2 ++ components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c | 2 ++ components/esp_hw_support/lowpower/port/esp32s31/sleep_cpu.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c index 6b3749a890c..f8d82367065 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c @@ -479,6 +479,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable) #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU static IRAM_ATTR void smp_core_do_retention(void) { + esp_cpu_branch_prediction_disable(); uint8_t core_id = esp_cpu_get_core_id(); if (core_id == 0) { @@ -550,6 +551,7 @@ static IRAM_ATTR void smp_core_do_retention(void) ; } atomic_store(&s_smp_retention_state[core_id], SMP_IDLE); + esp_cpu_branch_prediction_enable(); } diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c index affb48d3472..577ad9a53a3 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c @@ -397,6 +397,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable) #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU static SPM_IRAM_ATTR void smp_core_do_retention(void) { + esp_cpu_branch_prediction_disable(); uint8_t core_id = esp_cpu_get_core_id(); if (core_id == 0) { @@ -465,6 +466,7 @@ static SPM_IRAM_ATTR void smp_core_do_retention(void) ; } atomic_store(&s_smp_retention_state[core_id], SMP_IDLE); + esp_cpu_branch_prediction_enable(); } diff --git a/components/esp_hw_support/lowpower/port/esp32s31/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32s31/sleep_cpu.c index 495465573cf..424239db2a2 100644 --- a/components/esp_hw_support/lowpower/port/esp32s31/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32s31/sleep_cpu.c @@ -420,6 +420,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable) #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU static IRAM_ATTR void smp_core_do_retention(void) { + esp_cpu_branch_prediction_disable(); uint8_t core_id = esp_cpu_get_core_id(); if (core_id == 0) { @@ -486,6 +487,7 @@ static IRAM_ATTR void smp_core_do_retention(void) ; } atomic_store(&s_smp_retention_state[core_id], SMP_IDLE); + esp_cpu_branch_prediction_enable(); }