diff --git a/components/heap/CMakeLists.txt b/components/heap/CMakeLists.txt index 0a77108f66..234b776262 100644 --- a/components/heap/CMakeLists.txt +++ b/components/heap/CMakeLists.txt @@ -22,7 +22,7 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS include LDFRAGMENTS linker.lf - PRIV_REQUIRES soc) + PRIV_REQUIRES soc spi_flash) if(CONFIG_HEAP_TRACING) set(WRAP_FUNCTIONS diff --git a/components/heap/heap_caps.c b/components/heap/heap_caps.c index a86d004621..f6d3e871ed 100644 --- a/components/heap/heap_caps.c +++ b/components/heap/heap_caps.c @@ -22,7 +22,7 @@ #include "esp_log.h" #include "heap_private.h" #include "esp_system.h" - +#include "esp_private/cache_utils.h" // forward declaration IRAM_ATTR static void *heap_caps_realloc_base( void *ptr, size_t size, uint32_t caps); @@ -61,10 +61,16 @@ IRAM_ATTR static void *dram_alloc_to_iram_addr(void *addr, size_t len) } -static void heap_caps_alloc_failed(size_t requested_size, uint32_t caps, const char *function_name) +IRAM_ATTR static void heap_caps_alloc_failed(size_t requested_size, uint32_t caps, const char *function_name) { + static const DRAM_ATTR char *default_func_name = ""; if (alloc_failed_callback) { - alloc_failed_callback(requested_size, caps, function_name); + if (!spi_flash_cache_enabled() && !esp_ptr_internal(function_name)) { + alloc_failed_callback(requested_size, caps, default_func_name); + } + else { + alloc_failed_callback(requested_size, caps, function_name); + } } #ifdef CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS diff --git a/components/heap/heap_private.h b/components/heap/heap_private.h index 345ae032c8..bba9a86074 100644 --- a/components/heap/heap_private.h +++ b/components/heap/heap_private.h @@ -51,7 +51,7 @@ extern SLIST_HEAD(registered_heap_ll, heap_t_) registered_heaps; bool heap_caps_match(const heap_t *heap, uint32_t caps); /* return all possible capabilities (across all priorities) for a given heap */ -inline static uint32_t get_all_caps(const heap_t *heap) +inline static __attribute__((always_inline)) uint32_t get_all_caps(const heap_t *heap) { if (heap->heap == NULL) { return 0; diff --git a/components/heap/test/CMakeLists.txt b/components/heap/test/CMakeLists.txt index 6da69a0cbc..3496205c22 100644 --- a/components/heap/test/CMakeLists.txt +++ b/components/heap/test/CMakeLists.txt @@ -1,3 +1,17 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." PRIV_REQUIRES cmock test_utils heap) + +if(CONFIG_COMPILER_DUMP_RTL_FILES) + idf_build_get_property(elf_file_name EXECUTABLE GENERATOR_EXPRESSION) + add_custom_target(check_test_app_sections ALL + COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py + --rtl-dir ${CMAKE_BINARY_DIR}/esp-idf/heap/ + --elf-file ${CMAKE_BINARY_DIR}/${elf_file_name} + find-refs + --from-sections=.iram0.text + --to-sections=.flash.text,.flash.rodata + --exit-code + DEPENDS ${elf_file_name} + ) +endif() diff --git a/tools/unit-test-app/sdkconfig.defaults b/tools/unit-test-app/sdkconfig.defaults index 0a8e278166..e5b730ff03 100644 --- a/tools/unit-test-app/sdkconfig.defaults +++ b/tools/unit-test-app/sdkconfig.defaults @@ -26,3 +26,4 @@ CONFIG_SPIRAM_BANKSWITCH_ENABLE=n CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL=y CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n +CONFIG_COMPILER_DUMP_RTL_FILES=y