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.

malloc for c66 dsp

Other Parts Discussed in Thread: SYSBIOS

hello 

I use ...

1. vision_sdk_02_05

2. ccs5.0

now...I got  a problem about memory allocate 

Q1: I try to use malloc to create memory space... the size may be under 96*160*9(int)

and the program can be compiled and run...but it has a message "ti.sysbios.heaps.HeapMem: line 307: ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x970ee298, size=552968"

Q2: I try to create more heap size for it...in C:\VISION_SDK_02_05_00_00\ti_components\drivers\starterware_01_02_04_05\examples\sbl_multicore_mbx\tda2x\lnk_dsp1
""DDR3_DSP1_HEAP : org = 0x85500000, len = 0x00500000""  to change "len"

but it doesnt work!!!

Could you please to tell me what I can do for "malloc" in c66 dsp?

Thanks a  lot.

B.R

by Alice

  • Hi Alice,

    .but it has a message "ti.sysbios.heaps.HeapMem: line 307: ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x970ee298, size=552968"

    This is the SYS/BIOS heap.  You can configure its size via the BIOS configuration (*.cfg) file in your project.  If you open it in XGCONF, you can do it here:

    Please refer to section 7.7.2 Specifying the Default System Heap of the SYS/BIOS (TI-RTOS) User's Guide.

    Steve

  • Hi Steve

    I use the alg_plugins---objectdetection to write my algorithm, and it's not belong to the project...
    So I can't enter into the SYS/BIOS heap...

    Thanks

    by Alice

  • hello Steve

    I find the memory map... The start of dsp1 is 960a7400

    But I edit the size in """""C:\VISION_SDK_02_05_00_00\ti_components\drivers\starterware_01_02_04_05\examples\sbl_multicore_mbx\tda2xx""" 

    so... I guess I edited wrong file... 

  • Hi Alice,

    The out of heap error message above is due to the HeapMem heap in your application running out.  You need to increase the size of that heap in your application (as shown in the above screen shot).

    Alice said:
    I use the alg_plugins---objectdetection to write my algorithm, and it's not belong to the project...
    So I can't enter into the SYS/BIOS heap...

    I'm not sure I follow you on this.  I don't know what the "alg_plugins---objectdetection" is.

    Are you saying that you don't have control over the size setting for the HeapMem heap?

    Steve

  • Hi Steve

    Yes, I want say that.
    For me, CCS is just a tool to load code into evm board not a code complier.
    So I can't use you way to edit the heap size.
    I try many way to find where I can edit in vision sdk 0205... but it failed...(like above 6/28 reply)

    By Alice
  • The default heap is specified in the file

    \vision_sdk\src\main_app\<soc>\dsp<n>\Dsp<n>.cfg

    <soc> = tda2xx or tda3xx or tda2ex - depending on what platform you are using

    <n> = 1 or 2 for DSP1, DSP2

    Modify line shown in bold to increase default heap size.

    Default heap is the heap used by "malloc"

    /* create a default heap */
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    var heapMemParams = new HeapMem.Params();
    heapMemParams.size = 0x80000;

    If you still face issues, let me know exact API you use to allocate memory

    regards
    Kedar

     

  • Hi Kedar

    Today, I changed the size of heapMemParams.size from 0x8000 to 0x100000

    it still show the information...

    ti.sysbios.heaps.HeapMem: line 307: ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x971e6298, size=552968


    thanks

    by Alice
  • I would need the below to guide further,

    - .map file. Present at vision_sdk\binaries\vision_sdk\bin\tda2xx-evm\vision_sdk_c66xdsp_1_debug.xe66.map

        I assume you are using TDA2xx and DSP1

    - The code snippet in which you do the alloc

    regards
    Kedar

  • 1. width and height may be 96 and 160

    2. Above columsum, it can use malloc.... But when I put into """ test""", the program would crash....

    3. the map file here

    8867.TMS320C6x Linker PC v7.docx

    Thanks 

    by Alice 

  • <1>
    Can you also send me below file
    vision_sdk\binaries\obj\vision_sdk\tda2xx-evm\c66xdsp_1\debug\vision_sdk_configuro\package\cfg\MAIN_APP_c6xdsp1_pe66.c

    <2>
    In this file you should see a array like below
    __T1_ti_sysbios_heaps_HeapMem_Instance_State__buf ti_sysbios_heaps_HeapMem_Instance_State_0_buf__A[524288];

    Here size of array is the size specified in the cfg file.

    <3>
    I suspect the heap setting you are doing it not taking effect.

    Can you confirm once again the platform and DSP you are using.

    Is it tda2xx-evm and DSP1 ?


    regards
    Kedar
  • <1>
    Can you also send me below file
    vision_sdk\binaries\obj\vision_sdk\tda2xx-evm\c66xdsp_1\debug\vision_sdk_configuro\package\cfg\MAIN_APP_c6xdsp1_pe66.c

    I found it in C:\VISION_SDK_02_05_00_00\vision_sdk\binaries\obj\vision_sdk\tda2xx-evm\c66xdsp_1\release\vision_sdk_configuro\package\cfg
    Is it suitable?

    0121.MAIN_APP_c6xdsp1_pe66.c

    <2>
    In this file you should see a array like below
    __T1_ti_sysbios_heaps_HeapMem_Instance_State__buf ti_sysbios_heaps_HeapMem_Instance_State_0_buf__A[524288];

    Here size of array is the size specified in the cfg file.

    So... I modify the heap size here?

    <3>
    I suspect the heap setting you are doing it not taking effect.

    Can you confirm once again the platform and DSP you are using.

    Is it tda2xx-evm and DSP1 ?
     

    Yes,it is tda2x-evm and dsp1...



    regards
    Kedar

    Thanks

    BY Alice

  • Your heap size is 32*KB (0x8000)

    __T1_ti_sysbios_heaps_HeapMem_Instance_State__buf ti_sysbios_heaps_HeapMem_Instance_State_0_buf__A[32768];

    Can confirm you changed in the .cfg file as shown below ?

    Put additional prints in the .cfg file to confirm the change is taking effect, you should see the print during compiling.

    vision_sdk\src\main_app\tda2xx\dsp1\Dsp1.cfg

    heapMemParams.size = 0x100000; // for 1MB heap size

    xdc.print("# !!! Heap size is [" + heapMemParams.size + "] bytes !!!" );

    regards

    Kedar

  • Your heap size is 32*KB (0x8000)

    __T1_ti_sysbios_heaps_HeapMem_Instance_State__buf ti_sysbios_heaps_HeapMem_Instance_State_0_buf__A[32768];

    Can confirm you changed in the .cfg file as shown below ?

    Put additional prints in the .cfg file to confirm the change is taking effect, you should see the print during compiling.

    vision_sdk\src\main_app\tda2xx\dsp1\Dsp1.cfg

    heapMemParams.size = 0x100000; // for 1MB heap size

    xdc.print("# !!! Heap size is [" + heapMemParams.size + "] bytes !!!" );

    regards

    Kedar



    I re-compile...(gmake -s claen >> gmake -s all)

    but it has error...

    thanks


    by Alice

  • You have syntax error, the it should be

    heapMemParams.size = 0x100000;

    what you have is

    heapMemParams.size = 0x 0x100000;

    regards
    Kedar

  • HI Kedar

    Thanks ur solution...but it still has error...

    DSP1  ]    543.819366 s:  ### XDC ASSERT - ERROR CALLBACK START ###

    [DSP1  ]    543.819396 s:

    [DSP1  ]    543.819458 s: out of memory: handle=0x971e62c8, size=552968

    [DSP1  ]    543.819488 s:

    [DSP1  ]    543.819488 s:  ### XDC ASSERT - ERROR CALLBACK END ###

    Thanks

    BY Alice

  • I compiled at my end and I see below line in file, can you confirm you see the same,

    D:\ti\VISION_SDK_02_05_00_00\vision_sdk\binaries\obj\vision_sdk\tda2xx-evm\c66xdsp_1\release\vision_sdk_configuro\package\cfg\MAIN_APP_c6xdsp1_pe66.c

    Around Line 4188: __T1_ti_sysbios_heaps_HeapMem_Instance_State__buf ti_sysbios_heaps_HeapMem_Instance_State_0_buf__A[1048576];

    regards
    Kedar

  • hi Kedar

    The information is same as you...

    But it still appears error...

    Thanks

    By Alice

  • The heap size is getting reflected now.

    Now either you need more heap, so try increasing the heap size further to say 8MB or something

    OR

    malloc() is getting defined multiple times and its not using the heap whose size we increased.

    Try using below instead of malloc. Normally malloc should be using this heap.

    #include <xdc/runtime/Memory.h>
    #include <xdc/runtime/Error.h>

    void *my_alloc(unsigned int size);
    void my_free(void *addr, unsigned int size);

    void *my_alloc(unsigned int size)
    {
        Error_Block ebObj;

        return Memory_alloc(Memory_defaultHeapInstance,
                            size,
                            4,
                            &ebObj);
    }

    void my_free(void *addr, unsigned int size)
    {
        Memory_free(Memory_defaultHeapInstance,
                    addr,
                    size);
    }

    regards
    Kedar

  • Dear Kedar 

    1.

    I try to increase the heap size to 8MB, but it still has error (below the pic)

    Weird thing is "the size" gets much bigger than last times (check to above reply) 

    2.

    I try second solution...

    ti.sysbios.heaps.HeapMem: line 307: ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x978e8048, size=1281744

    Thanks

    BY Alice

  • Dear Kedar

    Could you tell me which file can read the memory space on dsp1?

    like...heap(or stack) from which memory allocation and its length...

    ex....

    DR3_DSP1_DATA : org = 0x84600000, len = 0x00A00000
    DDR3_DSP1_STACK :org = 0x85000000, len = 0x00500000
    DDR3_DSP1_HEAP : org = 0x85500000, len = 0x00D00000

    I need this file to check what happened for my problem I meet now...

    Thanks

    BY Alice

  • See .map file present here for the CPU you are interested in

    \vision_sdk\binaries\vision_sdk\bin\tda2xx-evm

    regards
    Kedar

  • DEAR Kedar

    I knew this file...

    I wanna ask that ... Is there the "simple" file just introduce stack and heap size...
    I can know where heap(or stack) memory starts and its len...

    Thanks

    BY Alice
  • No, that's the only way to know this information.

    regards
    Kedar

  • DEAR Kedar

    How I can know "heap and stack", whether they affect each other...

    Thanks

    BY Alice