External RTC sync to system

Hi, our custom board used a external RTC with Xavier NX module. But after I set time into it and restart, the system seems not sync time from this rtc.
I check this rtc can hold time and I can sync time to system by command. Information is showed below

uihadmin@nvidia:~$ sudo dmesg | grep rtc
[sudo] password for uihadmin:
[    0.471800] camchar: rtcpu character device driver loaded
[    2.637200] tegra_rtc c2a0000.rtc: registered as rtc1
[    2.639747] tegra_rtc c2a0000.rtc: Tegra internal Real Time Clock
[    2.810455] vdd-rtc: supplied by regulator-dummy
[    2.992662] max77686-rtc max77620-rtc: registered as rtc0
[    3.828808] tegra186-cam-rtcpu bc00000.rtcpu: Adding to iommu group 5
[    3.829959] tegra186-cam-rtcpu bc00000.rtcpu: Trace buffer configured at IOVA=0xbff00000
[    3.914896] tegra-ivc-bus bc00000.rtcpu:ivc-bus: region 0: iova=0xbfec0000-0xbfee01ff size=131584
[    3.915440] tegra-ivc-bus bc00000.rtcpu:ivc-bus:echo@0: echo: ver=0 grp=1 RX[16x64]=0x1000-0x1480 TX[16x64]=0x1480-0x1900
[    3.916412] tegra-ivc-bus bc00000.rtcpu:ivc-bus:dbg@1: dbg: ver=0 grp=1 RX[1x448]=0x1900-0x1b40 TX[1x448]=0x1b40-0x1d80
[    3.917093] tegra-ivc-bus bc00000.rtcpu:ivc-bus:dbg@2: dbg: ver=0 grp=1 RX[1x8192]=0x1d80-0x3e00 TX[1x8192]=0x3e00-0x5e80
[    3.918880] tegra-ivc-bus bc00000.rtcpu:ivc-bus:ivccontrol@3: ivccontrol: ver=0 grp=1 RX[64x320]=0x5e80-0xaf00 TX[64x320]=0xaf00-0xff80
[    3.919562] tegra-ivc-bus bc00000.rtcpu:ivc-bus:ivccapture@4: ivccapture: ver=0 grp=1 RX[512x64]=0xff80-0x18000 TX[512x64]=0x18000-0x20080
[    3.920087] tegra-ivc-bus bc00000.rtcpu:ivc-bus:diag@5: diag: ver=0 grp=1 RX[1x64]=0x20080-0x20140 TX[1x64]=0x20140-0x20200
[    3.921694] tegra186-cam-rtcpu bc00000.rtcpu: using cam RTCPU IRQ (48)
[    3.921962] tegra186-cam-rtcpu bc00000.rtcpu: tegra_camrtc_mon_create is successful
[    3.923791] tegra186-cam-rtcpu bc00000.rtcpu: firmware version cpu=rce cmd=6 sha1=571b1d9f5b93980c19e16eaf250cfa6deac6f03e
[    5.875869] tegra-camrtc-capture-vi tegra-capture-vi: subdev 13e10000.host1x:nvcsi@15a00000- bound
[    5.884738] tegra-camrtc-capture-vi tegra-capture-vi: subdev 13e10000.host1x:nvcsi@15a00000- bound
[    6.300139] rtc-ds1307 1-0068: registered as rtc2
[    6.302209] rtc-ds1307 1-0068: setting system clock to 2024-05-30T01:31:44 UTC (1717032704)
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$ date
Sat 01 Jan 2000 09:22:41 AM CST
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$ ls -l /dev/rtc*
lrwxrwxrwx 1 root root      4 May 30  2024 /dev/rtc -> rtc2
crw------- 1 root root 250, 0 May 30  2024 /dev/rtc0
crw------- 1 root root 250, 1 May 30  2024 /dev/rtc1
crw------- 1 root root 250, 2 May 30  2024 /dev/rtc2
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$ sudo hwclock -r --rtc=/dev/rtc
2024-05-30 09:36:48.332959+08:00
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$ sudo hwclock
2000-01-01 09:24:55.686720+08:00
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$ sudo hwclock --hctosys --rtc /dev/rtc
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$
uihadmin@nvidia:~$ date
Thu 30 May 2024 09:38:05 AM CST
uihadmin@nvidia:~$

How to set to enable system can sync time from this rtc2 automaticlly?
Thanks!

Check below topic.

I don’t think this is same as my situation, I have alrealy modified kernel config like this

CONFIG_RTC_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc2"
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc2"

and my external rtc regist as rtc2 as dmesg show.
I can set time into it by hwclock -w and after poweroff for minutes and reboot I can see it hold time as well.
The question is system do not read time from it and only by sudo hwclock --hctosys --rtc /dev/rtc can it sync time from rtc2.
It seems system only read rtc0 even I change the kernel config.

Please see the information I give above, it shows that after I set time and save into rtc, the board restart after minutes power off shows.
rtc2 can hold time as well. but system do not read time from it by default

Thanks

Modify the /etc/init.d/hwclock.sh if didn’t help then try /etc/systemd/nvrtc-sync-boot.sh.

Thanks, I modified /etc/systemd/nvrtc-sync-boot.sh and fix this problem

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.