analogdevicesinc / msdk

Software Development Kit for Analog Device's MAX-series microcontrollers
Apache License 2.0
60 stars 75 forks source link

perf(Other): Use FreeRTOS Heap Allocation Scheme 4, Allow Changing FreeRTOS Heap Allocation Scheme #1052

Closed Brandon-Hurst closed 1 day ago

Brandon-Hurst commented 1 week ago

Description

FreeRTOS gives some flexibility in the memory allocation scheme used to allow optimizing size/speed/heap fragmentation risk. The FreeRTOS documentation indicates that _heap2.c is considered outdated, and that _applications should at a minimum use heap4 as an alternative. Heap 4 uses a smarter allocation algorithm for avoiding heap fragmentation (first-fit algorithm + aggregates free RAM segments).

Sources for info: https://www.freertos.org/a00111.html https://github.com/FreeRTOS/FreeRTOS-Kernel-Book/blob/main/ch03.md

Summary of Changes

This would (positively) affect the way FreeRTOS builds for all supported MCUs.

Tests

Tested library builds with all 5 different heap types using FreeRTOSDemo for MAX78000 as the test source code. Example builds with the appropriate heap files based on the new FREERTOS_HEAP_TYPE macro. If the macro is not defined in project.mk, the library builds with heap_4.c by default.

Checklist Before Requesting Review