-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(Other): Use FreeRTOS Heap Allocation Scheme 4, Allow Changing FreeRTOS Heap Allocation Scheme #1052
perf(Other): Use FreeRTOS Heap Allocation Scheme 4, Allow Changing FreeRTOS Heap Allocation Scheme #1052
Conversation
…mmended 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. -Added an entry for FREERTOS_HEAP_TYPE in MAX78000's FreeRTOSDemo project.mk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! Just one change request for the documentation
@@ -16,6 +16,11 @@ DEBUG=1 | |||
|
|||
LIB_FREERTOS = 1 | |||
|
|||
# Can provide a value for the FREERTOS heap allocation scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of documenting this here, you can add some info to the UG.
See here for an example for the SDHC library.
The FreeRTOS lib hasn't had any options before, so I'd suggest adding a similar table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I'll update once this has been added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good now 👍
Description
FreeRTOS gives some flexibility in the memory allocation scheme used to allow optimizing size/speed/heap fragmentation risk. The FreeRTOS documentation indicates that heap_2.c is considered outdated, and that applications should at a minimum use heap_4 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