Tinker Board Forum

Full Version: RTC pcf8563
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I wanted to know if the rtc module pcf8563 can be used with the Tinker Board? If yes what's the way to use it?

I was using the DS3231 module flawlessly, after setting its overlay. But I'm not sure there's the same for pcf8563.

I figured out how to build it and enable it on kernel by compiling it with light changes.

I followed instructions here "https://tinkerboarding.co.uk/wiki/index.php/DS3231" but adapted to pcf8563. However I still get bad time for a few times before having it synced with RTC.

After start up (real time 2019-04-17 14:17:52):
linaro@tinkerboard:~$ date
Fri Jan 18 09:50:33 CET 2013
linaro@tinkerboard:~$ sudo hwclock --rtc=/dev/rtc1 --get
2019-04-17 14:17:52.257590+0200
linaro@tinkerboard:~$ sudo hwclock --rtc=/dev/rtc0 --get
2013-01-18 09:50:40.326774+0100

Here what I see in dmesg :
[    2.793726] rk808-rtc rk808-rtc: rtc core: registered rk808-rtc as rtc0
[    8.542186] rk808-rtc rk808-rtc: setting system clock to 2013-01-18 08:50:17 UTC (1358499017)
[    9.543125] rtc-pcf8563 1-0051: chip found, driver version 0.4.4
[    9.554620] rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc1

/etc/default/hwclock :
# Defaults for the hwclock init script.  See hwclock(5) and hwclock(8).

# This is used to specify that the hardware clock incapable of storing
# years outside the range of 1994-1999.  Set to yes if the hardware is
# broken or no if working correctly.

# Set this to yes if it is possible to access the hardware clock,
# or no if it is not.

# Set this to any options you might need to give to hwclock, such
# as machine hardware clock type for Alphas.

# Set this to the hardware clock device you want to use, it should
# probably match the CONFIG_RTC_HCTOSYS_DEVICE kernel config option.

# Set the System Time from the Hardware Clock and set the kernel's timezone
# value to the local timezone when the kernel clock module is loaded.

#KERNEL=="rtc0", RUN+="/lib/udev/hwclock-set $root/$name"
KERNEL=="rtc1", RUN+="/lib/udev/hwclock-set $root/$name"

SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc"
#SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100"
SUBSYSTEM=="rtc", KERNEL=="rtc1", SYMLINK+="rtc", OPTIONS+="link_priority=-100"

#if [ -e /run/systemd/system ] ; then
#    exit 0

Is there a way to force sync with rtc1 instead of rtc0?
udev rules, look the onward text. You might rename the device.
I tried to replace /dev/rtc :
linaro@tinkerboard:~$ ls -l /dev/rtc*
lrwxrwxrwx 1 root root      4 Nov  3  2016 /dev/rtc -> rtc1
crw------- 1 root root 253, 0 Nov  3  2016 /dev/rtc0
crw------- 1 root root 253, 1 Nov  3  2016 /dev/rtc1

But same behaviour. For now I fixed it with create a service to synchronize time :

ExecStart=/sbin/hwclock --hctosys


It works like this for now. I will create a wiki later with code and stuff if someone else need it.
I also wanted to know this