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 TI staffers,

I need some help to optimize the use of available memory.

Firstly, I have changed the cc3200R1.cmd linker file to create a single block of memory where program code is automatically followed by data, this is working perfectly.

Secondly using FreeRTOS (v8.2.1) module heap5.c and function vPortDefineHeapRegions() I am creating a multi segment heap memory configuration for pvPortMalloc() and vPortFree() functionality, also working perfectly.

Thirdly, I am already reclaiming the section 0x2000-0000 to 0x2000-3FFF as 1st part of the multi segment heap but want to automate the determination of the second section to use ALL unused memory from  symbol "__TI_static_base__" and ending at symbol "__stack". Using manually calculated values it runs perfectly starting with around 124kb of heap in total.

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) ;

My problem starts when I use the symbol "__TI_static_base__" in the xHeapRegions array, I get the compiler warning below although the code runs perfectly.

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

My questions is:

How can I FORCE  a segment created using the #pragma directive to always be located AFTER the LAST data segment?

Alternatively, how can I 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?

Andre

  • HI Andre,


    We will look into this and get back to you.


    Regards,
    Aashish
  • Thanks, much appreciated but fairly urgent...
  • Hi Andre,


    Please share modified linker and map file. Also want to know question "How can I FORCE a segment created using the #pragma directive to always be located AFTER the LAST data segment?" is related to warning that you are getting?


    Regards,
    Aashish
  • HI Aashish,

    MAP file attached below.

    Linker CMD file I am essentially using default except with the CODE & DATA segment combined into a single segment., need to change this further should I be creating another segment.

    The question on creating another segment is just based on the view that another segment, located after all code and data but before the stack, and containing the symbol used to mark the base of heap, will make the error go away.

    If there is a simpler/cleaner way to create the symbol/marker required for the heap placement, and that also makes the warning go away, that will be perfect.

    Andre

     

    --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)
    }
    
    imacs.txt

  • Hi Andre,


    Can you please try with following way


    1. Define below lines in main.c file:

    long g_usersection_start;
    #pragma RETAIN(g_usersection_start)
    #pragma DATA_SECTION(g_usersection_start, ".usersection")


    2. In linker file add below lines:
    .usersection : > SRAM_DATA
    .stack : > SRAM_DATA(HIGH)
    }

    3. And define xHeapRegions in heap5.c in following way:

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



    Regards,
    Aashish
  • Hi Aashish,

    As expected your suggestion makes the linker warning go away (since no more reference to the symbol __TI_static_base__), but then the problem comes back that g_usersection_start is located somewhere in the middle of other variables and the heap thus corrupts memory.

    Getting rid of the warning is the easy bit, locating the section created after all code and data, but in low memory opposite the stack, that is the challenge...

    Andre

  • Hi Aashish,

    Any update on this issue. I am continuing to use my workaround which makes the heap calculation work consistently, but (in addtion to the warning) also results in a larger binary file due to the disabled RLE compression/encoding.

    André
  • HI TI staffers,

    If somebody can PLEASE have a look at this and provide some constructive feedback. The query is almost 3.5 months old, and no resolution.

    Maybe it can be better solved in the CCS or TI compiler forums, if so can you please move it there?

    Thanks
  • Hi Andre,


    Sorry for delayed response.

    We have posted this query to TI compiler forum(here is link e2e.ti.com/.../444759). You can add any missing information there.


    Regards,
    Aashish