cancel
Showing results for 
Search instead for 
Did you mean: 

stm32mp157c rpmsg comminucation problem

aliMesut
Associate III

Hi,

I'm working QSMP-1570 SOM. There is STM32MP157C on it. I am trying to communicate between processors using RPMSG.

I see that RPMSG's are formed under /dev.

ttyRPMSG0, ttyRPMSG1.

I'm opened serial port in linux side;

if ((fd = open("/dev/ttyRPMSG0", O_RDONLY | O_NOCTTY)) < 0)

  {

    GL.status |= YNDL_STATUS_FATAL_ERROR;

    fd = STDERR_FILENO;

    return EXIT_FAILURE;

  }

Then when i call function write();

write(fd, buffer, 200); // return -1

Function retruns errno:11 (Resource temporarily unavailable)

Buffer in IPCC isn't it ring buffer?

Why am I getting an error ?

1 ACCEPTED SOLUTION

Accepted Solutions
Kevin HUBER
ST Employee

Hello @aliMesut​ ,

Ok, I made a small code in c to try to write 200 bytes in one write operation like you:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
 
int	main (int argc, char **argv)
{
  int32_t	i32Fd;
  int32_t	i32Ret;
  u_int8_t	au8Buffer[200];
  int32_t	i32Errno;
  
  if (memset(au8Buffer, 0, sizeof(au8Buffer)) == NULL)
    {
      printf("memset failed\n");
      return -1;
    }
  if ((i32Fd = open("/dev/ttyRPMSG0", O_WRONLY | O_NOCTTY)) < 0)
  {
 
    printf("Open failed and returned i32Fd = [%d]\n", i32Fd);
 
    i32Fd = STDERR_FILENO;
 
    return -1;
 
  }
  i32Ret = write(i32Fd, au8Buffer, sizeof(au8Buffer));
  if (i32Ret < 0)
    {
      i32Errno = errno;
      printf("write failed and returned ret = [%d] and errno = [%d][%s]\n", i32Ret, i32Errno, strerror(i32Errno));
      return -1;
    }
  printf("Success %d bytes written\n", i32Ret);
  return 0;
}

And it works every time.

root@stm32mp1:~# ls /dev/ttyRPMSG0 -l
crw-rw---- 1 root dialout 5, 3 Sep 20 11:26 /dev/ttyRPMSG0
root@stm32mp1:~# /usr/local/gtk_hello_world 
Success 200 bytes written
root@stm32mp1:~# /usr/local/test
Success 200 bytes written
root@stm32mp1:~# /usr/local/test
Success 200 bytes written
root@stm32mp1:~# /usr/local/test
Success 200 bytes written
root@stm32mp1:~# 

I used the application example OpenAMP_TTY_echo that is provided with the STM32Cube_FW_MP1: https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Install_STM32Cube_MP1_package

Please follow this page and the next one to test the OpenAMP_TTY_echo.

This application will executes the VIRT_UART_Init and other functions call to create the "/dev/ttyRPMSG0" and makes it operational.

Can you try your code with this M4 application to see how your code behaves.

And please send me the log, if you still encounter issue.

Other wiki page about this application:

https://wiki.st.com/stm32mpu/wiki/Exchanging_buffers_with_the_coprocessor#Direct_buffer_exchange_mode

Hope it helps you,

Regards,

Kevin

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.

View solution in original post

4 REPLIES 4
Kevin HUBER
ST Employee

Hi @aliMesut​ ,

You are opening "/dev/ttyRPMSG0" in Read Only by using the flag O_RDONLY.

In Read only, you can't write on this fd.

Please open with O_WRONLY or O_RDWR. Have a look to the manpage of the function "open" for more information.

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

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.
aliMesut
Associate III

Hi @Kevin HUBER​ ,

I'm sorry, I mistyped while copy-pasting. In fact, it is open in the O_WRONLY, but there is the problem that I explained at the beginning.

Best Regards.

Kevin HUBER
ST Employee

Hello @aliMesut​ ,

Ok, I made a small code in c to try to write 200 bytes in one write operation like you:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
 
int	main (int argc, char **argv)
{
  int32_t	i32Fd;
  int32_t	i32Ret;
  u_int8_t	au8Buffer[200];
  int32_t	i32Errno;
  
  if (memset(au8Buffer, 0, sizeof(au8Buffer)) == NULL)
    {
      printf("memset failed\n");
      return -1;
    }
  if ((i32Fd = open("/dev/ttyRPMSG0", O_WRONLY | O_NOCTTY)) < 0)
  {
 
    printf("Open failed and returned i32Fd = [%d]\n", i32Fd);
 
    i32Fd = STDERR_FILENO;
 
    return -1;
 
  }
  i32Ret = write(i32Fd, au8Buffer, sizeof(au8Buffer));
  if (i32Ret < 0)
    {
      i32Errno = errno;
      printf("write failed and returned ret = [%d] and errno = [%d][%s]\n", i32Ret, i32Errno, strerror(i32Errno));
      return -1;
    }
  printf("Success %d bytes written\n", i32Ret);
  return 0;
}

And it works every time.

root@stm32mp1:~# ls /dev/ttyRPMSG0 -l
crw-rw---- 1 root dialout 5, 3 Sep 20 11:26 /dev/ttyRPMSG0
root@stm32mp1:~# /usr/local/gtk_hello_world 
Success 200 bytes written
root@stm32mp1:~# /usr/local/test
Success 200 bytes written
root@stm32mp1:~# /usr/local/test
Success 200 bytes written
root@stm32mp1:~# /usr/local/test
Success 200 bytes written
root@stm32mp1:~# 

I used the application example OpenAMP_TTY_echo that is provided with the STM32Cube_FW_MP1: https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Install_STM32Cube_MP1_package

Please follow this page and the next one to test the OpenAMP_TTY_echo.

This application will executes the VIRT_UART_Init and other functions call to create the "/dev/ttyRPMSG0" and makes it operational.

Can you try your code with this M4 application to see how your code behaves.

And please send me the log, if you still encounter issue.

Other wiki page about this application:

https://wiki.st.com/stm32mpu/wiki/Exchanging_buffers_with_the_coprocessor#Direct_buffer_exchange_mode

Hope it helps you,

Regards,

Kevin

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.
aliMesut
Associate III

Hi @Kevin HUBER​ 

Thank you for your helping.

There hasn't been an inexplicable problem in where bug report before.

Best Regards,

Mesut