Automatical handling of /sys/class/rtc/rtcN/offset
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
Alexandre Belloni
maintainerHi,
Quoted 12 lines · Igor Plyatov
I have found that my RTC (M41T00) is capable to make precise compensation of offset in the Control register.
Its driver,
rtc-ds1307.chas support for such offset compensation and provide the/sys/class/rtc/rtc0/offsetfile.Compensation tested and operate as expected, when I manually read/write offset value (in PPB) from/into the
/sys/class/rtc/rtc0/offsetfile.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?
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Dear Alexandre,
Quoted 12 lines
Hi,
Quoted 9 lines · Igor Plyatov
I have found that my RTC (M41T00) is capable to make precise compensation of offset in the Control register.
Its driver,
rtc-ds1307.chas support for such offset compensation and provide the/sys/class/rtc/rtc0/offsetfile.Compensation tested and operate as expected, when I manually read/write offset value (in PPB) from/into the
/sys/class/rtc/rtc0/offsetfile.
Quoted 8 lines
Quoted 3 lines
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