Got it.

Try current git :

-       tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST;// |
ADJ_MAXERROR | ADJ_ESTERROR;
+       tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST |
ADJ_MAXERROR | ADJ_ESTERROR;

        tmx.offset = (long)(offset * 1000000); /* usec */
        if (SLEW_THRESHOLD < STEP_THRESHOLD) {
@@ -1738,16 +1738,23 @@ update_local_clock(peer_t *p)
        if (tmx.constant < 0)
                tmx.constant = 0;

-       //tmx.esterror = (uint32_t)(clock_jitter * 1e6);
-       //tmx.maxerror = (uint32_t)((sys_rootdelay / 2 + sys_rootdisp) * 1e6);
+       /* For ADJ_MAXERROR and ADJ_ESTERROR: */
+       /* kernel increments this by 500us each second, sets
STA_UNSYNC if exceeds 16 seconds: */
+       tmx.maxerror = (uint32_t)((G.rootdelay / 2 + G.rootdisp) * 1000000.0);
+       /* (without ADJ_MAXERROR, time adjustment still works, but kernel uses
+        * conservative maxerror value and quickly sets STA_UNSYNC)
+        */
+       /* esterror is not used by kernel, presumably may be used by
other programs reading adjtimex result: */
+       tmx.esterror = (uint32_t)(G.discipline_jitter * 1000000.0);
+

On Wed, Oct 8, 2025 at 5:41 PM Grant Edwards <[email protected]> wrote:
>
> On 2025-10-08, Denys Vlasenko <[email protected]> wrote:
> > On Fri, Sep 19, 2025 at 5:01 PM Grant Edwards <[email protected]> 
> > wrote:
> >> [Busybox version is rather old (v1.31.0) and the kenel is 2.6.33.7]
> >>
> >> I'm using busybox ntpd and it appears to be working except for the
> >> fact that the return value from the adjtimex() kernel system call
> >> almost always returns TIME_ERROR and status bits of PLL UNSYNC [and
> >> sometimes FREQHOLD].
> >>
> >> Once avery 64 seconds, ntpd polls the server, and the adjtimex()
> >> return is TIME_OK for a fraction of a second with status bits of PLL
> >> [sometimes FREQHOLD]. After a fraction of a second it returns to
> >> return of TIME_ERROR with the UNSYNC status bit set until the next
> >> poll.
> >
> > "It" returns? Can you be more specific? *What* returns?
>
> I'm asking about the TIME_ERROR return from the library call to
> adjtimex().
>
> >> It looks like usually the FREQHOLD status bit comes on initially
> >> and then goes away after several minutes — but it sometimes comes
> >> back on later.
> >
> > FREQHOLD is used for several minutes after startup to avoid
> > introducing bogus frequency correction while time offset being
> > corrected.
>
> OK, I thought it was probably something like that.
>
> >> The UNSYNC bit is always set except for a fraction of second after
> >> each ntp poll.
> >
> > Describe how do you check UNSYNC bit.
>
> When you call adjtimex(struct timex *buf), it writes to the timex
> strucutre 'buf'.  To check the UNSYNC bit you look at (buf.status &
> STA_UNSYNC).
>
> No matter how long I wait after starting busybox ntpd, the STAT_UNSYNC
> bit is almost always set. It only reads as zero for a couple hundred
> milliseconds after ntpd does a poll.
>
> --
> Grant
>
> _______________________________________________
> busybox mailing list
> [email protected]
> https://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to