Enable SPI driver in apalis IMX8QM

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


To enable the SPI driver on an Apalis iMX8QM module and ensure that the SPI device appears under the /dev tree, you need to follow these steps:

1. Modify the Device Tree

You need to add the SPI node in the device tree source (DTS) file. Here is an example of how you can modify the device tree to enable SPI and bind it to the spidev driver.

Example Device Tree Overlay

Create a device tree overlay file, for example, apalis-imx8qm-spi-overlay.dts:

/dts-v1/;
/plugin/;

/ {
    compatible = "toradex,apalis-imx8qm";

    fragment@0 {
        target = <&ecspi1>;
        __overlay__ {
            status = "okay";
            spidev@0 {
                compatible = "spidev";
                reg = <0>;
                spi-max-frequency = <10000000>;
                status = "okay";
            };
        };
    };
};

In this example:

  • &ecspi1 refers to the SPI1 controller. You may need to adjust this based on the specific SPI controller you are using.
  • spidev@0 is the SPI device node with a chip select of 0.
  • spi-max-frequency sets the maximum SPI clock frequency.

2. Build the Device Tree Overlay

Compile the device tree overlay to generate the .dtbo file:

dtc -I dts -O dtb -o apalis-imx8qm-spi-overlay.dtbo apalis-imx8qm-spi-overlay.dts

3. Deploy the Device Tree Overlay

Copy the compiled .dtbo file to the boot partition of your Apalis iMX8QM module. You can use scp or any other method to transfer the file.

scp apalis-imx8qm-spi-overlay.dtbo root@<your_board_ip>:/boot/overlays/

4. Enable the Device Tree Overlay

Edit the overlays.txt file located in the /boot directory on your Apalis iMX8QM module to include your new overlay:

vi /boot/overlays.txt

Add the following line to the fdt_overlays variable:

fdt_overlays=apalis-imx8qm-spi-overlay.dtbo

Please, also check if these links can help you solve your problem:

Maximum transfer size 4096 bytes with spidev driver for SPI on Colibri imx6.