Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Squeeze all memory into FreeRtos heap

Posted by joehinkle on October 22, 2016

I'm using heap4 which requires me to specify the amount of ram to allocate to the FreeRtos heap.

I would like to allocate all unallocated ram to the heap without playing with the configuration size.

Is there a way to use the linker to figure out what amount of ram is unallocated and assign it to my heap allocation size?

Thanks


Squeeze all memory into FreeRtos heap

Posted by edwards3 on October 22, 2016

There are as many answers to that question as there are compilers.

If you are using GCC then check out the gnu linker documentation. That describes how to set linker variables, then access those variables from C code. If the linker fills your RAM from low to high, then set a linker variable to the end of the section filled by the linker, and another to the top of the RAM, then you have the limits available to the heap. Here is an example that is more complicated than you need, it has lots of linker variables defined. Look for

__data_end__ = . ;

https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/CORTEXMPUSimulatorKeilGCC/GCC_Specific/sections.ld

The linker variables are used in this C file. Search "extern uint32t" to see how to bring them in https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/CORTEXMPUSimulatorKeil_GCC/main.c

Then best to use heap5.c because even with configAPPLICATIONALLOCATEDHEAP (http://www.freertos.org/a00110.html#configAPPLICATIONALLOCATEDHEAP) GCC makes it hard to place the ucHeap array at the address you want. heap5.c makes that easy.


Squeeze all memory into FreeRtos heap

Posted by joehinkle on October 22, 2016

Thanks.

I defined my heap this way using heap4 and GCC compiler.

byte ucHeap[configTOTALHEAPSIZE] attribute ((section (".heap")));

Would I gain anything by using heap5 if this is working fine?


Squeeze all memory into FreeRtos heap

Posted by rtel on October 22, 2016

The problem with this is the definition of configTOTALHEAPSIZE has to be a fixed constant at compile time. If you use heap_5 then you can set the heap region size using a linker variable, so it automatically adjusts as the memory map changes.

Make sure you understand your linker file. Some cruder linker files will set the stack at the top and the heap at the bottom of any RAM that is left over, but not dimension either of them, so they will eventually crash in the middle if too much RAM is used.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists