您、好、Nick
我们以前使用 rpmsg_char_zerocopy 在应用层发送和接收数据。 现在、我们希望在内核层发送和接收数据、因为我们有自己的内核驱动程序。 我们不确定内核层是否有这样的接口允许在 A53和 R5F 之间直接传输和接收数据。
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.
您、好、Nick
我们以前使用 rpmsg_char_zerocopy 在应用层发送和接收数据。 现在、我们希望在内核层发送和接收数据、因为我们有自己的内核驱动程序。 我们不确定内核层是否有这样的接口允许在 A53和 R5F 之间直接传输和接收数据。
Mack、您好!
内核级别绝对有一个接口用于在 Linux A53和 R5F 之间发送和接收数据。 事实上、您可以使用低级邮箱驱动程序来实现该内核驱动程序通信、而不是 RPMsg。 邮箱的延迟应比 RPMsg 低得多。
在本线程中、我深入探讨了如何使用邮箱从 Linux 向 R5F 发送"平稳关机"消息。 希望这能让您了解如何在内核驱动程序中开始邮箱通信: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1420796/sk-am62b-p1-how-to-enable-graceful-shutdown-of-remote-cores-with-multithreading-in-freertos-threads
如果您需要更多指导、请在此处告诉我。 如果您想进行代码审核、可随时将您的代码交给 Kevin、以便他与我分享。
此致、
Nick
Mack、您好!
供参考:讨论分为2个主题
我已将讨论拆分为两个线程:
上一个主题是关于 IPC 基准测试和零复制示例
本新主题介绍如何在 Linux 驱动程序和远程内核之间创建 IPC
有关邮箱外设的更多详细信息
有关更多信息、请参阅 AM64x 技术参考手册(TRM)的处理器间通信(IPC)>邮箱一节。
邮箱外设中包含8个集群。 每个群集有16个队列。 每个队列最多可容纳4条消息。 每条消息为32位。
当我们说我们为两个内核之间的 IPC 分配一个邮箱时、我们实际上是在分配一个特定的邮箱队列。
其中也有几个有关您的设计的重要详细信息:
1)您需要为每个方向分配不同的邮箱队列。
那么、假设您要在1个 Linux 驱动程序和4个 R5F 内核之间进行通信。 通常需要设置8个邮箱队列进行通信:
- 4邮箱队列用于从 Linux 驱动程序向每个 R5F 内核发送消息
-每个 R5F 内核有4个邮箱队列,用于向 Linux 驱动程序发送消息
2)一次最多只能有4封未读邮箱邮件。 因此、如果 Linux 尝试发送第5个邮箱消息到其中一个 R5F 内核、但 R5F 内核尚未读取之前4个邮箱消息中的任何一个、则 Linux 将等待发送第5个邮箱消息。 我们不支持覆盖已在邮箱队列中的邮件。
有关邮箱驱动程序的更多详细信息
邮箱驱动程序是一款低级内核驱动程序。 这意味着此驱动程序设计为供其他 Linux 驱动程序使用、而不是供用户空间使用。
Linux remoteproc 和 rpmsg 驱动程序是使用邮箱驱动程序进行低级通信的2个驱动程序、因此我们可以将它们作为您想要如何编写自定义内核驱动程序的示例。
我们来看看 AM64x SDK 10.0、 arch/arm64/boot/dts/ti/k3-am642-evm.dts、以了解如何 配置邮箱设置以及将邮箱信息传递给 Remoteproc 驱动程序的示例:
// the mailboxes are configured here
&mailbox0_cluster2 {
status = "okay";
mbox_main_r5fss0_core0: mbox-main-r5fss0-core0 {
ti,mbox-rx = <0 0 2>;
ti,mbox-tx = <1 0 2>;
};
mbox_main_r5fss0_core1: mbox-main-r5fss0-core1 {
ti,mbox-rx = <2 0 2>;
ti,mbox-tx = <3 0 2>;
};
};
&mailbox0_cluster4 {
status = "okay";
mbox_main_r5fss1_core0: mbox-main-r5fss1-core0 {
ti,mbox-rx = <0 0 2>;
ti,mbox-tx = <1 0 2>;
};
mbox_main_r5fss1_core1: mbox-main-r5fss1-core1 {
ti,mbox-rx = <2 0 2>;
ti,mbox-tx = <3 0 2>;
};
};
&mailbox0_cluster6 {
status = "okay";
mbox_m4_0: mbox-m4-0 {
ti,mbox-rx = <0 0 2>;
ti,mbox-tx = <1 0 2>;
};
};
// we pass the associated mailbox to the Linux remoteproc driver here
&main_r5fss0_core0 {
mboxes = <&mailbox0_cluster2 &mbox_main_r5fss0_core0>;
memory-region = <&main_r5fss0_core0_dma_memory_region>,
<&main_r5fss0_core0_memory_region>;
};
&main_r5fss0_core1 {
mboxes = <&mailbox0_cluster2 &mbox_main_r5fss0_core1>;
memory-region = <&main_r5fss0_core1_dma_memory_region>,
<&main_r5fss0_core1_memory_region>;
};
&main_r5fss1_core0 {
mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core0>;
memory-region = <&main_r5fss1_core0_dma_memory_region>,
<&main_r5fss1_core0_memory_region>;
};
&main_r5fss1_core1 {
mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core1>;
memory-region = <&main_r5fss1_core1_dma_memory_region>,
<&main_r5fss1_core1_memory_region>;
};
&mcu_m4fss {
mboxes = <&mailbox0_cluster6 &mbox_m4_0>;
memory-region = <&mcu_m4fss_dma_memory_region>,
<&mcu_m4fss_memory_region>;
status = "okay";
};
此致、
Nick
Mack、您好!
您可以看到、邮箱的 devicetree 节点同时定义了一个"TX"邮箱和一个"Rx"邮箱。 因此我希望 Linux 邮箱驱动程序能够"发送"和"接收"。
如果我们检查绑定文档、我们可以看到有 RX 和 TX 功能:
ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti$ grep -r --include=k3-am64* mailbox0_cluster4
k3-am64-main.dtsi: mailbox0_cluster4: mailbox@29040000 {
k3-am642-evm.dts:&mailbox0_cluster4 {
k3-am642-evm.dts: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core0>;
k3-am642-evm.dts: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core1>;
grep: k3-am642-evm.dtb: binary file matches
k3-am64-phycore-som.dtsi:&mailbox0_cluster4 {
k3-am64-phycore-som.dtsi: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core0>;
k3-am64-phycore-som.dtsi: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core1>;
k3-am642-sk.dts:&mailbox0_cluster4 {
k3-am642-sk.dts: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core0>;
k3-am642-sk.dts: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core1>;
k3-am642-tqma64xxl.dtsi:&mailbox0_cluster4 {
k3-am642-tqma64xxl.dtsi: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core0>;
k3-am642-tqma64xxl.dtsi: mboxes = <&mailbox0_cluster4 &mbox_main_r5fss1_core1>;
// let's get the compatibility string so we can find the driver
ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti$ vi k3-am64-main.dtsi
// now look at the bindings documentation
// this talks about devicetree usage
ti-linux-kernel-6.6.32+git-ti/arch/arm64/boot/dts/ti$ cd ../../../../../Documentation/devicetree/bindings/
ti-linux-kernel-6.6.32+git-ti/Documentation/devicetree/bindings$ grep -r 'ti,am64-mailbox'
mailbox/ti,omap-mailbox.yaml: - ti,am64-mailbox # for K3 AM64x SoCs
mailbox/ti,omap-mailbox.yaml: - ti,am64-mailbox
ti-linux-kernel-6.6.32+git-ti/Documentation/devicetree/bindings$ vi mailbox/ti,omap-mailbox.yaml
如果您查看驱动程序、将看到为接收数据而设置的 ISR:
ti-linux-kernel-6.6.32+git-ti/Documentation/devicetree/bindings$ cd ../../../drivers/ ti-linux-kernel-6.6.32+git-ti/drivers$ grep -r 'ti,am64-mailbox' grep: mailbox/omap-mailbox.o: binary file matches mailbox/omap-mailbox.c: .compatible = "ti,am64-mailbox", ti-linux-kernel-6.6.32+git-ti/drivers$ vi mailbox/omap-mailbox.c
我不确定驱动程序的确切使用方式、但我怀疑您没有调用特定函数到.receive_data。 相反、当收到邮箱且 ISR 代码运行时、你会得到一个中断。
Remoteproc 驱动程序应提供有关发送和接收邮箱的更多详细信息。
此致、
Nick