cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP1 A7 and M4 communication

ASega.1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
ArnaudP
Senior

Hello,

Seems that you are using a "customized" version of the rpmsg_tty driver.

The enum rpmsg_tty_type_t as been introduced in a version of the rpmsg_tty proposed for upstream:

https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2005980.html. But this temporary version should not have been neither delivered nor upstreamed.

This version is not compatible with the Cortex-M4 "virtual rpmsg"

So I would suggest you to come back to rpmsg_tty Linux driver delivered by ST.

Regards,

Arnaud

View solution in original post

6 REPLIES 6
ASega.1
Associate III

Hi,

Small update of my issue.

I find the problem but I don't know how fix it.

When I use in linux the following command:

stty -onlcr -echo -F /dev/ttyRPMSG0

in M4 code is called the callback associated to the Virtual UART 0:

sprintf(m_uart_buff_tx, "CM4 : VIRT_UART_RxCpltCallback: %s\n", virt_uart_channel_buff_rx);
 
VIRT_UART_Transmit(hdr_descr.virt_huart, (uint8_t*)m_uart_buff_tx, strlen(m_uart_buff_tx));

And It sends back what received, in this case:

"CM4 : VIRT_UART_RxCpltCallback: \n"

This string has length 34 so I can understand the value size:

[ 366.375280] rpmsg_tty virtio0.rpmsg-tty-channel.-1.1024: Invalid message: size 34, type 67

However I don't understand why the callback function is called with this command:

stty -onlcr -echo -F /dev/ttyRPMSG0

and what is the value tpye 67?

Thanks in advance,

Andrea Segalla

ArnaudP
Senior

Hello,

Seems that you are using a "customized" version of the rpmsg_tty driver.

The enum rpmsg_tty_type_t as been introduced in a version of the rpmsg_tty proposed for upstream:

https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2005980.html. But this temporary version should not have been neither delivered nor upstreamed.

This version is not compatible with the Cortex-M4 "virtual rpmsg"

So I would suggest you to come back to rpmsg_tty Linux driver delivered by ST.

Regards,

Arnaud

ASega.1
Associate III

Hi,

Thanks for the reply.

What commit/release should I refer to?

Best Regards,

Andrea

ArnaudP
Senior

You should find releases information on the ST Microelectronics wiki: stm32mpu

ASega.1
Associate III

Hi Arnaud,

thank you so much for the help and your time. I fixed my problem changing the driver as you told me.

Now it works correctly.

Best Regards,

Andrea

mpeton
Associate II

Hi,
I'am also using  STM32MP157C DK2  to communicate between the A7 and the M4 using the Virtual Uart (OPENAMP and IPCC).

I was trying to use STM32MXCube to configure the peripherals but the STM32MP157C DK2 board is not available instead it has STM32MP157D DK1.

I can create a project with MCU selector but that doesn't allow me enable OpenAMP.

As both boards have different MCU CAC3 and DAC1 respectively can I still run MXCube project created with D-DK1 board selected on C-DK2 board