In my yocto-based custom board, I see this message in syslog:
Sep 21 11:35:52 cerberus kernel: [89532.972769] spi-tegra114 3210000.spi: CpuXfer ERROR bit set 0x400005
Sep 21 11:35:52 cerberus kernel: [89532.972779] spi-tegra114 3210000.spi: CpuXfer 0x73e01807:0x00000000
Sep 21 11:35:52 cerberus kernel: [89532.972793] spi-tegra114 3210000.spi: SPI_ERR: CMD_0: 0x73e01807, FIFO_STS: 0x00400005
Sep 21 11:35:52 cerberus kernel: [89532.972799] spi-tegra114 3210000.spi: Error in Transfer
Sep 21 11:35:52 cerberus kernel: [89532.972802] spi-tegra114 3210000.spi: SPI_ERR: DMA_CTL: 0x00000000, TRANS_STS: 0x40ff0000
Sep 21 11:35:52 cerberus kernel: [89532.972816] spi_master spi0: failed to transfer one message from queue
It works fine when I send data with SPI_IOC_MESSAGE(1). In the code, it is easy to achieve by just setting size to 2. I didn’t change anything in device tree.
I need to send multiple data with a small delay between them.
NX is the master and the slave is ADIS IMU sensor which has register values of 2 bytes size.
When I use ioctl with SPI_IOC_MESSAGE(1), it has a big delay (more than 120us) between messages. And the delay is not consistent and much long than 120us sometimes.
As a workaround, I tried to use ioctl with SPI_IOC_MESSAGE(N) because the ioctl call has only one spidev_release after it. I need more than 60 messages to transfer and each message should have valid tx_buf and rx_buf in struct spi_ioc_transfer. spidev_fdx.c has a tx_buf at the first message and only rx_buf for the second message. If I put both tx_bufand rx_buf for each struct spi_ioc_transfer, it fails with the messages I reported in my first writing.
One more thing I can do was to put all messages into a message and used ioctl with SPI_IOC_MESSAGE(1). In this case, SPI communication is not stable and working weirdly. There are two main things happened. One is that the response message is not coming right after the request, one step after. It comes two steps later most of the time. The other is that data is corrupted sometimes.
Please see the comments in line 262 of the spidev_test_ioc_message_n.c file. You will find the commands.
“size” in the comment is the one in line 297:
size_t size = 8;
When the size is 6, it looks okay from the output. But in the oscilloscope, I can see only 5 bytes are transferred. Please see the image below that shows SCK: