linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Automatical handling of /sys/class/rtc/rtcN/offset
@ 2020-05-26 18:57 Igor Plyatov
  2020-05-27 23:06 ` Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Igor Plyatov @ 2020-05-26 18:57 UTC (permalink / raw)
  To: linux-rtc

Dear all,

I have found that my RTC  (M41T00) is capable to make precise 
compensation of offset in the Control register.

Its driver, rtc-ds1307.c has support for such offset compensation and 
provide the /sys/class/rtc/rtc0/offset file.

Compensation tested and operate as expected, when I manually read/write 
offset value (in PPB) from/into the /sys/class/rtc/rtc0/offset file.

Does handling of such RTC offset already automatized somehow instead of 
doing this manually?

I ask for community, because do not want to invent another one wheel if 
there are something already implemented for such purpose.

Best wishes.
--
Igor Plyatov

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Automatical handling of /sys/class/rtc/rtcN/offset
  2020-05-26 18:57 Automatical handling of /sys/class/rtc/rtcN/offset Igor Plyatov
@ 2020-05-27 23:06 ` Alexandre Belloni
  2020-05-28  5:56   ` Igor Plyatov
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2020-05-27 23:06 UTC (permalink / raw)
  To: Igor Plyatov; +Cc: linux-rtc

Hi,

On 26/05/2020 21:57:50+0300, Igor Plyatov wrote:
> I have found that my RTC  (M41T00) is capable to make precise compensation
> of offset in the Control register.
> 
> Its driver, rtc-ds1307.c has support for such offset compensation and
> provide the /sys/class/rtc/rtc0/offset file.
> 
> Compensation tested and operate as expected, when I manually read/write
> offset value (in PPB) from/into the /sys/class/rtc/rtc0/offset file.
> 
> Does handling of such RTC offset already automatized somehow instead of
> doing this manually?
> 

No, my plan was to add support for that in chrony. chrony is already
able to calculate the correct offset but it doesn't make use of it for
the moment.

What are you using to calculate the offset?

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Automatical handling of /sys/class/rtc/rtcN/offset
  2020-05-27 23:06 ` Alexandre Belloni
@ 2020-05-28  5:56   ` Igor Plyatov
  0 siblings, 0 replies; 3+ messages in thread
From: Igor Plyatov @ 2020-05-28  5:56 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-rtc

Dear Alexandre,

> Hi,
>
> On 26/05/2020 21:57:50+0300, Igor Plyatov wrote:
>> I have found that my RTC  (M41T00) is capable to make precise compensation
>> of offset in the Control register.
>>
>> Its driver, rtc-ds1307.c has support for such offset compensation and
>> provide the /sys/class/rtc/rtc0/offset file.
>>
>> Compensation tested and operate as expected, when I manually read/write
>> offset value (in PPB) from/into the /sys/class/rtc/rtc0/offset file.
>>
>> Does handling of such RTC offset already automatized somehow instead of
>> doing this manually?
>>
> No, my plan was to add support for that in chrony. chrony is already
> able to calculate the correct offset but it doesn't make use of it for
> the moment.
>
> What are you using to calculate the offset?

Currently I do not have production ready solution for RTC offset 
compensation.

For test purpose I do following:

* synchronize OS time to NTP - ntpd -q -n;

* copy OS time to RTC - hwclock --systohc;

* wait some period of time (24 hours or more) to reach noticeable RTC 
offset;

* copy RTC time to OS - hwclock --hctosys;

* synchronize OS time to NTP - ntpd -q -n.

Last step show me RTC offset, which used below in calculation of RTC 
drift, in ppb.

RTC_drift = 1000000000 * RTC_offset / Time_period.

For example, RTC_drift = 1000000000 * (-5.0676 s) / (24*60*60) = -58653 ppb.

Apply negative RTC_drift to Control register of RTC by command

echo "58653" > /sys/class/rtc/rtc0/offset.

Best wishes.

--

Igor Plyatov


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-28  5:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 18:57 Automatical handling of /sys/class/rtc/rtcN/offset Igor Plyatov
2020-05-27 23:06 ` Alexandre Belloni
2020-05-28  5:56   ` Igor Plyatov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).