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.