From 0f555b2a1dfc8a97264f87a8f25e85a14ae465e2 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 1 Aug 2022 10:36:19 +0800 Subject: [PATCH] system: fix brownout ISR triggering assert on single-core configs. ISR handler was incorrectly calling stall other cpu even on single core systems Closes https://github.com/espressif/esp-idf/issues/9456 --- components/esp_system/port/brownout.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/esp_system/port/brownout.c b/components/esp_system/port/brownout.c index 084344f074..c700f79d7d 100644 --- a/components/esp_system/port/brownout.c +++ b/components/esp_system/port/brownout.c @@ -41,8 +41,14 @@ IRAM_ATTR static void rtc_brownout_isr_handler(void *arg) * cleared manually. */ brownout_hal_intr_clear(); + // Stop the other core. - esp_cpu_stall(!esp_cpu_get_core_id()); +#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE + const uint32_t core_id = esp_cpu_get_core_id(); + const uint32_t other_core_id = (core_id == 0) ? 1 : 0; + esp_cpu_stall(other_core_id); +#endif + esp_reset_reason_set_hint(ESP_RST_BROWNOUT); #if CONFIG_SPI_FLASH_BROWNOUT_RESET if (spi_flash_brownout_need_reset()) {