I'm trying to 8192 bytes over SPI in a single transfer, but for some reason anything over 4096 bytes fails to send. How can I enable larger data transfers?

int ret;

uint8_t txn[] = { 0x00, ... };

struct spi_ioc_transfer tr = {
    .tx_buf = (unsigned long)txn,
    .len = (unsigned int)sizeof(txn),
    .delay_usecs = 0,
    .speed_hz = 10000000,
    .bits_per_word = 8,

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
if (ret < 1)
    pabort("Can't send SPI message");

I'm working with the Raspberry Pi Zero W if it matters.


1 Answer 1


As you have noticed the default maximum SPI transfer is 4096 bytes with the standard Linux driver.

To change the default add spidev.bufsiz=65536 to /boot/cmdline.txt and reboot. Where 65536 is the maximum size you want to allow.

Note that /boot/cmdline.txt is a single line. After the above change mine looked like:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes spidev.bufsiz=65536 rootwait logo.nologo

As an aside my pigpio SPI driver defaults to a buffer size of 64k.

  • I've done this but still get a the 4096 limit error.
    – Gilad
    Commented Aug 27, 2017 at 10:10
  • @Gilad I suggest you open a new question detailing exactly what you have done and any error messages you receive. Also try to explain why your set up might be different to the original questioner.
    – joan
    Commented Aug 27, 2017 at 11:20
  • What is this limitation good for? Except for making me lose 4 hours for troubleshooting, because one of the blocks was 4736 bytes long?
    – Pygmalion
    Commented Aug 7, 2023 at 12:47

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.