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] [参考译文] [常见问题解答] AM62x &AM64x:如何在 Processor SDK Linux 11.0上启用 PRU RPMsg

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

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1494495/faq-am62x-am64x-how-to-enable-pru-rpmsg-on-processor-sdk-linux-11-0

器件型号:PROCESSOR-SDK-AM62XPROCESSOR-SDK-AM64X

在 Linux 内核6.12中、我们删除单独的 PRU RPMsg (RPMessage)驱动程序、并改用通用 RPMsg 驱动程序。 但是、Linux SDK 11.0的更改并未及时完成。 这意味着 AM62x Linux SDK 11.0和 AM64x Linux SDK 11.0中的 PRU RPMsg 开箱即用。 请按照以下步骤在这些 SDK 版本上启用 PRU RPMsg。

所有更改都集成在 AM62x Linux SDK 11.1和 AM64x Linux SDK 11.1上。

如何运行开箱即用的 PRU 演示?  

运行开箱即用 PRU 演示的步骤与之前 SDK 版本的文档不同。 在 更新 RPMsg 快速入门指南之前、请参阅本常见问题解答中进一步的回复。

错误输出  

如果您在未执行以下步骤的情况下尝试使用 PRU RPMsg 加载固件、则固件加载可能会如下所示失败:

// find which PRU core you want to connect to
// remoteprocX association can change each boot, so use the name to determine
// which core is which
root@am64xx-evm:~# head /sys/class/remoteproc/remoteproc*/name
==> /sys/class/remoteproc/remoteproc0/name <==
78000000.r5f
...
==> /sys/class/remoteproc/remoteproc9/name <==
30034000.pru

// now let's check which firmware will get loaded by default
root@am64xx-evm:~# cat /sys/class/remoteproc/remoteproc9/firmware
am64x-pru0_0-fw

root@am64xx-evm:~# ls -al /lib/firmware/
...
lrwxrwxrwx  1 root root      53 Mar  9  2018 am64x-pru0_0-fw -> /usr/lib/firmware/pru/PRU_RPMsg_Echo_Interrupt0_0.out

// now let's try to load the RPMsg Echo firmware
root@am64xx-evm:~# echo start > /sys/class/remoteproc/remoteproc9/state
[258582.547936] remoteproc remoteproc9: powering up 30034000.pru
[258582.553702] remoteproc remoteproc9: Booting fw image am64x-pru0_0-fw, size 118672
[258582.556543] rproc-virtio rproc-virtio.5.auto: .kick method not defined for 30034000.pru
[258582.556576] remoteproc remoteproc9: failed to probe subdevices for 30034000.pru: -22
[258582.556930] remoteproc remoteproc9: Boot failed: -22
-sh: echo: write error: Invalid argument

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

    步骤1:修补 Linux 内核驱动程序  

    a)应用内核驱动程序补丁 "Remoteproc:PRU:添加对 virtio rpmsg 栈的支持":
    https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/patch/?id=f21a9eb2166ca69563deb32980fde16800c7e77a

    b)重新编译内核映像和内核模块 、如部分所述
    正在准备构建
    配置内核
    编译源代码
    https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/latest/exports/docs/linux/Foundational_Components_Kernel_Users_Guide.html 

    c)安装内核映像和内核模块 、如部分所述
    安装内核
    https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/latest/exports/docs/linux/Foundational_Components_Kernel_Users_Guide.html#installing-the-kernel

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

    步骤2:更新 PRU 固件  

    通用 Linux RPMsg 驱动程序使用与前一个 PRU RPMsg 驱动程序(rpmsg-PRU)不同的通道名称(rpmsg-raw)。 更新 PRU 固件以使用 rpmsg-raw。

    可从以下位置下载最新的 PRU 软件支持包(PSSP):
    https://git.ti.com/cgit/pru-software-support-package/pru-software-support-package/

    PSSP v6.5.0将更新所有固件以使用 rpmsg-raw。

    如果您在阅读此常见问题解答时未发布 PSSP v6.5.0、您可以按如下方式更新 PRU 固件:

    diff --git a/examples/am64x/PRU_RPMsg_Echo_Interrupt0/main.c b/examples/am64x/PRU_RPMsg_Echo_Interrupt0/main.c
    index f467eed..a8ee63a 100644
    --- a/examples/am64x/PRU_RPMsg_Echo_Interrupt0/main.c
    +++ b/examples/am64x/PRU_RPMsg_Echo_Interrupt0/main.c
    @@ -55,7 +55,7 @@ volatile register uint32_t __R31;
    * Using the name 'rpmsg-pru' will probe the rpmsg_pru driver found
    * at linux-x.y.z/drivers/rpmsg/rpmsg_pru.c
    */
    -#define CHAN_NAME "rpmsg-pru"
    +#define CHAN_NAME "rpmsg-raw"
    #ifndef CHAN_PORT
    #error "CHAN_PORT not defined, must be passed using the compiler CFLAGS"
    #endif

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

    步骤3:运行 PRU RPMsg Echo 示例  

    将更新的固件复制到 EVM 文件系统中  

    例如、

    AM62x example
    
    // remove or rename the firmware from before PSSP v6.5.0
    root@am62xx-evm:~# ls -al /lib/firmware/
    ...
    lrwxrwxrwx  1 root root      51 Mar  9  2018 am62x-pru0-fw -> /usr/lib/firmware/pru/PRU_RPMsg_Echo_Interrupt0.out
    lrwxrwxrwx  1 root root      51 Mar  9  2018 am62x-pru1-fw -> /usr/lib/firmware/pru/PRU_RPMsg_Echo_Interrupt1.out
    
    root@am62xx-evm:~# cd /usr/lib/firmware/pru/
    root@am62xx-evm:/usr/lib/firmware/pru# ls
    PRU_Halt.out  PRU_RPMsg_Echo_Interrupt0.out  PRU_RPMsg_Echo_Interrupt1.out
    root@am62xx-evm:/usr/lib/firmware/pru# mv PRU_RPMsg_Echo_Interrupt0.out PRU_RPMsg_Echo_Interrupt0.out.v6_4_0
    root@am62xx-evm:/usr/lib/firmware/pru# mv PRU_RPMsg_Echo_Interrupt1.out PRU_RPMsg_Echo_Interrupt1.out.v6_4_0
    
    // then copy the updated firmware into this location

    确定哪个 PRU 内核与哪个 remoteprocX 实例关联  

    // find which PRU core you want to connect to
    // remoteprocX association can change each boot, so use the name to determine
    // which core is which
    root@am62xx-evm:/sys/devices# head /sys/class/remoteproc/remoteproc*/name
    ...
    ==> /sys/class/remoteproc/remoteproc2/name <==
    30074000.pru
    
    ==> /sys/class/remoteproc/remoteproc3/name <==
    30078000.pru
    
    
    // now let's verify that we will load the updated firmware
    root@am62xx-evm:/sys/devices# cat /sys/class/remoteproc/remoteproc3/firmware
    am62x-pru1-fw
    
    root@am62xx-evm:/sys/devices# ls -al /lib/firmware
    ...
    lrwxrwxrwx  1 root root      51 Mar  9  2018 am62x-pru0-fw -> /usr/lib/firmware/pru/PRU_RPMsg_Echo_Interrupt0.out
    lrwxrwxrwx  1 root root      51 Mar  9  2018 am62x-pru1-fw -> /usr/lib/firmware/pru/PRU_RPMsg_Echo_Interrupt1.out

    引导 PRU 内核并确定关联的/dev/rpmsgY 实例  

    找到 PRU 内核与关联的/dev/rpmsgY 实例之间关联的最简单方法是在初始化 PRU 内核之前和之后检查/dev/文件夹。 初始化 PRU 内核后出现的/dev/rpmsgY 实例与该内核关联。

    请注意、同一个内核的 remoteprocX 和/dev/rpmsgY.编号可能不同

    // the existing rpmsgY instances are associated with remote cores that Linux has
    // already initialized or attached to
    
    root@am62xx-evm:~# ls /dev/
    ...
    remoteproc0
    remoteproc1
    remoteproc2
    remoteproc3
    rfkill
    rpmsg0
    rpmsg1
    rpmsg_ctrl0
    rpmsg_ctrl1
    
    root@am62xx-evm:~# echo start > /sys/class/remoteproc/remoteproc3/state
    [  569.960588] remoteproc remoteproc3: powering up 30078000.pru
    [  569.965107] remoteproc remoteproc3: Booting fw image am62x-pru1-fw, size 80152
    root@am62xx-evm:~# [  569.977230] virtio_rpmsg_bus virtio2: rpmsg host is online
    [  569.977263] virtio_rpmsg_bus virtio2: creating channel rpmsg-raw addr 0x1f
    [  569.977292] rproc-virtio rproc-virtio.5.auto: registered virtio2 (type 7)
    [  569.977302] remoteproc remoteproc3: remote processor 30078000.pru is now up
    
    // use /dev/rpmsg2 to communicate with this PRU core
    root@am62xx-evm:~# ls /dev/
    ...
    remoteproc0
    remoteproc1
    remoteproc2
    remoteproc3
    rfkill
    rpmsg0
    rpmsg1
    rpmsg2
    rpmsg_ctrl0
    rpmsg_ctrl1
    rpmsg_ctrl2

    我们可以通过在/sys/devices 下搜索 rpmsgY 实例来仔细检查此关联:

    root@am62xx-evm:~# cd /sys/devices
    root@am62xx-evm:/sys/devices# find -name "rpmsg2"
    ./platform/bus@f0000/30040000.pruss/30078000.pru/remoteproc/remoteproc3/rproc-virtio.5.auto/virtio2/virtio2.rpmsg-raw.-1.31/rpmsg/rpmsg2
    
    // this verifies that rpmsg2 is associated with 30078000.pru & remoteproc3

    运行回波测试  

    root@am62xx-evm:/sys/devices# cd ~
    root@am62xx-evm:~# echo "pru1 echo test" > /dev/rpmsg2
    root@am62xx-evm:~# cat /dev/rpmsg2
    pru1 echo test
    ^C