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/TMS570LC4357: How to export Heap start and end address in code files

Part Number: TMS570LC4357

Tool/software: TI C/C++ Compiler

Hi Ti Experts,

From the Compiler usage document, i could only find how to allocate the heap size in RAM.

I can also export RAM_START and RAM_END address, but if i want to know exactly where heap is allocated how do i know.

Regards,

Somesh

  • I need the run time Heap_Start and Heap_End addresses along with the size to be accessible in code. Please help me to get these details.
  • In the linker command file, for the output section that is the heap, create the symbols you need.  For the details, please search the ARM assembly tools manual for the sub-chapter titled Address and Dimension Operators.  To understand how to use those linker created symbols in C code, please search the same manual for the sub-chapter titled Using Linker Symbols in C/C++ Applications.

    Thanks and regards,

    -George

  • Hi George,

    I updated my command file and code files as per the details provided in the ARM Assembly tools manual. I am able to export them, but problem here is always the start, end and size are constant values. Not sure why.

    I applied similar approach for .bss and it worked perfectly.

    Here is the command file and the code file updated for the same. Can you please help why run time heap details are not coming, where as .bss data is coming perfectly.

    -e _c_int00 /* Start up code */
    -stack 0x800 /* 128 word STACK */
    -heap 0x800

    /*-----------------------------------------------------------------------*/
    /* Code object modules */
    /*-----------------------------------------------------------------------*/
    code\dabort.obj
    .

    .

    .

    code\cxxabiv1_.obj

    /*----------------------------------------------------------------------------*/
    /* Linker Settings */

    --retain="*(.intvecs)"

    /* USER CODE BEGIN (1) */
    /* USER CODE END */

    /*----------------------------------------------------------------------------*/
    /* Memory Map */

    RAM_START = 0x08001500;
    RAM_END = 0x08040000;
    FLASH0_START = 0x00000000;

    MEMORY
    {
    VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH0 (RX) : origin=0x00000020 length=0x0017FFD0
    FLASH1 (RX) : origin=0x00180000 length=0x00180000
    STACKS (RW) : origin=0x08000000 length=0x00001500
    RAM (RW) : origin=(0x08001500 + 0x100) length=(0x00025AFF- 0x100)
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }

    /* USER CODE BEGIN (3) */
    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Section Configuration */
    SECTIONS
    {
    .special: { ovsp_header.obj(.const) } load = 0x1FEE0
    .intvecs : {} > VECTORS
    .text : {} > FLASH0 | FLASH1
    .init_array: {} > FLASH0 | FLASH1
    .const : {} > FLASH0 | FLASH1
    .cinit : {} > FLASH0 | FLASH1
    .pinit : {} > FLASH0 | FLASH1
    .bss : {} > RAM
    RUN_START(RUN_BSS_START), RUN_SIZE(RUN_BSS_SIZE), RUN_END(RUN_BSS_END)
    .data : {} > RAM
    .sysmem : {} > RAM
    RUN_START(RUN_HEAP_START), RUN_SIZE(RUN_HEAP_SIZE), RUN_END(RUN_HEAP_END)
    }
    /* USER CODE BEGIN (4) */
    /* USER CODE END */

    Respective code:

    extern char RUN_HEAP_START, RUN_HEAP_SIZE, RUN_HEAP_END;
    extern char RUN_BSS_START, RUN_BSS_SIZE, RUN_BSS_END;

    Uint32 HEAP_START = (Uint32)&RUN_HEAP_START;
    Uint32 HEAP_SIZE = (Uint32)&RUN_HEAP_SIZE;
    Uint32 HEAP_END = (Uint32)&RUN_HEAP_END;

    Uint32 BSS_START = (Uint32)&RUN_BSS_START;
    Uint32 BSS_SIZE = (Uint32)&RUN_BSS_SIZE;
    Uint32 BSS_END = (Uint32)&RUN_BSS_END;

  • As far as I can tell, everything is correct. 

    I don't understand this ...

    Someswararao malla said:
    problem here is always the start, end and size are constant values

    I'm not sure what you mean.  Once the linker computes a section's size and address, all those attributes are constant after that.  You must be thinking of something else, and I'm overlooking it.

    Thanks and regards,

    -George

  • Please explain what you mean when you say ...

    Someswararao malla said:
    problem here is always the start, end and size are constant values

    What do you expect instead?

    Thanks and regards,

    -George

  • Hi George,

    Heap start and end addresses i am getting properly, my understanding was wrong.

    I have another question with respect to this, i am using memory.c file from the ti.

    If i exclude memory.c file from my build, i could see the .sysmem section not created in map file.

    Heap start and end addresses are showing save value.

    when i was looking at the memory.c file, i observed the below part of code from memory.c is creating the .sysmem.

    Can you please explain without these changes why .sysmem is not created, unlike other sections, and what  _sys_memory will hold.

    typedef struct pack
    {
    size_t packet_size; /* number of bytes */
    struct pack *size_ptr; /* next elem in free list */
    } PACKET;
    #pragma DATA_SECTION(_sys_memory, ".sysmem")
    PACKET _sys_memory[1];

    Regards,

    Somesh

  • Please follow this thread, where you posted the same question.

    Thanks and regards,

    -George