I have a Raspberry Pi 3, and I would like to use it to communicate with an SPI device.

The pins from the SPI device have been connected to the appropriate headers on the board. Windows 10 IoT interacts with my device OK, using Windows.Devices.Spi classes from .NET.

Now I want to do same in Linux.

I am getting a “Message too long” error, from both cat /dev/spidev0.0 & and my own C++ code that uses open & ioctl calls to interact with that device (however in my application, it's interesting that open & port setup complete without errors).



uname -r: 4.9.41-v7+

lsb_release -a: Raspbian GNU/Linux 9.1 (stretch)

My device is connected to pins 19, 21, 23, 24, 25:

Enter image description here

Does Linux use the same pins for SPI as Windows 10 IoT?


It was a stupid error on my side.

SPI_IOC_MESSAGE ioctl call expects pointer to the first spi_ioc_transfer element in the argument.

I passed a pointer to pointer instead, because I saw many samples passing &array there, and I’ve forgot about this. I’ve fixed my C++ code, and it works now.

Meanwhile, cat /dev/spidev0.0 & command still prints Message too long. Apparently, that’s normal state of things.

  • 2
    Nice. Since this worked for you, remember to mark this answer as correct as soon as possible (I think that it's 48h) – Luis Diaz Sep 13 '17 at 14:34

According to Raspberry Pi Foundation:

The SPI master driver is disabled by default on Raspbian. To enable it, use raspi-config, or ensure the line dtparam=spi=on isn't commented out in /boot/config.txt, and reboot. If the SPI driver was loaded, you should see the device /dev/spidev0.0.

So, try to reboot your board after enabling SPI.

  • Yes, I’ve rebooted the board and I have both spidev0.0 and spidev0.1 under /dev/ – Soonts Sep 13 '17 at 13:27

Since your error is "message too long", try increasing buffer size adding to /boot/cmdline.txt:


being xxxxxxx a number, ie: spidev.bufsiz=32768.

  • Edited, rebooted, same error. My messages are 5 bytes long. And the same error is returned when I’m sending even a single byte with SPI_IOC_MESSAGE ioctl call. – Soonts Sep 13 '17 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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