FreeRTOS-Plus-TCP with Static Memory Allocation

With configSUPPORT_STATIC_ALLOCATION set to 1 and configSUPPORT_DYNAMIC_ALLOCATION set to 0 within the FreeRTOSConfig.h file, the pvPortMallocSocket macro within the FreeRTOS_Socket.c file still expects a memory allocation scheme (i.e. heap_4.c) and configSUPPORT_DYNAMIC_ALLOCATION be set to 1. I already modified NetworkInterface.c and FreeRTOS_Sockets.c to utilize static allocation of RTOS objects much like the other +TCP stack modules already had… ?

Hello @rhaber80,

Yes, you are correct. This is a bug in the FreeRTOS+TCP stack. Currently, you can modify your code locally or use dynamic allocation.

We have added this to our backlog. Currently are working on other important things and we will get to fixing this problem in a while.

If you want to create a PR, you are very welcome. To track this issue and make sure it doesn’t get lost, I have created an issue in the FreeRTOS+TCP library repository: FreeRTOS+TCP library doesn’t compile with static allocation turned on and dynamic allocation turned off.

Thanks again for bringing this issue to our attention.

-Aniruddha

1 Like

So since use of dynamic allocation and the FreeRTOS heap is suggested for FreeRTOS+TCP network stack, has a exclusion to MISRA 2012 Directive 4.12: “Dynamic memory allocation shall not be used” been logged as a compliance deviation?

Hello @rhaber80,

It was not logged in the MISRA.md file that we have in the repository. Thank you for catching this discrepancy and pointing this out :slightly_smiling_face:
We’ll add this to the MISRA file ASAP.

Thanks again,
Aniruddha

@rhaber80,

Here is the PR adding the suppressions and justification to the MISRA.md file.
We’ll work on merging this ASAP.

Thank you for bringing this to our attention.

Thanks,
Aniruddha

I was wondering what the status of this bug is currently. Is support for static allocation using FreeRTOS-Plus-TCP something that will be added any time soon?

If not, is there any guidance or example to follow on how to implement this locally?