cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP1 cannot read M4 message

TArre.1
Associate III

Hi!

I have created a program to send messages between cores (A7 and M4), using virtual uart. The messages that are sent from the A7 core are received by the M4 core. My error occurs when I try to read the messages that are sent from the M4 core to the A7. The program that I have created in linux is the following (M4 program is running):

0693W00000WIgaeQAD.png 

How can I read the messages that are sent from the M4 core?

Is there any example to follow?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Erwan SZYMANSKI
ST Employee

Hello @TArre.1​,

I do not think we have a complete example of A7 code to read rmpsgs, but you are on the right track !

Indeed, in the context of a userspace application (in C or C++ for example), you will use file descriptor exactly like you did on your screenshot.

For an application, a good idea would be the next one:

  • Having one main thread that will manage your main application loop, and the rpmsg that you send from A7 to M4.
  • Having one other loop thread that will be used to receive all the messages in a read blocking loop, and will then take different actions at reception step depending on the message you receive (in a first step, you can just print your message, but I imagine that further you will develop your own communication protocol etc...)

Some attention point:

  • Open you file descriptor once, before creating the second thread and use the reference of this fd to read and write. Of course you cannot open it twice, that is why you need to pass this reference.
  • Stay coherent between buffer max size of M4 and A7 cortex
  • Later, when you will begin to take some actions after a message reception, be careful to concurrent access (mutex will be useful there).
  • Put in place a way to go out your reading loop thread properly when you want to stop your program, close the file descriptor and join your parallel thread to stop everything gracefully (of course) :).

If you have some trouble to develop your application, I will be glad to help you. Make a first try by yourself and come back to me if you face troubles 🙂

Kind regards,

Erwan.

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
Erwan SZYMANSKI
ST Employee

Hello @TArre.1​,

I do not think we have a complete example of A7 code to read rmpsgs, but you are on the right track !

Indeed, in the context of a userspace application (in C or C++ for example), you will use file descriptor exactly like you did on your screenshot.

For an application, a good idea would be the next one:

  • Having one main thread that will manage your main application loop, and the rpmsg that you send from A7 to M4.
  • Having one other loop thread that will be used to receive all the messages in a read blocking loop, and will then take different actions at reception step depending on the message you receive (in a first step, you can just print your message, but I imagine that further you will develop your own communication protocol etc...)

Some attention point:

  • Open you file descriptor once, before creating the second thread and use the reference of this fd to read and write. Of course you cannot open it twice, that is why you need to pass this reference.
  • Stay coherent between buffer max size of M4 and A7 cortex
  • Later, when you will begin to take some actions after a message reception, be careful to concurrent access (mutex will be useful there).
  • Put in place a way to go out your reading loop thread properly when you want to stop your program, close the file descriptor and join your parallel thread to stop everything gracefully (of course) :).

If you have some trouble to develop your application, I will be glad to help you. Make a first try by yourself and come back to me if you face troubles 🙂

Kind regards,

Erwan.

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.
TArre.1
Associate III

HI Erwan,

Thank you for your reply! 😁

I have tried to do what you indicate but I am not able to read the message that has been sent from M4 to A7.

I attach the project that I have created (STM32CubeIDE v1.6.0):

  • Firts, I have created a Linux user space project (Communication_Cores). With this, I have created a gtk application where I loaded the M4 program.
  • Then, in the Communication_Cores program, I have created three buttons:
    • LED ON and LED OFF: Send message from A7 to M4 to switch the LED.
    • GET M4 INFO: This creates a new window that is sending and receiving the information from the M4 core.

The problem is that I can´t read the message sent from M4 to A7 via ttyRPMSG0.

Can you help me?

Thanks!

TArre.1
Associate III

Hi @Erwan SZYMANSKI​ 

Finally, I have succeeded and I am now able to communicate. Thanks for your help!😁 ​ 

Hello @TArre.1​ ,

Sorry to not have answered quicker, I had a lot of other stuff to do aside.

I am glad to see that you were able to solve your issue ! Good luck for your dev 🙂

Kind regards,

Erwan.

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.