SPI with spidev failing to transmit one byte

Hello, I’m running some tests with the 9215 board and DigiEL. I can’t manage to transmit less than two bytes with the spidev example application in the kernel. The ioctl of the transfer fails. Is there any reason for this? Perhaps dma transfers of less than two bytes are not allowed?

There is no hardware limitations that will prevent NS9215 from transmitting one byte over SPI. Works fine in Netos

Hi Pedro,

Are you using the spidev_test.c application that comes in the kernel Documentation folder?
That application seems to have a bug at around line #60:

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
if (ret == 1)
	pabort("can't send spi message");

The SPI_IOC_MESSAGE ioctl returns a negative value in case of
error. Upon success, it returns the number of bytes sent.
If the application is transmitting 1 byte, the ioctl returns 1 and wrongly enters the if(ret == 1), thus aborting. The correct code should be ‘if (ret < 0)’:

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &amp;tr);
if (ret &lt; 0)
	pabort("can't send spi message");


Héctor Palacios

Nice post. I like it. Thanks for sharing these information. Keep it up. [:))]