Skip to main content
Visitor II
March 8, 2020
Solved

A question regarding OpenAMP RPMsg example

  • March 8, 2020
  • 4 replies
  • 3236 views

Hi, I'm currently porting OpenAMP virtio to Arduino platform:

https://github.com/stm32duino/Arduino_Core_STM32/pull/766

I would like to share one thing about the OpenAMP examples in CubeMP1.

Here is the implementation of MAILBOX_Poll:

int MAILBOX_Poll(struct virtio_device *vdev)
{
 /* If we got an interrupt, ask for the corresponding virtqueue processing */
 int ret = -1;
 
 /* USER CODE BEGIN PRE_MAILBOX_POLL */
 
 /* USER CODE END PRE_MAILBOX_POLL */
 
 if (msg_received_ch1 == RX_BUF_FREE) {
 
 /* USER CODE BEGIN MSG_CHANNEL1 */
 
 /* USER CODE END MSG_CHANNEL1 */
 
 OPENAMP_log_dbg("Running virt0 (ch_1 buf free)\r\n");
 rproc_virtio_notified(vdev, VRING0_ID);
 msg_received_ch1 = RX_NO_MSG;
 ret = 0;
 }
 
 if (msg_received_ch2 == RX_NEW_MSG) {
 
 /* USER CODE BEGIN MSG_CHANNEL2 */
 
 /* USER CODE END MSG_CHANNEL2 */
 
 OPENAMP_log_dbg("Running virt1 (ch_2 new msg)\r\n");
 rproc_virtio_notified(vdev, VRING1_ID);
 msg_received_ch2 = RX_NO_MSG;
 
 /* The OpenAMP framework does not notify for free buf: do it here */
 rproc_virtio_notified(NULL, VRING1_ID);
 ret = 0;
 }

I found a weird piece of code:

/* The OpenAMP framework does not notify for free buf: do it here */
 rproc_virtio_notified(NULL, VRING1_ID);

https://github.com/STMicroelectronics/STM32CubeMP1/blob/c604fa0965c73e430eebd5fa780180beb9a71b44/Projects/STM32MP157C-DK2/Applications/OpenAMP/OpenAMP_TTY_echo/Src/mbox_ipcc.c#L139-L140

Because rproc_virtio_notified(NULL) essentially do nothing because rproc_virtio_notified() will return a error code -EINVAL :

int rproc_virtio_notified(struct virtio_device *vdev, uint32_t notifyid)
{
	unsigned int num_vrings, i;
	struct virtio_vring_info *vring_info;
	struct virtqueue *vq;
 
	if (!vdev)
		return -EINVAL;
	/* We do nothing for vdev notification in this implementation */
	if (vdev->index == notifyid)
		return 0;
	num_vrings = vdev->vrings_num;
	for (i = 0; i < num_vrings; i++) {
		vring_info = &vdev->vrings_info[i];
		if (vring_info->notifyid == notifyid ||
		 notifyid == RSC_NOTIFY_ID_ANY) {
			vq = vring_info->vq;
			virtqueue_notification(vq);
		}
	}
	return 0;
}

https://github.com/STMicroelectronics/STM32CubeMP1/blob/66ec26f6422283fe5cd25a32babf925836df9399/Middlewares/Third_Party/OpenAMP/open-amp/lib/remoteproc/remoteproc_virtio.c#L290

Could anyone tell me any reasons to suggest people using this line from the examples? I believe that this line should be considered as a bug.

Thank you,

Bumsik Kim.

    This topic has been closed for replies.
    Best answer by ArnaudP

    I confirm, we will fix this internally

    Thanks for the feedback

    4 replies

    ST Employee
    March 9, 2020

    Hello Bumsik,

    Thanks for pointing out these lines.

    We have to crosscheck but this looks to me legacy code from a previous implementation, that as not been cleaned.

    Regards

    Arnaud P

    Visitor II
    March 10, 2020

    Thanks for reply. Please crosscheck, the line gave me an impression that I might need to put another parameters while I was porting it.

    ArnaudPAnswer
    ST Employee
    March 11, 2020

    I confirm, we will fix this internally

    Thanks for the feedback

    Visitor II
    March 11, 2020

    Thank you for confirming it!

    Visitor II
    March 14, 2020

    @Bumsik Kim​ -- what is the status on your port? I am attempting to get the powerSTEP01 IHM03A1 running on the DK2 (stm32mp1), and am very interested in being able to open /dev/ttyRPMSGx for bidirectional communication with the M4. I pulled the latest stm32 arduino core, and have selected the DK2, and am able to run a few examples, but the arduino examples I have used do not create the RPMSG connection. The openAMP demo works fine, so I am wondering what is involved in creating the port under arduino and using it.

    Thanks in advance for any info you can provide. If you would like any assistance on the port I would be happy to chip in.

    Visitor II
    March 14, 2020

    You can see the current status here: https://github.com/stm32duino/Arduino_Core_STM32/pull/766

    So the port is completed and will be merged in a few days to the master branch. However, you will have to wait for an official v1.9.0 release to use the port out-of-the-box.

    If you want to try this right now, go to "Getting Started" section of the README of stm32 to work with my kbumsik/virtio repository. https://github.com/stm32duino/Arduino_Core_STM32

    Here is the full description on how to use the port: https://github.com/kbumsik/Arduino_Core_STM32/tree/3b88ae207b3186a1769b84fff60f116109f759bf/variants/STM32MP157_DK

    Visitor II
    March 14, 2020

    Excellent response!

    I will definitely check it out.

    Any ideas on schedule for 1.9.0?

    Visitor II
    March 14, 2020

    I'm not sure, but I guess it will be soon enough because the last v1.8.0 is December.​