Unable to get the include directories to be used when using the "deploy" an overlay method with Torzioncore-builder

When using the deploy method when trying to deploy using a command like this example given in the documentation.
torizoncore-builder dto deploy --remote-host 192.168.12.117 --remote-username username --remote-password pw --reboot --device-tree ./linux/arch/arm64/boot/dts/freescale/imx8mp-verdin-wifi-dev.dts device-trees/overlays/my_overlay.dts

In my tcbuild.yaml in the top directory where I am running this command, I have the following include path under here:
customization:
device-tree:
include-dirs:
linux/arch/arm64/boot/dts/freescale

Which contains imx8mp-pinfunc.h file that i am including in my overlay file.

error: no include path in which to search for imx8mp-pinfunc.h

But it comes up and says there are no include directories given to actually find it.
When you do the deploy command, does it not use the tcbuild.yaml file that is in the local directory? If so, how do you get the include path in there? There doesn’t seem to be a command line option that allows a include path command.
If I comment out the include file, it complains that the “device-trees” directory already exists, like the path of where it reads my overlay file needs to be created.

Steve

Hi @Evets ,

But it comes up and says there are no include directories given to actually find it.
When you do the deploy command, does it not use the tcbuild.yaml file that is in the local directory? If so, how do you get the include path in there? There doesn’t seem to be a command line option that allows a include path command.

Keep in mind that the tcbuild.yaml file is only used by torizoncore-builder build and not by any other command. So any changes you make to it will not alter the default behavior of dto deploy for instance.

There is a command line option to specify the include path ( --include-dir):

$ torizoncore-builder dto deploy --help
usage: torizoncore-builder dto deploy [-h] --remote-host REMOTE_HOST [--remote-username REMOTE_USERNAME] [--remote-password REMOTE_PASSWORD] [--remote-port REMOTE_PORT] [--reboot]
                                      [--mdns-source MDNS_SOURCE] [--include-dir DIR] [--force] [--device-tree FILE] [--clear]
                                      OVERLAY [OVERLAY ...]

Deploy a device tree overlay in the device
[...]
optional arguments:
[...]
  --include-dir DIR     Search directory for include files during overlay compilation. Can be passed multiple times. If absent, defaults to 'device-trees/include'
[...]

The dto deploy command uses dt checkout under the hood, and given that this command currently has limitations with TorizonCore 6 images, dto deploy has the same limitations.

Because of that I’d recommend using torizoncore-builder build followed by images unpack and deploy instead. To deploy an overlay do the following:

  • Specify the overlay you want to deploy in tcbuild.yaml, as you did before;
  • Run torizoncore-builder build to create a custom TorizonCore image with the overlay;
  • Run torizoncore-builder images unpack <output-dir>, where <output-dir> is the directory path where the custom image created with build is located;
  • Run torizoncore-builder deploy --remote-host <SoM IP> --remote-username torizon --remote-password <password> --reboot . The module should reboot with the new overlay applied.

Let me know if this helps you.

Best regards,
Lucas Akira

Hi @lucas_a.tx,
Well, I did try what you said, but of course got stuck in the build process. See below:

torizoncore-builder build --file tcbuild2.yaml
Building image as per configuration file ‘tcbuild2.yaml’…

=>> Handling input section
Unpacking Toradex Easy Installer image.
Copying Toradex Easy Installer image.
Unpacking TorizonCore Toradex Easy Installer image.
Importing OSTree revision 064f2f8de4197b1c9e6c82888c333ffb4ea65f975c3d0d22b11ffb4468837407 from local repository…
933 metadata, 9271 content objects imported; 563.8 MB content written
Unpacked OSTree from Toradex Easy Installer image:
** Commit checksum: 064f2f8de4197b1c9e6c82888c333ffb4ea65f975c3d0d22b11ffb4468837407**
** TorizonCore Version: 6.2.0-devel-202303+build.6**

=>> Handling customization section

=> Handling device-tree subsection

=> Selecting custom device-tree ‘linux/arch/arm64/boot/dts/freescale/imx8mp-verdin-wifi-dev.dts’
‘imx8mp-verdin-wifi-dev.dts’ compiles successfully.
warning: removing currently applied device tree overlays
Device tree imx8mp-verdin-wifi-dev.dtb successfully applied.

=> Adding device-tree overlay ‘device-trees/overlays/verdin-imx8mp_spidev2_overlay.dts’
‘verdin-imx8mp_spidev2_overlay.dts’ compiles successfully.

Failed to apply ‘/tmp/tmpo6yy2wyb’: FDT_ERR_NOTFOUND

error: cannot apply device tree overlays [‘/tmp/tmpo6yy2wyb’] against device tree /storage/dt/usr/lib/modules/5.15.77-6.2.0-devel+git.5ee7b429cf75/dtb/imx8mp-verdin-wifi-dev.dtb.
error: overlay ‘device-trees/overlays/verdin-imx8mp_spidev2_overlay.dts’ is not applicable.

I am not sure that this error message is actually helpful, as it would be nice to know specifically what isn’t applicable. Does that mean that there are conflicts or that I can’t turn on SPI2, or that I didn’t specify enough?

Steve

Hi @Evets ,

FDT_ERR_NOTFOUND indicates that your overlay has referenced a node or property that doesn’t exist in the device tree. Can you share your overlay file so we can take a look at it?

Best regards,
Lucas Akira

Hi @lucas_a.tx,
OK, here it is:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*

  • Copyright 2022 Toradex
    */

// Verdin imx8mp spidev

/dts-v1/;
/plugin/; // Indicates that the file is a Device Tree Overlay

// A) Header file with pin definitions
/*#include <soc-pinfunc.h> */
#include <imx8mp-pinfunc.h>

/ {
compatible = “toradex,verdin-imx8mp”;
};
&iomuxc {
pin_cntl_spi2 {
spi2_pins: spi2_grp {
fsl,pins =
<MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x1c4>,
<MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 0x1c4>,
<MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x1c4>,
<MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x1c4>;

	};
};

};
/* Verdin SPI_2 */
&spi2 {
#address-cells = <1>;
#size-cells = <0>;
status = “okay”;

spidev@2 {
	/* Use compatible "rohm,dh2228fv" to bind spidev driver */
	compatible = "rohm,dh2228fv";
	reg = <2>;
	spi-max-frequency = <10000000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pin_cntl_spi2>;
	status = "okay";
};

};

/* Disable uart4 for safety */
&uart4 {
status = “disabled”;
};

Steve

Hi @Evets ,

I was able to compile your overlay by doing the following changes to it:

  • &spi2 should be &ecspi2;
  • The pin group declaration should be defined directly in iomuxc, not nested inside another node.

So the overlay should be similar to this:


EDIT: Outdated, non-working overlay. See later posts for newer versions.

verdin-imx8mp_spi2_overlay.dts
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

// Verdin imx8mp spidev

/dts-v1/;
/plugin/; // Indicates that the file is a Device Tree Overlay

// A) Header file with pin definitions
/*#include <soc-pinfunc.h> */
#include <imx8mp-pinfunc.h>

/ {
	compatible = "toradex,verdin-imx8mp";
};
&iomuxc {
	pin_cntl_spi2: spi2_grp {
		fsl,pins =
			<MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK	0x1c4>,
			<MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 	0x1c4>,
			<MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO	0x1c4>,
			<MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI	0x1c4>;
	};
};
/* Verdin SPI_2 */
&ecspi2 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	spidev@2 {
		/* Use compatible "rohm,dh2228fv" to bind spidev driver */
		compatible = "rohm,dh2228fv";
		reg = <2>;
		spi-max-frequency = <10000000>;
		pinctrl-names = "default";
		pinctrl-0 = <&pin_cntl_spi2>;
		status = "okay";
	};
};

/* Disable uart4 for safety  */
&uart4 {
	status = "disabled";
};


I was able to compile and apply the overlay above with TorizonCore Builder.

I’ve noticed that you’re trying to use some pins that are used to communicate with the Wi-Fi/Bluetooth IC. According to the Verdin iMX8M Plus datasheet these pins are only available on SoMs without Wi-Fi.

So if your Verdin Plus has Wi-Fi (you can confirm this by checking if your SoM has a ‘WB’ written on the sticker that has the serial number) it’s unlikely that the pins will work, even with the overlay applied.

Hope this helps you.

Best regards,
Lucas Akira

@lucas_a.tx
Thank you!

OK, I had already changed the &spi2 to &ecspi2 after I wrote this, but I hadn’t made the other iomuxc change. I got the same result though.
I don’t have the WB on the sticker, so i guess I don’t have WiFi/bluetooth. I should be OK.

It did build, so now onto the next step.

Steve

Hi @lucas_a.tx ,
I deployed it, and it came up but there is no second SPI device showing up in the /dev/ folder when I ssh into it. Is there something else I need to do so it can find it? Also, I am wondering about the 2 lines:
#address-cells = <1>;
#size-cells = <0>;
As these are the same as the original, but since the # was there, it looks like they are commented out. Also, I changed the reg = <2>; that was in the original from <1>. Would that make a difference?
It turns out I do have a WB SOM, as I was looking at the dev board, not the SOM S/N.

Looking at the manual above that you show, I read this that the ECSPI2 ECSPI2_SSO can come out on either pin 70 or 128 (only if it’s not a wireless board which mine is), so it appears that the ECSPI2_MOSI can only come out on 93, ECSI2_MISO can only come out on 72, ECSPI_SSO can only come out on 70 and ECSPI2_SCLK can only come out on 95. But the pinout says only SPI2 pins are 12 for SSO, 14 for MISO, 74 for MOSI and 78 for SCLK.

Can you clarify this?

Steve

Hi @lucas_a.tx ,
I think that the either the build with my overlay is not working, or it is not actually getting deployed because I have disabled i2c 1-4 respectively, and yet they all show up in the dev list and my SPI2 does not. Also I have tried using alternate output names like:
MX8MP_IOMUXC_ECSPI2_SCLK__I2C3_SCL
If I understand their meaning that the mux signal MX8MP_IOMUXC_ECSPI2_SCLK will now come out on ball name _I2C3_SCL which is pin 78. Is that the way this works? However, as I said, I don’t think the overlay is taking effect, since the I2C devices are all there.

Thanks,
Steve

Hi @Evets ,

I deployed it, and it came up but there is no second SPI device showing up in the /dev/ folder when I ssh into it. Is there something else I need to do so it can find it?

Right, I just tested the overlay and it didn’t work (I’ll edit my previous reply). So I had to do these changes to it:

  • Take out the pinctrl-0 field in spidev and put it in ecspi2;
  • Redefine pinctrl-0 in iomuxc so that it doesn’t have the group with the ECSPI2 pins.

So the updated overlay would be:


verdin-imx8mp_spi2_overlay.dts
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

// Verdin imx8mp spidev

/dts-v1/;
/plugin/; // Indicates that the file is a Device Tree Overlay

#include <imx8mp-pinfunc.h>

/ {
	compatible = "toradex,verdin-imx8mp";
};
&iomuxc {

	pinctrl-0 = <&pinctrl_gpio1>, <&pinctrl_gpio2>,
		    <&pinctrl_gpio3>, <&pinctrl_gpio4>,
		    <&pinctrl_gpio7>, <&pinctrl_gpio8>,
		    <&pinctrl_gpio_hog2>, <&pinctrl_gpio_hog3>,
		    <&pinctrl_hdmi_hog>;

	pin_cntl_spi2: spi2_grp {
		fsl,pins =
			<MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO	0x1c4>,
			<MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI	0x4>,
			<MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK	0x4>,
			<MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 	0x1c4>;
	};
};
/* Verdin SPI_2 */
&ecspi2 {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pin_cntl_spi2>;
	status = "okay";

	spidev@2 {
		/* Use compatible "rohm,dh2228fv" to bind spidev driver */
		compatible = "rohm,dh2228fv";
		reg = <2>;
		spi-max-frequency = <10000000>;
	};
};

/* Disable uart4 for safety  */
&uart4 {
	status = "disabled";
};


With the overlay above and with TC 6.2 I was able to find a new SPI in /dev/:

$ cat overlays.txt 
fdt_overlays=verdin-imx8mp_hdmi_overlay.dtbo verdin-imx8mp_dsi-to-hdmi_overlay.dtbo verdin-imx8mp_spidev_overlay.dtbo verdin-imx8mp_spi2_overlay.dtbo
$ ls -l /dev/spidev*
crw-rw-r-- 1 root spidev 153, 0 May 22 20:17 /dev/spidev1.0
crw-rw-r-- 1 root spidev 153, 1 May 22 20:17 /dev/spidev2.2

Keep in mind that I’ve used a Verdin Plus 1.1 that has Wi-Fi, and I didn’t check if the new SPI is actually working.

Looking at the manual above that you show, I read this that the ECSPI2 ECSPI2_SSO can come out on either pin 70 or 128 (only if it’s not a wireless board which mine is), so it appears that the ECSPI2_MOSI can only come out on 93, ECSI2_MISO can only come out on 72, ECSPI_SSO can only come out on 70 and ECSPI2_SCLK can only come out on 95. But the pinout says only SPI2 pins are 12 for SSO, 14 for MISO, 74 for MOSI and 78 for SCLK.

The Verdin iMX8M Plus datasheet says that there are some alternate functions available on more than one pin:

So looking at the table I referenced earlier, it shows that the ECSPI2_MOSI function can be delegated to either pin 74, 93 or 152, for instance.

Given that the pins you’re currently trying to use are supposedly not available on SoMs with Wi-Fi, using other pins for SPI2 could be an option as well.

Let me know if you can use the added SPI with the new overlay.

Best regards,
Lucas Akira

Hi @lucas_a.tx ,
OK. I now have 3 questions:

  1. Where do you get the 0x4 for the ECSOU2_MOSI and ECSPI2_SCLK?
  2. There are only 4 pins associated with this device. Why are there 10 pins in the pincntrl-0 and how do you correlate them with the pins for the device?
  3. In order to not conflict with other functions, shouldn’t the second hand part of the pin names be what the “ball name” is for a particular pin? For example _I2C3_SCL, I2C3_SDA, I2C4_SCL and I2C3 SDA ?

Oh and while it builds and says it deploys fine, it isn’t in any of the overlays.txt file(s) which shows up in 4 different places on the device.

Steve

Hi @Evets ,

To answer your questions:

  1. I got these values from the ECSPI1 pin group: imx8mp-verdin.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules . You can find more details about these IOMUXC values in the i.MX8MP SoC datasheet from NXP.

  2. The 10 pin groups you’re referring to are not associated with SPI2, but with node iomuxc. This means that these pins will be available to be used as GPIO in userspace. They’re in the overlay because the pins you’re using for SPI2 were originally there in the non-WiFi device tree, and the only way to remove them is to redefine iomuxc’s pinctrl-0 without them.

  3. In a pin macro the left part is the ball name, and the right part is the pin function e.g. in MX8MP_IOMUXC_SD1_DATA6__GPIO2_IO08:

  • MX8MP_IOMUXC_SD1_DATA6 is the ball name i.e. the name of the pin according to NXP;
  • GPIO2_IO08 is the function allocated to the pin.

To avoid conflicts the same pin or pin group must not be used in two or more activated nodes at the same time. So while you can have the same ball name in multiple pin groups, you can’t have more than one node with status = "okay"; referencing the same pin group.

Oh and while it builds and says it deploys fine, it isn’t in any of the overlays.txt file(s) which shows up in 4 different places on the device.

Are you sure you’re building the TC image with the updated overlay? Does the build log show it being compiled and applied? Did you execute torizoncore-builder images unpack <image dir> after running torizoncore-buider build?

Best regards,
Lucas Akira

Hi @lucas_a.tx,
Thank you for your reply. However, on the 1), it would seem you were using the ECSPI1 pin group, not the ECSPI2 pin group which isn’t in that file. I think the correct thing based on the btuartgrp (uses the same pins I have listed) uses 0x1c4 for all four pins. Let me know if I am incorrect in this case.

BTW, I am using a wifi SOM, so those pins ARE restricted for me. So, I will have to try the I2C4_SCL, SD2_CMD, I2C4_SDA and SD2_CLK pins.

Steve

Hi @lucas_a.tx ,
Well, I wasn’t doing the unpack as I read something that said I only needed to do that in certain cases. Anyway, I did that and now it won’t boot up. How do I get into UBoot? I see nothing on the screen. Where do I communicate with the SOM? I think I may have broken the board since I disabled all the Uarts due to worry of conflicts.

Can I boot is using a USB drive?

Steve

Hi @Evets ,

it would seem you were using the ECSPI1 pin group, not the ECSPI2 pin group which isn’t in that file. I think the correct thing based on the btuartgrp (uses the same pins I have listed) uses 0x1c4 for all four pins. Let me know if I am incorrect in this case.

If I recall correctly the IOMUXC values vary according to the pin function, so pins allocated as ECSPI should have similar values. In any case, you can try using the values from btuartgrp and see if it works.

BTW, I am using a wifi SOM, so those pins ARE restricted for me. So, I will have to try the I2C4_SCL, SD2_CMD, I2C4_SDA and SD2_CLK pins.

The I2C4 pins are used by the HDMI connection, so using I2C4_SCL and I2C4_SDA will remove HDMI functionality.

So using SD2_CMD, SD2_CLK, SD2_DATA2 and SD2_DATA3 instead, I created a new overlay:


verdin-imx8mp_new_spi2_overlay.dts
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

// Verdin imx8mp spidev

/dts-v1/;
/plugin/; // Indicates that the file is a Device Tree Overlay

#include <imx8mp-pinfunc.h>

/ {
	compatible = "toradex,verdin-imx8mp";
};

// Free pins SD2_CMD, SD2_CLK, SD2_DATA2 and SD2_DATA3
&usdhc2 {
	status = "disabled";
};

&iomuxc {
	pin_cntl_spi2: spi2_grp {
		fsl,pins =
			<MX8MP_IOMUXC_SD2_DATA3__ECSPI2_MISO	0x1c4>,
			<MX8MP_IOMUXC_SD2_CMD__ECSPI2_MOSI	0x4>,
			<MX8MP_IOMUXC_SD2_CLK__ECSPI2_SCLK	0x4>,
			<MX8MP_IOMUXC_SD2_DATA2__ECSPI2_SS0 	0x1c4>;
	};
};
/* Verdin SPI_2 */
&ecspi2 {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pin_cntl_spi2>;
	status = "okay";

	spidev@2 {
		/* Use compatible "rohm,dh2228fv" to bind spidev driver */
		compatible = "rohm,dh2228fv";
		reg = <2>;
		spi-max-frequency = <10000000>;
	};
};


With the overlays below applied on a Verdin Plus 1.1A with Wi-Fi:

$ cat overlays.txt
fdt_overlays=verdin-imx8mp_hdmi_overlay.dtbo verdin-imx8mp_dsi-to-hdmi_overlay.dtbo verdin-imx8mp_spidev_overlay.dtbo verdin-imx8mp_new_spi2_overlay.dtbo

I was able to see two spidev devices in /dev/. Just be aware that the SD reader will not work anymore, as we used the pins originally reserved for it.

Well, I wasn’t doing the unpack as I read something that said I only needed to do that in certain cases. Anyway, I did that and now it won’t boot up. How do I get into UBoot? I see nothing on the screen. Where do I communicate with the SOM? I think I may have broken the board since I disabled all the Uarts due to worry of conflicts.

Are you connecting to the SoM via serial? You should at least be able to see U-Boot initializing TorizonCore with the serial connection, even if you disabled all UARTs in the overlay (U-Boot has its own device tree which we’re not changing).

If you see the U-Boot initialization sequence press any key to stop the autoboot process then type this to disable all overlays in the next boot:

setenv skip_fdt_overlays 1

Then, boot TorizonCore:

boot

You can also try loading Toradex Easy Installer on the module and then once it’s loaded plug in a USB stick with the custom TC image you created with TorizonCore Builder.

Best regards,
Lucas Akira

Hi @lucas_a.tx ,
Got it going!! Thank you!!!

Thanks,
Steve

Hi @lucas_a.tx ,
Well, I got it going and just to be on the safe side I took your file. But when I got into it, the GUI doesn’t come up (I see this in the debug output - [ 0.878243] imx-drm display-subsystem: no available port) and I see a new SPI device, but I lost the original one. So I still only have one SPI device.

I have tried to do “recovery” but I can’t get the USB to go into it’s speical mode that the PC sees.

Steve

Hi @Evets ,

Well, I got it going and just to be on the safe side I took your file. But when I got into it, the GUI doesn’t come up (I see this in the debug output - [ 0.878243] imx-drm display-subsystem: no available port) and I see a new SPI device, but I lost the original one. So I still only have one SPI device.

Are you applying the HDMI overlay as well as the original SPIDEV one? Your overlays.txt should look like this:

fdt_overlays=verdin-imx8mp_hdmi_overlay.dtbo verdin-imx8mp_dsi-to-hdmi_overlay.dtbo verdin-imx8mp_spidev_overlay.dtbo verdin-imx8mp_new_spi2_overlay.dtbo

Just be aware that TorizonCore not having an image output coming from HDMI doesn’t necessarily mean that there are issues. In fact, if you install TorizonCore without the evaluation containers that’s the expected behavior: No image output as there is no application started by default that shows anything on screen.

Best regards,
Lucas Akira

@lucas_a.tx
Yes, but I was using one that has the containers, and I used the install from method so it would get the correct version based on what was loaded on my SOM.

So, from the documentation, it says that to just overlay what is currently used, you pull down the release and build that you have on your system, then add your overlay to it, which is what I did. So, in my build.yaml, I am only adding my overlay. Am I supposed to add all the original overlays as well?

Thanks,
Steve

Hi @Evets ,

In your tcbuild.yaml file, did you specify a custom device tree to be used? e.g. filled the custom field in a way similar to this:

[...]
customization:
  device-tree:
[...]
    custom: imx8mp-verdin-wifi-dev.dts
    # >> Device-tree overlays configuration:
    overlays:
      # >> Whether to ignore all overlays from the base image (or ostree
      # >> archive in the future).
      clear: false
      add:
        - verdin-imx8mp_new_spi2_overlay.dts
[...]

According to this section in our documentation if you specify a device tree in custom then all default overlays used in the base image are not applied (they are present in the image, just not loaded). For the Verdin Plus these default overlays include the HDMI and the original SPIDEV one.

Try removing the custom field from your tcbuild.yaml if it is being used, and also be sure that the clear field in the overlays section is set to false. If a custom device tree is not specified, then TorizonCore Builder will use the default one for the module.

Once the new TC image is installed, confirm that the overlays are being loaded by checking if they are listed in overlays.txt.

Best regards,
Lucas Akira