AnsweredAssumed Answered

mxc_timer1, rtc and clock accuracy on 6sololite

Question asked by jayakumar2 on Jan 27, 2017
Latest reply on Jan 30, 2017 by igorpadykov

Hi,

I'm looking into how accurate the time source is on a 6sololite evk based board. The board uses the 6sl internal rtc. The kernel shows mxc_timer1 as its primary clock source.

 

root@imx6slevk:~# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
mxc_timer1
root@imx6slevk:~# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
mxc_timer1

 

root@imx6slevk:~# dmesg|egrep -i rtc
snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc0
snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:00 UTC (0)

 

 

Here's a test I did:

ntpdate -b pool.ntp.org;

ntpdate -d pool.ntp.org 2>/dev/null| egrep offset | tail -1 ;
date;
hwclock -r ;
sleep 60 ;
hwclock -r ;
date ;
 ntpdate -d pool.ntp.org 2>/dev/null| egrep offset | tail -1 ;

 

The result shows:
27 Jan 09:41:24 ntpdate[645]: adjust time server 188.166.12.29 offset
0.003408 sec
Fri Jan 27 09:41:24 UTC 2017
Fri Jan 27 09:41:26 2017  0.000000 seconds
Fri Jan 27 09:42:41 2017  0.000000 seconds
Fri Jan 27 09:42:24 UTC 2017
27 Jan 09:42:33 ntpdate[653]: adjust time server 129.250.35.250 offset
0.003952 sec

 

That shows:
- system told to wait 60s, but actual time waited according to ntp
source (includes latency to reach ntp source so few seconds excess is
understandable) =  09:42:33 - 09:41:24 = 69 seconds
- amount of drift in 69 real seconds is 0.003952 - 0.003408 = 0.000544
= 544 microseconds.
That implies the system clock is fast by 544 microseconds / minute so
it would gain 0.68 s per day (0.000544 * 24 * 60 * 60/69).
- the RTC shows that it increased by 75s in that 60s.

 

That tells me that the 6sl internal RTC is drifting quite a lot, 15s/min which would lead to 6 hours / day if the system was off.

 

My questions are:

a) is that amount of RTC drift normal? Or is it indicating that there is some issue with the crystal used for the RTC?

 

b) what is the minimum current needed for the RTC? ie: if the system is fully off, and the licell is powering the RTC at 3.3V, what is the current consumption by the RTC? The closest thing I see to that is the "SNVS only" current which seems to be stated as 41uA. I think SNVS includes some security circuitry in addition to the RTC.

 

c) how to turn automatic correction of rtc time? I thought normally, the kernel will automatically correct RTC drift every 11 mins. But that doesn't seem to happen on my setup as I see the drift between system time and RTC time keep increasing:

root@imx6slevk:/mnt/mmc# while (/bin/true); do hwclock -r; date; sleep 60 ; done
Fri Jan 27 10:09:31 2017 0.000000 seconds
Fri Jan 27 10:04:52 UTC 2017
Fri Jan 27 10:10:46 2017 0.000000 seconds
Fri Jan 27 10:05:53 UTC 2017
Fri Jan 27 10:12:00 2017 0.000000 seconds
Fri Jan 27 10:06:53 UTC 2017
Fri Jan 27 10:13:15 2017 0.000000 seconds
Fri Jan 27 10:07:53 UTC 2017
Fri Jan 27 10:14:30 2017 0.000000 seconds
Fri Jan 27 10:08:53 UTC 2017
Fri Jan 27 10:15:45 2017 0.000000 seconds
Fri Jan 27 10:09:53 UTC 2017
Fri Jan 27 10:17:00 2017 0.000000 seconds
Fri Jan 27 10:10:53 UTC 2017
Fri Jan 27 10:18:15 2017 0.000000 seconds
Fri Jan 27 10:11:53 UTC 2017
Fri Jan 27 10:19:30 2017 0.000000 seconds
Fri Jan 27 10:12:53 UTC 2017
Fri Jan 27 10:20:45 2017 0.000000 seconds
Fri Jan 27 10:13:53 UTC 2017
Fri Jan 27 10:22:00 2017 0.000000 seconds
Fri Jan 27 10:14:53 UTC 2017
Fri Jan 27 10:23:14 2017 0.000000 seconds
Fri Jan 27 10:15:53 UTC 2017
Fri Jan 27 10:24:29 2017 0.000000 seconds
Fri Jan 27 10:16:53 UTC 2017

Fri Jan 27 10:25:44 2017 0.000000 seconds
Fri Jan 27 10:17:53 UTC 2017
Fri Jan 27 10:26:59 2017 0.000000 seconds
Fri Jan 27 10:18:53 UTC 2017

 

Thanks!

Outcomes