From 4d094ecccae4f5e52469357c238a40b8322c9a56 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Sun, 16 Feb 2020 17:46:50 +0500 Subject: [PATCH] esp_system: move brownout init due to dependency issue --- components/esp_system/port/cpu_start.c | 1 - components/esp_system/startup.c | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index 1efa5a677..9c50c0e84 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -28,7 +28,6 @@ #if CONFIG_IDF_TARGET_ESP32 #include "esp32/cache_err_int.h" -#include "esp32/brownout.h" #include "esp32/rom/cache.h" #include "esp32/rom/rtc.h" #include "esp32/rom/uart.h" diff --git a/components/esp_system/startup.c b/components/esp_system/startup.c index 0d7bed96c..f9bebeb48 100644 --- a/components/esp_system/startup.c +++ b/components/esp_system/startup.c @@ -54,9 +54,11 @@ #if CONFIG_IDF_TARGET_ESP32 #include "esp32/rom/uart.h" #include "esp32/spiram.h" +#include "esp32/brownout.h" #elif CONFIG_IDF_TARGET_ESP32S2 #include "esp32s2/rom/uart.h" #include "esp32s2/spiram.h" +#include "esp32s2/brownout.h" #endif /***********************************************/ @@ -181,6 +183,12 @@ static void IRAM_ATTR do_core_init(void) #endif } +#if CONFIG_ESP32_BROWNOUT_DET || CONFIG_ESP32S2_BROWNOUT_DET + // [refactor-todo] leads to call chain rtc_is_register (driver) -> esp_intr_alloc (esp32/esp32s2) -> + // malloc (newlib) -> heap_caps_malloc (heap), so heap must be at least initialized + esp_brownout_init(); +#endif + // Now we have startup stack RAM available for heap, enable any DMA pool memory #if CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL if (g_spiram_ok) {