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.

RTOS/TM4C129XNCZAD: Understanding Heapmem/sysmem

Part Number: TM4C129XNCZAD
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello.

I  am trying to better understand heapmem and sysmem usage.

in my CFG file:

if I use  BIOS.heapSize = 50000; // bios heapmem 

Malloc does not work.

if I use Program.heap = 50000; //sysmem

Malloc works, but the memory amount is taken twice, which I cannot allow... (see attached images: once in heapmem : ti_sysbios_heaps_HeapMem_Instance_State_0_buf__A and once in rtsv7M4_T_le_v4SPD16_eabi.lib : memory.obj (.sysmem).

What am I doing wrong here?

Thanks

  • I am suggesting that if I do not specifically assigning a size to the BIOS.heapSize, it will take the same size as assigned to the systmem?
  • Hi Shlomo,

    Can you attach your .cfg? Also, what version of TI-RTOS are you using?

    Todd
  • I am using TiRTOS 2.16.00.08, with drivers package 2.1.2.111 

    expEmbedded.cfg

  • Hi Shlomo,

    For non-TI-RTOS (i.e. non-SYS/BIOS) applications, Program.heap is used to determine the size of the system heap (e.g. what malloc uses).

    For TI-RTOS applications, BIOS.heapSize is used to determine the size of the system heap (also called the default heap).

    For legacy purposes, if BIOS.heapSize is not set, but Program.heap is, TI-RTOS applications use the Program.heap setting.

    If you have both in the .cfg file, Program.heap is ignored and denoted by this in the build output:

    "warning: ti.sysbios.BIOS: "C:/ti/tirtos_tivac_2_16_01_14/products/bios_6_45_02_31/packages/ti/sysbios/BIOS.xs", line 328: ti.sysbios.BIOS heapSize: BIOS.heapSize and Program.heap have both been set.  Program.heap ignored.  Using BIOS.heapSize."

    You can confirm the size of the heap in CCS->Tools->Runtime Object View->HeapMem->Detailed. For example, I used your .cfg file and got the following:

    When I commented out the BIOS.heapSize, the above totalSize was 50000. 

    For TI-RTOS applications, malloc (and Memory_alloc(NULL, ...)) use the system heap. When malloc is called, additional memory is allocated to store the size field before the buffer. So it does not surprise me that if you have a heap size of 50000 bytes, a malloc (50000) will fail. malloc(50000-8) would succeed (assuming no other memory has been allocated from the heap).

    Todd