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.
Hello,

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?


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

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):
Code:
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 :
Code:
[    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 :
Code:
# 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.
#BADYEAR=no

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

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

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

/lib/udev/rules.d/85-hwclock.rules
Code:
# 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"

/lib/udev/rules.d/50-udev-default.rules
Code:
[...]
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"
[...]

/lib/udev/hwclock-set
Code:
[...]
#if [ -e /run/systemd/system ] ; then
#    exit 0
#fi
[...]

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 :
Code:
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 :
Code:
[Unit]
Before=time-sync.target
Wants=time-sync.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock --hctosys

[Install]
WantedBy=time-sync.target

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