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.

C6678 MessageQ error

hi,I met a problem with c6678.I use MessageQ to transfer data with 8 cores

but there is always a bug when the program run a long time.That is 

TMsgQHeader* ptMsgQHead = NULL;

ptMsgQHead = (TMsgQHeader*)MessageQ_alloc(HEAPMP_ID, sizeof(TMsgQHeader));
if (ptMsgQHead == NULL)
{
u32 dwMsgNums = MessageQ_count(m_msgQHandle);
PciePrintf("MessageQ_alloc failed:%d--%d,%d\n", dwMsgNums, m_dwSendCount, m_dwRecvCount);
return Codec_Error_MSGQ_Memory;
}

I create the MessageQ with code like this:

if (MultiProc_self() == COREID0)
{
/*
* Create the heap that will be used to allocate messages.
*/
HeapBufMP_Params_init(&m_heapBufParams);
m_heapBufParams.regionId = 0;
m_heapBufParams.name = (String)g_szHeapMpNameList[COREID0];
m_heapBufParams.numBlocks = MSGQ_BUF_NUM_MAX;//6000
m_heapBufParams.blockSize = sizeof(TMsgQHeader);

m_heapHandle = HeapBufMP_create(&m_heapBufParams);
if (m_heapHandle == NULL)
{
printf("HeapBufMP_create failed\n" );
return Codec_Error_MSGQ_Init;
}
}
else
{
/* Open the heap created by the other processor. Loop until opened. */
do
{
nStatus = HeapBufMP_open((String)g_szHeapMpNameList[COREID0], &m_heapHandle);
/*
* Sleep for 1 clock tick to avoid inundating remote processor
* with interrupts if open failed
*/
if (nStatus < 0)
{
Task_sleep(1);
}
} while (nStatus < 0);
}
/* Register this heap with MessageQ */
MessageQ_registerHeap((IHeap_Handle)m_heapHandle, HEAPMP_ID);
//////////////////////////////////////////////////////////////////////////
//MessageQ
//u32 dwLocalcoreId = MultiProc_self();
m_dwLocalCoreId = MultiProc_self();
System_sprintf(m_szMsgQName, "%s", MultiProc_getName(m_dwLocalCoreId));

/* Create a message queue using SyncSem as synchronizer */
SyncSem_Handle syncSemHandle = NULL;
syncSemHandle = SyncSem_create(NULL, NULL);

/* Create the local message queue */
/*每个核都创建一个messageQ,*/
MessageQ_Params msgQParams;
MessageQ_Params_init(&msgQParams);
msgQParams.synchronizer = SyncSem_Handle_upCast(syncSemHandle);
m_msgQHandle = MessageQ_create(m_szMsgQName, &msgQParams);
if (m_msgQHandle == NULL)
{
printf("MessageQ_create failed:%d\n", __LINE__);
return Codec_Error_MSGQ_Init;
}

I use the MessageQ API like this:

MessageQ_alloc-->MessageQ_put

MessageQ_get-->MessageQ_free

I dont know what mistake I made?

the program can run 1442min,then it report error

sometimes it report MessageQ alloc error,but sometimes it report nothing,just like breakdown

i try to use emulator to debug the program, but i just can debug the core0.If i connect all the 8 cores and load the program,then run it,it doesnt work

please help me,ths

  • Hi Snow Wang,

     

    What's your goal with this exercise excatly? It isn't usual to run a program for over 1000 minutes. You mose likely either haven't allocated enough memory for the MessageQ to be able to run that long, or run at all. If you only debug core 0, the system should work since the other cores use that as a master core.

    I suspect the issue is with your memory allocation. Make sure you have enough space there to run your program, and that you are properly removing the MessageQ after you get it. It might be that some MessageQs are still stuck in memory, causing your memory to fill up too quickly.

     

    Kat Kelsch

  • Hi Kat Kelsch,

       Thanks for ur reply.

       I configure the share region for MessageQ with 4MB,and create HeapBuf's block num is 6000.

    /* Shared Memory base address and length */
    var SHAREDMEM = 0x0C000000;
    var SHAREDMEMSIZE = 0x00400000;

    /*
    * Need to define the shared region. The IPC modules use this
    * to make portable pointers. All processors need to add this
    * call with their base address of the shared memory region.
    * If the processor cannot access the memory, do not add it.
    */
    var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
    SharedRegion.setEntryMeta(0,
    { base: SHAREDMEM,
    len: SHAREDMEMSIZE,
    ownerProcId: 0,
    isValid: true,
    name: "MESGQ",
    });

    Exactly when I get one one MessageQ buffer, I free it.

    But it is strange that I call the MessageQ_count(), it always return 0.

    How can I get the right MessageQ nums that are stuck in the memory?

  • another problem is when I configure the 8 cores as one group to load and debug the program.I set a breakpoint on core3.but ccs report error:

    C66xx_3: Can't Synchronize Parallel Debug Execution 

    How can I debug the core3 separately?

  • If it fails after such a long time there is a good chance of memory leak somewhere. Try to check all your heaps by calling heap statistics functions from time to time.

  • I call the heap statistics functions to get stack and memory info,but no find any memory leak or overflow.

    Task_Stat statTask;
    Memory_Stats statMemory;

    //task status
    Task_stat(tsk, &statTask);

    //heap status
    Memory_getStats(statTask.stackHeap, &statMemory);

    I am still confused about How to get the exactly MessageQ nums that are stuck in the memory?And How to debug the core3 separately?

    Thanks

  • Do you check?

    IHeap_Handle Task_Module_heap();
    // The heap from which this module allocates memory
  • Yes

    //task status
    Task_stat(Task_self(), &statTask);

    this function get the task info, include the heap handle.

    statTask.stackHeap-->this is the task's memory handle

    //heap status
    Memory_getStats(statTask.stackHeap, &statMemory);

    Then I call this function to get the memory info.

    Who can answer my question?I cannot get the MessageQ nums,and cannot debug the core3 separately

  • the default memory handel is NULL, and memory heap size is 64k(I have modified) and all 8 cores cost 45k of the default memory space.

    the default task stack size is 8K and the maximum that the task used is 59%.

  • Hi Kat Kelsch and Alexey,

    Do u have some other suggestions?

    PS.I use CCS5.0.3 and MCSDK2.0.4.16

    Thanks

  • Hi Snow,

    The thing I notice the most about your situation is the fact that you are currently unable to get a count from MessageQ. That makes me believe that you're not putting the messages away properly, causing the count to be zero since the messages are never in memory. Which may be why it has memory leak, since your memory is taken up by messages that are meant to be somewhere else. Can you verify that the messages are actually going where they're supposed to?

      As far as debugging cores separately, I don't think you'll need to do that. Core 0 typically is the master core, and the other cores just follow direction. The best way to decode is to setup the debugging in CCS, and then to step into the code line by line to see what the system is doing. You might find something that surprises you that is your problem.

     

     

    Hope this helps!

    Kat Kelsch

  • Hi Kat Kelsch,

    I really appreciate ur hejp and thank Alexey too.

    I update the MCSDK 2.1.2.5,but it doesnt work.

    Then I follow ur advices to verify every MessageQ Buf and Address.I found sometimes the program used a buf that had been sent to another core.

    It is really hard to find the memory address error that cost my plenty of time cause I have to run the program over 1000min.I am so lucky to find it.

    It means that two cores use the same memory address at the same time!

    I hope it is the right reason that the program crashes.

    I will run it all the weekends and check it whether OK or breakdown.

    Thanks

  • I am still doing the test and I can confirm the answer tomorrow.Once I get the result, I will tell u!