Receiving garbage at M4 core while using RPMSG

I was trying to make a user application on A7 linux talk to the M4 core using RPMSG.

After a while, I was able to load the imx_rpmsg_tty e run the example str_eco_bm and str_echo_freertos. Both of then are working fine if I do just an echo on /dev/ttyRPMSG0.

After that I wrote a C program with a simple open/write/close and then I notice that the M4 receive some junk.

The program only works if I put some huge delay (1s) between open/write/close operation.
After that, I’ve done some tests with the echo on /dev/ttyRPMSG0 in a loop and I noticed the same problem.

If I keep my program running, then I got “systemd-journald[157]: /dev/kmsg buffer overrun, some messages lost.” on console.
It looks the same problem as @sooraj had here 1

Also, a read is not working at all.

What could be happening?

What data, how and how often are you sending? For binary you need to switch tty to raw mode, something like this

struct termios newtio;  

		Skt = open( hwdevice, O_RDWR | O_NOCTTY );
		tcflush(Skt, TCIOFLUSH);
		tcgetattr(Skt, &newtio);

With this done it should work well. If it doesn’t, then perhaps you are sending too much/too often. Default Linux driver and M4 side settings are 512 bytes buffers. So you can send up to 512-16=496 bytes in one write() transaction. Buffers count is limited as well, so you should send at rate Linux side will be able to empty those buffers.


I was just sending some numbers as test, but I wanted to send it repeatedly as fast as I could (at each 100us, for example). The problem is that even sending some numbers at each 500ms I could notice the problem.

I could fix the problem by removing the debug messages in the rpmsg callback (rpmsg_tty_cb inside imx_rpmsg_tty.c). This module was printing a lot of messages that I was not seeing until I run dmesg.

I was already using these configurations that you showed, but it did not work.

RPMSG is reliable and doesn’t produce garbage, unless you put it out of the limits. High interrupt rate is Linux performance killer (not only Linux). So you with lots of data you should send more but not more than 496 bytes in one write(), on both Cortex-A and -M ends. Each end has to pull received data ASAP.

I thought by garbage you mean garbage caused by data loss due to buffers overflow caused by failure to receive data in time or sending too few data in one write. If you see garbage at low rates, then I think something is wrong ion your SW, either on Cortex-A or -M.