Device Tree Overlay to enable a GPIO pin on Colibri iMX8 DualX 1GB

I have successfully made device tree overlays for the iMX7 in the past (With your help!), for example:

Now I am trying to do the same thing with a Colibri iMX8 DualX 1GB. The overlay file I am trying to use to disable the SD card interface and liberate SODIMM 190 to be a GPIO is shown below. This is based on my iMX7 overlay with some updates based on studying the iMX8 documentation.

#include <dt-bindings/gpio/gpio.h>
/dts-v1/;
/plugin/;
   #include "dt-bindings/pinctrl/pads-imx8qxp.h"

  / {
    compatible = "toradex,colibri-imx8x";

    fragment@0 {
      target = <&usdhc2>;
      __overlay__ { status = "disabled"; };
    };

    fragment@1 {
      target = <&iomuxc>;
      __overlay__ {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_test>;

        pinctrl_test: gpiomuxgrp {
          fsl,pins = <
            IMX8QXP_USDHC1_CMD_LSIO_GPIO4_IO24         0x20  /* SODIMM 190 */
          >;
        };
      };
    };
  };

When I try to build and deploy this overlay I get an exception from TorizonCore-Builder and a message telling me to contact the Toradex support team:

$ torizoncore-builder dto deploy --remote-host 192.168.86.25 --remote-username torizon --remote-password xxxx --force --reboot HeartbeatLed.dts
Downloading image from: https://artifacts.toradex.com/artifactory/torizoncore-oe-prod-frankfurt/dunfell-5.x.y/release/17/colibri-imx8x/torizon/torizon-core-docker/oedeploy/torizon-core-docker-colibri-imx8x-Tezi_5.7.0+build.17.tar

The download may take some time. Please wait...
Download Complete!

Unpacking Toradex Easy Installer image.
Copying Toradex Easy Installer image.
Unpacking TorizonCore Toradex Easy Installer image.
Importing OSTree revision ec744fac1d0a556c00400d205850fb443dc688efa478f2d8c60303430dcac227 from local repository...
1135 metadata, 12775 content objects imported; 530.9 MB content written
Unpacked OSTree from Toradex Easy Installer image:
  Commit checksum: ec744fac1d0a556c00400d205850fb443dc688efa478f2d8c60303430dcac227
  TorizonCore Version: 5.7.0+build.17
An unexpected Exception occured. Please provide the following stack trace to
the Toradex TorizonCore support team:


Traceback (most recent call last):
  File "/builder/torizoncore-builder", line 217, in <module>
    mainargs.func(mainargs)
  File "/builder/tcbuilder/cli/dto.py", line 357, in do_dto_deploy
    dt_cli.do_dt_checkout(args)
  File "/builder/tcbuilder/cli/dt.py", line 47, in do_dt_checkout
    if args.update:
AttributeError: 'Namespace' object has no attribute 'update'

Can you see a problem with my device tree overlay source code, or is the problem in the toolset?

Hi @MikeS,

Thanks for the report. I could reproduce the issue on my side. I’m talking with the development team to check what we should do in this case, I will let you know about any news.

Can you please share the version of your torizoncore-builder?

$ torizoncore-builder --version

Despite that, were you able to make your overlay work? For example, instead of using TorizonCore Builder, you can copy the dtbo file manually to your image (by using SCP for example) and activate your overlay.

Let me know if you need any help.

Best Regards,
Hiago.

Hi @MikeS,

The team told me that this issue is fixed on the early-access version. I tested it on my side and it works now. Can you please check if that works for you as well?

To do that, you might first remove the TorizonCore Builder on your computer first

$ docker image rm torizon/torizoncore-builder:3

And then source the script with the early access tag

$ source tcb-env-setup.sh -t early-access

This should download the new Torizon Core Builder.

Best Regards,
Hiago.

Hi Hiago,

I had torizoncode-builder 3.6.0 installed when I wrote this post. I installed the early access version which reports as version 3.6.0+early-access. That allowed torizon-core-builder to run successfully and generate a dtbo file which it then deployed. However, my iMX8 module is no longer able to boot. That probably means that the tools are working now but there is something wrong with my overlay file. Are you able to help me with that?

The output from the tool is:

$ torizoncore-builder dto deploy --remote-host 192.168.86.32 --remote-username torizon --rem
ote-password xxxx --force --reboot HeartbeatLed.dts
Downloading image from: https://artifacts.toradex.com/artifactory/torizoncore-oe-prod-frankfurt/dunfell-5.x.y/release/17/colibri-imx8x/torizon/torizon-core-docker/oedeploy/torizon-core-docker-colibri-imx8x-Tezi_5.7.0+build.17.tar

The download may take some time. Please wait...
Download Complete!

Unpacking Toradex Easy Installer image.
Copying Toradex Easy Installer image.
Unpacking TorizonCore Toradex Easy Installer image.
Importing OSTree revision ec744fac1d0a556c00400d205850fb443dc688efa478f2d8c60303430dcac227 from local repository...
1135 metadata, 12775 content objects imported; 530.9 MB content written
Unpacked OSTree from Toradex Easy Installer image:
  Commit checksum: ec744fac1d0a556c00400d205850fb443dc688efa478f2d8c60303430dcac227
  TorizonCore Version: 5.7.0+build.17
'device-trees' directory already exists
warning: --force was used, bypassing checking overlays against the device tree.
'HeartbeatLed.dts' compiles successfully.
Overlay HeartbeatLed.dtbo successfully applied.
Applying changes from STORAGE/dt.
Commit e3a4fa6a291f8501697ad21982fcb8e222c3bd9045870c9bb4cf53639bd76a22 has been generated for changes and is ready to be deployed.
Pulling OSTree with ref dto_deploy (checksum e3a4fa6a291f8501697ad21982fcb8e222c3bd9045870c9bb4cf53639bd76a22) from local archive repository...
Starting http server to serve OSTree.
OSTree server listening on "localhost:45791".
Starting OSTree pull on the device...
Deploying new OSTree on the device...
Deploying successfully finished.
Device reboot initiated...

And the output from the module on the debug port while booting is:

U-Boot 2020.04-5.7.0+git.33bb8e968332 (Jan 01 1970 - 00:00:00 +0000)

CPU:   NXP i.MX8QXP RevC A35 at 1200 MHz at 42C

DRAM:  1022 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex Colibri iMX8 DualX 1GB V1.0D, Serial# 07203057

 BuildInfo:
  - SCFW 216a2c2e, SECO-FW c9de51c0, IMX-MKIMAGE 6a315dbc, ATF 2fa8c63
  - U-Boot 2020.04-5.7.0+git.33bb8e968332

flash target is MMC:0
Net:   eth0: ethernet@5b040000 [PRIME]
Fastboot: Normal
Saving Environment to MMC... Writing to MMC(0)... OK
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
973 bytes read in 9 ms (105.5 KiB/s)
## Executing script at 83200000
5085 bytes read in 20 ms (248 KiB/s)
126514 bytes read in 32 ms (3.8 MiB/s)
130 bytes read in 26 ms (4.9 KiB/s)
Applying Overlay: colibri-imx8x_parallel-rgb_overlay.dtbo
1498 bytes read in 33 ms (43.9 KiB/s)
Applying Overlay: colibri-imx8x_ad7879_overlay.dtbo
403 bytes read in 32 ms (11.7 KiB/s)
Applying Overlay: display-vga_overlay.dtbo
831 bytes read in 34 ms (23.4 KiB/s)
Applying Overlay: HeartbeatLed.dtbo
677 bytes read in 35 ms (18.6 KiB/s)
12192077 bytes read in 291 ms (40 MiB/s)
Uncompressed size: 30659072 = 0x1D3D200
9179928 bytes read in 224 ms (39.1 MiB/s)
## Flattened Device Tree blob at 83100000
   Booting using the fdt blob at 0x83100000
   Loading Ramdisk to bcdab000, end bd66c318 ... OK
   Loading Device Tree to 00000000bcd69000, end 00000000bcdaafff ... OK

Starting kernel ...

But the module is unresponsive after sending that debug output.

Hi @MikeS,

I believe the error is that you need to separate in two different parts: the “compatible” configuration and then your next settings.

For example:

#include <dt-bindings/gpio/gpio.h>
/dts-v1/;
/plugin/;
   #include "dt-bindings/pinctrl/pads-imx8qxp.h"

  / {
    compatible = "toradex,colibri-imx8x";
};

${/} {
    fragment@0 {
      target = <&usdhc2>;
      __overlay__ { status = "disabled"; };
    };

    fragment@1 {
      target = <&iomuxc>;
      __overlay__ {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_test>;

        pinctrl_test: gpiomuxgrp {
          fsl,pins = <
            IMX8QXP_USDHC1_CMD_LSIO_GPIO4_IO24         0x20  /* SODIMM 190 */
          >;
        };
      };
    };
  };

Please note that I’ve added

};

${/} {

to your overlay, so it will be separated into two sections. This is what usually makes the kernel hangs on boot (although it compiles without errors).

Now a general recommendation: your overlay syntax is a bit old. Linux still supports it, using these “fragments” nodes, however, a more updated overlay would be:


/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include "dt-bindings/pinctrl/pads-imx8qxp.h"

/ {
    compatible = "toradex,colibri-imx8x";
};

&usdhc2 {
    status = "disabled";
};

&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_test>;

    pinctrl_test: gpiomuxgrp {
        fsl,pins = <
            IMX8QXP_USDHC1_CMD_LSIO_GPIO4_IO24         0x20  /* SODIMM 190 */
        >;
    };
};

This also eliminates the need to &{/} {. Please note that I didn’t test this overlay myself, it’s just a general recommendation for your overlay.

Let me know if that works for you.

Best Regards,
Hiago.

Hi Hiago,

I like that more modern style of overlay, it’s definitely easier to read. But I had the same result when I tested it: the kernel wouldn’t start. I also tried the intermediate version, where you split my file into two sections. That one wouldn’t compile and gave the following message. I think we can ignore this and just focus on the new style file.
Error: HeartbeatLed.dts:10.1-2 syntax error

My overlay is designed to disable the SD card interface and then convert one of the pins into a GPIO. I tried using just the part of the file which disables the SD card. This short file compiles and the kernel does boot when this is installed. That must mean that the part of my file which causes the problem is the second section which enabled SODIM 190 as a GPIO. Can you help me with that?

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include "dt-bindings/pinctrl/pads-imx8qxp.h"

/ {
    compatible = "toradex,colibri-imx8x";
};

&usdhc2 {
    status = "disabled";
};

Thanks,
Mike

Hi @MikeS,

Checking the overlay and the imx8x-colibri.dtsi file, we need to add the other pinctrl’s as well, otherwise, the kernel won’t boot. These pinctrl’s are responsible to enable other crucial parts of the board.

Please test this overlay, it should work now:

/dts-v1/;
/plugin/;

#include "dt-bindings/pinctrl/pads-imx8qxp.h"

/ {
    compatible = "toradex,colibri-imx8x";
};

&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_hog0>, <&pinctrl_hog1>, <&pinctrl_hog2>,
		    <&pinctrl_ext_io0>, <&pinctrl_lpspi2_cs2>, <&pinctrl_test>;

	colibri-imx8qxp {
		pinctrl_test: gpiomuxgrp {
        		fsl,pins = <
            			IMX8QXP_USDHC1_CMD_LSIO_GPIO4_IO24         0x20  /* SODIMM 190 */
        		>;
    		};
	};
};

&usdhc2 {
    status = "disabled";
};

Two things to notice:

  • I removed the #include <dt-bindings/gpio/gpio.h> since it’s not required here (the IMX8QXP_USDHC1_CMD_LSIO_GPIO4_IO24 is defined under #include "dt-bindings/pinctrl/pads-imx8qxp.h".

  • I added the “colibri-imx8qxp {” because it is also defined inside the imx8x-colibri.dtsi, however maybe it’s not needed.

Let me know if that works now.

Best Regards,
Hiago.

1 Like

Hi Hiago,
That worked! I now have control of that GPIO pin. I also see what I did wrong after I compared my first file with your last version, and by looking at imx8x-colibri.dtsi. So I think I learned something which will give me a better chance of getting my next device tree overlay file to work on my own. Thanks for your detailed and specific help.
Mike

1 Like

Hi @MikeS,

Happy to help!

Feel free to ask any questions you might have.

Best Regards,
Hiago.