diff --git a/Examples/MAX78000/FreeRTOSDemo/project.mk b/Examples/MAX78000/FreeRTOSDemo/project.mk index 06b5bd6933..6d66198d84 100644 --- a/Examples/MAX78000/FreeRTOSDemo/project.mk +++ b/Examples/MAX78000/FreeRTOSDemo/project.mk @@ -16,6 +16,11 @@ DEBUG=1 LIB_FREERTOS = 1 +# Can provide a value for the FREERTOS heap allocation scheme +# Default value is 4 +# FREERTOS_HEAP_TYPE := 2 +# export FREERTOS_HEAP_TYPE + ifeq ($(BOARD),Aud01_RevA) $(error ERR_NOTSUPPORTED: This project is not supported for the Audio board) endif \ No newline at end of file diff --git a/Libraries/FreeRTOS/Makefile b/Libraries/FreeRTOS/Makefile index a6faec8699..2157bcebd1 100644 --- a/Libraries/FreeRTOS/Makefile +++ b/Libraries/FreeRTOS/Makefile @@ -48,12 +48,29 @@ SRCS = list.c SRCS += queue.c SRCS += tasks.c SRCS += port.c -SRCS += heap_2.c SRCS += timers.c SRCS += croutine.c SRCS += event_groups.c SRCS += stream_buffer.c +# Setup a default heap allocation mechanism +# Default val is 4, which is recommended to best avoid heap fragmentation +FREERTOS_HEAP_TYPE ?= 4 + +ifeq ($(FREERTOS_HEAP_TYPE), 1) +SRCS += heap_1.c +else ifeq ($(FREERTOS_HEAP_TYPE), 2) +SRCS += heap_2.c +else ifeq ($(FREERTOS_HEAP_TYPE), 3) +SRCS += heap_3.c +else ifeq ($(FREERTOS_HEAP_TYPE), 4) +SRCS += heap_4.c +else ifeq ($(FREERTOS_HEAP_TYPE), 5) +SRCS += heap_5.c +else +$(error FREERTOS_HEAP_TYPE must be between 1-5. Default: 4) +endif + # Where to find source files for this project VPATH = Source/portable/GCC/ARM_CM4F VPATH += Source/portable/MemMang diff --git a/USERGUIDE.md b/USERGUIDE.md index 7b7e40902e..2e322be22d 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -2212,6 +2212,12 @@ Once enabled, the following [build configuration variables](#build-configuration FreeRTOS is supported by all parts in the MSDK. See the `FreeRTOSDemo` example application. +#### FreeRTOS Build Variables + +| Configuration Variable | Description | Details | +| ---------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ | +| `FREERTOS_HEAP_TYPE` | Specify the method of heap allocation to use for the FreeRTOS API | FreeRTOS provides options for the heap management alogirthms to optimize for memory size, speed, and risk of heap fragmentation. For more details, visit the [FreeRTOS MemMang Docs](https://www.freertos.org/a00111.html). Acceptable values are `1`, `2`, `3`, `4`, or `5`. The default value is `4` for heap_4. | + #### FreeRTOS-Plus [FreeRTOS-Plus](https://www.freertos.org/FreeRTOS-Plus/index.html) is an additional library that implements addon functionality for the FreeRTOS kernel. The MSDK maintains support for some, but not all, available addons.