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).
Changed default FreeRTOS heap allocation to heap_4.c -heap_4 is recommended by FreeRTOS as an updated alternate to heap_2 for avoiding heap fragmentation
Added FREERTOS_HEAP_TYPE compile time macro to select the heap allocation method
Default value is 4, but can be 1-5. Error message is included if invalid input is given.
Added an entry for FREERTOS_HEAP_TYPE in MAX78000's FreeRTOSDemo project.mk
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
[x] PR Title follows correct guidelines.
[x] Description of changes and all other relevant information.
[x] (Optional) Link any related GitHub issues using a keyword
[x] (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.
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