PPS GPIO - Adding to device tree syntax error

I am attempting to add a PPS GPIO to the device tree and get a syntax error while compiling the .dtb

I have successfully compiled and loaded my own dtb (dts overlay) and it seems I only get this error when I add the PPS node. My .dts file is included at the bottom of this post

The compile/ error message is:

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  DTC     arch/arm/boot/dts/imx7d-colibri-emmc-bwb-v1.dtb

  Error: arch/arm/boot/dts/imx7d-colibri-emmc-bwb-v1.dts:42.1-4 syntax error
  FATAL ERROR: Unable to parse input tree
make[1]: *** [arch/arm/boot/dts/imx7d-colibri-emmc-bwb-v1.dtb] Error 1
make: *** [dtbs] Error 2

scripts/Makefile.lib:313: recipe for target 'arch/arm/boot/dts/imx7d-colibri-emmc-bwb-v1.dtb' failed
arch/arm/Makefile:341: recipe for target 'dtbs' failed

I noticed on another forum thread with a similar topic on the iMX6 support mentions:

Additionally the pps-gpio driver needs to be enabled in the kernel configuration.

I’m not sure if this needs to be done to just compile the .dts , I have not yet looked into this as during boot I do see:
[ 1.040910] pps pps0: new PPS source ptp0

So I would assume the PPS driver is loaded. Any suggestions ? thoughts ? comments ?

/*
 * Copyright 2017 Toradex AG
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

/dts-v1/;
#include "imx7d-colibri-emmc.dtsi"
#include "imx7-colibri-eval-v3.dtsi"

/ {
	model = "Toradex Colibri iMX7D 1GB on Colibri Evaluation Board V3 Testing for custom carrier";
	compatible = "toradex,colibri_imx7d_emmc-eval", "toradex,colibri_imx7d_emmc", \
		     "fsl,imx7d";
};

&usbotg2 {
	vbus-supply = <&reg_usbh_vbus>;
	status = "okay";
};


// UART2 used for M4 debug port
&uart2 {
	status = "disabled";
};


//SPI used on M4
&ecspi3 {
 status = "disabled";
};
        
pps {
compatible = "pps-gpio";
gpios = <&gpio1 2 0>;
assert-falling-edge;
};

I just rebuilt the kernel after adding the PPS in the config - but I then realized this had been built into the image provided for the easy installer. No worries, at least now I know I can rebuild the kernel on my local machine if needed (it’s up and running on my target)

Linux version 4.9.166-2.8.6+gd899927728be (oe-user@oe-host) (gcc version 7.3.0 (GCC) ) #1 SMP Mon Apr 1 13:16:28 UTC 2019␍␊

[08:16:41:981] [    0.109053] pps_core: LinuxPPS API ver. 1 registered␍␊
[08:16:42:025] [    0.109079] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>␍␊

Hi @nrcm

Thanks for writing to the Toradex Community!

Is the issue solved now?

Best regards,
Jaski

Hi Jaski,

No, I have not yet solved the dts compile error. I was hoping another member of the community has done this and could share a .dts file. It was the last thing I want to test before laying out my custom carrier board and I had figured it was the one thing that would have worked right away :slight_smile:

Any chance you would have time to try this out ?

Cheers,
M

HI @nrcm

For the device-tree customization, you should read the following article.

I made some changes to our regular device-tree which you can find here. With these changes, the device-tree compilation is successful.

Best regards,
Jaski

Hi

The syntax error in your dts file is in here

 pps {
 compatible = "pps-gpio";
 gpios = <&gpio1 2 0>;
 assert-falling-edge;
 };

I assume that pps is a new node. Then it must be somewhere in the tree under the root node ‘/’.

(If pps is the reference to an existing node then you would need &pps. I don’t think that is the case here though.)

The simplest is to move the node up into the existing extension of the ‘/’ node:

 / {
     model = "Toradex Colibri iMX7D 1GB on Colibri Evaluation Board V3 Testing for custom carrier";
     compatible = "toradex,colibri_imx7d_emmc-eval", "toradex,colibri_imx7d_emmc", \
              "fsl,imx7d";
     pps {
         compatible = "pps-gpio";
         gpios = <&gpio1 2 0>;
        assert-falling-edge;
    };
 };

You may additionally need to to the pinmuxing, i.e. make sure that no other driver muxes and claims the pin function GPIO1_IO02 and to mux the pin to gpio as part of the pps node.

Max

Hi Max and Jaski,

Thanks for your responses - I am very much new to the device tree organization and just learning. I was suspecting it was going to be something straight forward like this.

From the articles I have read my impression was that I should be creating a .dts file that overlays the originals, as oppose to replacing the reference ones. Would it be better practice to redefine the nodes that need changing in the imx7-colibri.dtsi and eval files in my custom .dts file ? Just trying to make sure I start down the correct path. I’ll try to give this a try today.

Cheers !

Hi,

Just to follow up, I’ve made the changes as per Jaski’s patches and the .dtb does compile. I’m not seeing any new PPS source on boot up with the PPS-GPIO (below).

# dmesg | grep pps    
[    0.111724] pps_core: LinuxPPS API ver. 1 registered    
[    0.111750] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>    
[    1.043169] pps_core: source ptp0 got cdev (252:0)    
[    1.043180] pps pps0: new PPS source ptp0

I do see the ktimer come up when it’s configured in the kernel, and if I enable the PPS line discipline it is registered (below), but I don’t see any pulses captured in /sys/class/pps/pps0/assert

dmesg | grep pps
[    0.111932] pps_core: LinuxPPS API ver. 1 registered
[    0.111959] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    1.043473] pps_core: source ptp0 got cdev (252:0)
[    1.043484] pps pps0: new PPS source ptp0
[    1.322177] pps_ldisc: PPS line discipline registered

So, still something interesting going on. I’m not sure what I should try next - any advice would be helpful.

Cheers,
M

HI @nrcm

Could you check the output of cat /sys/kernel/debug/gpio?

Thanks and best regards,
Jaski

Hi Jaski,

Sorry about the delay getting back to you. I’ve found out problem - it was my mistake. While rushing around before the holiday break I had reset the uboot environment variables to stop my M4 code from running and I forgot to set my own .dtb again. I just found this out this morning as I was booting up the system again.

Thanks you for the support, I think I’m all good to spin my own carrier board now.

Cheers,
Mark

hi @nrcm

Perfect that it works. Thanks for the feedback.

Best regards,
Jaski