Time sensitive networking [TSN] on NX

The issue with creating a dtb overlay is that you’ll have to convert the TEGRA_GPIO macro yourself because it’s normally parsed by the kernel build dtb generation process. To convert it, look at kernel-4.9/include/dt-bindings/gpio/tegra-gpio.h. Find the number associated to the GPIO letter, 16 for Q in this case, multiply it by 8, then add the GPIO number, 5 for a result of 133. Now you need to replace GPIO_ACTIVE_LOW by “1”.

So the line becomes…

gpio = <&gpio 133 1>;

So now an overlay source file should look like this…

/dts-v1/;
/plugin/;
 
/ {
    overlay-name = "PPS Overlay";
    compatible = "nvidia,p3509-0000+p3668-0000";
 
    fragment@pps {
        target-path = "/";
        __overlay__ {
            pps {
                gpio = <&gpio 133 1>;
                compatible = “pps-gpio”;
                assert-falling-edge;
                status = “okay”;
            };
        };
    };
};

Once you have that file, follow the instructions in the L4T documentation to enable it…
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fhw_setup_jetson_io.html%23wwpID0E0EB0HA

I haven’t tried these exact steps yet but I will later today.

 cat /mnt/developoment/Linux_for_Tegra/source/public/kernel/kernel-4.9/include/dt-bindings/gpio/tegra-gpio.h
/*
 * This header provides constants for binding nvidia,tegra*-gpio.
 *
 * The first cell in Tegra's GPIO specifier is the GPIO ID. The macros below
 * provide names for this.
 *
 * The second cell contains standard flag values specified in gpio.h.
 */

#ifndef _DT_BINDINGS_GPIO_TEGRA_GPIO_H
#define _DT_BINDINGS_GPIO_TEGRA_GPIO_H

#include <dt-bindings/gpio/gpio.h>

#define TEGRA_GPIO_PORT_A 0
#define TEGRA_GPIO_PORT_B 1
#define TEGRA_GPIO_PORT_C 2
#define TEGRA_GPIO_PORT_D 3
#define TEGRA_GPIO_PORT_E 4
#define TEGRA_GPIO_PORT_F 5
#define TEGRA_GPIO_PORT_G 6
#define TEGRA_GPIO_PORT_H 7
#define TEGRA_GPIO_PORT_I 8
#define TEGRA_GPIO_PORT_J 9
#define TEGRA_GPIO_PORT_K 10
#define TEGRA_GPIO_PORT_L 11
#define TEGRA_GPIO_PORT_M 12
#define TEGRA_GPIO_PORT_N 13
#define TEGRA_GPIO_PORT_O 14
#define TEGRA_GPIO_PORT_P 15
#define TEGRA_GPIO_PORT_Q 16
#define TEGRA_GPIO_PORT_R 17
#define TEGRA_GPIO_PORT_S 18
#define TEGRA_GPIO_PORT_T 19
#define TEGRA_GPIO_PORT_U 20
#define TEGRA_GPIO_PORT_V 21
#define TEGRA_GPIO_PORT_W 22
#define TEGRA_GPIO_PORT_X 23
#define TEGRA_GPIO_PORT_Y 24
#define TEGRA_GPIO_PORT_Z 25
#define TEGRA_GPIO_PORT_AA 26

16 =Q
will it be physical GPIO pin 5 that will be equal to Q equal to 16?

attempt 1 seems failing at this point:

 cat  /mnt/developoment/Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dts
/*
 * Top level DTS file for CVM:P3668-0001 and CVB:P3509-0000.
 *
 * Copyright (c) 2019-2020, NVIDIA CORPORATION.  All rights reserved.
 *
 * 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; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

/dts-v1/;
#include "common/tegra194-p3668-common.dtsi"
#include "common/tegra194-p3509-0000-a00.dtsi"

/ {
        nvidia,dtsfilename = __FILE__;
        nvidia,dtbbuildtime = __DATE__, __TIME__;

        compatible = "nvidia,p3449-0000+p3668-0000", "nvidia,p3449-0000+p3668-0001", "nvidia,p3509-0000+p3668-0000", "nvidia,p3509-0000+p3668-0001", "nvidia,tegra194";

pps {
    gpio = <&gpio TEGRA_GPIO(Q, 5) GPIO_ACTIVE_LOW>;
    compatible = “pps-gpio”;
    assert-falling-edge;
    status = “okay”;
};
};

 make -j8 ARCH=arm64 O=$TEGRA_KERNEL_OUT dtbs
make[1]: Entering directory '/mnt/outdir'
  CHK     scripts/mod/devicetable-offsets.h
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-base.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-ape-cam.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-edp.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-dsi-hdmi-dp.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-dsi-hdmi-dp.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-dsi-dp.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-hdmi-primary-p3310-1000-c03-00.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-hdmi-primary-p3310-1000-a00-00.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-base-mods-display.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-imx274.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-imx185_v1.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-lc898212.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-hdmi-primary-p3310-1000-a00-00-imx274.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-hdmi-primary-p3310-1000-c03-00-imx274.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-ape-cam.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-imx185_v1.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-dsi-dp.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-dsi-hdmi-hdmi.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-dsi-hdmi-hdmi-imx274-hdmiin.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c00-00-auo-1080p-edp.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-e3313-1000-a00-00-e2598.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3489-1000-a00-00-ucm1.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3489-1000-a00-00-ucm2.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3489-1000-a00-00-e2598.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3489-0888-a00-00-base.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3489-0888-a00-00-e2598.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-as-0888.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t19x/galen/kernel-dts/tegra194-p2888-0001-p2822-0000.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t19x/galen/kernel-dts/tegra194-p2888-0001-p2822-0000-imx274-hdmi.dtb
  DTC     arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t19x/galen/kernel-dts/tegra194-p2888-0001-p2822-0000-imx185_v1.dtb
Error: /mnt/developoment/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dts:27.19-20 syntax error
FATAL ERROR: Unable to parse input tree
/mnt/developoment/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/Makefile:120: recipe for target 'arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dtb' failed
make[2]: *** [arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dtb] Error 1
make[2]: *** Waiting for unfinished jobs....
arch/arm64/Makefile:154: recipe for target 'dtbs' failed
make[1]: *** [dtbs] Error 2
make[1]: Leaving directory '/mnt/outdir'
Makefile:171: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
dtc -O dtb -o my-overlay.dtbo -@ my-overlay.dts
Error: my-overlay.dts:13.30-31 syntax error
FATAL ERROR: Unable to parse input tree

I think I have it working. I’m just testing with a GPS hat to see if I can actually see the pps transitions with ppstest.

OK, here we go…

Save this file as /boot/pps.dts

/dts-v1/;
/plugin/;

/ {
    overlay-name = "Jetson PPS";
    compatible = "nvidia,p3509-0000+p3668-0001";

    fragment {
        target-path = "/";
        __overlay__ {
			pps: pps_gpio {
				compatible = "pps-gpio";
				gpios = <&tegra_main_gpio 148 1>;
				assert-falling-edge;
				status = "okay";
			};
        };
    };
};

I changed the gpio to GPIO09 which is pin 7 on the 40 pin header because the GPS hat I have already hard wires the PPS signal to that pin.

Compile the dts into a dtbo

$ cd /boot
$ sudo dtc -I dts -O dtb -@ -o pps.dtbo pps.dts

Create a custom dtb from the stock dtbs and pps.dtbo

$ sudo fdtoverlay -i tegra194-p3668-all-p3509-0000.dtb -o tegra194-p3668-all-p3509-0000-user-custom.dtb tegra194-p3668-all-p3509-0000-hdr40.dtbo pps.dtbo

Now edit /boot/extlinux/extlinux.conf and add the following line to your menu entry…

    LINUX ...
    INITRD ...
    FDT /boot/tegra194-p3668-all-p3509-0000-user-custom.dtb
    APPEND ...

Now reboot.

When the system comes back up you should now have a /dev/pps0 device. If you connect your PPS source to pin 7 and you install the pps-tools package, you should be able to run

$ sudo ppstest /dev/pps0
trying PPS source "pps0"
found PPS source "pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1592529430.097600543, sequence: 2333 - clear  0.000000000, sequence: 0
source 0 - assert 1592529431.097604009, sequence: 2334 - clear  0.000000000, sequence: 0
source 0 - assert 1592529432.097600339, sequence: 2335 - clear  0.000000000, sequence: 0
source 0 - assert 1592529433.097601277, sequence: 2336 - clear  0.000000000, sequence: 0

Your next steps depend on how you want to get the kernel time to sync so that it can be sent by ptpd. What I do is use ntpd to take 2 sources. The first is a reliable upstream ntp server. The second is a generic nmea source that takes both the nmea sentences and the pps signal from the gps unit. Once the kernel is synced, ptpd can be set up as a master server.

3 Likes

Is it the only line that goes to the /boot/extlinux/extlinux.conf ?
Does the order matter?
I added it to the end of the file and rebooted; The remote device never get back online;
I will try to reflash it and repeat steps above.

Also :

sudo dtc -I dts -O dtb -@ -o pps.dtbo pps.dts
pps.dtbo: Warning (gpios_property): Could not get phandle node for /fragment/__overlay__/pps_gpio:gpios(cell 0)

The FDT line should go between the INITRD and APPEND lines.

The warning is OK. I get it as well.

between already existing INITRD & APPEND or newly created ones?
Thanks

Any that you want to use the new DTB with. Hard to give exact instructions without seeing your existing extconfig.conf.

it was the default stock non modified file


 cat /boot/extlinux/extlinux.conf 
TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      FDT /boot/tegra194-p3668-all-p3509-0000-user-custom.dtb
      APPEND ${cbootargs} quiet

# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
#      sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot

# LABEL backup
#    MENU LABEL backup kernel
#    LINUX /boot/Image.backup
#    INITRD /boot/initrd
#    APPEND ${cbootargs}

will that work ?

That’s perfect!

Hi @Andrey1984, Did it work?

It is what I am working on to understand, at the moment;
As all devices that I am working with are remote, it takes a while to recover after boot failure.
However, I shall update you soon.

Hi @gtj
on the fresh OS from sdcard image, after patching

It is staying blank with a flash _

[ as per the observatino of local person]
from remote dev: “Nothing is showing except the _ flashing on the top left”

mounted the sdcard to another device:

/media/boot$ ls
dtb                                                              tegra186-quill-p3310-1000-c03-00-base-hdr40.dtbo
extlinux                                                         tegra186-quill-p3310-1000-c03-00-dsi-hdmi-dp.dtb
grub                                                             tegra186-quill-p3489-0888-a00-00-base.dtb
Image                                                            tegra186-quill-p3489-1000-a00-00-ucm1.dtb
Image.sig                                                        tegra186-quill-p3489-1000-a00-00-ucm2.dtb
initrd                                                           tegra194-p2888-0001-p2822-0000-adafruit-sph0645lm4h.dtbo
initrd.img                                                       tegra194-p2888-0001-p2822-0000.dtb
initrd.img-4.9.140-tegra                                         tegra194-p2888-0001-p2822-0000-fe-pi-audio-z-v2.dtbo
pps.dtbo                                                         tegra194-p2888-0001-p2822-0000-hdr40.dtbo
pps.dts                                                          tegra194-p2888-0001-p2822-0000-maxn.dtb
tegra186-quill-p3310-1000-a00-00-base.dtb                        tegra194-p3668-all-p3509-0000-adafruit-sph0645lm4h.dtbo
tegra186-quill-p3310-1000-as-0888.dtb                            tegra194-p3668-all-p3509-0000.dtb
tegra186-quill-p3310-1000-c03-00-base-adafruit-sph0645lm4h.dtbo  tegra194-p3668-all-p3509-0000-fe-pi-audio-z-v2.dtbo
tegra186-quill-p3310-1000-c03-00-base.dtb                        tegra194-p3668-all-p3509-0000-hdr40.dtbo
tegra186-quill-p3310-1000-c03-00-base-fe-pi-audio-z-v2.dtbo      tegra194-p3668-all-p3509-0000-user-custom.dtb
xavier@agx:/media/boot$ cat extlinux/extlinux.conf 
TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      FDT /boot/tegra194-p3668-all-p3509-0000-user-custom.dtb
      APPEND ${cbootargs} quiet

# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
#      sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot

# LABEL backup
#    MENU LABEL backup kernel
#    LINUX /boot/Image.backup
#    INITRD /boot/initrd
#    APPEND ${cbootargs}

from AGX:

sudo chroot /media

inspection of the filesystem and logs doesn’t provide any hint.

cat pps.dts
/dts-v1/;
/plugin/;

/ {
    overlay-name = "Jetson PPS";
    compatible = "nvidia,p3509-0000+p3668-0001";

    fragment {
        target-path = "/";
        __overlay__ {
                        pps: pps_gpio {
                                compatible = "pps-gpio";
                                gpios = <&tegra_main_gpio 148 1>;
                                assert-falling-edge;
                                status = "okay";
                        };
        };
    };
};
 sudo /opt/nvidia/jetson-io/config-by-hardware.py -l
Configurations for the following hardware modules are available:
1. Adafruit SPH0645LM4H
2. FE-PI Audio Z V2
3. Jetson PPS
**
**
sudo /opt/nvidia/jetson-io/config-by-hardware.py -n "Jetson PPS"
Configuration saved to /boot/tegra194-p3668-all-p3509-0000-jetson-pps.dtb.
then Reboot.
Then
ls /dev/pp
ppp   pps0
$ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out).

It seems that the device needs to get attached the time-pulse wire to the pin 7
I anticipate it will not boot if I return the extlinux.conf FDT line

That’s very odd. Did you change the FDT entry to “/boot/tegra194-p3668-all-p3509-0000-jetson-pps.dtb” or did you leave it out altogether to get it to work?

it was changed by the jetson-io toolkit gracefully so that it appended an entire section in the bottom
I just commented with # the manually added FDT in order to boot at all ,as otherwise it wouldn’t boot