We are updating from an ARM embedded Ubuntu 14.04 to ARM embedded Ubuntu 16.04. On the first platform we are accessing a chip using SPIDEV without a problem. On the Ubuntu platform I am getting an EINVAL error following a ioctl SPI_IOC_MESSAGE.
I have seen the message SPI_IOC_MESSAGE(N) macro giving me fits and it does not solve the issue.
My code is as follows:
SpiComm_t::Transfer(int i4Length) {
int ret = -1;
m_tr.len = i4Length;
ret = ioctl(m_fd, SPI_IOC_MESSAGE(1), &m_tr);
if (ret ) {
printf("SPI IOCTL error %s\n", strerror(errno)); }
return ret;
}
The calling code looks like:
// Reset memory (Optional... Helps diagnose failures to read.)
memset(m_c1BufTx, 0xFF, sizeof(m_c1BufTx));
// Put address
m_c1BufTx[0] = address;
// Reset memory (optional...)
memset(m_c1BufRx, 0xFF, sizeof(m_c1BufRx));
// Invoke ioctl transaction
int result = Transfer(size+1);
We are using Kernel 4.9.59 from TI SDK 4.0. I have traced the EINVAL to the spidev.c driver but cannot make sense of why I am getting the error.
spidev.c code is:
tmp = _IOC_SIZE(cmd);
if ((tmp % sizeof(struct spi_ioc_transfer)) != 0)
return ERR_PTR(-EINVAL);
*n_ioc = tmp / sizeof(struct spi_ioc_transfer);
if (*n_ioc == 0)
return NULL;
/* copy into scratch area */
Any help would be greatly appreciated.