I am currently using nvpps on Jetson AGX Orin to capture a gpio pps event timestamp. After reading the document about time sync and source code of kernel, I think perhaps (not sure) it can get the timestamp of trigger event in different time source (ptp0, tsc…).
Here is the steps i had done:
modify dt and flash
check nvpps indeed in gpio mode.
write a user code to get event timestamp
It worked and got a timestamp of event, but the stamp looks weird, it doesn’t match the timestamp of /dev/ptp0. Here is the description of my question:
I reviewed the source code again, but I still have no idea why the timestamp is behaving strangely. The timestamp I’m getting is neither the system time nor the PTP time — it’s two days after the current time, and it increases faster than normal time.
From what I understand, the driver obtains PTP timestamps either by using the system clock or by reading from the PTP-capable EMAC hardware. The synchronization between the PTP clock and the TSC should work in both GPIO mode and timer mode.
I’m using devkit, the version is 6.2.1-r36.4.4, thank you for your advice, I will try pps-gpio.
But now I got a little confused, in which case, we can only use nvpps? Or we can use pps-gpio to solve all these external trigger in/out problems. I saw someone modify nvpps source code to generate pps pulse to other device, was it suppose to do that?
By the way, I found that when I use jetson-io.py to configure PWM, it may override the changes I applied before flashing or use overlay. Is there a way to prevent this from happening, or I will need to write all the overlay into one file?
I measure the pwm signal and confirm it is correct (10Hz). Also I check the dmesg and gpio, and the config.
[ 0.099377] pps_core: LinuxPPS API ver. 1 registered
[ 0.099380] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.182700] pps pps0: new PPS source ktimer
[ 0.182705] pps pps0: ktimer PPS source registered
[ 0.182708] pps_ldisc: PPS line discipline registered
[ 3.998683] pps pps1: new PPS source pps-gpio.-1
[ 3.998742] pps pps1: Registered IRQ 233 as PPS source
[ 10.842838] nvpps c6a0000.nvpps: nvpps_probe
[ 10.842982] nvpps c6a0000.nvpps: primary-emac found ethernet@6800000
[ 10.842996] nvpps c6a0000.nvpps: primary emac base address 0x6810000
[ 10.843000] nvpps c6a0000.nvpps: using ptp notifier method on emac ethernet@6800000
[ 10.843002] nvpps c6a0000.nvpps: tsc_res_ns(32)
[ 10.843014] nvpps c6a0000.nvpps: PPS GPIO not provided in DT, only Timer mode available
[ 10.845167] nvpps c6a0000.nvpps: nvpps cdev(488:0)
[ 10.845240] nvpps c6a0000.nvpps: TSC config ptx 0x113
gpio-357 (PC.00 |pps-gpio ) in lo IRQ ACTIVE LOW
$ zcat /proc/config.gz | less | grep PPS
CONFIG_PPS=y
# CONFIG_PPS_DEBUG is not set
# PPS clients support
CONFIG_PPS_CLIENT_KTIMER=y
CONFIG_PPS_CLIENT_LDISC=y
CONFIG_PPS_CLIENT_GPIO=y
# PPS generators support
And then I test with pwm output directly to pin 16 (gpio 357), however no irq were triggered, thus of course the ppstest failed.
[ 3.955310] pps-gpio pps-gpio: error -ENOENT: failed to request PPS GPIO
[ 3.955324] pps-gpio: probe of pps-gpio failed with error -2
rmmod the pps-gpio and tried gpiomon 0 9 and got nothing
Thanks for your patience and kindly reply.
Success
I finally use pin 12 (gpio 398) and successfully conduct pps interrupt and ppstest. I think it may be hardware issue, and here is my summary of debug steps, hope it may help for someone struggling.
must check the IO was triggered at first by gpiomon $chip %offset, you can use sudo cat /sys/kernel/debug/gpio to find chip and offset.
check module was load correctly by sudo cat /sys/kernel/debug/gpio and sudo dmesg | grep pps.
P.S. It seems the IO output of jetson is not powerful enough to push the input perfectly at 10Hz, the voltage would drop sometime.