cancel
Showing results for 
Search instead for 
Did you mean: 

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.

KChar.1
Senior

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.

5 REPLIES 5
KChar.1
Senior

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;
 
}

PatrickF
ST Employee

Hi, see also https://wiki.st.com/stm32mpu/wiki/How_to_exchange_large_data_buffers_with_the_coprocessor_-_example

There is link to logic analyzer example.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
KChar.1
Senior

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.

Did you already look at the OpenAMP_TTY_echo ? https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-EV1/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Modify,_rebuild_and_reload_a_firmware

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
KChar.1
Senior

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 =)