This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Creating a segment or symbol indicating end of memory used

Hi,

We are using FreeRTOS (v8.2.1) and try to create multi segment heap memory. The RAM is divided in two parts:
1. 0x2000000-0x20003FFF as bootloader, and
2. 0x20004000-0x2002FFFF that contains stack, text, data etc. as per below linker file.

--retain=g_pfnVectors
#define RAM_BASE 0x20004000
MEMORY
{
SRAM_BLOCK (RWX) : origin = 0x20004000, length = 0x3C000
}
SECTIONS
{
.intvecs: > RAM_BASE
.init_array: > SRAM_BLOCK
.vtable : > SRAM_BLOCK
.text : > SRAM_BLOCK
.const : > SRAM_BLOCK
.cinit : > SRAM_BLOCK
.pinit : > SRAM_BLOCK
.data : > SRAM_BLOCK
.bss : > SRAM_BLOCK
.sysmem : > SRAM_BLOCK
.stack : > SRAM_BLOCK(HIGH)
}

For multiple segment heap we are able to successfully claim first memory part means boot loader as well as second part with predetermined/manual determined unused memory(After text, data, stack etc section). The problem arises when we try to automate the determination of unused memory (rather than using pre-determined value) in second part using "__TI_static_base__" and ending at symbol "__stack". Below is code snippet to create multiple segments heaps with automate determination of unused memory for heap:

HeapRegion_t xHeapRegions[] = {
{ ( _u8 * ) 0x20000000UL, 0x04000 }, // portion of memory used by bootloader
{ ( _u8 * ) &__TI_static_base__, (size_t) &__stack },
{ NULL, 0 }
} ;

xHeapRegions[1].xSizeInBytes -= (size_t) xHeapRegions[1].pucStartAddress ;
vPortDefineHeapRegions(xHeapRegions) ;


When we use the symbol "__TI_static_base__" in the xHeapRegions array, we get the compiler warning as below although the code runs perfectly fine.

" warning #10229-D: output section ".data" refers to load symbol "__TI_static_base__" and hence cannot be compressed; compression "rle" is ignored "


So, our question is:
How can we FORCE a segment created using the #pragma directive to always be located AFTER the LAST data segment or in other words how can we use the existing symbols to accurately and safely determine the start of unused memory that can be used as the start of the second heap segment?

Regards,

Aashish

  • I have no expertise with FreeRTOS and how it manages memory segments.  So I'm a bit lost regarding that part of your post.  I summarize the question this way: Is there a way to determine the last address used in the memory range SRAM_BLOCK?  If that summary is wrong, then so is my answer.

    So long as you use the HIGH specifier exactly once, then this code ...

    .stack : > SRAM_BLOCK(HIGH), RUN_END(last_address_in_SRAM_BLOCK)

    creates the symbol last_address_in_SRAM_BLOCK.  Strictly speaking, this symbol is assigned the first address after the output section .stack.  Because of the single use of the HIGH location specifier, then .stack is the last (highest) output section in SRAM_BLOCK.  Thus the symbol last_address_in_SRAM_BLOCK is the last (highest) address in SRAM_BLOCK.

    Regarding ...

    Aashish Bhanawat said:
    " warning #10229-D: output section ".data" refers to load symbol "__TI_static_base__" and hence cannot be compressed; compression "rle" is ignored "

    Please see this post for a description of what happened.

    Thanks and regards,

    -George