Unify all heaps (stdlib + LVGL + FreeRTOS) into a single heap managed by FreeRTOS and heap_4_infinitime.c.

LVGL supports custom implementation of malloc() and free() so using pvPortMalloc() and vPortFree() is just a matter of setting the right variables.

Other libraries (NimBLE, LittleFS) and InfiniTime code (new) call malloc() and free() from stdlib. InfiniTime now provides the file stdlib.c that provides a custom implementation for malloc(), free(), calloc() and realloc(). This ensures that all calls to the standard allocator are redirected to the FreeRTOS memory manager.

Note that realloc() is needed by NimBLE.
This commit is contained in:
Jean-François Milants 2023-03-26 14:49:03 +02:00 committed by JF
parent 9e808a65ec
commit 1911e2d928
4 changed files with 36 additions and 6 deletions

View file

@ -367,6 +367,7 @@ list(APPEND IMAGE_FILES
displayapp/icons/battery/batteryicon.c
)
list(APPEND SOURCE_FILES
stdlib.c
FreeRTOS/heap_4_infinitime.c
BootloaderVersion.cpp
logging/NrfLogger.cpp
@ -496,6 +497,7 @@ list(APPEND SOURCE_FILES
)
list(APPEND RECOVERY_SOURCE_FILES
stdlib.c
FreeRTOS/heap_4_infinitime.c
BootloaderVersion.cpp
@ -560,6 +562,7 @@ list(APPEND RECOVERY_SOURCE_FILES
)
list(APPEND RECOVERYLOADER_SOURCE_FILES
stdlib.c
FreeRTOS/heap_4_infinitime.c
# FreeRTOS
@ -786,7 +789,7 @@ add_definitions(-DOS_CPUTIME_FREQ)
add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040)
add_definitions(-DFREERTOS)
add_definitions(-D__STACK_SIZE=1024)
add_definitions(-D__HEAP_SIZE=4096)
add_definitions(-D__HEAP_SIZE=0)
add_definitions(-DMYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME=1500)
# Note: Only use this for debugging