Hello,
I have performed some troubleshooting on this issue. First, I checked if the PPS signal cycle was incorrect. To do this, I modified the pps-gpio driver to print the timestamp in dmesg each time a hardware interrupt occurs. This helped me observe the PPS hardware interrupt cycle.
Here’s the modified code:
# Linux_for_Tegra/source/public/kernel/kernel-5.10/drivers/pps/clients/pps-gpio.c
static irqreturn_t pps_gpio_irq_handler(int irq, void *data)
{
const struct pps_gpio_device_data *info;
struct pps_event_time ts;
int rising_edge;
/* Get the time stamp first */
pps_get_ts(&ts);
info = data;
rising_edge = gpiod_get_value(info->gpio_pin);
if ((rising_edge && !info->assert_falling_edge) ||
(!rising_edge && info->assert_falling_edge))
pps_event(info->pps, &ts, PPS_CAPTUREASSERT, data);
else if (info->capture_clear &&
((rising_edge && info->assert_falling_edge) ||
(!rising_edge && !info->assert_falling_edge)))
pps_event(info->pps, &ts, PPS_CAPTURECLEAR, data);
+ printk("pps irq +1\n");
return IRQ_HANDLED;
}
After reloading the driver, I noticed that the cycle printed in dmesg was 1000ms:
nvidia@adu550:~$ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1753695194.352839958, sequence: 335 - clear 0.000000000, sequence: 0
source 0 - assert 1753695195.376838582, sequence: 336 - clear 0.000000000, sequence: 0
source 0 - assert 1753695196.400839670, sequence: 337 - clear 0.000000000, sequence: 0
source 0 - assert 1753695197.424838773, sequence: 338 - clear 0.000000000, sequence: 0
source 0 - assert 1753695198.448839957, sequence: 339 - clear 0.000000000, sequence: 0
source 0 - assert 1753695199.472839092, sequence: 340 - clear 0.000000000, sequence: 0
source 0 - assert 1753695200.496838036, sequence: 341 - clear 0.000000000, sequence: 0
source 0 - assert 1753695201.520839444, sequence: 342 - clear 0.000000000, sequence: 0
source 0 - assert 1753695202.544839187, sequence: 343 - clear 0.000000000, sequence: 0
source 0 - assert 1753695203.568838963, sequence: 344 - clear 0.000000000, sequence: 0
^C
nvidia@adu550:~$ sudo dmesg | grep pps
[ 1.418105] pps_core: LinuxPPS API ver. 1 registered
[ 1.423070] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 3.988032] pps pps0: new PPS source ktimer
[ 3.992330] pps pps0: ktimer PPS source registered
[ 3.997245] pps_ldisc: PPS line discipline registered
[ 194.505433] pps pps1: new PPS source pps.-1
[ 194.505486] pps pps1: Registered IRQ 303 as PPS source
[ 194.691572] pps irq +1
[ 195.690955] pps irq +1
[ 196.690829] pps irq +1
[ 197.691202] pps irq +1
[ 198.691386] pps irq +1
[ 199.691225] pps irq +1
[ 200.691217] pps irq +1
[ 201.691155] pps irq +1
It appears that the issue lies with the pps_get_ts(&ts); function, which is returning a system Unix timestamp that is incorrect. This suggests that my system clock might be adding 1024 milliseconds every second, rather than the expected 1000 milliseconds.
Could you confirm if this is the case?
Thank you!