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.

Compiler/DK-TM4C129X: any way to maximize the heap size?

Part Number: DK-TM4C129X
Other Parts Discussed in Thread: TM4C1294NCPDT

Tool/software: TI C/C++ Compiler

I am using CCS 8.0.0.00016 to develop code on a DK-TM4C129X dev kit. I am wondering if there is any way to tell the linker to allocate all remaining internal RAM to the heap, rather than having to specify an absolute size. For example, something along the lines of "--heap_size=MAX". It is somewhat of a pain to have to examine the map file to determine available RAM and then update the heap size options.

Regards,

Dave

  • Dave Hohl said:
    I am wondering if there is any way to tell the linker to allocate all remaining internal RAM to the heap, rather than having to specify an absolute size.

    Unfortunately, no.

    Thanks and regards,

    -George

  • Dave Hohl said:
    I am wondering if there is any way to tell the linker to allocate all remaining internal RAM to the heap, rather than having to specify an absolute size.

    I can't find any official documented way of doing that, but as an experiment made the following changes to a TM4C129NCPDT project using TI ARM v18.1.1:

    a) In the project properties set the --heap_size option to zero.

    b) In the linker command file replace the individual section placement to SRAM with a group:

    SECTIONS
    {
        .intvecs:   > 0x00000000
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
        .init_array : > FLASH
    
        .vtable :   > 0x20000000
        GROUP : > SRAM
        {
            .data
            .bss
            .stack
            .sysmem:
            {
                __SYSMEM_SIZE = END (SRAM) - .;
            }
        }
    }

    The group places .sysmem at the end of the SRAM, and the assignment to __SYSMEM_SIZE overrides the linker setting to tell the run time library the heap occupies all the upper unused space in SRAM.

    The linker map files shows the following segment allocation:

    SEGMENT ALLOCATION MAP
    
    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    00000000    00000000    00007948   00007948    r-x
      00000000    00000000    00000208   00000208    r-- .intvecs
      00000208    00000208    000073f0   000073f0    r-x .text
      000075f8    000075f8    000002b2   000002b2    r-- .const
      000078b0    000078b0    00000098   00000098    r-- .cinit
    20000000    20000000    00000bd0   00000000    rw-
      20000000    20000000    000001f4   00000000    rw- .data
      200001f4    200001f4    000001cf   00000000    rw- .bss
      200003c8    200003c8    00000800   00000000    rw- .stack
      20000bc8    20000bc8    00000008   00000000    rw- .sysmem

    And the setting of __SYSMEM_SIZE symbol which the memory.c file in the run time library uses to obtain the heap size:

    0003f438  __SYSMEM_SIZE

    While I tested the changes showed that memory.c did see a heap which occupied the free SRAM space from 0x20000bc8 ... 0x2003fffff.

    However, this does produce the following warning:

    Description	Resource	Path	Location	Type
    #10190-D absolute symbol "__SYSMEM_SIZE" being redefined	tm4c1294ncpdt.cmd	/TM4C_read_rom_symbols	line 46	C/C++ Problem

    Therefore, it might break under some conditions.

  • OK, thanks for the quick reply.

    Regards,

    Dave
  • Hi, Chester,

    Thanks for doing this investigative work. It's good to know that it might be possible to achieve what I was asking about. It would be nice if TI could add such capability to CCS so that there would be no warnings and we wouldn't need to worry about things breaking.

    Regards,

    Dave
  • Dave Hohl said:
    It would be nice if TI could add such capability to CCS so that there would be no warnings and we wouldn't need to worry about things breaking.

    Agree that it would be good for TI to raise an enhancement for this, as it seems reasonable for the heap to be sized to the maximum.

    I did try and use SPC arithmetic to set the size of .sysmem, but that just resulted in errors. While expressions can be used in a linker command file to set symbols which the program can reference, symbols can't be referenced to set section sizes. E.g. trying the following:

        GROUP : > SRAM
        {
            .data
            .bss
            .stack
            dummy:
            {
                my_sysmem_start = .;
            }
            .sysmem:
            {
                . = SIZE (SRAM) - my_sysmem_start;
            }
        }

    Results in the error:

    "../tm4c1294ncpdt.cmd", line 50: error #10194: symbol "my_sysmem_start" used in expression before it has been assigned a value

    Linker C6000: how to automatically set a sections size to the free (non allocated) memory? shows how a linker command file can be used to size a memory pool to the unused memory, but to make use of that would require either replacing or modifying memory.c from the run time library to change how the memory area for the heap is determined.

  • Enhancement request CODEGEN-4635 submitted for consideration.