heap: use ROM implementation for heap tlsf on esp32c2

This commit is contained in:
morris 2022-05-06 19:20:05 +08:00
parent 24f5fecef0
commit 068adfba70
10 changed files with 24 additions and 16 deletions

View File

@ -200,7 +200,7 @@ else() # Regular app build
rom_linker_script("newlib-nano")
endif()
if(CONFIG_HEAP_ROM_IMPL)
if(CONFIG_HEAP_TLSF_USE_ROM_IMPL)
rom_linker_script("heap")
endif()
endif()

View File

@ -34,3 +34,7 @@ config ESP_ROM_HAS_HAL_WDT
config ESP_ROM_HAS_HAL_SYSTIMER
bool
default y
config ESP_ROM_HAS_HEAP_TLSF
bool
default y

View File

@ -14,3 +14,4 @@
#define ESP_ROM_HAS_RVFPLIB (1) // ROM has the rvfplib
#define ESP_ROM_HAS_HAL_WDT (1) // ROM has the implementation of Watchdog HAL driver
#define ESP_ROM_HAS_HAL_SYSTIMER (1) // ROM has the implementation of Systimer HAL driver
#define ESP_ROM_HAS_HEAP_TLSF (1) // ROM has the implementation of the tlsf and multi-heap library

View File

@ -3,7 +3,7 @@ set(srcs
"heap_caps_init.c"
"multi_heap.c")
if(NOT CONFIG_HEAP_ROM_IMPL)
if(NOT CONFIG_HEAP_TLSF_USE_ROM_IMPL)
list(APPEND srcs "heap_tlsf.c")
endif()

View File

@ -71,14 +71,9 @@ menu "Heap memory debugging"
help
When enabled, if a memory allocation operation fails it will cause a system abort.
config HEAP_HAS_ROM_IMPL
bool
depends on IDF_TARGET_ESP32C2
default y if IDF_TARGET_ESP32C2
config HEAP_ROM_IMPL
bool "Use heap implementation in ROM"
depends on HEAP_HAS_ROM_IMPL
config HEAP_TLSF_USE_ROM_IMPL
bool "Use ROM implementation of heap tlsf library"
depends on ESP_ROM_HAS_HEAP_TLSF
default y
help
Enable this flag to use heap functions from ROM instead of ESP-IDF.

View File

@ -49,7 +49,7 @@ void heap_caps_enable_nonos_stack_heaps(void)
*/
void heap_caps_init(void)
{
#ifdef CONFIG_HEAP_ROM_IMPL
#ifdef CONFIG_HEAP_TLSF_USE_ROM_IMPL
extern void multi_heap_in_rom_init(void);
multi_heap_in_rom_init();
#endif

View File

@ -1,7 +1,7 @@
[mapping:heap]
archive: libheap.a
entries:
if HEAP_HAS_ROM_IMPL = n || HEAP_ROM_IMPL = n:
if HEAP_TLSF_USE_ROM_IMPL = n:
heap_tlsf (noflash)
multi_heap (noflash)
if HEAP_POISONING_DISABLED = n:

View File

@ -22,7 +22,7 @@
/* Defines compile-time configuration macros */
#include "multi_heap_config.h"
#if (!defined MULTI_HEAP_POISONING) && (!defined CONFIG_HEAP_ROM_IMPL)
#if (!defined MULTI_HEAP_POISONING) && (!defined CONFIG_HEAP_TLSF_USE_ROM_IMPL)
/* if no heap poisoning, public API aliases directly to these implementations */
void *multi_heap_malloc(multi_heap_handle_t heap, size_t size)
__attribute__((alias("multi_heap_malloc_impl")));
@ -77,7 +77,7 @@ typedef struct multi_heap_info {
tlsf_t heap_data;
} heap_t;
#ifdef CONFIG_HEAP_ROM_IMPL
#ifdef CONFIG_HEAP_TLSF_USE_ROM_IMPL
void _multi_heap_lock(void *lock)
{
@ -99,7 +99,7 @@ void multi_heap_in_rom_init(void)
multi_heap_os_funcs_init(&multi_heap_os_funcs);
}
#else //#ifndef CONFIG_HEAP_ROM_IMPL
#else //#ifndef CONFIG_HEAP_TLSF_USE_ROM_IMPL
/* Return true if this block is free. */
static inline bool is_free(const block_header_t *block)

View File

@ -334,7 +334,7 @@ multi_heap_handle_t multi_heap_register(void *start, size_t size)
memset(start, FREE_FILL_PATTERN, size);
}
#endif
#ifdef CONFIG_HEAP_ROM_IMPL
#ifdef CONFIG_HEAP_TLSF_USE_ROM_IMPL
tlsf_poison_fill_pfunc_set(multi_heap_internal_poison_fill_region);
#endif
return multi_heap_register_impl(start, size);

View File

@ -421,6 +421,14 @@ VFS
:CONFIG_ESP_ROM_HAS_HAL_SYSTIMER: * Enabling :ref:`CONFIG_HAL_SYSTIMER_USE_ROM_IMPL` can reduce the IRAM usage and binary size by linking in the systimer HAL driver of ROM implementation.
:CONFIG_ESP_ROM_HAS_HAL_WDT: * Enabling :ref:`CONFIG_HAL_WDT_USE_ROM_IMPL` can reduce the IRAM usage and binary size by linking in the watchdog HAL driver of ROM implementation.
.. only:: esp32c2
Heap
@@@@
.. list::
:CONFIG_ESP_ROM_HAS_HEAP_TLSF: * Enabling :ref:`CONFIG_HEAP_TLSF_USE_ROM_IMPL` can reduce the IRAM usage and binary size by linking in the TLSF library of ROM implementation.
Bootloader Size
---------------