Skip to content

system/gnsspps: Add GNSS PPS clock discipline application. - #4050

Open
acassis wants to merge 1 commit into
apache:masterfrom
acassis:gnsspps
Open

acassis wants to merge 1 commit into
apache:masterfrom
acassis:gnsspps

Conversation

@acassis

@acassis acassis commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

gnsspps synchronizes a NuttX board to GNSS time with the PPS output of a GNSS receiver, so that boards with their own receiver share the same time scale without a network.

It reads the PPS time stamps as external time stamp (EXTTS) events from a PTP clock (/dev/ptpX, for example CONFIG_PTP_PPS) and steers the clock with clock_adjtime():

  • Acquire: the frequency error is measured from two pulses, then the phase is removed with one step.
  • Locked: a PI servo (Kp 0.7, Ki 0.3 by default, as linuxptp) runs on every pulse, with outlier rejection and re-acquisition.
  • Holdover: the last frequency is kept when the PPS is lost.
  • The whole seconds come from the NMEA RMC or ZDA sentences of the receiver, confirmed by two sentences before a step.
  • Optionally (-r) CLOCK_REALTIME follows the PTP clock.

The RMS and maximum phase error and the frequency are printed every 16 pulses.

Impact

Users could use a low cost GNSS with PPS to sync two or more boards.

Testing

  nsh> uname -a
  NuttX 0.0.0 b2fb8a7c Nov 13 2026 19:37:12 arm stm32f4discovery
  nsh> ls /dev
  /dev:
   console
   null
   ptp0
   ttyS0
   ttyS1
   zero
  nsh> gnsspps -s /dev/ttyS1 -n 100
  gnsspps: /dev/ptp0 channel 0, NMEA from /dev/ttyS1
  gnsspps: locked, offset -296857179 ns stepped, freq -71155 ppb
  gnsspps: stepping +27383908 s to NMEA time
  gnsspps: rms 183 ns max 474 ns freq -71033 ppb
  gnsspps: rms 190 ns max 461 ns freq -70690 ppb
  gnsspps: rms 81 ns max 153 ns freq -71205 ppb
  gnsspps: rms 200 ns max 508 ns freq -71048 ppb
  gnsspps: rms 186 ns max 459 ns freq -70798 ppb
  gnsspps: rms 80 ns max 115 ns freq -71256 ppb
  nsh>

Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
Comment thread system/gnsspps/gnsspps_main.c Resolved
gnsspps synchronizes a NuttX board to GNSS time with the PPS output of
a GNSS receiver, so that boards with their own receiver share the same
time scale without a network.

It reads the PPS time stamps as external time stamp (EXTTS) events
from a PTP clock (/dev/ptpX, for example CONFIG_PTP_PPS) and steers
the clock with clock_adjtime():

* Acquire: the frequency error is measured from two pulses, then the
  phase is removed with one step.
* Locked: a PI servo (Kp 0.7, Ki 0.3 by default, as linuxptp) runs on
  every pulse, with outlier rejection and re-acquisition.
* Holdover: the last frequency is kept when the PPS is lost.
* The whole seconds come from the NMEA RMC or ZDA sentences of the
  receiver, parsed with minmea (CONFIG_GNSSUTILS_MINMEA_LIB) and
  confirmed by two sentences before a step.
* Optionally (-r) CLOCK_REALTIME follows the PTP clock.

The RMS and maximum phase error and the frequency are printed every
16 pulses.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Alan Carvalho de Assis <acassis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants