How I can adjust RTC offset to NXP Pcf85063tp?
I have custom imx6ull board and it is built from buildroot.
Hwclock read and write functions works correct and NTP '11 minute mode' is written clock correctly.
Hwclock(8) man says that it can adjust with hwclock --adjustment function. But I cant find it at all. I can't find /etc/adjtime file also.
# hwclock --help
BusyBox v1.31.1 (2020-10-22 09:46:51 EEST) multi-call binary.
Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [--systz] [--localtime] [-u|--utc] [-f|--rtc FILE]
Query and set hardware clock (RTC)
-r Show hardware clock time
-s Set system time from hardware clock
-w Set hardware clock from system time
--systz Set in-kernel timezone, correct system time
if hardware clock is in local time
-u Assume hardware clock is kept in UTC
--localtime Assume hardware clock is kept in local time
-f FILE Use specified device (e.g. /dev/rtc2)
I added printk debug to driver code
and I can see cf85063_read_offset debug, but I have no idea how to set offset.
# cat /sys/class/rtc/rtc0/offset
[ 940.317834] DEBUG: pcf85063_read_offset
0
Is there something which block to adjustment manually, or do I need add more packages to buildroot, kernel or busybox?
-Janne
Solved! Go to Solution.
Hi Igor
I found way to write PCF85063TP offset register. For 1ppm drift just use
echo 4340 > /sys/class/rtc/rtc0/offset
I didn't try it before, because I read, that those are read only attributes.
Best regards,
Janne
Hi Igor,
I got hwclock adjtime-file to work well after add BR2_PACKAGE_UTIL_LINUX_HWCLOCK [=y] package to buildroot and it's much easier to control drift when disable RTC_SYSTOHC [=n] from kernel.
I think that better way is to adjust offset value straight to rtc chip. Our devices can be installed to places where isn't network at all, so the better way is to adjust drift in factory. I think that it's easier to control kernel update also, if adjust has done to rtc chip.
Manual says that there can be adjust offset in chapter 8.2.3 "Register Offset".
https://www.nxp.com/docs/en/data-sheet/PCF85063TP.pdf
and there is pcf85063_set_offset()-function in driver where offset can be set.
How can I call this funcfion?
Best regards,
Janne
Hi Janne
linux provides standard ways for handling rtc described in documentation
If one wishes to access driver directly it is necessary to write custom application.
Best regards
igor
Hi Igor
I found way to write PCF85063TP offset register. For 1ppm drift just use
echo 4340 > /sys/class/rtc/rtc0/offset
I didn't try it before, because I read, that those are read only attributes.
Best regards,
Janne
Hi janne_terho
for external rtc usage one can look at examples on:
https://variwiki.com/index.php?title=IMX_RTC
https://github.com/varigit/linux-imx/blob/imx_4.19.35_1.1.0_var01/arch/arm/boot/dts/imx6q-var-dt6cus...
Best regards
igor