How to use gpio pps as input signal for agx orin/jp5.1.1

hi nv team,

目标:agx orin 上,使用GPS/PPS信号(组合导航定位系统),用于设备时间同步的调试。
使用的是自制的customer board,pps gpio 使用的是PQ.02,作为pps in;

打开了config 中的pps 内核定义,重新编译了内核Image;
dts 中,新增定义了pps node,重新编译出dtb 文件;
把image 和dtb 直接替换到了设备的/boot 路径下。

重启系统后,/dev 出现了pps0 设备名称;
CONFIG_PPS=m 生成的pps-gpio.ko 文件,insmod 安装后,出现了设备/dev/pps1。

但在调试,测试的过程中,当前发现了2个问题:
1、ppstest 无法连接,查看pps1
ppstest /dev/pps0 有时间数据,
“source 0 - assert 1732109027.928433272, sequence: 18822 - clear 0.000000000, sequence: 0”
但pps1 测试有误。
“time_pps_fetch() error -1 (Connection timed out)”

请问这里的pps1 异常,是个严重错误,还是可以忽略的?

2、gps 信息,可以通过串口查看到,但cgps/gpsmon 无法正常查看,显示是N/A。
gps 的NEMA 数据示例:
$GPGGA,125440.00,2232.54487378,N,11356.55564338,E,1,12,3.5,20.5724,M,-3.6876,M,*40

通过gpsd -b -n -D1 /dev/ttyTHS4 /dev/pps1 后,cgps/gpsmon 无法查看到有效的gps 信息。
此时,设备gpio PQ.02 已经连接了gps 的pps 信号,实际测量的pps 信号是周期200 ms 的矩形波。

查看到dmesg log 中,“pps pps1: PPS_FETCH” 
“pps pps1: timeout 3.000000000”。

check了sysfs 中的gpio 定义,PQ.02 是作为pps 特性使用的。
"gpio-450 (PQ.02               |pps                 ) in  lo IRQ ACTIVE LOW"

参考了forum 中的驱动源码修改,	null 替换为gpios 后,
data->gpio_pin = devm_gpiod_get(&pdev->dev,
	NULL,	/* request "gpios" */
	GPIOD_IN);
	
insmod 会报错"failed to request PPS GPIO",这是改动引起的。但lsmod 还是能查询到。
应该是有问题的。

由于以前没有使用过gps/pps,怎么check,解决以上的2个问题呢?
哪里有配置/使用错误吗,谢谢解答。

hello sam_yangli,

please see-also forum topics for the steps to use GPIO as PPS interface.
for instance,
Unable to achieve PPS with Jetpack 5.0.2 - #7 by mhtechdev,
HOW to Increase GNNS timing module on Xavier? - #9 by shgarg,

继续请教一下chrony 中的pps 用法。

在/etc/chrony/chrony.conf 文件末尾,增加了
refclock SOCK /run/chrony.ttyTHS4.sock refid GPS precision 1e-1 offset 0.9999
refclock SOCK /run/chrony.pps0.sock refid PPS precision 1e-7

chronyc 相关命令没有查询到pps 时钟生效,查询结果如图

该场景下,期望能够使能pps 时钟信息的。
但sources cmd 中,没有看到pps 的前缀*,tracking 中查询的是ntp 时间,没有看到PPS。

pps 信号是3.3V,T=200 ms;

怎么使用上pps 时钟同步呢?

hello sam_yangli,

please also test with pps utility, $ sudo apt install pps-tools
for instance, $ sudo ppstest /dev/pps0 to check whether you’re able to get one timer trigger for each pulse.

设备上,pps 驱动的测试情况是这样的:

hello sam_yangli,

may I know what’s your hardware connections,
here’re demonstration for running ppstest
for instance,
(1) $ sudo ppstest /dev/pps0
it should show timer triggers for each second the kernel timer is going.
(2) $ sudo ppstest /dev/pps1
it will show timer triggers for each pulse on the GPIO-IN pin.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.