From 0ab385ab888233762944fe44df9712e56f69c1cb Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 29 Apr 2026 14:56:13 +0800 Subject: [PATCH] fix(ulp): correct target LP memory reservation limits The configured maximum should match each target's fixed LP/RTC reservations so menuconfig does not advertise values that the linker cannot support. Keep the linker failure explicit about CONFIG_ULP_COPROC_RESERVE_MEM because application RTC sections still share the remaining LP/RTC RAM. --- components/esp_system/ld/ld.rtc.sections | 14 ++++++++++++-- components/ulp/Kconfig | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/components/esp_system/ld/ld.rtc.sections b/components/esp_system/ld/ld.rtc.sections index 26edbe9daac..23bb8181df6 100644 --- a/components/esp_system/ld/ld.rtc.sections +++ b/components/esp_system/ld/ld.rtc.sections @@ -2,6 +2,16 @@ #include "ld.common" #if CONFIG_SOC_RTC_MEM_SUPPORTED +#if CONFIG_ULP_COPROC_ENABLED +#define RTC_SLOW_SEGMENT_FIT_ERROR \ + "RTC_SLOW segment data does not fit. CONFIG_ULP_COPROC_RESERVE_MEM may be too large for the remaining LP/RTC RAM; lower it or shrink application .rtc.* usage." +#define RTC_FAST_SEGMENT_FIT_ERROR \ + "RTC_FAST segment data does not fit. CONFIG_ULP_COPROC_RESERVE_MEM may be too large for the remaining LP/RTC RAM; lower it or shrink application .rtc.* usage." +#else +#define RTC_SLOW_SEGMENT_FIT_ERROR "RTC_SLOW segment data does not fit." +#define RTC_FAST_SEGMENT_FIT_ERROR "RTC_FAST segment data does not fit." +#endif + /** * RTC fast memory holds RTC wake stub code, * including from any source file named rtc_wake_stub*.c @@ -155,9 +165,9 @@ ? (_rtc_force_fast_end - _rtc_fast_start) : (_rtc_noinit_end - _rtc_fast_start); ASSERT((_rtc_slow_length <= LENGTH(rtc_slow_seg)), - "RTC_SLOW segment data does not fit.") + RTC_SLOW_SEGMENT_FIT_ERROR) ASSERT((_rtc_fast_length <= LENGTH(rtc_data_seg)), - "RTC_FAST segment data does not fit.") + RTC_FAST_SEGMENT_FIT_ERROR) #if CONFIG_P4_REV3_MSPI_CRASH_AFTER_POWER_UP_WORKAROUND .rtc.p4_rev3_mspi_workaround : diff --git a/components/ulp/Kconfig b/components/ulp/Kconfig index 09e88a81699..f019da87680 100644 --- a/components/ulp/Kconfig +++ b/components/ulp/Kconfig @@ -35,11 +35,21 @@ menu "Ultra Low Power (ULP) Co-processor" default 4096 if !IDF_TARGET_ESP32 range 32 8176 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 range 32 16352 if IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32C6 + range 32 32744 if IDF_TARGET_ESP32S31 range 32 31088 if IDF_TARGET_ESP32P4 # Some memory are reserved for ROM/RTC reserved help Bytes of memory to reserve for ULP Co-processor firmware & data. Data is reserved at the beginning of RTC slow memory. + The target-specific maximum only accounts for fixed LP/RTC reservations + such as retained RTC data, LP ROM, and secure-boot digest storage. + On targets where the application RTC sections also live in LP/RTC RAM, + this reservation shares the same memory pool with .rtc.text, + RTC_DATA_ATTR, RTC_NOINIT_ATTR, RTC_SLOW_ATTR, and related sections. + Setting this value close to the maximum may therefore still leave too + little LP/RTC RAM for the rest of the application and cause link-time + errors. + menu "ULP RISC-V Settings" depends on ULP_COPROC_TYPE_RISCV