cubieplayer / Cubian

Debian for Cubieboard
http://cubian.org
271 stars 49 forks source link

Both HW and SW date/time are reset on each boot; also hwclock problem #449

Open alex3kov opened 9 years ago

alex3kov commented 9 years ago

I'm on Cubieboard1. On each boot, I get the same date of 2010:

# date
Fri Jan  1 03:15:12 MSK 2010

I tried setting the date/time like this:

# date --set 2015-02-18 
# date --set 11:16:00
# hwclock -w
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: No such file or directory
# hwclock --test --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1424247402 seconds after 1969
Last calibration done at 1424247402 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: 2015/02/18 08:16:47
Hw clock time : 2015/02/18 08:16:47 = 1424247407 seconds since 1969
Wed 18 Feb 2015 11:16:47 AM MSK  -1.146759 seconds

ntp is up and running. I'm not sure if Cubieboard1 has an actual HW clock. Is there a way to make date/time stick between reboots?

EtlamGit commented 9 years ago

As far as I know, only Cubieboard 3 (Cubietruck) has an RTC. There is a script /usr/sbin/cubian-ntpdate (if I remember right) that should sync your time to an NTP server. But you need Internet for that.

alex3kov commented 9 years ago

Thanks for feedback @EtlamGit cubian-ntpdate does nothing (cubie is connected to Internet):

root@Cubian:~# cubian-ntpdate
root@Cubian:~# echo $?
0
root@Cubian:~# date
Fri Jan  1 05:01:58 MSK 2010

Regarding RTC: there is a /dev/rtc0 file on the system, is this some sort of emulation? Strange thing is, hwclock command works intermittently - sometimes hwclock -w sets HW clock to software date/time, and sometimes it reports

root@Cubian:~# hwclock -w
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: No such file or directory
root@Cubian:~# ls -l /dev/rtc0 
crw------- 1 root root 254, 0 Jan  1  2010 /dev/rtc0

I think it should be at least explained in Cubian documentation.

Nightbane112 commented 9 years ago

In order to allow the time and date to recalibrate on every boot, install "ntpd" on to your system. Seems like ntpdate is depreciated as of September 2012.

http://askubuntu.com/questions/297560/ntpd-vs-ntpdate-pros-and-cons http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate

Ever since I replaced ntpdate with ntpd, my system always recalibrate to the correct time on boot.

EtlamGit commented 9 years ago

There is a bug (deadlock) in cubian-ntpdate when NTPD is installed: See last commit of: https://github.com/mmplayer/fsupdate/pull/1

So you have to change that script (or disable it completely) when NTPD is installed.

By the way: I would appreciate, if someone could help to improve that "NTPD is installed" check in the mentioned pull request.

citroboy commented 9 years ago

On cubieboard 1 and 2 you can install fake-hwclock to approximate proper timekeeping.

On cubietruck, which has a real battery-backed hardware clock, you will still see this problem when you boot up without internet access. This is because the hwclock program (which is installed) is not configured to copy the hw clock time to the system time on boot (except in single user mode). You can fix this with the command sudo update-rc.d hwclock 01 2 which will run hwclock soon after booting into normal mode.