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.

[参考译文] PROCESSOR-SDK-AM62X:IPC 通信:邮箱和 VRING 之间的关系

Guru**** 2538960 points


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

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1382072/processor-sdk-am62x-ipc-communication-relationship-between-mailbox-and-vring

器件型号:PROCESSOR-SDK-AM62X

工具与软件:

您好、TI 专家

我尝试了 rpmsg 示例代码将消息从 m62x 发送到 M4。

我想知道在没有从其他 MCU 接收任何消息的情况下可以从 m62x 发送多少条消息。

因此我修复了  rpmsg  样例源代码的 rpmsg_char_ping()函数、如下所示。

(删除  recv_msg()函数、仅发送函数)

/* single thread communicating with a single endpoint */
int rpmsg_char_ping(int rproc_id, char *dev_name, int remote_endpt,
		    int num_msgs, char *msg_contents)
{
	int ret = 0;
	int i = 0;
	int packet_len;
	char eptdev_name[32] = { 0 };
	char packet_buf[512] = { 0 };
	rpmsg_char_dev_t *rcdev;
	int flags = 0;

        /*
         * Open the remote rpmsg device identified by dev_name and bind the
	 * device to a local end-point used for receiving messages from
	 * remote processor
         */
	sprintf(eptdev_name, "rpmsg-char-%d-%d", rproc_id, getpid());
	rcdev = rpmsg_char_open(rproc_id, dev_name, remote_endpt,
				eptdev_name, flags);
        if (!rcdev) {
		perror("Can't create an endpoint device");
		return -EPERM;
        }
        printf("Created endpt device %s, fd = %d port = %d\n", eptdev_name,
		rcdev->fd, rcdev->endpt);

        printf("Exchanging %d messages with rpmsg device ti.ipc4.ping-pong on rproc id %d ...\n\n",
		num_msgs, rproc_id);
		
	for (i = 0; i < num_msgs; i++) {
		memset(packet_buf, 0, sizeof(packet_buf));
		sprintf(packet_buf, msg_contents);
		packet_len = strlen(packet_buf);
		printf("Sending message #%d: %s\n", i, packet_buf);
		ret = send_msg(rcdev->fd, (char *)packet_buf, packet_len);
		if (ret < 0) {
			printf("send_msg failed for iteration %d, ret = %d\n", i, ret);
			goto out;
		}
		if (ret != packet_len) {
			printf("bytes written does not match send request, ret = %d, packet_len = %d\n",
				i, ret);
		    goto out;
		}
		/* TODO: Verify data integrity */
	}

	printf("\nCommunicated %d messages successfully on %s\n\n",
		num_msgs, eptdev_name);

out:
	ret = rpmsg_char_close(rcdev);
	if (ret < 0)
		perror("Can't delete the endpoint device\n");

	return ret;
}

然后、我执行文件并收到错误消息

1.我可以发送42条消息,没有任何错误

root@am62xx-evm:~# ./ti_send_only -r 9 -n 42
Created endpt device rpmsg-char-9-1054, fd = 3 port = 1024
[   88.578465] omap-mailbox 29000000.mailbox: Try increasing MBOX_TX_QUEUE_LEN
Exchanging 42 messages with rpmsg device ti.ipc4.ping-pong on rp[   88.590224] k3-m4-rproc 5000000.m4fss: failed to send mailbox message, status = -105
roc id 9 ...

Sending message #0: hello there 0!
Sending message #1: hello there 1!
Sending message #2: hello there 2!
Sending message #3: hello there 3!
Sending message #4: hello there 4!
Sending message #5: hello there 5!
Sending message #6: hello there 6!
Sending message #7: hello there 7!
Sending message #8: hello there 8!
Sending message #9: hello there 9!
Sending message #10: hello there 10!
Sending message #11: hello there 11!
Sending message #12: hello there 12!
Sending message #13: hello there 13!
Sending message #14: hello there 14!
Sending message #15: hello there 15!
Sending message #16: hello there 16!
Sending message #17: hello there 17!
Sending message #18: hello there 18!
Sending message #19: hello there 19!
Sending message #20: hello there 20!
Sending message #21: hello there 21!
Sending message #22: hello there 22!
Sending message #23: hello there 23!
Sending message #24: hello there 24!
Sending message #25: hello there 25!
Sending message #26: hello there 26!
Sending message #27: hello there 27!
Sending message #28: hello there 28!
Sending message #29: hello there 29!
Sending message #30: hello there 30!
Sending message #31: hello there 31!
Sending message #32: hello there 32!
Sending message #33: hello there 33!
Sending message #34: hello there 34!
Sending message #35: hello there 35!
Sending message #36: hello there 36!
Sending message #37: hello there 37!
Sending message #38: hello there 38!
Sending message #39: hello there 39!
Sending message #40: hello there 40!
Sending message #41: hello there 41!

Communicated 42 messages successfully on rpmsg-char-9-1054

TEST STATUS: PASSED

2.我发送43条消息时收到错误消息

root@am62xx-evm:~# ./ti_send_only -r 9 -n 43
Created endpt device rpmsg-char-9-1060, fd = 3 port = 1024
[   26.746459] omap-mailbox 29000000.mailbox: Try increasing MBOX_TX_QUEUE_LEN
Exchanging 43 messages with rpmsg device ti.ipc4.ping-pong on rp[   26.758212] k3-m4-rproc 5000000.m4fss: failed to send mailbox message, status = -105
roc id 9 ...

Sending message #0: hello there 0!
Sending mess[   26.771521] omap-mailbox 29000000.mailbox: Try increasing MBOX_TX_QUEUE_LEN
age #1: hello there 1!
Sending message #2: hello there 2!
Send[   26.783949] k3-m4-rproc 5000000.m4fss: failed to send mailbox message, status = -105
ing message #3: hello there 3!
Sending message #4: hello there 4!
Sending message #5: hello there 5!
Sending message #6: hello there 6!
Sending message #7: hello there 7!
Sending message #8: hello there 8!
Sending message #9: hello there 9!
Sending message #10: hello there 10!
Sending message #11: hello there 11!
Sending message #12: hello there 12!
Sending message #13: hello there 13!
Sending message #14: hello there 14!
Sending message #15: hello there 15!
Sending message #16: hello there 16!
Sending message #17: hello there 17!
Sending message #18: hello there 18!
Sending message #19: hello there 19!
Sending message #20: hello there 20!
Sending message #21: hello there 21!
Sending message #22: hello there 22!
Sending message #23: hello there 23!
Sending message #24: hello there 24!
Sending message #25: hello there 25!
Sending message #26: hello there 26!
Sending message #27: hello there 27!
Sending message #28: hello there 28!
Sending message #29: hello there 29!
Sending message #30: hello there 30!
Sending message #31: hello there 31!
Sending message #32: hello there 32!
Sending message #33: hello there 33!
Sending message #34: hello there 34!
Sending message #35: hello there 35!
Sending message #36: hello there 36!
Sending message #37: hello there 37!
Sending message #38: hello there 38!
Sending message #39: hello there 39!
Sending message #40: hello there 40!
Sending message #41: hello there 41!
Sending message #42: hello there 42!

Communicated 43 messages successfully on rpmsg-char-9-1060

TEST STATUS: PASSED

我可以找到2个错误日志、如下所示

- [26.746459]  OMAP-mailbox 29000000.mailbox:尝试增加 MBOX_TX_QUEED_LEN

- [26.758212]  k3-m4-rproc 5000000.m4fss:发送邮箱消息失败,状态=-105

但我只能找到2次,并在发送 msg3后,我不能收到任何错误

3.我尝试发送257封邮件。 我得到不同的错误日志,如以下(超时错误日志和应用程序错误日志后发送256消息)

Sending message #255: hello there 255!
[   35.077819] omap-mailbox 29000000.mailbox: Try increasing MBOX_TX_QUEUE_LEN
[   35.088237] k3-m4-rproc 5000000.m4fss: failed to send mailbox message, status = -105
Sending message #256: hello there 256!
[   50.237617] rpmsg_chrdev virtio0.rpmsg_chrdev.-1.14: timeout waiting for a tx buffer
Can't write to rpmsg endpt device
: Unknown error 512
send_msg failed for iteration 256, ret = -1

它会受到 vring 大小256的影响、但我想知道 test#2错误日志计时。

结果我想知道如下。

1. vring 和 mailobx 之间的关系: 1 vring = 1邮箱?  

2.为什么在发送第一条消息之前出现错误日志(测试2)

3.为什么我可以发送最多42条消息而没有错误日志(但缓冲区大小为256 )。

4.从用户应用程序发送到 M4内核的消息序列

  (我搜索了其他核心内容、am62x 是否相同? : TMDS64EVM:关于 IPC 和邮箱-处理器论坛-处理器- TI E2E 支持论坛)

感谢您一如既往的支持!

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

    您好!

    我们的 IPC 专家将在未来两周不在办公室。 请预计会延迟响应。

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

    另外、我还有关于测试3的其他问题。

    [   35.077819] omap-mailbox 29000000.mailbox: Try increasing MBOX_TX_QUEUE_LEN
    [   35.088237] k3-m4-rproc 5000000.m4fss: failed to send mailbox message, status = -105

    此错误会影响并仅出现内核段、因此应用程序 write()函数在 vring 缓冲区已满(256)"之前仍会执行。

    所以、将无法重试发送消息。  

    您是否有任何过程设计可以从用户空间和应用程序中检查当前邮箱队列大小(最大值:mbox_TX_queue_LEN 20)。  

    谢谢你

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

    您好、李继云:

    对于此处的延迟响应、我们深表歉意。 我现在又回到办公室了。

    什么是 RPMsg 以及什么是邮箱?

    首先、RPMsg 是一个更高级别的 IPC 协议、在内核之间发送多达496字节的数据。 邮箱是一种较低级别的通知方法、用于通知另一个内核在 VRING 中有一个 RPMSG 在等待它们。

    如需更多信息、请参阅 AM62x Academy 多核部分 IPC 基础知识:
    https://dev.ti.com/tirex/explore/node?node=A__AVYlbIHvOdYOTWe2faPbkQ__AM62-ACADEMY__uiYMDcq__LATEST

    这些队列和 FIFO 都是什么?

    请牢记下面几个不同的 FIFO/邮箱队列/ Virtio 缓冲器:

    1)邮箱硬件 FIFO:每个邮箱的硬件邮箱 FIFO 中只有4个条目。 因此、如果接收内核没有从硬件 FIFO 中弹出邮箱消息、则 Linux 将无法将任何更多的邮箱消息放入硬件以供远程内核接收。

    2)邮箱驱动程序的软件队列:这是正在等待被放入硬件邮箱 FIFO 的邮箱消息队列。 默认情况下、邮箱驱动程序编程为在软件队列中有20个位置、但这是一个任意数字。 事实上、邮箱驱动程序是独立于 RPMsg 驱动程序开发的、因此如果您不将邮箱驱动程序用于任何其他用途、我实际上建议修改该邮箱驱动程序为更特定的 RPMsg。 如果需要、可以增大此值(稍后详细说明)

    3) RPMsg virtio 缓冲区:这是 RPMsg 协议存储等待其他处理器内核接收的消息的存储器。 默认情况下、Linux 在每个方向上分配256个缓冲区、总共512个缓冲区。 从技术上讲、可能有一种方法可以减少分配的缓冲区数量以节省 DDR 存储器中的内容、但上次我看了看、在不得不讨论其他内容之前、我无法让它开始工作。 因此、我建议目前单独保留这些缓冲器。

    您可以修改什么?  

    其他一些客户已修改 Linux 邮箱驱动程序、使软件邮箱队列包含256个条目、以匹配可等待另一个处理器内核接收的最大256个 RPMsg 消息。

    此致、

    Nick