SPI configuration

Hi there! I’ve been working with spi interface of duo using spidev linux library, and found out that maximum tx buffer size to send data is 4096 bytes. I can not change file /sys/module/spidev/parameters/bufsize as it is write-protected, so i wonder, is there a legal way to increase spi buffer size? It seems to me, that i can change this value when building duo-buildroot-sdk, but i also couldn’t find any configs related to that in repository. Thanks in advance!

1 Like

To support running metastatic i use loadable kernel modules

Specify the bufsize as option

insmod /lib/modules/5.10.4-tag-/drivers/spi/spidev.ko bufsiz=20480

Have SPI LoRa SX1262 and 3.5" 320x480 SPI Display here
Milk-V DUO 256

And

Milk-V DUO 64 with USB keyboard mouse input 2.0" 320x240 SPI Display and SPI SX1262 LoRa

2 Likes

yep, this is great idea, but i’d like to keep default buildroot-sdk image as i’m also working with camera sdk. Maybe someone knows how to change this bufsiz varaible from buildroot side? I can see sources of spidev driver in buildroot-sdk repo in duo-buildroot-sdk/linux_5.10/drivers/spi/spidev.c and there is bufsiz variable. Can i simply change it to my desired value and rebuild image w/o any unexpected consequences? Thank you!

1 Like

Ok, i did also try to pass the parameter from u-boot but my attempts it did stop the boot process for some reason

but you could edit the kernel source and change the default size ?
./linux_5.10/drivers/spi/
spidev.c

line 85
static unsigned bufsiz = 4096;

1 Like

Yep, i did it right now, image built successfully within docker, i’ll test the results and let you know about it.

2 Likes

Well, as i expected, it couldn’t be so easy) Right now i have bufsiz 32768 bytes in /sys/module/spidev/parameters that i changed in spidev sources of buildroot drivers. Spidev still working fine, i can transfer data, but maximum tx buffer size is still 4096, and when im trying to transfer message more than 4096 bytes i got return code -1 from ioctl.



It seems to me, that i need to change something else to let kernel know that bufsiz is more than 4096…

1 Like

Oh, i set to max 32767

cat /sys/module/spidev/parameters/bufsiz ?

1 Like

it is 32768, which is funny

1 Like

oh ok i see, not sure where else then

I finish my pcb breakout now (DUO 64 and DUO 256)

2 Likes