System Clock Date & Time Lost After reboot

I used “date -s “xx-xx-xx xx:xx:xx”” command to update system clock. However, it did not remember the updated date & time after board reboot. Same thing happened when using “hwclock -s” to set system clock to RTC clock. There was no internet connection on the board. Automatic synchronization was turned off by command " timedatectl set-ntp false". How are we supposed to permanently update system clock?

William

Did you already have a look at the following article on our developer website?

Yes, I have read through that article. My understanding is that system clock gets updated from hardware clock at boot time. Right? The system clock works fine when the module is inserted into the Colibri EvalBoard. When it is inserted into our own custom board, it’s not working properly. Below are commands issued on our customer board.

root@colibri-imx6:~# date
Wed Jun 28 09:19:20 UTC 2017
root@colibri-imx6:~# hwclock -r
Fri Dec 20 09:26:42 2013 0.000000 seconds
root@colibri-imx6:~# hwclock -r -f /dev/rtc0
Fri Dec 20 09:26:57 2013 0.000000 seconds
root@colibri-imx6:~# date -s "2014-12-19 15:11:40"
Fri Dec 19 15:11:40 UTC 2014
root@colibri-imx6:~# date
Fri Dec 19 15:11:43 UTC 2014
root@colibri-imx6:~# hwclock -w
root@colibri-imx6:~# hwclock -r
Fri Dec 19 15:12:11 2014 0.000000 seconds

Then the board was powered off. After around 5 minutes, it was powered on again.

root@colibri-imx6:~# date
Wed Jun 28 09:19:19 UTC 2017
root@colibri-imx6:~# hwclock -r
Fri Dec 19 15:17:30 2014 0.000000 seconds

The external RTC on custom board appears working just fine. But the system clock does not get updated.

Yes, I have read through that article. My understanding is that system clock gets updated from hardware clock at boot time. Right?

Yes, the Linux kernel usually does so from rtc0 which it logs during boot as follows:

root@colibri-imx6:~# dmesg | grep rtc
[    1.567008] rtc-ds1307 2-0068: rtc core: registered m41t0 as rtc0
[    1.575788] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc1
[    2.572771] rtc-ds1307 2-0068: setting system clock to 2017-06-30 20:34:10 UTC (1498854850)

The system clock works fine when the module is inserted into the Colibri EvalBoard. When it is inserted into our own custom board, it’s not working properly. Below are commands issued on our customer board.

That really indicates another difference in the overall systems.

The external RTC on custom board appears working just fine. But the system clock does not get updated.

Maybe it does get updated however the system later decides that this can not be a valid time (e.g. for monotonic reasons) or simply sets the time from a time server over the network.

Interesting would be the full boot log as well as the journal output indicating what it is doing exactly:

root@colibri-imx6:~# journalctl -b 0 | grep timesyncd
Jun 30 20:34:17 colibri-imx6 systemd-timesyncd[238]: Network configuration changed, trying to establish connection.
Jun 30 20:34:47 colibri-imx6 systemd-timesyncd[238]: Synchronized to time server 216.239.35.8:123 (time3.google.com).