I've written an LPSPI program for a W25Q128 using inter-core communication, but every time I try to read data from the external device, the M33 core hangs without providing feedback to the A55 core. After investigating, I discovered that the communication buffer between the A55 and M33 cores is too small. How can I modify the size of this buffer? What files in the A55 and M33 cores need to be changed? Are there any formulas related to buffer size modification?
It is understandable to change the communication cache of A and M cores from 512bytes to 1024bytes. I want to know why 0x100000 and 0x200000 represent 512bytes and 1024bytes respectively. How is the buffer length calculated (0x100000 and 0x200000), in the ST platform, sharememory size is vdev0vring0+vdev0vring1+vdev0buffer
They also don't have a reasonable explanation for how to convert a 512-byte buffer into a device tree memory size of 0x100000; simply explaining it as a multiple relationship is unclear.
vdevrings are used to record buffer index and flags, these two ring are struct vring_avail and vring_used in Linux kernel, they are not true buffer pool. They are used to sync buffer index and status between A and M core. The real buffer pool to store the message you sent is vdevbuffer. So increasing buffer pool to avoid the problem of not having enough memory after using 1024Kbytes. 0x200000(2MB) just double of 0x100000(1MB)
The memory regions are defined in dts:
cm33: imx93-cm33 {
compatible = "fsl,imx93-cm33";
mbox-names = "tx", "rx", "rxdb";
mboxes = <&mu1 0 1
&mu1 1 1
&mu1 3 1>;
memory-region = <&vdevbuffer>, <&vdev0vring0>, <&vdev0vring1>,
<&vdev1vring0>, <&vdev1vring1>, <&rsc_table>;
fsl,startup-delay-ms = <500>;
};
This is my idea only about increasing buffer size, not number, not test it
A side:
1. Modify drivers/rpmsg/virtio_rpmsg_bus.c
//! @def RL_BUFFER_PAYLOAD_SIZE
//!
//! Size of the buffer payload, it must be equal to (240, 496, 1008, ...)
//! [2^n - 16]. Ensure the same value is defined on both sides of rpmsg
//! communication. The default value is 496U.
#define RL_BUFFER_PAYLOAD_SIZE (496U)
2. Modify vring size in SDK
/* contains pool of descriptors and two circular buffers */
#ifndef VRING_SIZE
#define VRING_SIZE (0x8000UL)
Hi @WJianQ_CN
Sorry for this late reply.
I have tested the modification with demo sdk on EVK.
Here are steps:
1. Modify payload size to 1008, the head size is 16bytes. So the size of each buffer is 1024bytes
//! @def RL_BUFFER_PAYLOAD_SIZE
//!
//! Size of the buffer payload, it must be equal to (240, 496, 1008, ...)
//! [2^n - 16]. Ensure the same value is defined on both sides of rpmsg
//! communication. The default value is 496U.
#define RL_BUFFER_PAYLOAD_SIZE (1008)
2.Modify rpmsg buf size in kernel and buiffer pool in dts
#define MAX_RPMSG_BUF_SIZE (1024)
3. I am using imx_rpmsg_tty.ko to test, here i use larger buffer in driver:
#define MSG "hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world! hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world! hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!"
4.Modify the SDK code:
/* Globals */
static char app_buf[1024]; /* Each RPMSG buffer can carry less than 512 payload */
5. Terminal
Get Message From Master Side : "hello world!" [len : 12]
Get Message From Master Side : "hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!" [len : 168]
ASSERT ERROR " len < sizeof(app_buf) ": file
RPMSG String Echo FreeRTOS RTOS API Demo...
Nameservice sent, ready for incoming messages...
Get Message From Master Side : "hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world! hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world! hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!" [len : 674]
The buffer size is not limited to 512 bytes now.