I am trying to use the Raspberry Pi 4 model B to program the Lattice ICE40 FPGA chip via SPI. It requires continuous clock signal throughout the whole transmission of the bitfile, which is easily bigger than 1Mb.

I am using the spidev library and thanks to the following posts:

SPI transfer fails with buffer size greater than 4096

How to transfer large amount of data (100Kbytes) over SPI?

I was able to configure the buffer size to a bigger number. However even after this, the transmission is still split after 65536 bytes no matter the buffer size setting in /boot/cmdline.txt

Where does this limitation come from? Can it be bypassed?

1 Answer 1


It turns out that this limitation is set directly in spidev and it has its reason:


Indeed, it looks like that the maximum supported transfer length is limited by the device driver, which can be seen right there:


I am not sure whether fixing this would be as easy as changing the value and recompiling the driver as I am going to instead bitbang the bitmap myself.


So I've spent some more time on this and found, that the 65535 bytes limit is unfortunately definitive right now. The reason for this is that the register DLEN which holds the data length inside the CPU is 16-bit. This has been the case for the first BCM2835 CPU used in RPi 1 and still remains the case for the BCM2711 in RPi 4.

This can be found in the CPU datasheet here (page 139):


You can still remove the constrain in the spidev code (spidev_module.c line 47) and this will work, however the driver will not use DMA for this and thus the transfer speed can be significantly limited.

  • 1
    Suggest you mark your answer as "Selected" as this may help others struggling with the same issue.
    – Seamus
    Sep 3, 2023 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.