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/TDA2P-ACD: UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!

Part Number: TDA2P-ACD

Tool/software: TI-RTOS

Hi Rishabh,

I am reopening mu previous thread

After fixing the invalid free issue I am facing some other problems. As I said earlier I have ported my algorithm code in Vision SDK which has a lot of memory allocations in between function calls.

My usecase is as below,

**********************************************************************

NetworkRx (A15) -> Decode -> VPE -> Sync -> Alg_A (DSP1) -> Display_Video

**********************************************************************

For the same algorithm, I have a separate eclipse project for executing on the Windows platform. There are lot of mathematical computations being done in this code and to verify the ported algorithm works as expected on the TDA2P platform I am verifying the output step by step.

The only difference between the original algorithm code and the ported code is that printf's, malloc's & free's are replaced with Vps_printf's, Utils_memAlloc's & Utils_memFree's respectively.

My usecase was working when I executed the algorithm with malloc & free on TDA2P platform. But after I replaced them with Utils_memAlloc  & Utils_memFree, I am not getting the expected output and after starting the usecase I am getting below error,

**********************************************************************

[DSP1 ] 73.627066 s: UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!

[DSP1 ] 73.629079 s: UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!

[DSP1 ] 73.637070 s: UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!

**********************************************************************

Can you suggest what could be the reason for this. Do I need to take care of the mathematical functions being used in my algorithm (fabs(), rand(), sqrtf()...etc) as I am getting different output values on windows platform and on TDA2Px platform after executing these functions, which is why I believe I am getting the above error.

Thanks,

Abhay

  • Hi Abhay,

    Message alloc fails when it runs out of message boxes, there are around 1K messages boxes, so either it is corrupted or all your messages are stuck somewhere.
    I would suggest first to run your new algo link without any mathematical equations.. First make sure that the chain is working fine without these equations and mem alloc/free..
    Once this starts working, please add code one by one and check which causes failure.
    Most likely the newly added algo link is not running real time and causes wait for many messages..

    Rgds,
    Brijesh
  • Hi Brijesh,

    Thanks for quick reply. Actually I verified that the chains is working when I was using malloc & free on TDA2P.
    After I replaced them with Utils_memAlloc and Utils_memFree the chain was getting stuck.
    I observed while debugging that in one my functions there is while loop with some condition. For example,

    while(var < MAX_VALUE), here the "var" is updated every time after executing some math operations, but in my case it is not updated (side by side I was debugging the same code on Windows where the value of "var" was updated). The condition is always satisfied and the control is not coming out of this while loop on TDA2P platform. And after some time I get "UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!" continuously on console.

    Regards,
    Abhay
  • Hi Abhay,

    Yes, this might be reason for running out of message boxes. Since there is busy waiting for longer duration, the messages boxes, required for the NEW_DATA command, will eventually run out..
    So why is this variable not getting updated? Is it allocated from this shared memory, which gets updated from other core? Is there a way to break this loop, if this variable is not updated for, lets say, few milliseconds..
    Please note that you are allocating memory from the cached section, every update to this memory requires cache invalidate before update and cache write back after update..

    Regards,
    Brijesh
  • Hi Brijesh,

    I will try out by adding cache_inv and cache_wr calls and will update you.

    Thanks,
    Abhay
  • Hi Abhay,

    ok, since you are adding cache operations, make sure that the allocated memory and cache size in the operations are aligned to cache line size.. Otherwise it could potentially create bigger problems..

    Rgds,
    Brijesh
  • Hi Brijesh,

    If I am not wrong, by cache line size you mean Cache_Type_ALLD right ?
    While allocating memory I have used Heap id's UTILS_HEAPID_DDR_CACHED_LOCAL & UTILS_HEAPID_DDR_CACHED_SR. So can I use "Cache_Type_ALLD" while doing cache_inv and cache_wr.
    Please suggest.

    Regards,
    Abhay
  • Abhay,

    No, this is cache type. when you are using heapid as UTILS_HEAPID_DDR_CACHED_SR, the code takes care of allocating cache line size aligned memory, but when you do cache_inv and cache_wb, you need to do this operation using aligned line size.
    If you see second parameter for these function, it is size. this should be aligned to, if i remember, 128bytes..

    Rgds,
    Brijesh
  • Hi Brijesh,

    Actually while allocating memory I have 32 as alignment as shown below,

    *************************************************************************

    pObj = Utils_memAlloc(UTILS_HEAPID_DDR_CACHED_LOCAL,

                                          sizeof(pObj),

                                          32);

    *************************************************************************

    Can this be a problem. Do I need to use 128 as alignment. I refered one example where I saw 32 as alignment so I have used the same.

    Regards,

    Abhay

  • Hi Abhay,

    For the local cached memory, it should be fine, because it is not shared and it is going to be accessed by this core only.
    I was talking about the shared memory, which is allocated using UTILS_HEAPID_DDR_CACHED_SR heapid. Here the size must be cache line size aligned.

    Rgds,
    Brijesh
  • Hi Brijesh,

    Eventually we found out by debugging that the problem was with one the mathematical functions used for hypotenuse. There was a issue with the type of variable used for the hypotenuse function which was causing the "UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!" issue. It was never a problem with the Utils_memAlloc or Utils_memFree.

    Thank you very much for your support. I am closing this thread.

    Regards,
    Abhay