A generic way to make use of rpmsg from user space

I would like to write a user space application on the A7 linux side of the iMX7 and talk with the M4 using rpmsg.
I have used and analyzed the imx_rpmsg_pingpong LKM and looked carefully at the other rpmsg modules but cannot seem to make the leap to what I want to do.
I noticed for example that the imx_rpmsg_tty LKM when installed allows you to access it from the command line which makes it fairly generic.
The pingpong example is done entirely within an LKM but I don’t want to do that because I have a large application that needs to use it and I want to have it run from user space.

So, what is the expected mechanism for sending and receiving generic data of my choosing across the interface to the M4 without incorporating it all into an LKM? Is there an LKM I can install that will provide me an open/close/read/write rpmsg interface from user space for example?

The imx_rpmsg_tty is pretty much what you describe here: It offers /dev/ttyRPMSG. The device can also be used by a C program, using open/close and read/write data to it. This get automatically sent in packages to the other side. With a proper protocol ontop you (e.g. a simple ASCII protocol with newline as command delimiters, or something more sophisticated such as an TLV protocol).

NXP also offers more advanced examples in their erpc-imx-demos repository. Especially the multi-endpoint example uses another approach to access the RPmsg through a user space API (using the rpmsg-sysfs kernel module). We have not used/tried the examples on our platform, but I would expect it to be fairly easily used with our platform as well.

I tried like you said. I used simple open, read, write instructions on file /dev/RPMsg to send data to M4. The code works for single write command. But when i am trying to write in a loop, i receive junk data at m4. Also the read() command is not at all working.
Also if there is only a single write command and if i put a delay after it, same thing occurs (receives junk data at M4). I am only using simple open, read, write commands. Am i missing something here? Can you please provide a sample program with simple read-write? Please help

hi @sooraj

Welcome to the Toradex Community!!!

Could you please ask a new question and provide the details of your module and your issue?

Best regards, Jaski