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.

[FAQ] RPMsg: How to add multiple endpoints to a remote core running RTOS?

I am using RPMsg to communicate from Linux with a remote core running RTOS (e.g., R5F or M4F). I want to define multiple RPMsg endpoints in my remote core software. How do I do that?

.

This FAQ applies to AM62x, AM62A, AM64x, AM65x, and probably other devices. The provided sample code was written for AM64x R5F, and tested on Processor SDK 8.6. The concepts will apply to all processors that use RPMsg to communicate between a Linux core and an RTOS remote core, but some of the details may change between cores and devices.

.

For other FAQs about multicore subjects, please reference Sitara multicore development and documentation

UPDATE January 2024: The information in this FAQ has been added to the processor academy modules. This FAQ will not be maintained going forward.
Please find the latest information in the processor's academy > Multicore module > Multicore Development > How to develop with RPMsg IPC > How to add multiple RPMsg endpoints to a remote core running RTOS:
AM62x
AM62Ax
AM64x

  • The code changes

    The attached patch adds two additional RPMsg endpoints that can be used to communicate with Linux userspace:

    4760.0001-Linux_RPMsg_Echo-add-additional-endpoints.patch

    Key details 

    Each additional endpoint uses the same RPMsg service name that was defined for Linux userspace, "rpmsg_chrdev".

    The expected service name for RPMsg endpoints that will communicate with Linux userspace is defined in the Linux rpmsg_char driver.

    Each endpoint needs to have a separate RPMessage_Object with a unique semaphore in the RTOS-side code.

    The way that TI has tested this is to give each endpoint a separate task in the RTOS-side code.

  • APPENDIX

    How do I apply and build the code? 

    For customers who are unfamiliar with applying git patch files, this is the process I use on the Linux terminal:

    $ cd location/of/mcu+/sdk
    $ git status
    // we see no git repo has been created yet
    $ git init
    $ git add .
    // create the initial commit by adding everything in the SDK
    // this works best with a fresh SDK installation
    $ git branch
    // the master branch is the only branch
    $ git branch featureBranchName
    $ git checkout featureBranchName
    // copy over the patch file
    // now we can apply the patch
    $ git apply patchFileName

    Now I can build the project:

    make -s -C examples/drivers/ipc/ipc_rpmsg_echo_linux/am64x-evm/r5fss0-0_freertos/ti-arm-clang all

    For more information about building a specific project with a makefile from the terminal, reference the MCU+ SDK docs: https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/08_06_00_45/exports/docs/api_guide_am64x/MAKEFILE_BUILD_PAGE.html#MAKEFILE_EXAMPLE_BUILD

    How do I load the firmware and test it?

    For more information about loading a specific binary into a remote core from Linux, reference the Linux Academy: https://dev.ti.com/tirex/explore/node?a=7qm9DIS__LATEST&node=A__ANKEb6LZY6VAX.9xvGwQ-g__linux_academy_am64x__7qm9DIS__LATEST

    For more information about testing IPC, reference the Linux Academy: https://dev.ti.com/tirex/explore/node?a=7qm9DIS__LATEST&node=A__AAtN.uvfmDSx4mvQ7f4R.w__linux_academy_am64x__7qm9DIS__LATEST

    What should my output look like if I am testing the provided patch on AM64x? 

    // code is running on R5F0_0, so use RPROC_ID 2
    
    root@am64xx-evm:~# rpmsg_char_simple -r 2 -n 3 -d rpmsg_chrdev -p 14
    Created endpt device rpmsg-char-2-986, fd = 3 port = 1024
    Exchanging 3 messages with rpmsg device ti.ipc4.ping-pong on rproc id 2 ...
    
    Sending message #0: hello there 0!
    Receiving message #0: hello there 0!
    Sending message #1: hello there 1!
    Receiving message #1: hello there 1!
    Sending message #2: hello there 2!
    Receiving message #2: hello there 2!
    
    Communicated 3 messages successfully on rpmsg-char-2-986
    
    TEST STATUS: PASSED
    root@am64xx-evm:~# rpmsg_char_simple -r 2 -n 3 -d rpmsg_chrdev -p 15
    Created endpt device rpmsg-char-2-988, fd = 3 port = 1024
    Exchanging 3 messages with rpmsg device ti.ipc4.ping-pong on rproc id 2 ...
    
    Sending message #0: hello there 0!
    Receiving message #0: hello there 0!
    Sending message #1: hello there 1!
    Receiving message #1: hello there 1!
    Sending message #2: hello there 2!
    Receiving message #2: hello there 2!
    
    Communicated 3 messages successfully on rpmsg-char-2-988
    
    TEST STATUS: PASSED
    root@am64xx-evm:~# rpmsg_char_simple -r 2 -n 3 -d rpmsg_chrdev -p 16
    Created endpt device rpmsg-char-2-990, fd = 3 port = 1024
    Exchanging 3 messages with rpmsg device ti.ipc4.ping-pong on rproc id 2 ...
    
    Sending message #0: hello there 0!
    Receiving message #0: hello there 0!
    Sending message #1: hello there 1!
    Receiving message #1: hello there 1!
    Sending message #2: hello there 2!
    Receiving message #2: hello there 2!
    
    Communicated 3 messages successfully on rpmsg-char-2-990
    
    TEST STATUS: PASSED
    
    // now let's see what happens if you talk to a nonexistent endpoint
    
    root@am64xx-evm:~# rpmsg_char_simple -r 2 -n 3 -d rpmsg_chrdev -p 17
    _rpmsg_char_find_ctrldev: could not find the matching rpmsg_ctrl device for virtio1.rp
    msg_chrdev.-1.17
    Can't create an endpoint device: Success
    TEST STATUS: FAILED