Cannot set hwclock

Hi,

On my Turris Omnia 5.1.1, I cannot set my hardware clock which is several days late. Here is what I do:

root@turris:~# date
Fri Sep 25 16:25:07 CEST 2020
root@turris:~# hwclock -r
Fri Sep 18 14:48:26 2020  0.000000 seconds
root@turris:~# hwclock -w
root@turris:~# hwclock -r
Fri Sep 18 14:48:26 2020  0.000000 seconds
root@turris:~# date
Fri Sep 25 16:25:24 CEST 2020

The -w option has no effect at all. I would expect it to sync the hwclock to the current system time.

From busybox perspective, all went well when writing:

open("/dev/rtc0", O_WRONLY|O_LARGEFILE) = 3
clock_gettime(CLOCK_REALTIME, {tv_sec=1601045609, tv_nsec=617766075}) = 0
open("/etc/TZ", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
ioctl(3, RTC_SET_TIME, {tm_sec=29, tm_min=53, tm_hour=16, tm_mday=25, tm_mon=8, tm_year=120, ...}) = 0
exit_group(0)                           = ?
+++ exited with 0 +++

With util-linux hwclock, I can’t even access /dev/rtc0

root@turris:~# /usr/sbin/hwclock -r -v
hwclock from util-linux 2.34
System Time: 1601045759.232281
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
...synchronization failed

Hello @X-dark,

I am going through your thread and I think this could be caused that your RTC battery, which is located on the router could be dead. Would you please try to check it and swap with a new one?

I installed hwclock from util-linux, which didn’t replace busybox one. And because of that you need to use as you pointed out /usr/sbin/hwclock. This should be fixed.

Here is my output:

root@omnia:~# /usr/sbin/hwclock -r -v
hwclock from util-linux 2.34
System Time: 1602880392.581673
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1602880343 seconds after 1969
Last calibration done at 1602880343 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: 2020/10/16 20:33:13
Hw clock time : 2020/10/16 20:33:13 = 1602880393 seconds since 1969
Time since last adjustment is 50 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2020-10-16 22:33:12.580224+02:00

Nitpick: While using strace, you should specify which tool with parameteres you tried.

Thanks, I will try that. I did suspect the battery but I was thinking it would give me different behavior. It’s worth a try anyway.

Indeed. I said it was the busybox tool just above the output, and as it is doing a RTC_SET_TIME operation, I assume it was a -w I tried. Sorry for not having been more explicit.