Мы используем внешний RT C (PCF8563) для установки / считывания времени. Мы можем обнаружить RTC1. Также можно установить местное время на / dev / rtc1 с помощью утилиты hwclock . Но при чтении времени с помощью hwclock -r выдается следующая ошибка. выберите () для / dev / rtc1, чтобы дождаться истечения времени отсчета времени ... синхронизация не удалась Следующие шаги были выполнены для установки даты / времени.
To set time:
hwclock -f /dev/rtc1 --localtime --set --date "2/20/2020 10:26:00"
To read date/time :
# cat /sys/class/rtc/rtc1/date ---- displays correct date
2020-02-24
# cat /sys/class/rtc/rtc1/time ----- displays correct time
10:02:28
Using hwclock utility: (**Displays incorrect date/time**)
# hwclock --systohc --localtime -f /dev/rtc1 --debug
hwclock from util-linux 2.28.1
Using the /dev interface to the clock.
Last drift adjustment done at 761 seconds after 1969
Last calibration done at 761 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
**select() to /dev/rtc1 to wait for clock tick timed out...synchronization failed**
Time since last adjustment is -761 seconds
Calculated Hardware Clock drift is 0.000000 seconds
missed it - 783.635658 is too far past 783.500000 (0.135658 > 0.001000)
784.500004 is close enough to 784.500000 (0.000004 < 0.002000)
Set RTC to 784 (783 + 1; refsystime = 783.000000)
Setting Hardware Clock to 05:43:04 = 784 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
Not adjusting drift factor because the --update-drift option was not used.
# hwclock -r --debug
hwclock from util-linux 2.28.1
Using the /dev interface to the clock.
Last drift adjustment done at 1357 seconds after 1969
Last calibration done at 1357 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 1970/01/01 00:34:14
Hw clock time : 1970/01/01 00:34:14 = -17746 seconds since 1969
Time since last adjustment is -19103 seconds
Calculated Hardware Clock drift is 0.000000 seconds
1970-01-01 00:34:12.070022+5:30