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.

IPC_COMMUNICATION ??

Hi,

I want to run the example code of IPC in CCS 5.2 .

BIOS :6.34.02.18

IPC:1.25.00.04

FAmily:C6000 and processor as C6678,

I want to run the ipc example code :

IPC & I/O example -> C6678 Examples -> C6678:MessageQ (Single image for all cores) .

I tried to run on simulator and I got the result that is nothing but - message sent among all eight cores.

But I want to run the 2 cores only .So i used Ipc_attach() and Ipc_detach() API's in my code and I got the following error:

[TMS320C66x_0] number of cores are 8
LocalQueueName :CORE0
NextQueueName  :CORE1
ti.sdo.ipc.Ipc: line 103: assertion failure: A_invArgument: Invalid argument supplied
xdc.runtime.Error.raise: terminating execution
[TMS320C66x_1] number of cores are 8
LocalQueueName :CORE1
NextQueueName  :CORE2
ti.sdo.ipc.Ipc: line 103: assertion failure: A_invArgument: Invalid argument supplied
xdc.runtime.Error.raise: terminating execution


PLease help me resolving this issue.I have modified my .cfg file also.

Pfa my .c and .cfg file with this.

#include <stdio.h>

#include <xdc/std.h>
#include <string.h>
/*  -----------------------------------XDC.RUNTIME module Headers    */
#include <xdc/runtime/System.h>
#include <xdc/runtime/IHeap.h>

/*  ----------------------------------- IPC module Headers           */
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/MultiProc.h>
#include <ti/ipc/HeapBufMP.h>

/*  ----------------------------------- BIOS6 module Headers         */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

#include <xdc/cfg/global.h>

#define HEAP_NAME   "myHeapBuf"
#define HEAPID      0
#define NUMLOOPS    2

Char localQueueName[10];
Char nextQueueName[10];
UInt16 nextProcId;
UInt16 proc_id;
Void tsk0_func(
				UArg arg0 ,
		        UArg arg1
		      ){
    Int              		status;
    MessageQ_Msg     		msg;
    MessageQ_Handle  		messageQ;
    MessageQ_QueueId 		remoteQueueId;
    UInt16                  msgId = 0;
    HeapBufMP_Handle        heapHandle;
    HeapBufMP_Params        heapBufParams;

	if (MultiProc_self() == 0) {
			printf("Create the heap that will be used to allocate messages.\n");fflush(stdout);
			HeapBufMP_Params_init(&heapBufParams);
	        heapBufParams.regionId       = 0;
	        heapBufParams.name           = HEAP_NAME;
	        heapBufParams.numBlocks      = 1;
	        heapBufParams.blockSize      = sizeof(MessageQ_MsgHeader);
	        heapHandle = HeapBufMP_create(&heapBufParams);
	        if (heapHandle == NULL) {
	            System_abort("HeapBufMP_create failed\n" );
	        }
	}
	else{
		printf("Opened the heap created by the other processor. Loop until opened \n");fflush(stdout);
		do{
			 status = HeapBufMP_open(HEAP_NAME, &heapHandle);

	            if (status < 0) {
	                Task_sleep(1);
	            }
		}while(status<0);

	}
    printf("Registered this heap with MessageQ \n");fflush(stdout);
    printf("Register this heap with MessageQ \n");
    MessageQ_registerHeap((IHeap_Handle)(heapHandle), HEAPID);
    printf("Created the local message queue that is LocalQueueName queue \n");fflush(stdout);
    messageQ = MessageQ_create(localQueueName, NULL);
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n" );
    }
    printf("Open the remote message queue. Spin until it is ready \n");fflush(stdout);
    do {
           status = MessageQ_open(nextQueueName, &remoteQueueId);
           /*
            *  Sleep for 1 clock tick to avoid inundating remote processor
            *  with interrupts if open failed
            */
           if (status < 0) {
               Task_sleep(1);
           }
       } while (status < 0);
    if (MultiProc_self() == 0) {
        printf("Allocate a message to be ping-ponged around the processors \n");fflush(stdout);
        msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader));
        if (msg == NULL) {
           System_abort("MessageQ_alloc failed\n" );
        }
      printf("Send the message to the next processor and wait for a message from the previous processor.\n");
      fflush(stdout);
      printf("Start the main loop\n");
      while (msgId < NUMLOOPS) {
          printf("Increment...the remote side will check this\n");fflush(stdout);
          msgId++;
          MessageQ_setMsgId(msg, msgId);
          System_printf("Sending a message #%d to %s\n", msgId, nextQueueName);fflush(stdout);

          status = MessageQ_put(remoteQueueId, msg);
          if (status < 0) {
          System_abort("MessageQ_put had a failure/error\n");
          }
          printf("sent the message to the remote processor \n");
          status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
          if (status < 0) {
              System_abort("This should not happen since timeout is forever\n");
          }
          printf("got a message \n");fflush(stdout);
      }
    }
    else{
    	printf("Wait for a message from the previous processor and send it to the next processor \n");fflush(stdout);
    	printf("Start the main loop\n");
    	 while (1){
    		 printf("Get a message\n");fflush(stdout);
             status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
             if (status < 0) {
                System_abort("This should not happen since timeout is forever\n");
             }
             System_printf("Sending a message #%d to %s\n", MessageQ_getMsgId(msg),
                             nextQueueName);
             printf("Get a message ID\n");fflush(stdout);
             msgId = MessageQ_getMsgId(msg);
             printf("send the message to the remote processor\n");fflush(stdout);
             status = MessageQ_put(remoteQueueId, msg);
             if (status < 0) {
                    System_abort("MessageQ_put had a failure/error\n");
             }
             printf("test done\n");fflush(stdout);
             if (msgId >= NUMLOOPS) {
                 break;
             }
    	 }
    }
    while (TRUE)                                 /* IPC DETACH FUNCTION IS CALLING HERE */
    {
    	printf("137\n");fflush(stdout);
        status = Ipc_detach(proc_id);
        printf("139\n");fflush(stdout);
        if (status == Ipc_E_NOTREADY) {
            Task_sleep(1);
        }
        else if (status < 0) {
            System_printf("Ipc_detach failed \n");
            break;
        }
        else {
           break;
        }
        printf("150\n");fflush(stdout);
    }
    printf("The test is complete\n");
    BIOS_exit(0);


}


int main(int argc, char* argv[]){

    Int status;
    Int loop_num_processor;
    Int Numprocessor = 0;
    proc_id = MultiProc_self();
    nextProcId   = (MultiProc_self() + 1) % MultiProc_getNumProcessors();
    Numprocessor = MultiProc_getNumProcessors();
    printf("number of cores are %d \n",Numprocessor);fflush(stdout);
    printf("LocalQueueName :%s \n", MultiProc_getName(MultiProc_self()));fflush(stdout);
    printf("NextQueueName  :%s \n",  MultiProc_getName(nextProcId));fflush(stdout);


    /*
     *  Ipc_start() calls Ipc_attach() to synchronise all remote processors
     *  because 'Ipc.procSync' is set to 'Ipc.ProcSync_ALL' in *.cfg
     */
    status = Ipc_start();

    if (status < 0) {
        System_abort("IPS IS NOT STARTED PROPERLY\n");
    }
    //proc_id = MultiProc_self();
    for(loop_num_processor=0;loop_num_processor<2;loop_num_processor++){
    	if(proc_id !=loop_num_processor)
    	{
                while(Ipc_attach(loop_num_processor) < 0){
                Task_sleep(1);
    		}
    	}
    }

    printf("Completed the synchronisation of all cores\n");fflush(stdout);
    BIOS_start();
    return 0;
}




  2055.ipc_example.cfg

-Studinstru

  • Hi,

    It's strange but I didn't get the same error msg that you got, I think that your error is caused because you're using only two cores, but is setting the queues names of 8 eight cores, that's why tou get this error. Note that

    NextQueueName  :CORE2

    It should be CORE0, so C0 sends a msg to C1 and C1 to C0. I think that you only have to change this line in you .cfg file

    line 7: var nameList = MultiProc.getDeviceProcNames();

    change to:

    var nameList = ["CORE0", "CORE1"];

    Also, you're trying to detach from the same core Id, according to the doc it should be to nextProcId. Doing this you should not get any error, but leaves to an infinite loop of 137, 139, 150

    BTW, if you get an error mesage like this when trying to simulate:

    [TMS320C66x_2] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name list
    xdc.runtime.Error.raise: terminating execution

    [TMS320C66x_3] ti.sdo.ipc.family.c647x.MultiProcSetup: line 62: assertion failure: A_invalidProcessor: This core is not present in the MultiProc name list
    xdc.runtime.Error.raise: terminating execution

    ...

    Nevermind, it's because the simulator is configured to use 8 cores, as you've configured to use only two, it will complain, but cores 0 and 1 will work properly.

    Hope this helps.

    Regards