FreeRTOS memory footprint reduction at build time

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

formatting link
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

Reply to
John Speth
Loading thread data ...

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
Reply to
Joe Chisolm

It seems REALLY strange that freeRTOS uses 15KByte of RAM for itself. From this:

formatting link

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

Reply to
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

formatting link

Thanks for getting me started - JJS

Reply to
John Speth

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

formatting link

Thanks - JJS

Reply to
John Speth

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"]

formatting link
The purely static approach to memory allocation is so much simpler and is required in most safety-related application.

--------------------------------------- Posted through

formatting link

Reply to
QL

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.