Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #27870 > unrolled thread

FreeRTOS memory footprint reduction at build time

Started byJohn Speth <johnspeth@yahoo.com>
First post2018-07-05 17:29 -0700
Last post2018-07-10 11:30 -0500
Articles 6 — 4 participants

Back to article view | Back to comp.arch.embedded


Contents

  FreeRTOS memory footprint reduction at build time John Speth <johnspeth@yahoo.com> - 2018-07-05 17:29 -0700
    Re: FreeRTOS memory footprint reduction at build time Joe Chisolm <jchisolm6@earthlink.net> - 2018-07-06 00:12 -0500
      Re: FreeRTOS memory footprint reduction at build time John Speth <johnspeth@yahoo.com> - 2018-07-06 09:18 -0700
    Re: FreeRTOS memory footprint reduction at build time Jack <jack4747@gmail.com> - 2018-07-05 22:37 -0700
      Re: FreeRTOS memory footprint reduction at build time John Speth <johnspeth@yahoo.com> - 2018-07-06 09:15 -0700
        Re: FreeRTOS memory footprint reduction at build time "QL" <80499@EmbeddedRelated> - 2018-07-10 11:30 -0500

#27870 — FreeRTOS memory footprint reduction at build time

FromJohn Speth <johnspeth@yahoo.com>
Date2018-07-05 17:29 -0700
SubjectFreeRTOS memory footprint reduction at build time
Message-ID<phmd7m$1kas$1@gioia.aioe.org>
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

[toc] | [next] | [standalone]


#27871

FromJoe Chisolm <jchisolm6@earthlink.net>
Date2018-07-06 00:12 -0500
Message-ID<wcednYmkh6nFZ6PGnZ2dnUU7-KWdnZ2d@earthlink.com>
In reply to#27870
On Thu, 05 Jul 2018 17:29:18 -0700, John Speth wrote:

> 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

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

[toc] | [prev] | [next] | [standalone]


#27874

FromJohn Speth <johnspeth@yahoo.com>
Date2018-07-06 09:18 -0700
Message-ID<pho4sd$gc2$1@gioia.aioe.org>
In reply to#27871
On 7/5/2018 10:12 PM, Joe Chisolm wrote:
> On Thu, 05 Jul 2018 17:29:18 -0700, John Speth wrote:
> 
>> 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
> 
> 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.
> 

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

[toc] | [prev] | [next] | [standalone]


#27872

FromJack <jack4747@gmail.com>
Date2018-07-05 22:37 -0700
Message-ID<69fc6487-81fe-43ed-9c5f-7156a5475089@googlegroups.com>
In reply to#27870
On Friday, July 6, 2018 at 2:30:53 AM UTC+2, John Speth wrote:
> 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

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

[toc] | [prev] | [next] | [standalone]


#27873

FromJohn Speth <johnspeth@yahoo.com>
Date2018-07-06 09:15 -0700
Message-ID<pho4lm$g1g$1@gioia.aioe.org>
In reply to#27872
On 7/5/2018 10:37 PM, Jack wrote:
> On Friday, July 6, 2018 at 2:30:53 AM UTC+2, John Speth wrote:
>> 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
> 
> 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
> 

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

[toc] | [prev] | [next] | [standalone]


#27875

From"QL" <80499@EmbeddedRelated>
Date2018-07-10 11:30 -0500
Message-ID<J-Kdna-fw6ugQtnGnZ2dnUU7-c3NnZ2d@giganews.com>
In reply to#27873
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.arch.embedded


csiph-web