Enable i.MX7d SPI interface on debian build

I’ve followed successfully an exceptional guide linked below:

I’ve got debian up and running on this board.
I would like to know if there are any additional steps required to enable SPI interface.
It appears that
Freescale i.MX SPI controllers are selected to be built as module in menuconfig.

Still, I’ve got no

How can I configure the build to allow me to use SPI interfaces on the board?

Did you update the board’s device-tree?

The default mainline device tree does not have a spidev node setup at this time:

Stick it around here:


Do you have an example branch where this is current enabled? Something we can copy over by default?


No, I don’t, didn’t find anything yet. I reckon I’ll need to add &ecspi1 block according to:


but of course adjusted to imx7d pi board pin settings.

Some documentation Serial Peripheral Interface (SPI)

Not sure how to edit the file, maybe should I try looking at yocto dtb?

This is actually the first time fiddling around this, so excuse my lack of knowledge.

Correct, you’ll need to do something similar for the pin’s on this specific board…


1 Like

I could really use any readily made &ecspi1 code block for this board, I looked into this and definitely lack the knowledge to write it myslef :frowning:

It’s not too difficult for a first time user, Just tedious, so make sure to valdiate your settings…

First you’ll need the schematic for your board, and firgure out which pins you want to use for spi…

Next, grab NXPs pinmux tool and use it to figure out the magic register offset values you need for spi…

Here’s a quick example where i moved one pin to a gpio-led struct…


1 Like

Thank You for the instuctions!
My board is the “Android thigs” one - as far I know it’s i.MX7d PICO PI model.
I want to use the ‘standard’ spi pins from the J8 connector:
Screenshot 2022-04-19 at 18.52.35

CSPI2_MISO_3V (21)
CSPI2_MOSI_3V (19)
CSPI2_SCLK_3V (23)
CSPI2_CS1_3V (24)

Using the config tool, I got this:

                MX7D_PAD_SAI2_TX_SYNC__ECSPI3_MISO         0x00000002
                MX7D_PAD_SAI2_TX_BCLK__ECSPI3_MOSI         0x00000002
                MX7D_PAD_SAI2_RX_DATA__ECSPI3_SCLK         0x00000002
                MX7D_PAD_SAI2_TX_DATA__ECSPI3_SS0          0x00000014

Now I need to edit the imx7d-pico-pi.dts file.
This file imports the following files: imx7d-pico.dtsi imx7d.dtsi imx7s.dtsi

There are several SPI interfaces defined in the imported files, upto ecspi4
I define:

aliases {

&ecspi on top level:

&ecspi3 {
	cs-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi3>;
	status = "okay";

then add the following in &iomuxc

pinctrl_ecspi3: ecspi3grp {
		fsl,pins = <

How am I doing?
then I do a kernel rebuild that finishes successfully.

What should be the cs-gpios value?
I’m not sure if the pinctrl_ecspi3 should be in &iomuxc

Whole file contntent is here:

That looks good, and I was able to build test the changes too…

Next add the spidev node…

&ecspi3 {
	cs-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi3>;
	status = "okay";

	spidev0: spi@0 {
		compatible = "spidev";
		reg = <0>;
		spi-max-frequency = <54000000>;

	spidev1: spi@1 {
		compatible = "spidev";
		reg = <1>;
		spi-max-frequency = <54000000>;


Thank you for pointing me to the right direction.
I’ve analysed the .dtsi files for imx7d-pico-pi.dts board and found out:

  • &ecspi3 is properly declared in imx7s.dtsi
  • pins are already muxed and enabled in imx7d-pico.dtsi

What I needed to do is to just add:

 &ecspi3 {
	spidev@0 {
		compatible = "rohm,dh2228fv";
		spi-max-frequency = <25000000>;
		reg = <0>;

in .dts.
using rohm,dh2228fv to spidev didn’t work, the spi driver is not picking it up.
What is more, my version of the board (the initial android things brcm with 4g flash) has a little different J8 schema - JP8-24 is NC, I needed to use JP8-26 pin instead.


spi_imx 30840000.spi: can't get the TX DMA channel, error -19!
spi_imx 30840000.spi: dma setup error -19, use pio
spi_imx 30840000.spi: registered master spi2
spi spi2.0: spi_imx_setup: mode 0, 8 bpw, 25000000 hz
spi spi2.0: setup mode 0, 8 bits/w, 25000000 Hz max --> 0
spi_imx 30840000.spi: registered child spi2.0

With that I’ve got successful SPI communication with ADXL345.

It took a fair bit of time to figure this out, but was worth it. Thank you @RobertCNelson :slight_smile:

1 Like