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.

AM623: M4F side packets can't exceed 256 bytes

Genius 13655 points
Part Number: AM623

Hello Champs,

Customer is testing ipc communication between m4f and a53-linux. He got the ti-rpmsg-char code from git-clone (link https://git.ti.com/cgit/rpmsg/ti-rpmsg-char/)) and modified  ti-rpmsg-char code, recompiled it. 

I modified the ti-rpmsg-char code to send out any length of data, as shown in the following figure, data_len is the length of the send data obtained from the ssh command line, whereas the original code only issues "hello there %d"


This code is communicatiing to m4f, the function of the m4f side is what is received and what is returned (one thing he already understands is that the user data cannot be sent more than 496 bytes).

As shown in the following figure, when he sends 256 bytes or less, linux receives the reply from the m4f side in its entirety, starting with ‘s’. End with ‘e’

As shown in the following figure, when he sends more than 256 bytes, the linux side only receives 256 bytes of data, and sending 496 bytes also returns 256 bytes. 300 bytes, which returns 256 bytes, 

He printed the message through the m4f serial DebugP_log function and saw that m4f actually received all the data, and when it was sent, it was passed in to the RPMessage_send function as long as it was received.

However, if it does not come out, it is truncated beyond 256 bytes.

The following figure shows the configuration of the m4f-side vring, the number of vringbufs is 256, each vringbuf is 512 bytes long (512 bytes already here, why is the 256 byte truncation problem described above?)

Below is the part of the code where the m4f side is being received

#define IPC_RPMESSAGE_MAX_MSG_SIZE        (512u)
char recvMsg[IPC_RPMESSAGE_MAX_MSG_SIZE+1]; /* +1 for NULL char in worst case */
    /* wait for messages forever in a loop */
    while(1) {
        /* set 'recvMsgSize' to size of recv buffer,
        * after return `recvMsgSize` contains actual size of valid data in recv buffer
        */
        //DebugP_log("runing task_id=%d localEndPoint=%d rec_cnt=%d\r\n", inputArgs->task_id, localEndPoint, rec_cnt);

        recvMsgSize = IPC_RPMESSAGE_MAX_MSG_SIZE;
        status = RPMessage_recv(pRpmsgObj,
            recvMsg, &recvMsgSize,
            &remoteCoreId, &remoteCoreEndPt,
            0);

        if(status==SystemP_SUCCESS)
        {

            /* echo the same message string as reply */
            #if 1 /* not logging this so that this does not add to the latency of message exchange */
            recvMsg[recvMsgSize] = 0; /* add a NULL char at the end of message */
            //DebugP_log("recvMsg:%s\r\n", recvMsg);
            #endif

            /* send ack to sender CPU at the sender end point */
            status = RPMessage_send(
                recvMsg, recvMsgSize,
                remoteCoreId, remoteCoreEndPt,
                RPMessage_getLocalEndPt(pRpmsgObj),
                5);
            //DebugP_log("Rec Size=%d Cnt=%d ",recvMsgSize, rec_cnt);
            rec_cnt ++;
            if(status==SystemP_SUCCESS)
            {

                //DebugP_log("send ok %d\r\n", send_cnt);
                send_cnt++;
            }
            else
            {
                DebugP_log("send error = %02X\r\n", status);
            }            //DebugP_assert(status==SystemP_SUCCESS);
        }
        else
        {
            vTaskDelay(1);
        }
    }

Question 1: What is the problem and how to fix it?

Question 2: What are the two parameters of IPC_RPESSAGE_NUM_VRING_BUF and IPC_RPESSAGE_MAX_VRING_BUF_SIZE that are found in the following figures?

Are there are NUM_VRING cache areas in ipc communication, each of which is VRING_BUF_SIZE, if so, Does linux send NUM_VRING messages in succession, m4f never reads, and once read is started, NUM_VRING messages can be read and removed?

/* Number of a buffers in a VRING, i.e depth of VRING queue */
#define IPC_RPMESSAGE_NUM_VRING_BUF (256U)
/* Max size of a buffer in a VRING */
#define IPC_RPMESSAGE_MAX_VRING_BUF_SIZE (512U)

Thanks
Regards
Shine

  • Hello Shine,

    Which versions of the MCU+ SDK and the Linux SDK are the customer using?

    We accidentally placed a limitation on the size of the RPMsg message that the M4F would receive in earlier MCU+ SDK examples for Linux RPMsg. So the M4F code is the first place I would look.

    e.g., if I check MCU+ SDK 8.3, file examples/drivers/ipc/ipc_rpmsg_echo_linux/ipc_rpmsg_echo.c

    I see

    /* maximum size that message can have in this example */
    #define IPC_RPMESSAGE_MAX_MSG_SIZE        (96u)
    

    while if we check MCU+ SDK 9.0, file examples/drivers/ipc/ipc_rpmsg_echo_linux/ipc_rpmsg_echo.c
    I see

    /* Maximum size that message can have in this example
     * RPMsg maximum size is 512 bytes in linux including the header of 16 bytes.
     * Message payload size without the header is 512 - 16 = 496
     */
    #define IPC_RPMESSAGE_MAX_MSG_SIZE        (496u)
    

    Regards,

    Nick

  • As far as IPC_RPESSAGE_NUM_VRING_BUF and IPC_RPESSAGE_MAX_VRING_BUF_SIZE:

    IPC_RPESSAGE_NUM_VRING_BUF - this is the number of RPMsg messages that can be queued up in each direction (i.e., 256 from Linux to M4F, and 256 from M4F to Linux, for a total of 512 VRING buffers total)

    IPC_RPESSAGE_MAX_VRING_BUF_SIZE - this should stay at 512 bytes total per VRING buffer.

  • Thank you for reply. 

    i'm the customer, The version of mcu and linux sdk  I use is under Below:

    ti-processor-sdk-linux-rt-am62xx-evm-08.06.00.42-Linux-x86-Install.bin

    mcu_plus_sdk_am62x_08_06_00_18-windows-x64-installer.exe

    I have noticed “IPC_RPMESSAGE_MAX_MSG_SIZE”  when I writing the m4f code. and be modified to 512,

    #define IPC_RPMESSAGE_MAX_MSG_SIZE        (512u)

    On the linux side, the limited send length is 496 bytes, so It doesn't matter if we define IPC_RPMESSAGE_MAX_MSG_SIZE  to 512.

    I think the problem is not caused by this define.

     After read your reply, I installed mcu_plus_sdk_am62x_09_01_00_39 and Import mcu_plus_sdk_am62x_09_01_00_39\examples\drivers\ipc\ipc_rpmsg_echo_linux project to run, The result is still the same, 

    I'm sure the M4F has received all the data from linux, but it is not besure the m4f do not send or linux do not receive?

  • Hello wjj,

    Hmm. I am not able to replicate your results when I do a quick command-line test on SDK 9.0. So the RPMsg protocol itself is working as expected.

    I typed out 496 characters, and sent them from Linux to a remote core. If I tried to send 497 characters, Linux threw an error.

    I then read the message that the remote core echoed back. It looks like only 495 characters were returned (which I didn't expect, that might be something I need to look into - maybe there's something like a termination character that needs to be kept in mind).

    root@am62xx-evm:~# ls /dev/ | grep rpmsg
    rpmsg0
    rpmsg1
    rpmsg_ctrl0
    rpmsg_ctrl1
    
    root@am62xx-evm:~# echo "00000000001111111111222222222233333333334444444444555555555566
    666666666777777777788888888889999999999000000000011111111112222222222333333333344444444
    444555555555566666666667777777777888888888899999999990000000000111111111122222222223333
    333333344444444445555555555666666666677777777778888888888999999999900000000001111111111
    122222222223333333333444444444455555555556666666666777777777788888888889999999999000000
    000001111111111222222222233333333334444444444555555555566666666667777777777888888888899
    9999" > /dev/rpmsg0
    
    root@am62xx-evm:~# cat /dev/rpmsg0
    
    00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223333333333444444444455555555556666666666777
    77777778888888888999999999900000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223333333333444444
    44445555555555666666666677777777778888888888999999999900000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999

    Regards,

    Nick

  • Thanks,To solve the problem as soon as possible.

    Can I send you my m4f and linux code to test and run?How I send my code to you?Via E-mail?

    LWATUO' Wjj

  • Hello wjj,

    How to debug where the characters are going missing?

    You can do that pretty easily with Debug print statements. After M4F receives the buffer, just use debug print to write the message to the trace log. Then you can read the trace log from the Linux terminal. You can also use CCS if you want more granular debug.

    Refer to the AM62x academy, multicore module, page "Application Development on Remote Cores", section "How to debug a remote core while Linux is running"
    https://dev.ti.com/tirex/explore/node?node=A__AVn3JGT9fqm0PbS.pegO-g__AM62-ACADEMY__uiYMDcq__LATEST 

    Code review

    You can send the code through Shine. Do keep in mind that I can't really support custom code development, so I won't try to read through everything. If you have specific portions of the code you want me to look at, please point out the lines you want feedback on and I'll look at them.

    Regards,

    Nick