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.

AM2634: Getting error while sending messages from one core to another using IPC

Part Number: AM2634


Tool/software:

Hi Team,

I am getting below error while trying to send message from core 0 to core 1. It only executes only when data sent for first time. It fails for 2nd time and onwards. Please let me know what parameters settings is wrong.

ERROR: RPMessage_send:301: [IPC RPMSG] Message send to remote core 1 @ 13 end po
int failed due to invalid parameters !!!

ASSERT: 144.251423s: ../ipc_rpmsg_echo.c:ipc_send_message:639: status==SystemP_S
UCCESS failed !!!

As part of requirements, I have done below steps

1. configured Core0 to get UDP data of 1024 bytes in buffer

2. Take that data and pass it to core 1 using  RPMessage_send() function

3. Core 1 receives for 1st time but not for 2nd time

4. Core 1 needs to send data over SPI bus

Appreciate your help!

  • Hello,

    Please check function RPMessage_send in "SDK_INSTALL_PATH/source/drivers/ipc_rpmsg/ipc_rpmsg.c/ipc_rpmsg.c".

    Above mentioned error is triggered when this if condition fails: "if(((remoteCoreId < CSL_CORE_ID_MAX)) && ((gIpcRpmsgCtrl.isCoreEnable[remoteCoreId] != 0U)) && ((data != NULL)) && ((dataLength != 0U)) && (localEndPt < RPMESSAGE_MAX_LOCAL_ENDPT)" .

    Best Regards,
    Gunjan

  • Thanks Gunjan!

    I am following below algorithm for my requirement

    1. Created a task to get data from UDP

    gUDPTask = xTaskCreateStatic( UDP_fn, /* Pointer to the function that implements the task. */
    "UDP_fn", /* Text name for the task. This is to facilitate debugging only. */
    UDP_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
    &gArincTXConnInfo.socketAddr, /* We are not using the task parameter. */
    UDP_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
    gUDPStack, /* pointer to stack base */
    &gUDPObj ); /* pointer to statically allocated task object memory */
    configASSERT(gUDPTask != NULL);

    2. Below function to get data from UDP data

    void UDP_fn()
    {
          uint32_t msg, i, numRemoteCores;
          uint64_t curTime;
          char msgBuf[MAX_MSG_SIZE];
          int32_t status;
          uint16_t remoteCoreId, remoteCoreEndPt, msgSize;

          err_t err;
          ssize_t bytes_received=0;
          const TickType_t xDelay = 2 / portTICK_PERIOD_MS;
          struct sockaddr* pAddr = args;
          struct sockaddr_in from = { 0 };
          int32_t count=0;

          if ((gUDPSock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
          {
             DebugP_log("UDPUDP server: Error creating Socket\r\r\n");
             return;
          }
          else
          {
             DebugP_log("UDPUDP server: socket created\r\r\n");

          }

          err = bind(gUDPSock, pAddr, sizeof(*pAddr));
          if (err != ERR_OK)
          {
             DebugP_log("UDP server: Error on bind: %d\r\r\n", err);
             close(gUDPSock);
             return;
          }
          else
          {
             DebugP_log("UDP server: socket bounded\r\r\n");

          }

          while(1)
          {
             bytes_received= lwip_recvfrom(gUDPSock, gUDPData, UDP_RECV_BUFSIZE, 0,NULL,NULL);
             if(bytes_received > 0)
                   {
                      DebugP_log("ARINC Packets received: %d \r\n\r",count);

                      CacheP_wbInv(gUDPData, sizeof(gUDPData), CacheP_TYPE_ALLD);
                      DebugP_log("Client: %x,%x\r\n", gUDPData[0], gUDPData[1]);
                      count=count+1;
                   }
          }
         
            vTaskDelay( xDelay );
    }
    3. I have routine for IPC communication used from ipc_rpmsg example as below

    void ipc_rpmsg_echo_main_core_start(void)
    {
    RPMessage_CreateParams createParams;
    uint32_t msg, i, numRemoteCores;
    uint64_t curTime;
    char msgBuf[MAX_MSG_SIZE];
    int32_t status;
    uint16_t remoteCoreId, remoteCoreEndPt, msgSize;

    RPMessage_CreateParams_init(&createParams);
    createParams.localEndPt = MAIN_CORE_ACK_REPLY_END_PT;
    status = RPMessage_construct(&gAckReplyMsgObject, &createParams);
    DebugP_assert(status==SystemP_SUCCESS);

    numRemoteCores = 0;
    for(i=0; gRemoteCoreId[i]!=CSL_CORE_ID_MAX; i++)
    {
    numRemoteCores++;
    }

    /* wait for all cores to be ready */
    IpcNotify_syncAll(SystemP_WAIT_FOREVER);

    ClockP_usleep(500*1000); /* wait for log messages from remote cores to be flushed, otherwise this delay is not needed */

    DebugP_log("[IPC RPMSG ECHO] Message exchange started by main core !!!\r\n");

    curTime = ClockP_getTimeUsec();

    for(msg=0; msg<gMsgEchoCount; msg++)
    {
    snprintf(msgBuf, MAX_MSG_SIZE-1, "%" PRIu32, msg);
    msgBuf[MAX_MSG_SIZE-1] = 0;
    msgSize = strlen(msgBuf) + 1; /* count the terminating char as well */

    /* send the same messages to all cores */
    for(i=0; gRemoteCoreId[i]!=CSL_CORE_ID_MAX; i++ )
    {
    status = RPMessage_send(
    msgBuf, msgSize,
    gRemoteCoreId[i], gRemoteServiceEndPt,
    RPMessage_getLocalEndPt(&gAckReplyMsgObject),
    SystemP_WAIT_FOREVER);
    DebugP_assert(status==SystemP_SUCCESS);
    }
    /* wait for response from all cores */
    for(i=0; gRemoteCoreId[i]!=CSL_CORE_ID_MAX; i++ )
    {
    /* set 'msgSize' to size of recv buffer,
    * after return `msgSize` contains actual size of valid data in recv buffer
    */
    msgSize = sizeof(msgBuf);
    status = RPMessage_recv(&gAckReplyMsgObject,
    msgBuf, &msgSize,
    &remoteCoreId, &remoteCoreEndPt,
    SystemP_WAIT_FOREVER);
    DebugP_assert(status==SystemP_SUCCESS);
    }
    }

    curTime = ClockP_getTimeUsec() - curTime;

    DebugP_log("[IPC RPMSG ECHO] All echoed messages received by main core from %d remote cores !!!\r\n", numRemoteCores);
    DebugP_log("[IPC RPMSG ECHO] Messages sent to each core = %d \r\n", gMsgEchoCount);
    DebugP_log("[IPC RPMSG ECHO] Number of remote cores = %d \r\n", numRemoteCores);
    DebugP_log("[IPC RPMSG ECHO] Total execution time = %" PRId64 " usecs\r\n", curTime);
    DebugP_log("[IPC RPMSG ECHO] One way message latency = %" PRId32 " nsec\r\n",
    (uint32_t)(curTime*1000u/(gMsgEchoCount*numRemoteCores*2)));

    RPMessage_destruct(&gAckReplyMsgObject);

    DebugP_log("All tests have passed!!\r\n");


    }
    Can you please help me with how can I merge two things together? I have tried to call IPC send function in UDP task to send data to another core but it gets stuck. It even stops UDP receive. Is there any sync issue with cores. If yes, how can I solve it.
    Appreciate for your help!
  • Appreciate for your support on this!

  • Hello Ajit,

    Today, I was occupied with some other tasks. I will look into it tomorrow.

    Best Regards,
    Gunjan

  • Hello Ajit,

    "SDK_INSTALL_PATH/source/drivers/ipc_rpmsg/ipc_rpmsg.c/ipc_rpmsg.c".

    Above mentioned error is triggered when this if condition fails: "if(((remoteCoreId < CSL_CORE_ID_MAX)) && ((gIpcRpmsgCtrl.isCoreEnable[remoteCoreId] != 0U)) && ((data != NULL)) && ((dataLength != 0U)) && (localEndPt < RPMESSAGE_MAX_LOCAL_ENDPT)" .

    Can you add a breakpoint here and check which parameter is responsible for failure of ipc message?

    Thanks and Best Regards,
    Gunjan