Unabled to add PPS to GPIO iMX6DL

#support
Attempting to add pps to GPIO1 I007 SODIMM 55.
Software : kirkstone 6.x.y toaradex 6
hardware: col imx6dl 512mb board: colibri eval board v3

Code:
home/usr/oe-core/layers/meta-custom/recipes-kernel/linux-toradex/conf/machine
colibri-imx6-extra.conf
KERNEL_DEVICETREE:append = " custom-devicetree.dtb"
/home/usr/oe-core/layers/meta-custom/recipes-kernel/linux-toradex

custom-devicetree.dts

/dts-v1/;


#include <dt-bindings/gpio/gpio.h>
#include "imx6dl.dtsi"
#include "imx6qdl-colibri.dtsi"

/ {
	model = "Toradex Colibri iMX6DL/S on Colibri Iris Board";
	compatible = "toradex,colibri_imx6dl-iris", \
			"toradex,colibri_imx6dl", "fsl,imx6dl";

            pps {
                compatible = "pps-gpio";
                gpios = <&gpio1 7 0>;
                status = "okay";
            };
      
};

/home/usr/oe-core/layers/meta-custom/recipes-kernel/linux-toradex

defconfig

....
CONFIG_PPS_CLIENT_LDISC=m
CONFIG_PPS_CLIENT_GPIO=m
CONFIG_PPS_CLIENT_KTIMER=m
....

/home/usr/oe-core/layers/meta-custom/recipes-kernel
linux-toradex.bbappend

FILESEXTRAPATHS:prepend := "${THISDIR}/linux-toradex:"

# Prevent the use of in-tree defconfig
unset KBUILD_DEFCONFIG

CUSTOM_DEVICETREE = "custom-devicetree.dts"

SRC_URI += "\ 
    file://${CUSTOM_DEVICETREE} \
    file://defconfig \
    "

do_configure:append() {
    # For arm32 bit devices
    cp ${WORKDIR}/${CUSTOM_DEVICETREE} ${S}/arch/arm/boot/dts
    # For arm64 bit freescale/NXP devices
    # cp ${WORKDIR}/${CUSTOM_DEVICETREE} ${S}/arch/arm64/boot/dts/freescale
}

/home/usr/oe-core/layers/meta-custom/recipes-bsp/u-boot
u-boot-toradex_%.bbappend

....
do_configure:append() {
    # Remove exisiting fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/colibri_imx6.h
    # Add new fdtfile, "custom-devicetree.dtb" should be replaced with your device tree binary file
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=custom-devicetree.dtb\\0" \\/' ${S}/include/configs/colibri_imx6.h
}
...

local.conf

# This file does not need to exist, if it does it can be used to influence machine specific
# configurations without copying the machine file.
include conf/machine/include/${MACHINE}.inc
include conf/machine/include/colibri-imx6-extra.conf


# DO NOT SET THE MACHINE AFTER THE ABOVE INCLUDE

#
# Accepting any EULA 
#

ACCEPT_FSL_EULA = "1"

#
# Switching to the the real-time kernel  for for the Linux
#

PREFERRED_PROVIDER_virtual/kernel = "linux-toradex-rt"

Issues:

If i run as is the bake completed but my device tree is not in the images.
I am thinking that is because bake doesn’t know where my conf lives.

If i add
KERNEL_DEVICETREE:append = " custom-devicetree.dtb"
to the machine inc directory i get :

|   DTC     arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dtb
| Error: /home/usr/oe-core/build/tmp/work-shared/colibri-imx6/kernel-source/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts:78.1-4 syntax error
| FATAL ERROR: Unable to parse input tree
| scripts/Makefile.lib:285: recipe for target 'arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dtb' failed
| make[2]: *** [arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dtb] Error 1
| /home/usr/oe-core/build/tmp/work-shared/colibri-imx6/kernel-source/Makefile:1270: recipe for target 'imx6dl-colibri-cam-eval-v3.dtb' failed
| make[1]: *** [imx6dl-colibri-cam-eval-v3.dtb] Error 2
| /home/usr/oe-core/build/tmp/work-shared/colibri-imx6/kernel-source/Makefile:179: recipe for target 'sub-make' failed
| make: *** [sub-make] Error 2
| ERROR: oe_runmake failed

I have also also build a working exteral kernel and device tree and they receive the same Unable to parse errors when i include the pps block. That is if i create my own dst or place the pps block in an existing dts.

@tmassalene

Maybe I can help with this as I had some issues getting this to work as well. I will list some things that I noticed from your statements vs what I have (for the record, I did mine on an Apalis module but it shouldn’t matter)

For starters, you ${MACHINE}.conf file should go in the conf folder of your custom layer, i.e.
home/usr/oe-core/layers/meta-custom/conf/machine/${MACHINE}.conf

The above file should be included in your custom layer conf file, i.e.
home/usr/oe-core/layers/meta-custom/conf/layer.conf

In your device tree, you need to do 2 things to enable PPS, configure it like you did above, and then iomux the gpio pin

/ {
    ....
    pps {
        compatible = "pps-gpio";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_pps>;
        gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
        assert-falling-edge;
        status = "okay";
    };
....
};

....

&iomuxc {
    ....
    pinctrl_pps: ppsgrp {
        fsl,pins = <
            MX6QDL_PAD_NANDF_D4__GPIO2_IO04 0x1b0b0    # Look up this in the datasheet
        >;
    };
    ....
};

Once all of this has been done, check the Makefile for the device tree build, it should be located in
home/usr/oe-core/build/tmp/work-shared/${MACHINE}/kernel-source/arch/arm/boot/dts/Makefile

There should be an entry in there under dtb-$(CONFIG_SOC_IMX6Q) heading that says
'custom_devicetree.dtb '
If you haven’t added this, you need to, also be careful when you do, the Makefile is highly sensitive to extra spaces and tabs, for example after the ''. Also put your .dtb file in there in alphabetical order.

You can automate the addition to the makefile in your linux_toradex%.bbappend (make sure your file includes the ‘%’, your post didn’t have it) file like so

CUSTOM_DEVICETREE = "custom-devicetree"

do_configure:append() {
    cp ${WORKDIR}/${CUSTOM_DEVICETREE}.dts ${S}/arch/arm/boot/dts
    echo "dtb-$(CONFIG_SOC_IMX6Q) += ${CUSTOM_DEVICETREE}.dtb" >> ${S}/arch/arm/boot/Makefile
}

Kernel config (defconfig) should include
CONFIG_PPS=y
CONFIG_PPS_CLIENT_LDISC=y
CONFIG_PPS_CLIENT_GPIO=y
Using ‘m’ for module should be fine, I used ‘y’. You don’t need KTIMER, it creates a dummy pps in /dev to be used for testing/debugging.

Ok, I think that’s all I got, hopefully this helps

-Mike

Hell Mike,
Thanks for the assistance.
I have make the suggested change but still getting the same error:

|   DTC     arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dtb
| Error: /home/asei/oe-core/build/tmp/work-shared/colibri-imx6/kernel-source/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts:78.1-4 syntax error
| FATAL ERROR: Unable to parse input tree

Changes made:
Updated
linux-toradex.bbappend to linux-toradex%.bbappend
move my machine/{machine}.conf to the new location
update the PPS and mux is at MX6QDL_PAD_GPIO_7__GPIO1_IO07 0x1b0b0
code:

/dts-v1/;


#include <dt-bindings/gpio/gpio.h>
#include "imx6dl-colibri-eval-v3.dts"

/ {
	model = "Toradex Colibri iMX6DL/S on Colibri Iris Board";
	compatible = "toradex,colibri_imx6dl-iris", \
			"toradex,colibri_imx6dl", "fsl,imx6dl";

            pps {
                compatible = "pps-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_pps>;
                gpios = <&gpio1 7 0>;
                assert-falling-edge;
                status = "okay";
            };
      
&iomuxc {
    pinctrl_pps: ppsgrp {
        fsl,pins = <
            MX6QDL_PAD_GPIO_7__GPIO1_IO07 0x1b0b0
        >;
    }; 
};
};

This might be my inexperience on what I’m still missing.

I think i have solved my first errors.

Now i am receiving this error:

NOTE: Resolving any missing task queue dependencies
ERROR: Nothing RPROVIDES 'linux-toradex' (but /home/user/oe-core/build/../layers/meta-custom/recipes-core/images/custom-core-image.bb RDEPENDS on or otherwise requires it)
linux-toradex was skipped: incompatible with machine colibri-imx6 (not in COMPATIBLE_MACHINE)
NOTE: Runtime target 'linux-toradex' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['linux-toradex']
ERROR: Required build target 'custom-core-image' has no buildable providers.
Missing or unbuildable dependency chain was: ['custom-core-image', 'linux-toradex']

@tmassalene

Try setting the below
PREFERRED_PROVIDER_virtual/kernel = “linux-toradex-mainline-rt”

BSP6 eliminated using downstream kernel builds with the exception of the iMX8. This means that you must use the upstream distro (i.e. mainline).

I just attempted that change receiving the same error.

@tmassalene

Can you post your custom-core-image.bb and your local.conf?

I was able to resolve. I copied the dts imx6dl-colibri-iris-v2, added my code to it. It appears to have been syntax errors but I’m not truly sure.

It build and the PPS is showing. Running testing now.

Update still not solved. After testing a new connection was create but it appears to be a dummy connection for the ktimer. So I believe i may have tripped myself up
customer-image.bb

#
# Summary is the title of the build 
#

SUMMARY = " production image v1.0"

#
# License is the opensource lincense required for the the build
#

LICENSE = "MIT"

#
# This build will inherit the the base yocto image and the extend it with built in and custom layers 
#

inherit core-image



#
# Adding the image features package-management to handle packages in combination with apt
#

IMAGE_FEATURES_append += " package-management"


#
# Create a image name and the tag the system   
#


IMAGE_NAME = "${MACHINE_NAME}_${IMAGE_BASENAME}"


#
# Copy Licenses to image /usr/share/common-license
#
COPY_LIC_MANIFEST ?= "1"
COPY_LIC_DIRS ?= "1"


#
# Setting the language for the image 
#
IMAGE_LINGUAS = "en-us"


#
# Adding the  specific program specific packages 
# irqbalance 
# Added apps:
# dropbear 
# nano
# libstdc++
# apt
# usbutils
# pciutils
# kernel-modules
# custom apps:
# startup
# udev
# pps-tools
#

IMAGE_INSTALL_append += "  \ 
                            apt \
                            libstdc++ \
                            nano \
                            kernel-modules \
                            usbutils \
                            pciutils \
                            dropbear \
                            startup \
                            udev \
			    pps-tools \
                            systemd-conf\
   			    packagegroup-boot \
    			    packagegroup-basic \
    			    packagegroup-base-tdx-cli \
    			    packagegroup-machine-tdx-cli \
    			    packagegroup-wifi-tdx-cli \
    			    packagegroup-wifi-fw-tdx-cli \
    			    udev-extraconf \
                            u-boot-toradex \
                            ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'timestamp-service systemd-analyze', '', d)} \
                            "

If linux-toradex is added it will produce the error:

Nothing RPROVIDES 'linux-toradex'

layer.conf


include conf/machine/colibri-imx6-extra.conf

# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
            ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "meta-custom"
BBFILE_PATTERN_meta-custom = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-custom = "6"

LAYERDEPENDS_meta-custom = "core"
LAYERSERIES_COMPAT_meta-asei-custom = "dunfell"

local. conf

.....
#MACHINE ?= "apalis-imx6"
#MACHINE ?= "apalis-imx8"
#MACHINE ?= "apalis-tk1"
#
#MACHINE ?= "colibri-imx6"
MACHINE ?= "colibri-imx6-extra"
#MACHINE ?= "colibri-imx6ull"
#MACHINE ?= "colibri-imx6ull-emmc"
#MACHINE ?= "colibri-imx7"
#MACHINE ?= "colibri-imx7-emmc"
#MACHINE ?= "colibri-imx8x"
.....

# Use this distro by default
DISTRO ?= "tdx-xwayland-rt"

# Don't generate the mirror tarball for SCM repos, the snapshot is enough
# BB_GENERATE_MIRROR_TARBALLS = "0"

# This file does not need to exist, if it does it can be used to influence machine specific
# configurations without copying the machine file.
include conf/machine/include/${MACHINE}.inc

# DO NOT SET THE MACHINE AFTER THE ABOVE INCLUDE

#
# Accepting any EULA 
#

ACCEPT_FSL_EULA = "1"

#
# Swithing to the the real-time kerenel  for for the linux
#

PREFERRED_PROVIDER_virtual/kenerel = "linux-toradex-mainline-rt"

Hey @tmassalene,

Sorry for the delayed response. I see a reference to Dunfell in your layer.conf, I assume you want this to be kirkstone.

I’m a little confused on your tree structure for your layer. Here is one for adding a new layer to add PPS via device tree overlays.

eric@txlaptop:~/workdir/bsp_6/layers/meta-pps$ tree
.
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-overlay
    └── linux
        ├── device-tree-overlays-mainline_%.bbappend
        └── files
            └── colibri-imx6_pps_overlay.dts

with our .bbappend file looking like this: following this guide

And to dive into the files we can see our appended file.

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"


SRC_URI += " \
    file://colibri-imx6_pps_overlay.dts \
"

TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT = " \
    colibri-imx6_pps_overlay.dtbo \
"

do_collect_overlays:prepend() {
    cp ${WORKDIR}/colibri-imx6_pps_overlay.dts ${S}
}

And if you were to use device tree overlay method, the dts file would the /plugin/ addition :

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include "imx6dl-pinfunc.h"

I hope this example can clear somethings up.

-Eric

Thank you for the follow up. As I’m only beholden to working state. I have now downgraded back to Dunfell, I will attempt the steps provided. Thank you.

I have built device tree from make following the documentation : Device Tree Overlays Compilation using make

I manually included the the overlay in the the boofs tar and the updated the overlay but now the kernel won’t boot.
I understand this may be from a kernel conflict but im not seeing a conflict on GPIO1-IO07.
I have even disabled can1 per the board datasheet code below:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include "imx6dl-pinfunc.h"

/{
  compatible = "toradex,colibri_imx6dl";
};


      pps {
                compatible = "pps-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_pps>;
                gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
                assert-rising-edge;
                status = "okay";
     };



&iomuxc {

        pinctrl_pps: gpio-pps {
	        fsl,pins = <
		    MX6QDL_PAD_GPIO_7__GPIO1_IO07	0x10b0 /* SODIMM 55 */
			>;
        };
};

&flexcan1 {
               status = "disabled";
};

update: attempted flecan1 as well. No magic. Now receiving boot error:

Applying Overlay: colibri-imx6-eval_pps.dtbo
885 bytes read in 15 ms (57.6 KiB/s)
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND

The article you linked is for developing device trees without using yocto. So far you have been trying to use the yocto project for your build/adding device tree overlays.

This is the article you would want to follow if trying to add device tree overlays with using yocto.

-Eric

Thank you Eric,
Unfortunately, I have attempted both options with and without yocto with no success, the failure appears to be stemming from the same issue though. The device tree nor the device tree overlay will allow the system to boot. In reading through the documentation, it reads like it is conflict with the pin.

I believe I have resolved the pin conflict. The error I’m getting, tells me I have not.

Hey @tmassalene,

I see a few things that need correcting with your device tree overlay.

When adding a new node it is important to reference the root node. here is an example: dts with adding new node

The next thing is I see you are trying to disable the pin, but you need to rather disable to node that is using the pin. So in this case it would be &can1 and not &flexcan1.

-Eric

Hello @eric.tx,

Appending the node to root and switching to &can1 was able to resolve the error:

failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND

Now the system is just stuck on starting kernel. I have checked both the datasheet and the pinout designer tool and there should be no other conflicts on the pin.

New dts:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include "imx6dl-pinfunc.h"

/ {
		compatible = "toradex,colibri_imx6dl-eval-v3",
		     "toradex,colibri-imx6dl-eval-v3"
                     "toradex,colibri_imx6dl";
};

&{/} {
        

          pps {
                compatible = "pps-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_pps>;
                gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
                assert-falling-edge;
                status = "okay";
              };

};

&can1 {
               status = "disabled";
};

&iomuxc {

        pinctrl_pps: gpio-pps {
	        fsl,pins = <
		    MX6QDL_PAD_GPIO_7__GPIO1_IO07	0x10b0 /* SODIMM 55 */
			>;
        };
};

Are there any error messages?

How are you booting the OS?

-Eric

@eric.tx
Current boot sequence:

MMC: no card present
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
5962 bytes read in 19 ms (305.7 KiB/s)
## Executing script at 17000000
Loading DeviceTree: imx6dl-colibri-eval-v3.dtb
72921 bytes read in 15 ms (4.6 MiB/s)
110 bytes read in 10 ms (10.7 KiB/s)
Applying Overlay: colibri-imx6_lcd-vga_overlay.dtbo
788 bytes read in 23 ms (33.2 KiB/s)
Applying Overlay: colibri-imx6_stmpe-ts_overlay.dtbo
402 bytes read in 19 ms (20.5 KiB/s)
Applying Overlay: colibri-imx6-eval_pps.dtbo
978 bytes read in 25 ms (38.1 KiB/s)
6554304 bytes read in 244 ms (25.6 MiB/s)
Bootargs: enable_wait_mode=off galcore.contiguousSize=50331648 root=PARTUUID=a165081b-02 ro rootwait fec_mac=00:14:2d:a7:05:64 consoleblank=0 no_console_suspend=1 console=tty1 console=ttymxc0,115200n8 fbmem=8M
## Flattened Device Tree blob at 12100000
   Booting using the fdt blob at 0x12100000
   Loading Device Tree to 1ffcb000, end 1fffffff ... OK

Starting kernel ...

booting from mmc

Hey @tmassalene,

This is a bit strange, unfortunately it could be a wide range of issues. My suggestion is to get the system back to a running stable state. And try and recreate the adding of the overlay. I was able to add PPS via these files:

device-tree-overlays-mainline_%.bbappend

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"


SRC_URI += " \
    file://colibri-imx6_pps_overlay.dts \
"

TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT = " \
    colibri-imx6_pps_overlay.dtbo \
"

do_collect_overlays:prepend() {
    cp ${WORKDIR}/colibri-imx6_pps_overlay.dts ${S}
}


and in the same directory files/colibri-imx6_pps_overlay.dts

/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>
#include "imx6dl-pinfunc.h"
/ {
        compatible = "toradex,colibri-imx6dl";
};
&{/} {
        pps {
             compatible = "pps-gpio";
             pinctrl-names = "default";
             pinctrl-0 = <&pinctrl_pps>;
             gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
             status = "okay";
        };
};

&iomuxc {
	pinctrl-names = "default";

	pinctrl_pps: pps {
		fsl,pins = <
		MX6QDL_PAD_NANDF_D4__GPIO2_IO04 0x130b0
		>;
	};	
};

&can1 {
	status = "disabled";
};


You can only bitbake the overlays and then manually transfer it over to the device.

bitbake device-tree-overlays-mainline

after bitbaking just the overlays you should see your .dtbo file in the deploy directory: somewhere like this:


workdir/bsp_6/build/deploy/images/colibri-imx6/overlays

And then you should be able to follow the deploy directions here:

-Eric

Thank you @eric.tx ,

The only difference I’m visually seeing is you used a different pin. I will complete a fresh build from working state and attempt with these perimeters. Could there be issues with SODDIM_55, GPIO1_IO07?