2019-05-16 07:37 PM
The routine I tested was stm32mp157\STM32Cube_FW_MP1_V1.0.0\Projects\STM32MP157C-DK2\Applications\OpenAMP\OpenAMP_TTY_echo, The test method is guided by the following address, https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157C-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Modify,_rebuild_and_reload_a_firmware.
According to the test method, the virtual device /dev/ttyRPMSG0 needs to be initialized first by the stty command . The communication test between A7 and M4 can then be performed by echo and cat. As described in the routine, A7 sends data to M4 via the echo command, and M4 will send this data to A7 again. As shown below:
Board $> stty -onlcr -echo -F /dev/ttyRPMSG0
Board $> cat /dev/ttyRPMSG0 &
Board $> echo "Hello Virtual UART0" > /dev/ttyRPMSG0
Hello Virtual UART0
The above test method is no problem. Then the problem is in the test below.
I use the linux file IO operation method to read and write the virtual device /dev/ttyRPMSG0.
As with the cat and echo implementations, I run a blocking read of /dev/ttyRPMSG0 through the read function, and print to the console via printf once the data is read. Then write data to /dev/ttyRPMSG0 via the write function. The code implementation is very simple, the source code is not posted here.
I used the System Workbench for STM32 tool to simulate M4. I can see that M4 has received the data from A7 and successfully sent it to A7. (Of course, the communication between A7 and M4 is implemented by OpenAMP architecture, similar to Shared memory), but the read function is blocked all the time, and no data is sent from M4. I think there will be the following possibilities:
1, M4 has put the data into the shared memory, but did not trigger the interrupt to let A7 go to the memory address to read the data. (I saw through the simulation of M4, M4 has changed the IPCC status register, it can be understood that the notification interrupt for M4 has been triggered)
2. A7 does receive an interrupt from M4 and reads the data from memory. But because of the initial setting of stty, the data is not read. All of this will be assumed because I am passing the echo command again, such as:
Board $> echo "Hello Virtual UART0" > /dev/ttyRPMSG0
At this point the read function prints out all the data I wrote with the write function and echo.
Aside from the impact of the echo command, I rewrote a "hello world" program, the program will print out "hello world", and then I will redirect:
Board $> ./hello_world > /dev/ttyRPMSG0
At this point the read function will also read "hello world".
3, As described in 2, because stty has some settings for /dev/ttyRPMSG0, the write function is not the same as the redirect function (I have tested, if not initialized, even through the echo and cat instructions It is also impossible to complete the communication test, which will cause the shell terminal to be stuck.) I tried to analyze the previous initialization directive: stty -onlcr -echo -F /dev/ttyRPMSG0
Stty: The main function is to change and print common commands for terminal settings;
-onlcr: Output device, convert line breaks to carriage returns;
-echo: prohibiting echoing;
-F /dev/ttyRPMSG0 : Open and use the specified device instead of standard input
So, in summary,
1. What is the initialization of /dev/ttyRPMSG0 by the stty command, why can't it be communicated without initialization?
2, what causes read, the write function can not complete the operation of /dev/ttyRPMSG0.
2019-05-17 07:58 AM
Hi,
Not sure to catch exactly your problem so just guess.
Sharing your simple code might help.
Anyway I succeed at my end to perform simple write/read program on top of /dev/ttyRPMSG
Trick is to not forget to append LF caracter at the end of the writen string to not be block in read. This is required by tty framework.
You can noticed that the "echo" command automatically do this instrumenting rpmsg with following dynamic trace :
echo -n 'file virtio_rpmsg_bus.c +p' > /sys/kernel/debug/dynamic_debug/control
echo -n 'file virtio_ring.c +p' > /sys/kernel/debug/dynamic_debug/control
echo -n 'file rpmsg* +p' > /sys/kernel/debug/dynamic_debug/control
https://wiki.st.com/stm32mpu/wiki/How_to_use_the_kernel_dynamic_debug
Hope it help
Olivier
2019-08-31 02:49 AM
Hi Oliver,
you had said "Anyway I succeed at my end to perform simple write/read program on top of /dev/ttyRPMSG"
How did you do that ? Can you please send me the program source code, if possible ?
thank you !