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.

memory allocation on msmc

Other Parts Discussed in Thread: SYSBIOS

Hi all,

I wanna allocate a size of memory on MSMC. Currently the only way I know is to use TI extensions. However, I suppose the allocation happens on the ARM side and use gcc compiler. And the allocated memory could be shared by the DSP, as MSMC is shared by ARM and DSP.

However, how can I allocate an array on MSMC from the DSP side, which is compilable by cl6x DSP compiler?

Does there exist a way to do that?

Thanks

Cheng

  • Something like:

    In C code:

    #pragma DATA_SECTION(arrayA, ".dataBuffer")
    uint32_t arrayA[1024];

    Then in your linker command file:

    SECTIONS
    {
        .dataBuffer   > MSMCRAM
    }

    The range of the MSMCRAM either can be defined in  linker command file, or from RTSC platform.

    Regards, Eric

  • Thanks, Eric,

    Attached is the linker command file I used for KS II. I renamed the suffix to .txt in order to upload it.

    Is that the right one for  KSII? I was used for KS I, but seems that the L2 and  SHRAM is just a subset of KS II. 

    So in that file, the SHRAM must be the MSMCRAM you showed in your example, right?

    Another quick question, If I created an array using malloc(), e.g. int *a = (int *)malloc(n * sizeof(int)), which data section it will be located?

    Thanks

    Cheng

    6064.c6678_unified.txt

  • KS II has 6MB MSMC and 1M L2 per core, you need to check with datasheet to update the memory range. If you use malloc, it is allocated from heap.
    Regards, Eric

     

  • But where is the heap resided? On MSMC or DDR? From the linker command, I did not find a data section called .heap ? Or heap has another name in the name section? I just wanna control an array allocated using malloc() to either ddr or msmc...

    Cheng

  • I found heap can be defined in SYSBIOS, is that working for you? Attached is a .cfg file where defined a heap and placed into DDR.

    /*

    ** Create a Heap.

    */

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

    var heapMemParams = new HeapMem.Params();

    heapMemParams.size = 0x300000;

    heapMemParams.sectionName = "systemHeap";

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

    /* This is the default memory heap. */

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

    Regards, Eric

    5074.helloWorld.cfg

  • Yes, exactly. I also found a probably easier way to define a heap on DDR or MSMC. 

    According to 

    Dynamic memory allocation is not a standard part of the C language. The
    run-time-support library supplied with the C6000 compiler contains several
    functions (such as malloc, calloc, and realloc) that allow you to allocate
    memory dynamically for variables at run-time.
    Memory is allocated from a global pool, or heap, that is defined in the .sysmem
    section. You can set the size of the .sysmem section by using the −heap size
    option with the linker command. The linker also creates a global symbol,
    __SYSMEM_SIZE, and assigns it a value equal to the size of the heap in
    bytes. The default size is 0x400 bytes. For more information on the −heap
    option, see section 5.2, Linker Options, on page 5-6.
    So I can control the heap on DDR or MSMC by editing .sysmem data section. Is that correct?
    Thanks
    Cheng
  • Yes, I tried and it worked.

    Regards, Eric