How to extend the buffer size of A55 in iMX9352 when using heteronuclear communication with M33 core

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to extend the buffer size of A55 in iMX9352 when using heteronuclear communication with M33 core

942件の閲覧回数
WJianQ_CN
Contributor II

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?

  1. Board :i.MX9352
  2. Software environment  :
  • A55: Linux Kernel version 6.1.22;
  • M33: SDK_2_14_0_MCIMX93-EVK.
理无专在, 而学无止境也, 然则问可少耶?
タグ(4)
0 件の賞賛
返信
9 返答(返信)

396件の閲覧回数
ChumingYang
Contributor I

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

0 件の賞賛
返信

395件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

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)

0 件の賞賛
返信

882件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

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>;
	};
0 件の賞賛
返信

803件の閲覧回数
WJianQ_CN
Contributor II
Thank you for your reply, I may not have expressed myself particularly well. What I mean is how to modify the amount of data received in a single pass in rpmsg communication, how to change it from 512 bytes to 1024 bytes.
理无专在, 而学无止境也, 然则问可少耶?
0 件の賞賛
返信

793件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

This is my idea only about increasing buffer size, not number, not test it

A side:

1. Modify drivers/rpmsg/virtio_rpmsg_bus.c

#define MAX_RPMSG_BUF_SIZE  (512)
2. As you double the buffer size, you need double the shared memory vring in dts.
 
M side:
1.Modify buffer payload size:
//! @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)
0 件の賞賛
返信

782件の閲覧回数
WJianQ_CN
Contributor II
Thanks for your answer, but I would like to know what are the design rules for these parameters, for example if I want to change the buffer load size to 1024, then how do I change these relevant data?
理无专在, 而学无止境也, 然则问可少耶?
0 件の賞賛
返信

699件の閲覧回数
Zhiming_Liu
NXP TechSupport
NXP TechSupport

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)

 

Zhiming_Liu_0-1706766339655.png

 

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.

0 件の賞賛
返信

677件の閲覧回数
WJianQ_CN
Contributor II
reg = <0 0xa8020000 0 0x100000>; 
-> reg = <0 0xa8020000 0 0x200000>; 
 
Why should 0x100000 be changed to 0x200000 and how is it calculated?
理无专在, 而学无止境也, 然则问可少耶?
0 件の賞賛
返信

594件の閲覧回数
WJianQ_CN
Contributor II
Do you have a reply?
理无专在, 而学无止境也, 然则问可少耶?
0 件の賞賛
返信