PTP synchronization and PPS output from Nvidia NX

Hi,

We have two devices with NX. Each NX device controls its own camera via GPIO.

We would like to synchronize NX devices via PTP. After synchronization, we would like each NX device to send a pulse per second to its own camera.

Currently, we could synchronize two NX devices via PTP. Both system clocks are synced.
But we are trying to find a way to send a pulse per second to the camera via GPIO.

We tried a user-space program that will toggle a GPIO every second, but we see the pulses drift between two NX devices.
We also tried the sample kernel module, and we also see drift.
Jetson TX2 + PTP capture synchronization - Jetson & Embedded Systems / Jetson TX2 - NVIDIA Developer Forums

Is there any way to send these pulses so that is not dependent on software.(ie) similar to a hardware PPS pin ? Basically we would like to send a pulse per second very accurately to our cameras.

Thanks,

hello Srinivasan.Arvindh,

you might refer to Jetson Xavier hardware pps_out - #16 by shgarg, which produce pps signals on GPIO.
it’s sample driver to feed pps signals in GPIO and capture timestamps to synchronize system every second.
thanks

Hi JerryChang,

Thanks, we executed the sample code. gte_mon

From the sample code and steps,
[we are toggling 40-pin header Pin 16 (gpio=256) and feeding signals to Pin 32(gpio=257) every 1 second.]

We understand that gte_mon monitors GPIO257.
GPIO256 is toggled per second via shell script. On each toggle, gte_mon registers the timestamp.

However, in our case, we want NX to send a pulse per second to an external peripheral. Please see the picture below,

In such a case, could you please let us know why to use gte_mon ? Because we can already toggle a gpio via shell script every 1 second.

We are searching for a way to generate this one second pulse via hardware control and not through software control as it depends on CPU scheduling.

image

Thanks,

There’s a kernel driver named “nvpps” that can generate the PPS signal on a GPIO pin from PTP. You have to enable the driver in the kernel config and add the gpio pin to the DTB.

Thanks gtj.
Will explore and check out nvpps driver.

As of now, we found a way, (ie) using a modified PPS generator on GPIO. The code is available in the thread.
http://www.linuxpps.org/pipermail/discussions/2013-May/004430.html

Hi gij,

Just updating our findings here.

We checked the nvpps driver.
It appears the default nvpps driver code can have PPS input via GPIO in GPIO mode.
The code by default does not support PPS output on GPIO unless we modify the code.

We modified the nvpps driver code to generate PPS on GPIO in timer mode. The timer mode in nvpps driver is based on linux timer. And on each timer event, it reads the PTP time from PHC.
When two NX boards synced over PTP use nvpps driver, we could not get the PPS accurately.

We choose to use the GPIO PPS generator code and it is based on high resolution timer. We could get PPS accurately upto microsecond drift from two NX boards after they sync their system clocks over PTP.

Yeah, sorry about that. I had my directions mixed up.

We’ve had some discussions about this in the past.

@Srinivasan.Arvindh
probably it is gpio limitation, as frequency of the gpio would have very long delay not fitting precision of PTP standard?

Is the modified nvpps driver code available for review?

@Andrey1984
Please find the modified nvpps driver code for PPS out. nvpps_main.c (20.7 KB)

The macro PPS_OUT_MODE is set to 1 for activating the changes.

We toggle GPIO 408,
the device tree [tegra194-p3668-common.dtsi] is modified as

nvpps {
compatible = “nvidia,tegra194-nvpps”;
status = “okay”;
gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(P, 0) 0>;
};

However the nvpps driver code is based on linux timer and jiffies. The drift in PPS between two boards is huge. Probably if we modify this, it may become closer.

Thanks,