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.

Linux/AM5728: Questions about PRU RPMsg driver on linux

Part Number: AM5728

Tool/software: Linux

Hello,I tried to figure it out how A15 kicks PRU through RPMSG & mailbox,can you help me ,thanks ahead.

I read drivers/remoteproc/pru_rproc.c

static void pru_rproc_kick(struct rproc *rproc, int vq_id)
{
	struct device *dev = &rproc->dev;
	struct pru_rproc *pru = rproc->priv;
	int ret;

	dev_dbg(dev, "kicking vqid %d on PRU%d\n", vq_id, pru->id);

	if (pru->mbox) {
		/*
		 * send the index of the triggered virtqueue in the mailbox
		 * payload
		 */
		ret = mbox_send_message(pru->mbox, (void *)vq_id);
		if (ret < 0)
			dev_err(dev, "mbox_send_message failed: %d\n", ret);
	} else if (pru->irq_kick > 0) {
		ret = pruss_intc_trigger(pru->irq_kick);
		if (ret < 0)
			dev_err(dev, "pruss_intc_trigger failed: %d\n", ret);
	}
}

And I thought the driver rpmsg_pru should call "pru_rproc_kick" when it A15 send data out .

But : in drivers/rpmsg/rpmsg_pru.c("-->" means call  )

rpmsg_write() --> rmpsg_send() --> virtio_rpmsg_send --> rpmsg_send_offchannel_raw --> virtqueue_kick

I am now getting confused , question is :

1. How do the driver "rpmsg_pru.c" kicks PRU, I think the driver must access mailbox.

2.How do these drivers cooperate?  "rpmsg_pru.c",   "pru_rproc.c",   "omap-mailbox.c"

  • Hello,

    What version of Linux are you using? The RemoteProc portion of that wiki still applies, but the RPMsg part of the wiki needs to be updated for our recent SDKs.

    The RPMsg buffers are still used in the same way to pass a message from the ARM to the PRU (or vice versa). The difference in the current code is that instead of using mailboxes, we use system interrupts to communicate between cores. So the PRU's INTC is configured to send and receive interrupts from the ARM that a buffer is available to be read by the ARM core or the PRU core.

    Regards,
    Nick
  • I am using ti-processor-sdk-linux-rt-am57xx-evm-04.01.00.06,linux version is linux-rt-4.9.41+gitAUTOINC+c038d21a22-gc038d21a22.

    Platform is am5728_idk_board.

  • I expect RT Linux SDK 4.1 to use interrupts rather than mailboxes. Linux SDK 4.1 uses interrupts. I double checked by finding &pruss_soc_bus in the device tree file am57x-beagle-x15-common.dtsi (which is included by am57xx-beagle-x15-revb1.dts, which is included by am57xx-evm-reva3-base.dts). If pru1_0, pru1_1, etc list interrupts, then it uses interrupts. If it lists mailboxes, the example for that version of the SDK uses mailboxes.

    You can double check those interrupt settings in the PRU RPMsg firmware in your RT Linux SDK, e.g. example-applications/pru-icss-5.1.0/examples/am572x/PRU_RPMsg_Echo_Interrupt1_0/main.c

    Does that answer your question?

    Regards,
    Nick
  • Hello , Thanks for reply .I checked my sdk, and yes pru is using INTC.

    Auctually,our team is trying to build the communication bridge between A15 and PRU , A15 and M4(using mailbox , I know ti team has establish remoteproc for doing that ,but we have special demands).

    I am developing the mailbox driver on A15, and really confused .

    There is a driver of omap-mailbox in ,e,g,KERNEL/driver/mailbox/omap-mailbox.c.

    1. I want to write a driver to create a device in /dev, e,g, "/dev/m4_kfifo", and when I open and write to "/dev/m4_kfifo" in custom application  , mailbox will kick the processor M4.  

    I don't know whether there is a simple example of using omap-mailbox. Mailbox_controller & mailbox _client really confuse me.

    2. By the way , after reading the pru driver code , I still wonderring why "echo start > /sys/class/remoteproc/remoteproc4/state " will create e,g, "/dev/rpmsg_rpu30 "?

    Thanks !

  • Hello,

    Here is the patch from the PRU side where we switched from mailboxes to interrupts - hopefully it clarifies how we used to implement mailboxes from the PRU side. I have not had time to try to look at mailboxes from the ARM side much yet to see if there are better examples than Mailbox_controller & mailbox_client. Let me know if you want me to look at that more.

     /dev/rpmsg_pru30 is created when the PRU_RPMsg_Echo_Interrupt_x_x/main.c file calls pru_rpmsg_channel(). The ARM side of this is located at linux-x.y.z/drivers/rpmsg/rpmsg_pru.c

    Regards,

    Nick

  • I am marking this thread resolved on my end. Feel free to reply if there are follow-up questions.

    Regards,
    Nick