I have a problem using the spidev in the BSP 3.0B2.
Here are the steps I take:
-
Initalize the build environment:
$ mkdir ~/oe-coreV3.0
$ cd ~/oe-coreV3.0
$ repo init -u Index of /toradex-bsp-platform.git -b LinuxImage3.0 -m default.xml
$ repo sync
$ . export -
Add custom layer (link) that includes a custom device tree enabling the spidev
-
Build the image (exact copy of console-tdx-image)
$ bitbake console-tdx-image-gemac
-
Flash the image with the Easy Installer
-
Reboot the board (logfile, please have a look at timestamp 0.205224: sdma firmware isn’t found)
-
When I load and execute the following SPI test program:
#include <unistd.h> // write
#include <fcntl.h> // open
#include <sys/ioctl.h> // ioctl
#include <linux/spi/spidev.h>
#include#define SPI_DEVADDR “/dev/spidev2.0”
int main(int argc, char *argv)
{
int spidev_fd;
unsigned char spi_mode = SPI_MODE_0; // Mode
unsigned char spi_bpw = 32; // Bits per Word
unsigned long spi_speed = 52 * 1000 * 1000; // Speed [Hz]if ((spidev_fd = open(SPI_DEVADDR, O_RDWR)) >= 0) { // set mode if (ioctl(spidev_fd, SPI_IOC_WR_MODE, &spi_mode) < 0) { perror("SPI set mode"); } // set number of bits per word else if (ioctl(spidev_fd, SPI_IOC_WR_BITS_PER_WORD, &spi_bpw) < 0) { perror("SPI set bits per word"); } // set max speed (in Hz) else if (ioctl(spidev_fd, SPI_IOC_WR_MAX_SPEED_HZ, &spi_speed) < 0) { perror("SPI set speed"); } // send data else { unsigned char buf[16 * 256]; if (write(spidev_fd, buf, sizeof(buf)) < 0) perror("SPI write"); } close(spidev_fd); } else perror("SPI open");
}
I got the following error messages:[ 2014.161978] imx-sdma 30bd0000.sdma: sdma firmware not ready!
[ 2014.167668] spidev spi2.0: SPI transfer failed: -22
[ 2014.172657] spi_master spi2: failed to transfer one message from queue
SPI write: Invalid argument
I don’t get the error when:
- I use the very same device tree with the official BSP3.0B2 image
- I follow the above procedure with BSP2.8b6