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:如何将多个端点添加到运行 RTOS 的远程内核中?

Guru**** 657500 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1245326/faq-rpmsg-how-to-add-multiple-endpoints-to-a-remote-core-running-rtos

我正在使用 RPMsg 从 Linux 与运行 RTOS 的远程内核(例如、R5F 或 M4F)进行通信。 我想在远程核心软件中定义多个 RPMsg 端点。 我该怎么做?

此常见问题解答适用于 AM62x、AM62A、AM64x、AM65x 以及可能的其他器件。 提供的示例代码是为 AM64x R5F 编写的、并在 Processor SDK 8.6上进行了测试。 这些概念将适用于所有使用 RPMsg 在 Linux 内核和 RTOS 远程内核之间进行通信的处理器、但其中的某些细节可能会因内核和器件而异。

有关多核主题的其他常见问题解答、请参考 Sitara 多核开发和文档

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    代码发生变化

    附加的补丁添加了两个可被用来与 Linux 用户空间通信的额外的 RPMSg 端点:

    e2e.ti.com/.../4760.0001_2D00_Linux_5F00_RPMsg_5F00_Echo_2D00_add_2D00_additional_2D00_endpoints.patch

    关键详细信息  

    每个附加的端点使用为 Linux 用户空间定义的相同的 RPMSG 服务名称"rpmsg_chrdev"。

    将与 Linux 用户空间通信的 RPMSg 端点的预期服务名称在 Linux rpmsg_char 驱动程序中定义。

    每个端点需要在 RTOS 端代码中有一个具有唯一信标的单独 RPMessage_Object。

    TI 对此进行测试的方法是在 RTOS 端代码中为每个端点分配单独的任务。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    附录

    如何应用和构建代码?  

    对于不熟悉应用 Git 补丁文件的客户、我在 Linux 终端上使用此过程:

    $ 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

    现在我可生成项目:

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

    有关通过终端 makefile 构建特定工程的更多信息、请参阅 MCU+ SDK 文档: 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

    如何加载并测试固件?

    有关从 Linux 将特定二进制文件加载到远程内核中的详细信息、请参阅 Linux Academy: https://dev.ti.com/tirex/explore/node?a=7qm9DIS__LATEST&node=A__ANKEb6LZY6VAX.9xvGwQ-g__linux_academy_am64x__7qm9DIS__LATEST

    有关测试 IPC 的更多信息、请参阅 Linux Academy: https://dev.ti.com/tirex/explore/node?a=7qm9DIS__LATEST&node=A__AAtN.uvfmDSx4mvQ7f4R.w__linux_academy_am64x__7qm9DIS__LATEST

    如果在 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