[ntp:questions] NTP with GPS and RTC

Harlan Stenn stenn at ntp.org
Thu Apr 25 19:44:22 UTC 2013

First and foremost - there are people on this list who know a *whole*
lot more than I do about RTC clocks.  The following sounds good to me,
and I may be wrong about some significant items.

Biebaut Sven writes:
> Hello,
> I found confirmation that the kernel updates the RTC every 11 minutes
> when synchronised with an external source. This leaves me with using
> my RTC as a reference clock in ntpd.

That's probably not the way to go, using external time sources to
validate and discipline your RTC and also using your RTC as a time

And I have no idea if the kernel takes proper care to set the RTC so the
transition from one second to the next occurs at the right moment.

The purpose of setting the RTC in the kernel may only be to get the RTC
to within a second of correct time.

> I found references on the web that is can be achieved with reference
> driver 43. When I configure ntpd like this, it returns with something
> like "no reference ids found" .  In the log file /var/log/ntp I can
> find : refclock_newpeer: clock type 43 invalid
> I think this means that there are no valid devices found for the
> driver to use ?

In ntp-dev, driver 43 is the RIPENCC refclock, and that is probably not
the one you should be using.  Which version of NTP are you using?

> My RTC is a DS3231 I2C based RTC, with a custom driver. Do I need a
> special clock driver for this or can I parametrize one of the other
> reference clock drivers ? Or does my custom driver need extra calls to
> allow ntp to read its values ?

The specs on that look way better than the average RTC/crystal :)

I gather it returns time to the nearest second - that will not be very
useful for OS or NTP timestamps.  If you have to set the time to the
nearest second you will also need to take special care to make sure that
you set the clock at the "correct" moment of the second in order to get
the "seconds" transition to happen ar the right time.

As I said above, I do not know if the OS is that careful about setting
the time of the RTC every 11 minutes.

> I cannot find the interface used by ntpd reference clock drivers
> towards the device clock drivers on the other hand ( which calls,
> device node, ..)
> Any help is greatly appreciated,

It may be that your best bet is to use the DS3231 as your system clock
and let ntpd do its job that way, using the DS3231 as a stable
oscillator for the system (OS) clock.  The RTC in the DS3231 could be
used to set the system time at boot, and it wit a little bit of careful
coding you could set the system time closely enough (<128 ms) that when
ntpd started it would slew any time change.  This assumes that the time
on the DS3231 was set so the seconds "advance" at the correct moment.
Harlan Stenn <stenn at ntp.org>
http://networktimefoundation.org - be a member!

More information about the questions mailing list