imx6ull RTC adjustment

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx6ull RTC adjustment

Jump to solution
1,805 Views
janne_terho
Contributor III

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

https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/rtc/rtc-pcf85063.c?h=imx_5.4.3_2.0...

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

0 Kudos
1 Solution
1,753 Views
janne_terho
Contributor III

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

 

View solution in original post

0 Kudos
4 Replies
1,779 Views
janne_terho
Contributor III

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.

https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/rtc/rtc-pcf85063.c?h=imx_5.4.3_2.0...

How can I call this funcfion?


Best regards,
Janne

0 Kudos
1,768 Views
igorpadykov
NXP Employee
NXP Employee

Hi Janne

 

linux provides standard ways for handling rtc described in documentation

https://source.codeaurora.org/external/imx/linux-imx/tree/Documentation/admin-guide/rtc.rst?h=imx_5....

If one wishes to access driver directly it is necessary to write custom application.

 

Best regards
igor

0 Kudos
1,754 Views
janne_terho
Contributor III

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

 

0 Kudos
1,792 Views
igorpadykov
NXP Employee
NXP Employee
0 Kudos