Re: [chrony-dev] [RFC] Transparent fallback from NTP reference clock to RTC

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


On Mon, Mar 31, 2025 at 05:38:11PM +0200, Ahmad Fatoum wrote:
> > I.e. use it only for stabilization of the system clock, not as a time
> > source. That would work even when it's synchronizing to NTP servers.
> > When NTP is not reachable, it would activate the local reference as
> > configured by the local directive. I guess something would be needed
> > for the case when it's started without NTP.
> 
> Do you have a suggestion how to go about it?

Try it with this patch:

--- a/refclock.c
+++ b/refclock.c
@@ -732,7 +732,13 @@
   SST_Stats stats = SRC_GetSourcestats(inst->source);
 
   if (SST_Samples(stats) < SST_GetMinSamples(stats)) {
+#if 0
     UTI_ZeroTimespec(ref);
+#else
+    LCL_ReadCookedTime(ref, NULL);
+    *freq = 0.0;
+    *offset = 0.0;
+#endif
     return;
   }
 
That should force the first adjustment to accumulate the "local"
refclock's frequency offset and track it closely until a time source
is selected. I suspect there could be numerical errors accumulating
over long periods of time, but insignificant when compared to a real
time source like RTC.

It could be a new option, if I can get a name for it.

> I also think that even if
> local works for us, we still need to address the synchronization of the
> RTC to system time when the system is NTP-synchronized.
> 
> Currently, chrony disallows rtc reference clock to co-exist with
> rtcsync, but maybe we should allow it and enable the rtcsync only when
> NTP is reachable and the RTC is local and not activated?

rtcsync cannot work. That's the kernel doing changes at random times
unknown to chronyd. I think it could work with rtcfile if it shared
the descriptor and timestamps with the refclock driver.

-- 
Miroslav Lichvar


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/