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.

MCU-PLUS-SDK-AM243X: RPMessage with callback interrupt

Part Number: MCU-PLUS-SDK-AM243X
Other Parts Discussed in Thread: SYSCONFIG

Hello experts,

I'm trying to use rpmessage for cross core communication.

I'll need to use an interrupt with callback for my program.

Is there any example/guideline on how to setup the constructor?

Here's what I tried:

I use this function to set the callback

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
RPMessage_CreateParams createParams;
RPMessage_CreateParams_init(&createParams);
createParams.localEndPt = gRemoteServiceEndPt; /* pick any unique value on that core between 0..RPMESSAGE_MAX_LOCAL_ENDPT-1
* the value need not be unique across cores
*/
createParams.recvCallback = &ISR_ipcRecvCallback; //Register receive interrupt callback function
//Callback args
gIPCArgs.obj = &gRecvMsgObject;
gIPCArgs.arg = NULL;
gIPCArgs.data = (void *) gBufIn;
gIPCArgs.dataLen = sizeof(gBufIn);
gIPCArgs.remoteCoreId = CSL_CORE_ID_R5FSS0_0;
gIPCArgs.remoteEndPt = MAIN_CORE_ACK_REPLY_END_PT;
createParams.recvCallbackArgs = &gIPCArgs;
return RPMessage_construct(&gAckReplyMsgObject, &createParams);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In the callback function I echo the received message

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void ISR_ipcRecvCallback(RPMessage_Object *obj, void *arg,
void *data, uint16_t dataLen,
uint16_t remoteCoreId, uint16_t remoteCoreEndPt)
{
uint32_t status;
//echo the same message string as reply
//send ack to sender CPU at the sender end point
status = RPMessage_send(
data, dataLen,
remoteCoreId, remoteCoreEndPt,
RPMessage_getLocalEndPt(obj),
SystemP_WAIT_FOREVER);
DebugP_assert(status==SystemP_SUCCESS);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I modified the example "IPC RP Message Echo" provided by the SDK, but it seems that the callback function never gets called

Regards,

Andrea F,

  • Hi Andrea,

    The way you registered call back seems to be fine, however it seems like the arguments you are passing is not being used anywhere in the callback. Any specific reason you're passing these?

    Also, I'll try this at my end and share you an example.

    Thanks,
    G Kowshik

  • Hi Kowshik,

    this is my first time registering a callback function without using sysconfig.

    The reason I picked this arguments is because I copied the function from the header "ipc_rpmsg.h" where the callback function is defined as

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /**
    * \brief Callback that is invoked when a message is received from any CPU at the specified local end point
    *
    * The callback can be optionally registered during \ref RPMessage_construct
    *
    * \note All message contents MUST be consumed in the callback.
    * When callback returns the message buffer is released back to the sender.
    * If the message contents are needed for deferred processing then take a copy of the message contents
    *
    * \param obj [in] RPMessage end point object created with \ref RPMessage_construct
    * \param arg [in] Arguments specified by user during \ref RPMessage_construct
    * \param data [in] Pointer to message
    * \param dataLen [in] Length of message
    * \param remoteCoreId [in] Core ID of sender
    * \param remoteEndPt [in] End point of sender
    */
    typedef void (*RPMessage_RecvCallback)(RPMessage_Object *obj, void *arg,
    void *data, uint16_t dataLen,
    uint16_t remoteCoreId, uint16_t remoteEndPt);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    In my final project I'll need to copy the received buffer in a local buffer in order to process it later in the main loop, so I don't need all this arguments.

      Here's the code I'm using if you want to test it out

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (C) 2021 Texas Instruments Incorporated
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the
    * distribution.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Best Regards,

    Andrea

  • Hi Andrea,

    I have imported the system project from the MCU+SDK and added the following macro in the createParams.recvCallback, and I am able to hit the callback whenever I receive a message from the other cores.

    Thanks,
    G Kowshik

  • Thank you Kowshik,

    now the callback works fine Slight smile

    All I had to do was change the callback function return type from void to RPMessage_RecvCallback:

    What I had

    Fullscreen
    1
    2
    3
    void ISR_ipcRecvCallback(RPMessage_Object *obj, void *arg,
    void *data, uint16_t dataLen,
    uint16_t remoteCoreId, uint16_t remoteEndPt);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The change I made to make it work

    Fullscreen
    1
    2
    3
    RPMessage_RecvCallback ISR_ipcRecvCallback(RPMessage_Object *obj, void *arg,
    void *data, uint16_t dataLen,
    uint16_t remoteCoreId, uint16_t remoteEndPt);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    BR,

    Andrea