Skip to content
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

[Feature Request] Enable completely disabling the heap through CMake #594

Closed
CrustyAuklet opened this issue Nov 30, 2022 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@CrustyAuklet
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I am using FreeRTOS on a very small MCU where we want no heap implementation. This is normally done by
setting configSUPPORT_DYNAMIC_ALLOCATION to 0. But I don't see a way to disable the heap via CMake.

Describe the solution you'd like
I would like to be able to set the CMake cache variable FREERTOS_HEAP to a "falsey" string and have no heap file added to
the project. Strings that CMake considers false are described here

I think this is a pretty simple fix, to change the generator expression to

# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
# Disable heap if set to an empty string, 0, FALSE, OFF, N, NO, IGNORE, NOTFOUND, or ends with -NOTFOUND
$<IF:$<BOOL:${FREERTOS_HEAP}>,$<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>,>

I have this in a branch on my fork here

Describe alternatives you've considered
Looking at the CMakeLists.txt in this repo I don't see a lot of other options. I tried setting FREERTOS_HEAP to an empty string and it tried to add portable/MemMang/heap_.c to the project. I tried just using a heap file but then I get the error

#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0

How many devices will this feature impact?
thousands

What are your project timelines?
Working on an MVP shipping date in January

Additional context
None.

If you have the same (or similar) feature request, please upvote this issue with thumbs up 👍
and use the comments section to provide answers to the questions above.

@CrustyAuklet CrustyAuklet added the enhancement New feature or request label Nov 30, 2022
@jasonpcarroll
Copy link
Member

jasonpcarroll commented Nov 30, 2022

Hi @CrustyAuklet,
This definitely seems like an oversight as configSUPPORT_DYNAMIC_ALLOCATION will only be taken into account at compile time. Would probably be easier to just have a bool for it, like FREERTOS_DO_NOT_INCLUDE_HEAP or something along those lines that can just be added to your higher level Cmakelists or passed on the command line -DFREERTOS_DO_NOT_INCLUDE_HEAP. I'll make a PR for it on my fork for you to try.

@jasonpcarroll
Copy link
Member

jasonpcarroll commented Nov 30, 2022

Could you try my fork / apply this commit and see if that fixes your issue? I haven't actually tested it yet as I do not currently have a build setup to use the FreeRTOS-Kernel using the Cmake lists, but it should work if you add
-DFREERTOS_DO_NOT_INCLUDE_HEAP to the command line for cmake. Alternatively defining FREERTOS_DO_NOT_INCLUDE_HEAP in a higher level CMakeLists should also work.

@CrustyAuklet
Copy link
Contributor Author

That works too, and I think I like a little better. I wasn't sure if it was OK to add another variable but it is a bit more explicit that way.

@chinglee-iot
Copy link
Member

This feature is included in #807. User now don't have to define FREERTOS_HEAP in cmake if heap is not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants