我正在尝试使用 chrony 将 PPS 与 GPSD 同步,但收到“#?”之前没有gps会是什么原因呢?我的chrony.conf
文件是
# Welcome to the chrony configuration file. See chrony.conf(5) for more
# information about usable directives.
# Include configuration files found in /etc/chrony/conf.d.
confdir /etc/chrony/conf.d
# Use Debian vendor zone.
#pool 2.debian.pool.ntp.org iburst
#refclock PPS /dev/pps1 lock NMEA trust prefer
refclock SHM 0 offset 0.395 delay 0.2 refid GPS trust
#refclock SOCK /run/chrony.ttyS4.sock
refclock SOCK /run/chrony.pps1.sock refid PPS precision 1e-7 trust prefer
# Use time sources from DHCP.
sourcedir /run/chrony-dhcp
# Use NTP sources found in /etc/chrony/sources.d.
sourcedir /etc/chrony/sources.d
# This directive specify the location of the file containing ID/key pairs for
# NTP authentication.
keyfile /etc/chrony/chrony.keys
# This directive specify the file into which chronyd will store the rate
# information.
driftfile /var/lib/chrony/chrony.drift
# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony
# Uncomment the following line to turn logging on.
#log tracking measurements statistics
# Log files location.
logdir /var/log/chrony
# Stop bad estimates upsetting machine clock.
maxupdateskew 100.0
# This directive enables kernel synchronisation (every 11 minutes) of the
# real-time clock. Note that it can’t be used along with the 'rtcfile' directive.
rtcsync
# Step the system clock instead of slewing it if the adjustment is larger than
# one second, but only in the first three clock updates.
makestep 1 3
# Get TAI-UTC offset and leap seconds from the system tz database.
# This directive must be commented out when using time sources serving
# leap-smeared time.
leapsectz right/UTC
最初是这样的
root@BeagleBone:~# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#- GPS 0 4 17 20 -223ms[ -223ms] +/- 103ms
#* PPS 0 4 17 18 +4406ns[-1926ns] +/- 905ns
但10到20秒后,它变成如下所示
root@BeagleBone:~# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#x GPS 0 4 377 12 -235ms[ -235ms] +/- 102ms
#x PPS 0 4 377 12 -31us[ -31us] +/- 1464ns
我正在使用以下版本-
Chrony 4.0
gpsd 3.22
任何帮助都会非常感激!
答案1
现在我正在使用debian-11.6-minimal-armhf-2022-12-20
从链接下载的
https://rcn-ee.com/rootfs/eewiki/minfs/
/etc/default/gpsd
现在我已经完成了路径上的gpsd配置
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttymxc3 /dev/pps2"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"
# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="false"
#New_Addition
GPSD_SOCKET="/var/run/gpsd.sock"
BAUDRATE="38400"
/bin/stty -F $(DEVICE) $(BAUDRATE)
/bin/setserial $(DEVICE) low_latency
启动文件如下所示
#!/bin/bash
echo "<----------------------- Startup File---------------------------->"
killall -9 gpsd chronyd
chronyd -f /etc/chrony/chrony.conf
sleep 2
gpsd -n /dev/ttymxc3
sleep 2
systemctl start gpsd
ethtool --set-eee eth0 eee off
ptp4l -H -f /usr/local/etc/ptp4l.conf &
#phc2sys -a -r -E ntpshm -m -M 0 &
#phc2sys -s eth0 -O -35
echo "<--------------------Out From Start File--------------------->"
exit 0
我已经创建了一个 PTP 配置文件/usr/local/etc/ptp4l.conf
[global]
# only syslog every 1024 seconds
summary_interval 10
# send to chronyd/ntpd using SHM 0
clock_servo ntpshm
ntpshm_segment 0
[eth0]
最后 chrony.conf 文件看起来像
#server 0.pool.ntp.org
#server 1.pool.ntp.org
#server 2.pool.ntp.org
#initstepslew 30 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
# SHM0 from gpsd is the NMEA data at 4800bps, so is not very accurate
refclock SHM 0 delay 0.8 refid NMEA trust prefer
# SHM1 from gpsd (if present) is from the kernel PPS_LDISC
# module. It includes PPS and will be accurate to a few ns
#refclock SHM 2 offset 0.0 delay 0.1 refid NMEA+
# SOCK protocol also includes PPS data and
# it also provides time within a few ns
refclock SOCK /var/run/chrony.pps2.sock delay 0.0 refid SOCK trust prefer
refclock SHM 2 refid PTP precision 1e-7 trust prefer
#refclock SHM 0 delay 0.9 refid GPS trust prefer
# PPS is from the /dev/pps0 device. Note that
# chronyd creates the /var/run/chrony.ttyS1.sock device, but
# gpsd creates the /dev/pps0 device
# openrc rules start gpsd /after/ chronyd, so /dev/pps0
# is not created until after chronyd is started
# If you want to use pps0, either edit the openrc rules
# or add this source after gpsd is started
#refclock PPS /dev/pps1 refid PPS trust prefer
# If you see something in ns... its good.
# 1 second =
# 1000 ms =
# 1000000 us =
# 1000000000 ns
rtcsync
logchange 0.5
local stratum 10
logdir /var/log/chrony
keyfile /etc/chrony/chrony.keys
commandkey 10
dumpdir /var/log/chrony
driftfile /var/log/chrony/chrony.drift
allow all
现在一切都很好。