RPMsg implementation

Hello community,
We were using Toradex colibri iMX6 for our product but now for precise data acquisition, we changed iMX6 to iMX7D. Our product runs a application on GTK. Our objective is to plot two graphs between data from four channels of a ADC. The ADC is connected to iMX7D using SPI communication of the M4 micro-controller running with freeRTOS. So we need to send the acquired data (float array) to the A7 processor through RPMsg. We need some suggestions regarding this approach. The size of the each array will be around 50000.

  1. Is it possible to send the whole array using RPMsg?
  2. Examples or documents regarding RPMsg implementation will be helpful.

Thanks and regards,Nishanth

Dear @nishanth1829

  1. By default the buffer size for one RpMsg is 512 Bytes by default. So you need to split up your data into blocks of maximum 512 Bytes.
    As an alternative you can increase the buffer size. This has to be done identically in Linux and in FreeRTOS. There’s a description how to do this in the following developer page article:
  1. There is a RpMsg tutorial on our developer page, too:

Regards, Andy

Hi @andy.tx ,
Thanks for your quick reply.

  1. If we can increase the RpMsg buffer size, what will be maximum size?
  2. For example, lets say we have 512bytes of RpMsg buffer size. So I will be able to send 128 float values (128*4). Will be values be overwritten if I keep on sending from M4 and not receiving from A7?
  3. Is it necessary to develop a kernel module for our requirement or the imx_rpmsg_tty enough?

Regards,
Nishanth

Dear @nishanth1829

  1. The maximum size is limited by the available RAM only
  2. Just try it out. If all available buffers are used up, the send will be stalled.
  3. The tty solution has some performance impacts. If you can live with that, you don’t need a custom kernel module.

Regards, Andy

Dear @andy.tx ,
Our requirement is that we will be sending blocks of data all the time and we will be reading only when needed from the Linux side. So for this, will RPMsg be suitable?
Also, is it possible to create seperate channels for transfer from M4 to A7?

Regards,
Nishanth

Dear @Nishanth

Yes, RpMsg is suitable for this.

There is one channel from M4 to A7, and another channel from A7 to M4. There is no easy way to generate additional channels, unless you extend the current RpMsg implementation on both the Linux and M4 side.

Regards, Andy

Dear @andy.tx ,
I have implemented RPMsg in iMX7 and I am sending 250 buffers of data and each buffer contains 100 float values from M4 to A7. But I could see that once when 250 buffers are sent, I cannot sent next unless I read the buffers from A7 side as the default no. of buffers is 256. So I need to read 250 buffers from A7 side and then sent a acknowledgement to M4 that all buffers are read and then M4 will send next set of 250 buffers. Is this a right way?Any suggestions regarding this approach?

Regards,Nishanth

Dear @nishanth1829

You don’t need to send an acknowledgement to the M4. The M4 sending will continue automatically as soon as there is some space in the buffers.
So as soon as the A7 reads a buffer, the M4 sending will continue automatically.

Regards, Andy

Dear @andy.tx ,
I tried by continous writing in from M4 and reading at some intervals from A7 but I am missing some data and also kernel prints the below error

 [   97.848295] imx_rpmsg_tty virtio0.rpmsg-openamp-demo-channel.-1.0: RX copy to tty layer failed

Dear @andy.tx , To make it more clear, my issue is similiar to this. What I am doing in my code is I will be sending a 4000 byte data (increased buffer size to 5000) from M4 to A7 at 25ms interval. In A7 side, I will be reading the data in a while loop at an interval of 25ms. But I am getting this error

[  153.640785] imx_rpmsg_tty virtio0.rpmsg-openamp-demo-channel.-1.0: RX copy to tty layer failed

after starting to send. Also i searched for this line in the kernel module and found this in imx_rpmsg_tty.c under drivers/rpmsg folder. So this error is printed once when the tty queue is filled and then the data is dropped. But I am reading data in A7 at the same rate of sending. So why does the queue gets filled up? Also is 25ms too small to use in rpmsg?
Regards,
Nishanth

Hi @jaski.tx ,
I too tried with this and changed the delay to 1ms and now I am able to read all the data without getting kernel message. But sometime times, I am reading a single 4000 byte message , two times as 3512 and 488 bytes. But the data is correct so that’s not an issue. Thanks for your support.
Regards,Nishanth

HI Nishant

Sorry for the delayed answer.

So this error is printed once when the tty queue is filled and then the data is dropped. But I am reading data in A7 at the same rate of sending. So why does the queue gets filled up?

Linux is not a real-time OS, but free RTOS is. So if you write every 25ms in freeRTOS then this does not mean then in Linux this is read at the exact same rate. Try to shorten the time in while loop and read faster from Linux side.

Best regards,
Jaski

Perfect that the issue is solved.

Best regards,
Jaski