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.

Hello,

I was able to confirm setting kernel parameters w/ tdxargs worked for me w/ the u-boot cmd prompt. However, I haven’t figured out how to implement this change in my BSP build. The following u-boot bbappend didn’t work for me:

diff --git a/recipes-bsp/u-boot/u-boot-toradex_2022.04.bbappend b/recipes-bsp/u-boot/u-boot-toradex_2022.04.bbappend
index bde48d7..a1cfab4 100644
--- a/recipes-bsp/u-boot/u-boot-toradex_2022.04.bbappend
+++ b/recipes-bsp/u-boot/u-boot-toradex_2022.04.bbappend
@@ -1,2 +1,5 @@
+
+# Increase the spidev buffer size to 32 kB
+tdxargs:append = " spidev.bufsiz=32768"

I also tried tdxargs += " spidev.bufsiz=32768" to no avail as well. Any suggestions? Also is there a way to see what tdxargs expands to in the build artifacts?

Thanks!
Evan Hosseini

Output of tdx-info:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.148-6.6.0-devel+git.23a8e831749d #1-TorizonCore SMP PREEMPT Wed Oct 25 20:12:26 UTC 2023
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/ae50154daa5fc5314f465360
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=6.6.0-devel-20240828211723-build.0
Distro variant:           VARIANT="Docker"
Hostname:                 verdin-imx8mp-15229942
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 redacted
Toradex version:          0058 V1.1B
Serial number:            15229942
Processor arch:           aarch64
------------------------------------------------------------

Hi @ehosseini

The short answer is that tdxargs is a U-Boot environment variable, not a Yocto variable as you are trying to do here. To make this change at the build level you will need to create a custom layer and patch the U-Boot sources to modify the default value of this variable as it is compiled into the UBoot image. Custom meta layers, recipes and images in Yocto Project (hello-world examples) | Toradex Developer Center

If you still have questions, please file a new ticket as this ticket is quite old and we want to avoid crossing the streams.

Thanks,
Drew Moseley

1 Like