Static and Dynamic allocation together

stmuser wrote on Wednesday, October 30, 2019:

is it possible create static allocated tasks and dynamically allocated tasks? i.e can we enable both the flags to gether configSUPPORT_STATIC_ALLOCATION, configSUPPORT_DYNAMIC_ALLOCATION. I tried to enable and I am observing the following behavior, created one task which uses dynamic allocation, when I call the schedular, it tries to create idle task and timer task(had given the call backs for stack), The program crashes(i.e hardfault) in function vListInsertEnd. while creating the timertask from vTaskStartScheduler function, If I don’t create the task which uses dynamic memory, the scheular runs without any issues.

rtel wrote on Wednesday, October 30, 2019:

Yes it is possible to use both static and dynamic allocation at the same
time - many of the demos do this and it is a very common scenario in
production (especially where libraries are using static allocation even
if application code is not).

However, if you have configSUPPORT_STATIC_ALLOCATION set to 1 then the
timer/daemon and idle tasks WILL use static allocation and you MUST
provide the statically allocated memory via callbacks. See the
following documentation to see how:
https://www.freertos.org/a00110.html#configSUPPORT_STATIC_ALLOCATION

aggarg-aws wrote on Thursday, October 31, 2019:

If I don’t create the task which uses dynamic memory, the scheular runs without any issues.

Seems like some memory corruption.

Thanks.

stmuser wrote on Thursday, October 31, 2019:

Apparenlty I found that this is happening if I use the MPU port. If I use non mpu port file, I don’t face any issues. the hard fault occurs exactly on executing the line pxIndex->pxPrevious = pxNewListItem; in function vListInsertEnd. Continuing to debug this.

To answer the questions:

  1. Yes I am using the same call back functions.
  2. The task doesn’t do anything, except calling delay(its a demo task doesn’t do any work)
  3. There is no stack overflow possibility as the task does nothing, also the issue happens when the shedular is trying to create the idle task and timer task, i.e even before the first task is being run.
  4. Nope the call back function never hit.