Skip to main content
Graduate
April 25, 2021
Question

Is there any OpenAMP, RPMSG, simple C example? I am trying to learn more about IPC from user-space and I am looking for a simple C example that can send messages to ttyRPMSG0 in STM32MP1.

  • April 25, 2021
  • 4 replies
  • 2764 views

Hey there,

I am new to STM32MP1 and this forum has been a great help. During the last week I am trying to understand the OpenAMP between the M4 and A7. The ttyRPMSG makes things quite straight forward for the M4 part. When going to the linux part, using terminal is also very convenient, but I would like to send some simple messages from inside C. Until now, I have struggled quite a bit with getting the concept. I have not found yet any simple examples for that. If you have something in mind it would be of great help.

    This topic has been closed for replies.

    4 replies

    KChar.1Author
    Graduate
    April 26, 2021

    Hi, I managed to make something simple for writing that works. I leave it here for future reference and any possible feedback.

    //write a fixed message in ttyRPMSG0 
     
    #include <stdio.h>
     
    #include <unistd.h>
     
    #include <fcntl.h>
     
    #define TTY_RPMSG "/dev/ttyRPMSG0"
     
    int main()
     
    {
     
    //open the device
     
     int fd = open(TTY_RPMSG, O_RDWR | O_NOCTTY | O_SYNC | O_NDELAY);
     
    //write a simple message and its lenght
     
     write(fd, "restart", 7);
     
    //close the device 
     
     close(fd);
     
     return 0;
     
    }

    Technical Moderator
    April 26, 2021
    KChar.1Author
    Graduate
    April 27, 2021

    Hi Patrick,

    Thanks a lot for this! This is my next challenge. Since the code on this one is a bit more complex I was looking for a simpler starting point.

    Technical Moderator
    April 27, 2021
    KChar.1Author
    Graduate
    April 27, 2021

    Yes, this was my starting point. Very clear and super useful! I just wanted to transfer the echo functionality from the console to C. The small C code above did the work just fine for now =)