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.

Moving default system heap memory dynamically to a different region

Other Parts Discussed in Thread: SYSBIOS

hi,

In DSP/BIOS 5.xx, MEM_redefine of MEM module can be used for moving default heap memory to a different region. But this API is not working fine for SYS/BIOS 6.xx. Is there any way, I can move the default system heap memory runtime in SYS/BIOS 6.xx?

Please help me in this regard.

Thanks and regards,

Lijo

 

  • Hi Lijo,

    In BIOS 6.xx, the dafault system heap located in target's default data section.

    And you can reassign it in ti.sysbios.BIOS module by the following option:

    BIOS.heapSection = ''myheap";

    BIOS.heapSize = 0x4000;

    Through these options, you put the system heap in a section called "myheap" and a size of 0x4000. Then put the section "myheap" into any region in your cmd link file like

    SECTIONS{

    myheap > DDR3

    }

    or directly setup in cfg file like:

    Program.sectMap["myheap"]      = "DDR3";

  • Thank you for the reply.

    This approach will move the default heap statically.  The heap will be assigned while linking.

    What I am looking for is, to move the default heap dynamically (Runtime.) . I need to move the system heap to a specific location in the main function.

     

  • Hi Lijo --

    Which version of SYS/BIOS are you using?  And which device?

    You can use HeapMem_construct() for this.   You need to create a small heap in local L2 memory.  64 bytes is big enough.  For ELF targets, this local heap is used during boot time to allocate a small structure for atexit().  Then you can use HeapMem_construct() to reconstruct this heap with different parameters.

    I've attached some sample code that should help. 

    4645.memconstruct.zip

    Note that you need something like this in your .cfg file:

    /*
     * The BIOS module will create the default heap for the system.
     * Specify the size of this default heap.
     */
    // BIOS.heapSize = 0x1000;

    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    var myHeapParams = new HeapMem.Params;
    myHeapParams.sectionName = ".bootHeap";
    myHeapParams.size = 64;
    Program.global.myHeap = HeapMem.create(myHeapParams);

    Memory.defaultHeapInstance = Program.global.myHeap;

    Program.sectMap[".bootHeap"] = new Program.SectionSpec();
    Program.sectMap[".bootHeap"].loadSegment = "L2SRAM";

    and something like this in main():

    Void main()
    {
        Task_Handle task;
        Error_Block eb;
        HeapMem_Params heapParams;
        HeapMem_Params_init(&heapParams);
        heapParams.buf = memoryBlock;
        heapParams.size = MEMORYBLOCKSIZE;
        HeapMem_construct((HeapMem_Struct *)myHeap, &heapParams);

    Regards,
    -Karl-

  • Hi Karl,

    Thank you for the fix. With this, the application seems working as the way I wanted.

    I am using c6678l EVM. with sys-bios version bios_6_32_04_49 .

    Thanks and regards,

    Lijo