Search code examples
embedded-linuxclocklinaro

Tinkerboard with RTC board does not update the system time


I'm working on a ASUS TinkerBoard, OS Linaro 9.5 - Kernel 4.4.132

I added a little RTC board based on DS3231 chip.
The system creates the device /dev/rtc1 added to /dev/rtc0 and /dev/rtc (link to /dev/rtc0).
I'm able to talk with the RTC chip via i2cdetect and hwclock commands but I have a strange behavior.

This is my tests - of course I'm disconnected from the network to avoid the ntp sync:

WITHOUT RTC: at every power up the board/OS resets the date and time from Nov 03 2016 00:00

WITH RTC:

  • synced the date/time by Internet connection
  • forced the RTC value set by hwclock -f /dev/rtc1 --systohc
  • checked the value by 'hwclock -f /dev/rtc1 --get'
  • disconnected from the network and powered down the board - let's say at 18:00
  • powered up the board at 18:15
  • when the desktop is ready I see the system time is set to 18:00 (?)
  • if I read the RTC by hwclock -f /dev/rtc1 --get and I have 18:15
  • the data is correctly set to today (!)

It seems the system date is restored, the system time is freezed at the power down time, the RTC time is correct but it is not restored to the system time.

Any idea?


Solution

  • You say that /dev/rtc is a link to /dev/rtc0, this means that your kernel is configured with CONFIG_RTC_HCTOSYS_DEVICE set to rtc0. You can either set it to rtc1 or update your device tree aliases so that the DS3231 becomes rtc0.

    The other solution would be to stop relying on the kernel hctosys and use hwclock -f /dev/rtc1 --hctosys in a startup script.