我正在尝试增加 rpmsg lite 的缓冲区大小,因为我无法在 M 和 A 内核之间实现更高的传输速率(我需要大约 200kBytes/s,达到大约 90kBytes/s)。
imx_rpmsg.c 驱动程序, 并使用来自 SDK_2_12_1_MIMX8MM6xxxKZ 的 M4 上的 rpmsg 运行 FreeRTOS
在 Linux 端,imx_rpmsg.c 中的缓冲区值在这里:
#define RPMSG_NUM_BUFS (512) #define RPMSG_BUF_SIZE (512)
#define RPMSG_BUFS_SPACE (RPMSG_NUM_BUFS * RPMSG_BUF_SIZE)
#define RPMSG_VRING_ALIGN (4096)
#define RPMSG_RING_SIZE ((DIV_ROUND_UP(vring_size(RPMSG_NUM_BUFS / 2, RPMSG_VRING_ALIGN), PAGE_SIZE)) * PAGE_SIZE)然后我在 imx_rpmsg_tty.c 旁边:
/* this needs to be less then (RPMSG_BUF_SIZE - sizeof(struct rpmsg_hdr)) */
#define RPMSG_MAX_SIZE 256在 vir
tio_rpmsg_bus.c 里面:
/*
* We're allocating buffers of 512 bytes each for communications. The
* number of buffers will be computed from the number of buffers supported
* by the vring, upto a maximum of 512 buffers (256 in each direction).
*
* Each buffer will have 16 bytes for the msg header and 496 bytes for
* the payload.
*
* This will utilize a maximum total space of 256KB for the buffers.
*
* We might also want to add support for user-provided buffers in time.
* This will allow bigger buffer size flexibility, and can also be used
* to achieve zero-copy messaging.
*
* Note that these numbers are purely a decision of this driver - we
* can change this without changing anything in the firmware of the remote
* processor.
*/
#define MAX_RPMSG_NUM_BUFS (512)
#define MAX_RPMSG_BUF_SIZE (512)在 M4 端,有 rpmsg_config.h :
//! @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)
//! @def RL_BUFFER_COUNT
//!
//! Number of the buffers, it must be power of two (2, 4, ...).
//! The default value is 2U.
//! Note this value defines the buffer count for one direction of the rpmsg
//! communication only, i.e. if the default value of 2 is used
//! in rpmsg_config.h files for the master and the remote side, 4 buffers
//! in total are created in the shared memory.
#define RL_BUFFER_COUNT (256)
我发现命名系统令人困惑,因为缓冲区计数有时指整个环形缓冲区,有时指一半(tx 或 rx 一半)。由于我为设备树中的环形缓冲区分配了 128kb 的内存,如果我将缓冲区大小加倍,我也会将缓冲区计数分成两半(512x512 到 1024x256 等)。
我的第一个测试显示:更改 linux 端没有任何作用,M4 仍然收到 496
字节的 hello world 消息。一旦我更改了 M4 端的 rpmsg_config.h,即使只是将缓冲区数量减半至 128,也不再收到 hello world 消息并且驱动程序无法正常工作。
我发现了许多类似的主题,但它们似乎都没有解决,或者使用的是旧版本的 rpmsg,因此无法直接应用解决方案。
此线程中报告了相同的问题 ,但未解决。