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/TMS320C6654: Select heap used by sysbios

Part Number: TMS320C6654
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi,

I have in my project a big heap that is placed into DDR3:

BIOS.heapSize = 262144;
BIOS.heapSection = "HEAP_SECTION";

Program.sectMap["HEAP_SECTION"] = new Program.SectionSpec();
Program.sectMap["HEAP_SECTION"].loadSegment = "DDR3";

I've discovered that sysbios Hwi store its dispatchTable into the heap. To avoid performance issue I want to split my heap to put a small part in L2 and the big part in DDR3. So I've created a new heap and defined it as default. I've assumed that sysbios Hwi will continue to use "BIOS heap" and that "new ()" in my code will go into this default heap, but Hwi also used this default heap:

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params;
heapMemParams.size = 262144;
heapMemParams.sectionName = ".myHeap";
Program.global.heap1 = HeapMem.create(heapMemParams);
Defaults.common$.instanceHeap = Program.global.heap1;

Program.sectMap["HEAP_SECTION"] = new Program.SectionSpec();
Program.sectMap["HEAP_SECTION"].loadSegment = "L2SRAM";
Program.sectMap[".myHeap"] = new Program.SectionSpec();
Program.sectMap[".myHeap"].loadSegment = "DDR3";

How is it possible to put sysbios allocated memory into L2 and memory allocated by me in DDR3?

thanks

(I'm using sysbios 6.46.00.23, xdctool 3.32.00.06, compiler 7.4.16)

  • Hi Gildas,

    I've forwarded this to the software team. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Gildas,
    it seems that you still have only one heap "heap1". You did create a section "HEAP_SECTION" in L2, but you didn't allocate any heap there. You need:
    ...
    heapparams.sectionName = "HEAP_SECTION";
    Program.global.heap2 = HeapMem.create(heapparams);

    That said, can you tell me why do you think that dispatchTable is in a heap? In an example I was looking at, I can see that 'dispatchTable' is a part of the Hwi's Module_State and that means it's statically defined and it should be in .data or somewhere similar.
  • I've keep the bios heap definition in addition with the new .myHeap:

    BIOS.heapSize = 262144;

    BIOS.heapSection = "HEAP_SECTION";

    Both heap appear in my map file.

    I've put a breakpoint on Hwi_dispatchCore and look with ccs ti_sysbios_family_c64p_Hwi_Module__state__V. This structure contains a field dispatchTable[16] of type ti_sysbios_c64p_Hwi_Object*. The address contained in value from [5] to [12] (corresponding to my used interrupts) are all corresponding to adress in my heap:

    run origin  load origin   length   init length attrs members

    ----------  ----------- ---------- ----------- ----- -------

     9c68ee80    9c68ee80    00050000   00000000    rw- HEAP_SECTION

    So it's not the dispatchTable that is in heap but the object pointed by dispatchTable

    Gildas

  • Sorry, I assumed you want the actual dispatch table to be in your heap, not Hwi instances.
    So, you have two heaps, which you can refer to as Program.global.heap1 and Memory.defaultHeapInstance.
    If you want only Hwi instances to go to the default heap, you have to do this:
    Defaults.common$.instanceHeap = Program.global.heap1;
    Hwi.common$.instanceHeap = Memory.defaultHeapInstance;

    If you want instances of some other modules to also go to the BIOS heap, you'll have to specify their instance heap as I did for 'Hwi'.

    Are you using C++? If yes, I would have to check what happens with new(). The calls to malloc() go to the BIOS heap, but I don't know about new().
  • Hi,

    Hwi objects are still going in heap in DDR3. This is the extract of my cfg file:

    BIOS.libType = BIOS.LibType_NonInstrumented;

    BIOS.cpuFreq.lo = 850000000;

    BIOS.heapSize = 196608;

    BIOS.heapSection = "HEAP_SECTION";

    BIOS.assertsEnabled = false;

    BIOS.logsEnabled = false;

    BIOS.clockEnabled = false;

    var Defaults = xdc.useModule('xdc.runtime.Defaults');

    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');

    var heapMemParams = new HeapMem.Params;

    var Memory = xdc.useModule('xdc.runtime.Memory');

    heapMemParams.size = 196608;

    heapMemParams.sectionName = ".myHeap";

    Program.global.heap1 = HeapMem.create(heapMemParams);

    Defaults.common$.instanceHeap = Program.global.heap1;

    Hwi.common$.instanceHeap = Memory.defaultHeapInstance;

    Program.sectMap["HEAP_SECTION"] = new Program.SectionSpec();

    Program.sectMap["HEAP_SECTION"].loadSegment = "L2SRAM";

    Program.sectMap[".myHeap"] = new Program.SectionSpec();

    Program.sectMap[".myHeap"].loadSegment = "DDR3";

     

    I don't know if it's help you but Memory_getStats tell me that 854 bytes are used in bios heap. I try to comment Hwi.common$.instanceHeap definition but I always have 854. I don't know what is placed in this heap, but Hwi objets seems to not be in this one.

     

    Yes I'm using C++

     

    regards

  • Can you check that Hwi referenced in your code snippet is a reference to ti.sysbios.family.c64p.Hwi? Could you also post .map file? Can you also find the variable ti_sysbios_heaps_HeapMem_Object__table__V in Memory Browser and screenshot its content? That's where the defined heaps are and their buffer addresses should be visible there.
  • Previously I used var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');

    I change to var Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi'); but it doesn't change anything

    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
      0085b340    0085b340    00030000   00000000    rw- HEAP_SECTION
      9c68ee80    9c68ee80    00030000   00000000    rw- .myHeap

    I can send you in private my map file, but don't want to post it here

  • I've tried several configuration and find one that seems to do what I want, but I'm not sure if it's clean. I just have an issue to monitoring heap.
    previously I use
    Memory_getStats( BIOS_Module_heap(), &stats );
    to get usage of the stack. I've replaced this by
    Memory_getStats( BIOS_Module_heap(), &stats );
    HeapMem_getStats(heap1, &stats);
    but these 2 function now return the usage of my heap and I don't know how to get sysbios heap usage

    I have removed Hwi.common$.instanceHeap definition as it never change anything.

    Please give me your advice on my new configuration (change of defaut heap definitipon, change of heap size, reverse heap allocation in ram):
    BIOS.libType = BIOS.LibType_NonInstrumented;
    BIOS.cpuFreq.lo = 850000000;
    BIOS.heapSize = 262144;
    BIOS.heapSection = "HEAP_SECTION";
    BIOS.assertsEnabled = false;
    BIOS.logsEnabled = false;
    BIOS.clockEnabled = false;

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    var heapMemParams = new HeapMem.Params;
    heapMemParams.size = 2048;
    heapMemParams.sectionName = ".myHeap";
    Program.global.heap1 = HeapMem.create(heapMemParams);
    Defaults.common$.instanceHeap = Program.global.heap1;

    Program.sectMap["HEAP_SECTION"] = new Program.SectionSpec();
    Program.sectMap["HEAP_SECTION"].loadSegment = "DDR3";
    Program.sectMap[".myHeap"] = new Program.SectionSpec();
    Program.sectMap[".myHeap"].loadSegment = "L2SRAM";
  • Your new configuration doesn't look different from the one that you started from except for different sizes. Are you saying that Hwi instances are now in L2SRAM? That seems unlikely to happen just by changing heap sizes, but if it does what you want then great!
    As for heap stats, I'll have to ask someone else more familiar with that code to respond.
  • The call to BIOS_Module_heap() returns the heap that's asigned to the module BIOS, which is 'heap1' because of that assignment to Default.common$.instanceHeap. If you want the default heap, you need to pass NULL to Memory_getStats:
    Memory_getStats(NULL, &stats);
  • My understand is that :
    - C++ new () still use the BIOS.heap and not the heap defined as default
    - Hwi use the default heap to put its objetcs
    So I've changed the placement of my 2 heaps in memory and adjust the size (big in DDR3 and small in L2)

    Your answer also help me to get statistics for both heap

    Thanks for your help