Hello Everyone,
I am using an AM3352 with TI SDK 7.0 (Linux 3.12 Kernel) and have written a driver for our hardware that uses SPI bus. I have successfully tested the driver and also interfaced with a user space application. The AM3352 is the host and our hardware is the slave and the SPI frequency is 1Mhz.
I am facing some problems when I read data greater than 256 bytes from my device. I am using a protocol analyzer on the SPI bus and clearly see that instead of reading 256 bytes or 512 bytes in a single transaction it will occasionally read 202 or 458 bytes, exactly 54 bytes less than what is specified as the length. All other transactions involving smaller length of data works properly every single time. The buffers I'm using are not malloced and are allocated statically.The function I'm using is below. I pass in the pointer to the buffer and the length of data to be read.
static int mydriver_spi_read(struct mydriver_data *pdata, u8 *buf, u32 length) { struct spi_transfer xfer = { .rx_buf = buf, .len = length, }; struct spi_message msg; int error; spi_message_init(&msg); spi_message_add_tail(&xfer, &msg); error = spi_sync(pdata->spi, &msg); if (error) { dev_err(&pdata->spi->dev, "%s - failed, error: %d\n", __func__, error); return error; } return 0; }
This only happens on some occasion and on others all 512 data is read correctly. I've even tried printing the length variable and each time it is 512. Can someone please let me know if there is something wrong in the code or the setup?
Thank you for your help.
Regards
Santhosh