From 44b9e6e05572b3accff885422bf0c5311bb0e808 Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Wed, 10 Nov 2021 11:46:46 +0800 Subject: [PATCH] Fix crash caused by bluetooth high level interrupt --- components/esp_pm/Kconfig | 4 ++++ components/esp_pm/pm_impl.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index f10e888746..0f9c0bb218 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -113,4 +113,8 @@ menu "Power Management" If enabled, the I/D-cache tag memory will be retained in light sleep. Depending on the the cache configuration, if this option is enabled, it will consume up to 9 KB of internal RAM. + config PM_UPDATE_CCOMPARE_HLI_WORKAROUND + bool + default y if PM_ENABLE && BTDM_CTRL_HLI + endmenu # "Power Management" diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index 55c7a47ea0..94302e15e6 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -536,6 +536,10 @@ static void IRAM_ATTR do_switch(pm_mode_t new_mode) */ static void IRAM_ATTR update_ccompare(void) { +#if CONFIG_PM_UPDATE_CCOMPARE_HLI_WORKAROUND + /* disable level 4 and below */ + uint32_t irq_status = XTOS_SET_INTLEVEL(XCHAL_DEBUGLEVEL - 2); +#endif uint32_t ccount = cpu_hal_get_cycle_count(); uint32_t ccompare = XTHAL_GET_CCOMPARE(XT_TIMER_INDEX); if ((ccompare - CCOMPARE_MIN_CYCLES_IN_FUTURE) - ccount < UINT32_MAX / 2) { @@ -546,6 +550,9 @@ static void IRAM_ATTR update_ccompare(void) XTHAL_SET_CCOMPARE(XT_TIMER_INDEX, new_ccompare); } } +#if CONFIG_PM_UPDATE_CCOMPARE_HLI_WORKAROUND + XTOS_RESTORE_INTLEVEL(irq_status); +#endif } #endif // CONFIG_FREERTOS_SYSTICK_USES_CCOUNT