Spidev on BSP3.0B2

I have a problem using the spidev in the BSP 3.0B2.

Here are the steps I take:

  1. 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

  2. Add custom layer (link) that includes a custom device tree enabling the spidev

  3. Build the image (exact copy of console-tdx-image)

    $ bitbake console-tdx-image-gemac

  4. Flash the image with the Easy Installer

  5. Reboot the board (logfile, please have a look at timestamp 0.205224: sdma firmware isn’t found)

  6. 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>

    #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
     		unsigned char buf[16 * 256];
     		if (write(spidev_fd, buf, sizeof(buf)) < 0)
     			perror("SPI write");
     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

Starting with BSP 3.0b2 we changed for the SDMA driver to be a loadable Linux kernel module fixing all issues concerning firmware loading.

Please make sure to use our latest default Linux kernel configuration e.g. here or when building with OpenEmbedded here (should be in synch).

Thank you for your answer. In the last weeks I was busy with another project so please excuse my late reply.

I use the vanilla kernel configuration. As stated above I sync with the official 3.0 repo and only add a custom layer with nothing more than a changed device tree.

It seems that I made some errors.

I made a clean build environment with BSP3.0b3, use a patch to activate the spidev and build the console-tdx-image.

Now everything works.

Perfect. Thanks for the feedback.