I started out with an MCUXpresso SDK 2.3 sample project for using FreeRTOS and I customized it to create three tasks and an event queue for dispatching requests from two of the tasks into the third. (freertos_queue example) The initial SDK example project ran out of SRAM, so I converted the project to run out of hyperflash on the MIMXRT1050-EVK.
This step was performed using notes from Overview of using the MIMXRT1050-EVK(B) with MCUXpresso IDE to convert a RAM project to XIP from flash (doc v104, page 17).
At this point, the project builds and runs well, however the heap used by FreeRTOS along with all other data memory resources come from SRAM_DTC. This area maxes out at 128KB and the project that I am preparing for will use several hundred KB of heap space. For this reason I am attempting to use the MIMXRT1050-EVK SDRAM (32 MB) device.
I changed the project config for memory details to include an SDRAM section and positioned it immediately below the hyperflash section.
I then edited FreeRTOSConfig.h and increased my heap allocation:
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE ((size_t)(500 * 1024))
#define configAPPLICATION_ALLOCATED_HEAP 0
The build completed error/warning free, but I get a hard fault thrown at runtime.
By decreasing the heap size to 30 * 1024, I no longer get the hard fault, but rather my second of 3 tasks fails to create (pvPortMalloc call returns NULL). My queue and task that uses the queue create without problems.
I searched for similar issues posted to the community and found Jack King's thread:
as well as a thread describing similar hard fault issues with FreeRTOS for the LPC1778:
The takeaway from one of Jack King's comments: