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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,789 Views
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.
理无专在, 而学无止境也, 然则问可少耶?
Tags (4)
0 Kudos
Reply
10 Replies

1,243 Views
ChumingYang
Contributor II

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 Kudos
Reply

271 Views
WJianQ_CN
Contributor II

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.

理无专在, 而学无止境也, 然则问可少耶?
0 Kudos
Reply

1,242 Views
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 Kudos
Reply

1,729 Views
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 Kudos
Reply

1,650 Views
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 Kudos
Reply

1,640 Views
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 Kudos
Reply

1,629 Views
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 Kudos
Reply

1,546 Views
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 Kudos
Reply

1,524 Views
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 Kudos
Reply

1,441 Views
WJianQ_CN
Contributor II
Do you have a reply?
理无专在, 而学无止境也, 然则问可少耶?
0 Kudos
Reply