diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 10c72be32d..3788e97bc1 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -769,16 +769,4 @@ menu "ESP32-specific" This is possible due to handling of exceptions `LoadStoreError (3)` and `LoadStoreAlignmentError (9)` Each unaligned read/write access will incur a penalty of maximum of 167 CPU cycles. - config ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP - bool "Enable RTC fast memory for dynamic allocations" - default y - depends on FREERTOS_UNICORE - help - This config option allows to add RTC fast memory region to system heap with capability - similar to that of DRAM region but without DMA. This memory will be consumed first per - heap initialization order by early startup services and scheduler related code. Speed - wise RTC fast memory operates on APB clock and hence does not have much performance impact. - RTC fast memory is accessible to PRO cpu only and hence this is allowed for single core - configuration only for ESP32. - endmenu # ESP32-Specific diff --git a/components/esp32c3/Kconfig b/components/esp32c3/Kconfig index 617c158bfa..e72f54ec2c 100644 --- a/components/esp32c3/Kconfig +++ b/components/esp32c3/Kconfig @@ -206,14 +206,4 @@ menu "ESP32C3-Specific" If enabled, this disables the linking of binary libraries in the application build. Note that after enabling this Wi-Fi/Bluetooth will not work. - config ESP32C3_ALLOW_RTC_FAST_MEM_AS_HEAP - bool "Enable RTC fast memory for dynamic allocations" - depends on !ESP32C3_MEMPROT_FEATURE - default y - help - This config option allows to add RTC fast memory region to system heap with capability - similar to that of DRAM region but without DMA. This memory will be consumed first per - heap initialization order by early startup services and scheduler related code. Speed - wise RTC fast memory operates on APB clock and hence does not have much performance impact. - endmenu # ESP32C3-Specific diff --git a/components/esp32s2/Kconfig b/components/esp32s2/Kconfig index 89e28c7011..1928ac5498 100644 --- a/components/esp32s2/Kconfig +++ b/components/esp32s2/Kconfig @@ -512,13 +512,4 @@ menu "ESP32S2-specific" help RAM size dedicated for static variables (.data & .bss sections). - config ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP - bool "Enable RTC fast memory for dynamic allocations" - default y - help - This config option allows to add RTC fast memory region to system heap with capability - similar to that of DRAM region but without DMA. This memory will be consumed first per - heap initialization order by early startup services and scheduler related code. Speed - wise RTC fast memory operates on APB clock and hence does not have much performance impact. - endmenu # ESP32S2-Specific diff --git a/components/esp32s3/Kconfig b/components/esp32s3/Kconfig index 3fb8177030..a083bd6a57 100644 --- a/components/esp32s3/Kconfig +++ b/components/esp32s3/Kconfig @@ -515,14 +515,4 @@ menu "ESP32S3-Specific" help RAM size dedicated for static variables (.data & .bss sections). - config ESP32S3_ALLOW_RTC_FAST_MEM_AS_HEAP - bool "Enable RTC fast memory for dynamic allocations" - depends on !ESP32S3_MEMPROT_FEATURE - default y - help - This config option allows to add RTC fast memory region to system heap with capability - similar to that of DRAM region but without DMA. This memory will be consumed first per - heap initialization order by early startup services and scheduler related code. Speed - wise RTC fast memory operates on APB clock and hence does not have much performance impact. - endmenu # ESP32S3-Specific diff --git a/components/esp_common/sdkconfig.rename b/components/esp_common/sdkconfig.rename index 169f49a057..9a550688e1 100644 --- a/components/esp_common/sdkconfig.rename +++ b/components/esp_common/sdkconfig.rename @@ -27,3 +27,5 @@ CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIME CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 CONFIG_ESP32_DEBUG_STUBS_ENABLE CONFIG_ESP_DEBUG_STUBS_ENABLE +CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP +CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index 4d8f572d0c..e900799548 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -62,4 +62,21 @@ menu "ESP System Settings" To accurately determine if the crystal has started, set a larger "Number of cycles for RTC_SLOW_CLK calibration" (about 3000). + config ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK + bool + default y if IDF_TARGET_ESP32 && FREERTOS_UNICORE + default y if IDF_TARGET_ESP32S2 + default y if IDF_TARGET_ESP32C3 + default y if IDF_TARGET_ESP32S3 + + config ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP + bool "Enable RTC fast memory for dynamic allocations" + default y + depends on ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK + help + This config option allows to add RTC fast memory region to system heap with capability + similar to that of DRAM region but without DMA. This memory will be consumed first per + heap initialization order by early startup services and scheduler related code. Speed + wise RTC fast memory operates on APB clock and hence does not have much performance impact. + endmenu # ESP System Settings diff --git a/components/esp_system/sleep_modes.c b/components/esp_system/sleep_modes.c index b1997c0461..3ce36bb2de 100644 --- a/components/esp_system/sleep_modes.c +++ b/components/esp_system/sleep_modes.c @@ -275,10 +275,10 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) // For deep sleep, wait for the contents of UART FIFO to be sent. bool deep_sleep = pd_flags & RTC_SLEEP_PD_DIG; -#if !CONFIG_FREERTOS_UNICORE && ESP32S3_ALLOW_RTC_FAST_MEM_AS_HEAP +#if !CONFIG_FREERTOS_UNICORE && CONFIG_IDF_TARGET_ESP32S3 && CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP /* Currently only safe to use deep sleep wake stub & RTC memory as heap in single core mode. - For ESP32-S3, either disable ESP32S3_ALLOW_RTC_FAST_MEM_AS_HEAP in config or find a way to set the + For ESP32-S3, either disable ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP in config or find a way to set the deep sleep wake stub to NULL. */ assert(!deep_sleep || esp_get_deep_sleep_wake_stub() == NULL); @@ -360,7 +360,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) */ portENTER_CRITICAL(&spinlock_rtc_deep_sleep); -#if !CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP && !CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP && !CONFIG_ESP32S3_ALLOW_RTC_FAST_MEM_AS_HEAP +#if !CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP /* If not possible stack is in RTC FAST memory, use the ROM function to calculate the CRC and save ~140 bytes IRAM */ set_rtc_memory_crc(); result = call_rtc_sleep_start(reject_triggers); @@ -869,7 +869,7 @@ static uint32_t get_power_down_flags(void) } #endif -#if !CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP && !CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP && !CONFIG_ESP32S3_ALLOW_RTC_FAST_MEM_AS_HEAP +#if !CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP /* RTC_FAST_MEM is needed for deep sleep stub. If RTC_FAST_MEM is Auto, keep it powered on, so that deep sleep stub can run. In the new chip revision, deep sleep stub will be optional, and this can be changed. */ diff --git a/components/esp_system/test/test_sleep.c b/components/esp_system/test/test_sleep.c index 9c3e8d9ad2..dec80fca44 100644 --- a/components/esp_system/test/test_sleep.c +++ b/components/esp_system/test/test_sleep.c @@ -289,8 +289,7 @@ TEST_CASE_MULTIPLE_STAGES("can set sleep wake stub", "[deepsleep][reset=DEEPSLEE check_wake_stub); -#if CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP || CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP \ - || CONFIG_ESP32S3_ALLOW_RTC_FAST_MEM_AS_HEAP +#if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP #if CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION /* Version of prepare_wake_stub() that sets up the deep sleep call while running @@ -348,7 +347,7 @@ TEST_CASE_MULTIPLE_STAGES("can set sleep wake stub from stack in RTC RAM", "[dee check_wake_stub); #endif // CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION -#endif // CONFIG_xyz_ALLOW_RTC_FAST_MEM_AS_HEAP +#endif // CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP TEST_CASE("wake up using ext0 (13 high)", "[deepsleep][ignore]") { diff --git a/components/soc/esp32/soc_memory_layout.c b/components/soc/esp32/soc_memory_layout.c index d6303161bd..51983ce409 100644 --- a/components/soc/esp32/soc_memory_layout.c +++ b/components/soc/esp32/soc_memory_layout.c @@ -81,7 +81,7 @@ Because of requirements in the coalescing code which merges adjacent regions, th from low to high start address. */ const soc_memory_region_t soc_memory_regions[] = { -#ifdef CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP +#ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP { SOC_RTC_DRAM_LOW, 0x2000, 16, 0}, //RTC Fast Memory #endif #ifdef CONFIG_SPIRAM @@ -190,7 +190,7 @@ SOC_RESERVE_MEMORY_REGION((intptr_t)&_data_start, (intptr_t)&_heap_start, dram_d SOC_RESERVE_MEMORY_REGION((intptr_t)&_iram_start, (intptr_t)&_iram_end, iram_code); // RTC Fast RAM region -#ifdef CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP +#ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP #ifdef CONFIG_ESP32_RTCDATA_IN_FAST_MEM SOC_RESERVE_MEMORY_REGION(SOC_RTC_DRAM_LOW, (intptr_t)&_rtc_noinit_end, rtcram_data); #else diff --git a/components/soc/esp32c3/soc_memory_layout.c b/components/soc/esp32c3/soc_memory_layout.c index b28d294d06..3078d74003 100644 --- a/components/soc/esp32c3/soc_memory_layout.c +++ b/components/soc/esp32c3/soc_memory_layout.c @@ -64,7 +64,7 @@ const soc_memory_region_t soc_memory_regions[] = { { 0x3FC80000, 0x20000, SOC_MEMORY_TYPE_DEFAULT, 0x40380000}, //Block 4, can be remapped to ROM, can be used as trace memory { 0x3FCA0000, 0x20000, SOC_MEMORY_TYPE_DEFAULT, 0x403A0000}, //Block 5, can be remapped to ROM, can be used as trace memory { 0x3FCC0000, 0x20000, 1, 0x403C0000}, //Block 9, can be used as trace memory -#ifdef CONFIG_ESP32C3_ALLOW_RTC_FAST_MEM_AS_HEAP +#ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP { 0x50000000, 0x2000, 4, 0}, //Fast RTC memory #endif }; diff --git a/components/soc/esp32s2/soc_memory_layout.c b/components/soc/esp32s2/soc_memory_layout.c index 3b3b1e7565..a3c4f97844 100644 --- a/components/soc/esp32s2/soc_memory_layout.c +++ b/components/soc/esp32s2/soc_memory_layout.c @@ -70,7 +70,7 @@ Because of requirements in the coalescing code which merges adjacent regions, th from low to high start address. */ const soc_memory_region_t soc_memory_regions[] = { -#ifdef CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP +#ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP { SOC_RTC_DRAM_LOW, 0x2000, 5, 0}, //RTC Fast Memory #endif #ifdef CONFIG_SPIRAM @@ -149,7 +149,7 @@ SOC_RESERVE_MEMORY_REGION(0x3fffc000 - CONFIG_ESP32S2_TRACEMEM_RESERVE_DRAM, 0x3 #endif // RTC Fast RAM region -#ifdef CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP +#ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP #ifdef CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM SOC_RESERVE_MEMORY_REGION(SOC_RTC_DRAM_LOW, (intptr_t)&_rtc_noinit_end, rtcram_data); #else diff --git a/components/soc/include/soc/soc_memory_layout.h b/components/soc/include/soc/soc_memory_layout.h index 9620237a7f..b967006c95 100644 --- a/components/soc/include/soc/soc_memory_layout.h +++ b/components/soc/include/soc/soc_memory_layout.h @@ -177,7 +177,7 @@ inline static bool IRAM_ATTR esp_ptr_byte_accessible(const void *p) intptr_t ip = (intptr_t) p; bool r; r = (ip >= SOC_BYTE_ACCESSIBLE_LOW && ip < SOC_BYTE_ACCESSIBLE_HIGH); -#if CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP +#if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP /* For ESP32 case, RTC fast memory is accessible to PRO cpu only and hence * for single core configuration (where it gets added to system heap) following * additional check is required */ @@ -197,7 +197,7 @@ inline static bool IRAM_ATTR esp_ptr_internal(const void *p) { bool r; r = ((intptr_t)p >= SOC_MEM_INTERNAL_LOW && (intptr_t)p < SOC_MEM_INTERNAL_HIGH); r |= ((intptr_t)p >= SOC_RTC_DATA_LOW && (intptr_t)p < SOC_RTC_DATA_HIGH); -#if CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP +#if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP /* For ESP32 case, RTC fast memory is accessible to PRO cpu only and hence * for single core configuration (where it gets added to system heap) following * additional check is required */