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/TDA3: TDA3x

Part Number: TDA3

Tool/software: TI-RTOS

Hi,I come across some problems with Utils_memAlloc() function.I want to alloc all my space on L2SRAM,

 [DSP2  ]     35.259501 s:  SYSTEM: Heap = LOCAL_L2             @ 0x00800000, Total size = 227264 B (221 KB), Free size = 227264 B (221 KB)

which is          float * outputtmp1 = (float*)Utils_memAlloc(UTILS_HEAPID_L2_LOCAL,input1_mat->cols*2*input1_mat->rows*sizeof(float),8);

I find out that the system will open space where there already been alloced(I do not free it)

For example:

[DSP2  ]     35.358872 s:  z.data_pt is 800000

[DSP2  ]     35.358903 s: z_ipl.data_pt is 800800
[DSP2  ]     35.359391 s: tracker_pt->tmpl.data_pt is 801000
[DSP2  ]     35.359635 s: tracker_pt->hann.data_pt is 803000
[DSP2  ]     35.359665 s: hann1t.data_pt is 805000
[DSP2  ]     35.359696 s: hann2t.data_pt is 805080
[DSP2  ]     35.359726 s: hann2d.data_pt is 805180


[DSP2  ]     35.360153 s: tracker_pt->prob.data_pt is 800000

[DSP2  ]     35.360641 s: outputtmp2 in createGaussianPeak is 804000

before alloc  tracker_pt->prob.data_pt,   I free  z.data_pt and z_ipl.data_pt,  but I do not free tracker_pt->tmpl.data_pt  and tracker_pt->hann.data_pt .So when I alloc tracker_pt->prob.data_pt,the data in tracker_pt->tmpl.data_pt is gone.How does it happen?

Firstly I think there is enough space for the heap because after that there is:output2 in GuassCorrelation is 820000.Secondly,I use UTILS_HEAPID_DDR_CACHED_LOCAL replace  UTILS_HEAPID_L2_LOCAL,it goes perfectly.So I do not think there exits memory leak.

Thanks

Chen 

  • Hi,

    Can you please add log before allocation and freeing memory and share the log of all allocation and freeing memory with pointer address and its size for a single run.

    Regards,
    Anuj
  • Hi,Anuj:

    I will do it.But first I want to tell you something more I find about the alloc and free on L2_SRAM for tda3x.(with alloc and free short for Utils_memAlloc(UTILS_HEAPID_L2_LOCAL,...,8) and Utils_memFree(UTILS_HEAPID_L2_LOCAL,...,8) )

    alloc(a);

    alloc(b);

    alloc(c);

    alloc(d);

    ......

    ......

    ......

    free(b)

    free(a)

    alloc(e);

    alloc(f);

    ......

    free(d);

    free(c);

    free(f);

    free(e);

    explain:   I alloc space for a b c d,for some reason I need to keep c d for a longer time,but I free a and b because they are OK to free.I cannot free c and d now.Also I need to alloc e and f.When I alloc e and f,trouble comes. e starts from where a used to be.But in this case, e needs to be a bigger memory. Remember that c and d are still there,not free.So the data in e just overlap with c.

    My question is that is this the mechanism for tda3x of allocing and freeing space on L2 because there is no problem if I choose to to this on ddr?Thanks and I will do what you have suggested.Thanks 

  • Hi,

    If you use local l2 the you will face this issue as we do not actually allocate memory, we just use the static address.
    So in VSDK, we have assumption that all allocation we be during create phase and all free will happen during delete.

    Still you can use it by some modification in Utils_memAlloc and Utils_memFree api and add your own logic but this will be trickier and may cause some issue in existing VSDK, so i will suggest to go with DDR.

    If you want to use dynamic memory allocation then use it from DDR where memory allocation happened using some utility instead of directly assigning an address and everything is maintained properly.

    Regards,
    Anuj
  • Hi,Anuj:

    About your comment about local l2,I may have  made a mistake,I will correct my discription below,alos I have two questions:

    1)you say"as we do not actually allocate memory, we just use the static address.",

    but in the log message printed through serial port,it says "[DSP1  ]     31.665802 s:  SYSTEM: Heap = LOCAL_L2             @ 0x00800000, Total size = 227264 B (221 KB), Free size = 227264 B (221 KB)"

    I think in this case you mean "DSP1_L2_SRAM " or "DSP2_L2_SRAM",but in this case,I mean "L2SRAM",which starts form 0x00800000.Since you have set such a big heap on SRAM,I bet you will allocate memory.Also when I set the argument of the Utils_memAlloc to "UTILS_HEAPID_L2_LOCAL",I can have the address starting from 0x00800000.

    All the question above is about this part of memory.You recommend me to use ddr,but in ddr the time spend is too much.So my question again:if use the heap of "L2SRAM"(start from 0x00800000),I will still meet the problem metioned above,Is it the mechanism of using heap on "L2SRAM" as I mentioned above?

    2)In the folder "....\vision_sdk\binaries\apps\tda3xx_evm_bios_all\vision_sdk\bin\tda3xx-evm\vision_sdk_c66xdsp_1_release.xe66.map",

    I can see the map file.I notice that the stack was on "L2SRAM".There is only one stack for the whole system?Because I think size of 0x800 is not enough for me.But the room for L2SRAM is not enough.Where and How can I change the size of stack and the place of the stack?Thank you!

    .stack     0    008377c0    00000800     UNINITIALIZED
                      008377c0    00000008     boot.ae66 : boot.oe66 (.stack)
                      008377c8    000007f8     --HOLE--

    mechanism