mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
fix(heap): MALLOC_CAP_EXEC does not allocate in RTC IRAM
This commit fixes the issue when trying to allocate memory with the MALLOC_CAP_EXEC in RTC memory. Prior to the fix, the heap allocator was returning an address in RTC DRAM. To fix this issue: - modified memory_layout.c of the concerned targets to fill the iram_address field in the rtc entry of the soc_memory_region array properly. - modified heap component related functions to return IRAM address when an allocation in RTC memory with MALLOC_CAP_EXEC is requested. Closes https://github.com/espressif/esp-idf/issues/14835
This commit is contained in:
@@ -28,7 +28,12 @@ extern "C" {
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static bool esp_dram_match_iram(void) {
|
||||
return (SOC_DRAM_LOW == SOC_IRAM_LOW && SOC_DRAM_HIGH == SOC_IRAM_HIGH);
|
||||
bool dram_match_iram = (SOC_DRAM_LOW == SOC_IRAM_LOW) &&
|
||||
(SOC_DRAM_HIGH == SOC_IRAM_HIGH);
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED
|
||||
dram_match_iram &= (SOC_RTC_IRAM_LOW == SOC_RTC_DRAM_LOW);
|
||||
#endif
|
||||
return dram_match_iram;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +102,7 @@ inline static bool esp_ptr_in_diram_iram(const void *p) {
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static bool esp_ptr_in_rtc_iram_fast(const void *p) {
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED && (SOC_RTC_IRAM_LOW != SOC_RTC_DRAM_LOW)
|
||||
return ((intptr_t)p >= SOC_RTC_IRAM_LOW && (intptr_t)p < SOC_RTC_IRAM_HIGH);
|
||||
#else
|
||||
return false;
|
||||
@@ -151,6 +156,21 @@ inline static void * esp_ptr_diram_dram_to_iram(const void *p) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert a RTC DRAM pointer to equivalent word address in RTC IRAM
|
||||
|
||||
- Address must be word aligned
|
||||
- Address must pass esp_ptr_in_rtc_dram_fast() test, or result will be invalid pointer
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static void * esp_ptr_rtc_dram_to_iram(const void *p) {
|
||||
intptr_t ptr = (intptr_t)p;
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED && (SOC_RTC_IRAM_LOW != SOC_RTC_DRAM_LOW)
|
||||
return (void *) ( SOC_RTC_IRAM_LOW + (ptr - SOC_RTC_DRAM_LOW) );
|
||||
#else
|
||||
return (void *) ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert a D/IRAM IRAM pointer to equivalent word address in DRAM
|
||||
|
||||
- Address must be word aligned
|
||||
|
Reference in New Issue
Block a user