FreeRTOS memory footprint reduction at build time

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi Folks-

FreeRTOS has a build config file (FreeRTOSConfig.h) that users can apply  
at build time to customize the RTOS.  The FreeRTOS web site has a page  
to describe the options (https://www.freertos.org/a00110.html ).  What it  
doesn't have is any hints about how much RAM it might save me.

Does anybody have any first hand advice about how much RAM each option  
might contribute to the RAM footprint?  Google isn't helping me.

I'm trying prepare an STM32L151 to accommodate my as yet unwritten  
application code with FreeRTOS.  The map file is showing me that  
FreeRTOS is using 15,000 bytes of RAM.  The HAL and startup/interrupt  
codes use 2,400 bytes of RAM.  That leaves me with about 14,800 bytes  
for application code.  I would like to be prepared to reduce the  
FreeRTOS RAM footprint if I need to in the future.

I know I can elevate optimization (presently set to none) but I don't  
want to do that this early in the code-writing stage because it makes  
the debugger present better steppable code.

Thanks - JJS

Re: FreeRTOS memory footprint reduction at build time
On Thu, 05 Jul 2018 17:29:18 -0700, John Speth wrote:

Quoted text here. Click to load it

It has been a couple of years since I did a lot with FreeRTOS but if
I remember correctly there are very few static built data structures.
Most are linked list and such that grow based on your resource usage
(number of task, queues, semaphores, etc).  How are you allocating
your heap.  If you are using the default simple allocators then part
of that 15K is the heap.  You can try decreasing the size or plan on
your app doing a lot of malloc allocation for data structures and allocate
more ram to the heap.

Optimization is not going to do a lot for your RAM usage.  It will decrease
your flash usage some.  If you are starting to run out of flash that is a
different story.  You can try and remove some of API features you are not using and
cut down some on flash usage.  

--  
Chisolm
Republic of Texas


Re: FreeRTOS memory footprint reduction at build time
On 7/5/2018 10:12 PM, Joe Chisolm wrote:
Quoted text here. Click to load it

That's a good point about the optimizer.  It was long and late day  
fatigue that made me say it.

The STM32 is swimming in flash compared to RAM.  It's the RTOS heap  
that's pigging out on RAM (15K according to my config file).  I can  
manage it easily from the config file.  See  
https://www.freertos.org/a00111.html .

Thanks - JJS

Re: FreeRTOS memory footprint reduction at build time
On Friday, July 6, 2018 at 2:30:53 AM UTC+2, John Speth wrote:
Quoted text here. Click to load it

It seems REALLY strange that freeRTOS uses 15KByte of RAM for itself.
From this:
https://www.freertos.org/FAQMem.html

it seems that RAM usage is under 1KB.

Or you meant flash instead of RAM, so 15KB might be correct, depending on the configuration.

Bye Jack

Re: FreeRTOS memory footprint reduction at build time
On 7/5/2018 10:37 PM, Jack wrote:
Quoted text here. Click to load it

A good nights sleep cleared my head for a closer examination of the map  
file.  The config file specifies a single RTOS heap of 15K bytes.  The  
map file confirmed it.  So of course there is a tradeoff that I'll need  
to examine my application to minimize task heap usage.  It's explained  
in greater detail at https://www.freertos.org/a00111.html .

Thanks for getting me started - JJS

Re: FreeRTOS memory footprint reduction at build time
You don't need to use the heap and the various "heap management" policies
of FreeRTOS. Pre-allocating the precious RAM is always terribly wasteful.
Starting with FreeRTOS 9, you can use ["static memory
allocation"](https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html ).
The purely static approach to memory allocation is so much simpler and is
required in most safety-related application.


---------------------------------------
Posted through http://www.EmbeddedRelated.com


Site Timeline