Packages
nbpr_chrony
4.8.0
NTP client and server (`chrony`) that can discipline the clock from a local GPS reference, packaged for Nerves
Current section
Files
Jump to
Current section
Files
nbpr_chrony
README.md
README.md
# nbpr_chrony
> NTP client and server (`chrony`) that can discipline the clock from a local GPS reference.
[`chrony`](https://chrony-project.org/) packaged for Nerves. Tracks the upstream Buildroot `chrony` package — this release wraps **4.8**.
Licence: GPL-2.0-only.
## This replaces `nerves_time`
Two daemons stepping the same system clock fight each other.
`nerves_time` ships in most Nerves projects by default (via
`nerves_pack`), so reach for this package only when you're deliberately
swapping it out — and remove `:nerves_time` from your deps when you do.
The usual reason to swap is a local reference clock: chrony can
discipline the system clock from GPS to microseconds, which SNTP over a
network can't approach.
## Usage
Add this package to your Nerves project's `mix.exs`:
{:nbpr_chrony, "~> 4.0"}
Run `mix deps.get`, then `mix firmware`. The full consumer flow —
including the `firmware:` alias that pulls binaries ahead of the
firmware build, and supervision-tree wiring for daemon-bearing
packages — lives in the [NBPR Getting Started
guide](https://nbpr.hexdocs.pm/getting-started.html). The fastest
path to a working setup is `mix igniter.install nbpr`.
Ship a config file via `rootfs_overlay/etc/chrony.conf`, then add the
daemon to your own supervision tree:
children = [
{NBPR.Chrony.Chronyd, config_file: "/etc/chrony.conf"}
]
See `NBPR.Chrony.Chronyd`'s `@moduledoc` for the full runtime options
schema.
## Taking time from gpsd
`:nbpr_gpsd` writes its time samples into two SHM segments, which chrony
reads as reference clocks:
refclock SHM 0 refid GPS precision 1e-1 offset 0.9999 delay 0.2
refclock SHM 1 refid PPS precision 1e-7
SHM 0 is the NMEA sentence time — only good to a few tens of milliseconds,
since it's timestamped whenever the sentence finished arriving. The `offset`
compensates for that latency and is specific to your receiver and baud rate;
`0.9999` is upstream's placeholder, deliberately too large to leave in
production. Measure yours against a known-good source.
SHM 1 is the PPS edge, and where the microseconds come from. The explicit
`precision` matters — chronyd doesn't read it out of the SHM structure, so
without it the PPS samples get weighted no better than the NMEA ones. It
needs gpsd built with `pps: true`, a `CONFIG_PPS` kernel, and a wired PPS
line.
Run gpsd with `nowait: true` (the default) or the samples stop whenever no
client is connected.
## Dependencies
Buildroot's chrony `select`s libcap unconditionally, so `chronyd` always
links `libcap.so.2` — which no stock Nerves system provides. That's what
`:nbpr_libcap` is for, and it comes in automatically as a dependency.
`chronyd` also links `libgnutls.so.30` and `libnettle.so.8` on systems that
carry them, which is what gets you NTS (authenticated NTP). Those are
conditional in Buildroot, so chrony links them only where the base system
already provides them and they always resolve — but it does mean NTS support
is inherited from the system rather than chosen here. The Raspberry Pi
systems have both; `bbb`, `trellis`, `x86_64` and `qemu_aarch64` don't.
Source: <https://github.com/jimsynz/nbpr>.