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


C18 linker restrictions loosened

Posted by Nobody/Anonymous on July 20, 2006

I studied the remarks by John Franklin about how to set up the linker script and modify heap_1.c to prevent variables leaking across page boundaries.

I think his solution is way too complex.

The goal is to get the heap in one memory section (which can cross multiple banks), and keep the rest of the variables from crossing a bank boundary.

This can simply be realised by combining no more banks than required for the heap.
Let's say the desired heap is 2200 bytes

This is done by
#define configTOTAL_HEAP_SIZE( ( size_t ) 2200 )
in FreeRTOSConfig.h

As a result the variable 'xHeap' defined in heap_1.c will be 2204 bytes long because of the additional long variable in the struct.
In hexadecimal 2204 is 0x89C, which is the minimum required size of the memory region. (There are no other variables defined in heap_1.c, so this is all the memory required for de .udata_heap_1.o memory section)

It is now sufficient to define a region in the linker script which is between 0x89C and 0x900 long.
The rest of the banks will be left alone and have a length of 0x100, starting at a boundary.

The linker will automatically fit the .udata_heap_1.o memory section (containing the xHeap variable) into the first region with enough space. The remaining space in the combined region can be used by other memory sections.
(It is in this example _not_ allowed to define the region _larger_ than 0x900 bytes since other variables stored in the region can then cross a boundary.)

- There is no need to modify the FreeRTOS library file heap_1.c with
#pragma udata heap_section
#pragma udata
- There is no need to define the combined region "PROTECTED"
- There is no need for a "SECTION NAME=heap_section RAM=heapregion" mapping in the linker script

All that is required is to combine no more banks than strictly required to accomodate configTOTAL_HEAP_SIZE+4 bytes
It is allowed to oversize the region to the next bank boundary, and let the linker fill up the rest of the region. You don't have to define your own (non-PROTECTED) region to fill up the bank if you don't want to waste the remaining space.


RE: C18 linker restrictions loosened

Posted by Nobody/Anonymous on July 20, 2006
Makes sense. Comments John?

[ 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