STM32MP1 A7 and M4 communication
Hi,
I'm using STM32MP153C and I would like to communicate between the A7 and the M4 using the Virtual Uart (OPENAMP and IPCC).
I'm using a custom distribution created using Yocto.
When I initialize the virtual uart in the M4, /dev/ttyRPMSG0 is instantiated in the A7.
[ 142.543903] remoteproc remoteproc0: powering up m4
[ 142.649727] remoteproc remoteproc0: Booting fw image DHCOR_MBM_GEN_3_v4.1_CM4.elf, size 3518900
[ 142.661217] remoteproc0#vdev0buffer: assigned reserved memory node vdev0buffer@10042000
[ 142.669330] remoteproc0#vdev0buffer: registered virtio0 (type 7)
[ 142.674309] remoteproc remoteproc0: remote processor m4 is now up
[ 142.722658] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 148.575929] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty-channel addr 0x400
[ 149.074414] virtio_rpmsg_bus virtio0: creating channel rpmsg-sdb-channel addr 0x401
But when I use this command:
stty -onlcr -echo -F /dev/ttyRPMSG0
linux returns:
[ 366.375280] rpmsg_tty virtio0.rpmsg-tty-channel.-1.1024: Invalid message: size 34, type 67
[ 366.384280] rpmsg_tty virtio0.rpmsg-tty-channel.-1.1024: Invalid message: size 34, type 67
I saw that this error is returned by the function rpmsg_tty_cb in the if condition (line 109 of the driver rpmsg_tty.c):
static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len,
void *priv, u32 src)
{
struct rpmsg_tty_payload *rbuf = data;
if (len <= sizeof(*rbuf) || rbuf->cmd >= NUM_RPMSG_TTY_TYPE)
{
dev_err(&rpdev->dev, "Invalid message: size %d, type %d
len, rbuf->cmd);
return -EINVAL;
}
rpmsg_tty_handler[rbuf->cmd](rpdev, &rbuf->data,
len - sizeof(rbuf->cmd), priv, src);
return 0;
}The error is caused because rbuf->cmd is greater than NUM_RPMSG_TTY_TYPE. In this case:
rbuf->cmd = 67
NUM_RPMSG_TTY_TYPE = 2
What is the meaning of this parameter NUM_RPMSG_TTY_TYPE?
It is declared in the driver at lines 21 without initialization (I can't find it):
enum rpmsg_tty_type_t {
RPMSG_DATA,
RPMSG_CTRL,
NUM_RPMSG_TTY_TYPE
};The problem is caused by the A7 or M4 code? Because even if i'm not sending anything with the command "stty -onlcr -echo -F /dev/ttyRPMSG0", the M4 seems to receive something and (I think) it tries to send it back (M4 code send back what received).
I try also to send directly a simple "hello" to M4 from A7:
echo "Hello" > /dev/ttyRPMSG0
[ 105.752908] rpmsg_tty virtio0.rpmsg-tty-channel.-1.1024: Invalid message: size 34, type 67
[ 105.782157] rpmsg_tty virtio0.rpmsg-tty-channel.-1.1024: Invalid message: size 33, type 67
[ 105.810142] rpmsg_tty virtio0.rpmsg-tty-channel.-1.1024: Invalid message: size 34, type 67
Any suggestion to fix my communication?
Thanks in advance,
Andrea Segalla
