I have a Cubox i4-pro which runs arch linux very nicely. However, after rebooting the cubox, the value of the date/time from the date command and the hwclock command is not current but set to a default time in 1970. I am running chrony as a systemd service enabled at boot, which appears to update nicely but the system and hardware clocks don't seem to synchronise with the value from chrony so what I do after rebooting is to set the clock manually using (as root):
$this->bbcode_second_pass_code('', '
date -s "Nov 30 2014 21:21:00"
hwclock -systohc
')
(with the relevant current time), and then checking chronyc later I see something like:
$this->bbcode_second_pass_code('', '
# chronyc tracking
Reference ID : 195.242.98.57 (mail.no-sense.net)
Stratum : 3
Ref time (UTC) : Wed Dec 3 21:59:14 2014
System time : 0.001257644 seconds slow of NTP time
Last offset : -0.001719983 seconds
RMS offset : 0.001624198 seconds
Frequency : 54.316 ppm slow
Residual freq : -0.082 ppm
Skew : 2.089 ppm
Root delay : 0.043619 seconds
Root dispersion : 0.021451 seconds
Update interval : 517.4 seconds
Leap status : Normal
')
which looks fine and then the clocks seem OK.
However I also noticed that the rtc has values:
$this->bbcode_second_pass_code('', '
# ls -l /dev/rtc*
lrwxrwxrwx 1 root root 4 Jan 1 1970 /dev/rtc -> rtc0
crw------- 1 root root 254, 0 Jan 1 1970 /dev/rtc0
crw------- 1 root root 254, 1 Jan 1 1970 /dev/rtc1
')
and testing the two clocks:
$this->bbcode_second_pass_code('', '
# hwclock -r -f /dev/rtc0 --debug
hwclock from util-linux 2.25.2
Using the /dev interface to the clock.
Last drift adjustment done at 1417641793 seconds after 1969
Last calibration done at 1417641793 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc0 does not have interrupt functions. Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2014/12/03 21:40:54
Hw clock time : 2014/12/03 21:40:54 = 1417642854 seconds since 1969
Wed Dec 3 21:40:54 2014 -0.606948 seconds
# hwclock -r -f /dev/rtc1 --debug
hwclock from util-linux 2.25.2
Using the /dev interface to the clock.
Last drift adjustment done at 1417641793 seconds after 1969
Last calibration done at 1417641793 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2014/12/03 21:41:07
Hw clock time : 2014/12/03 21:41:07 = 1417642867 seconds since 1969
Wed Dec 3 21:41:07 2014 -0.454050 seconds
')
So rtc0 seems to have a problem which is not present in rtc1, but I also see from a posting on the SolidRun forum:
There are two RTC inside CuBox-i
1. One connected to the SNVS rail (internal i.MX6) which is not battery backed and typically goes to /dev/rtc0
2. Second is NXP PFC8523 based and that one has battery backup (/dev/rtc1)
So the question I would love to answer is whether there is a way to make /dev/rtc1 be the link to /dev/rtc at boot, and whether this would then allow the rtc to have the backed up time from the battery sustained hardware clock rather than the default that is a date and time in 1970?
If I manually remove the link to rtc0 and change it to rtc1 then it goes back to rtc0 after rebooting, say when pacman updates to a new kernel.
Any help with this would be appreciated.