Maximum transfer size 4096 bytes with spidev driver for SPI on Colibri imx6

Hi,

We need bigger than 4096 bytes transfer via the SPI using the SPIDEV driver. Unfortunately when try even one more byte if fails with “can’t send spi message: Message too long”.

The problem is that this is actually communication with ADC and if we do multiple transfers by 4096 bytes the time between transfers is very big and that “gap” messes up entire sampling rate that we want to achieve.

We currently using Toradex Angstrom Linux 4.1.44-2.7.5+g18717e2 with the included SPIDEV driver.

How we can fix that or workaround it to make possible bigger single transfers via the SPI?

Thanks,

This seems to be the default buffer size of the spidev driver. You can increase the default buffer size by setting the kernel parameter spidev.bufsiz, e.g. by using the following command in U-Boot:

setenv defargs ${defargs} spidev.bufsiz=32768
saveenv

Big thanks for that solution!
Could I set that somewhere into device tree, so not to set up into the bootloader for every device when we start mass production? Like for display type and resolution for example?

There is no device tree property to configure a driver. You can change the default in drivers/spi/spidev.c and compile a kernel with the new default.

Even though this topic is a bit older, I found another solution. Maybe it will help someone sometime.

Here ([Solved] Change SPI buffer size - Jetson Nano - NVIDIA Developer Forums) it is described that you can set the size of the buffer when reloading the SPI driver. Condition is that the driver is configured as a module in the kernel (CONFIG_SPI_SPIDEV=m):

$ rmmod spidev
$ modprobe spidev bufsize=20480

Or rather the size of the buffer can be set by a configuration /etc/modprobe.d/spidev.conf file during the boot process.

Hi,
We tried to use U-Boot to change SPI buffer as you mentioned here. I can see the output through the UART_A, however I cannot enter in U-BOOT by stopping the autoboot. It cannot receive any key pressed.
After autoboot, It was able to receive characters on the login line. What to do in this case?

Thank you in advance

Colibri iMX8DX
Iris V2.0

How to verify that this configuration passed successfully from the docker image?

Hi @falhi ,

Given that this thread was first created, discussed and solved years ago, can you open a new topic in the community detailing your issue?

Best regards,
Lucas Akira

Just in case anyone else has this same issue , the defargs variable is not used in Torizon (and maybe newer Yocto BSP reference builds but I have not had a chance to confirm.). We did verify that using “tdxargs” instead of “defargs” does the right thing on recent Torizon builds.