cdsteinkuehler / br2rauc

Buildroot + RAUC
Other
52 stars 18 forks source link

Raspberry Pi system clock is not synchronized #10

Closed Sourabh1107 closed 2 years ago

Sourabh1107 commented 2 years ago

Hello,

This is not the issue with rauc but my raspberry pi system clock is not in sync.

Its set to some static time and I want to show real time instead. I have selected BR2_PACKAGE_RTC_TOOLS=y, BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y and BR2_PACKAGE_NTP=y, BR2_PACKAGE_NTP_NTPDATE=y, BR2_PACKAGE_NTP_NTPTIME=y in menuconfig. But still it's same result.

The timedatectl shows:

Local time: Tue 2022-01-18 11:52:05 UTC Universal time: Tue 2022-01-18 11:52:05 UTC RTC time: n/a Time zone: Etc/UTC (UTC, +0000) System clock synchronized: no NTP service: active RTC in local TZ: no

The systemctl status systemd-timesyncd shows:

systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled;
     Active: active (running) since Tue 2022-01-18 11:35:47 UTC; 17min ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 194 (systemd-timesyn)
     Status: "Daemon is running"
      Tasks: 1 (limit: 1009)
        CPU: 396ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─194 /usr/lib/systemd/systemd-timesyncd

Jan 18 11:35:46 br2rauc systemd[1]: Starting Network Time Synchronization...
Jan 18 11:35:47 br2rauc systemd[1]: Started Network Time Synchronization.

And timedatectl show-timesync results in:

FallbackNTPServers=time1.google.com time2.google.com time3.google.com time4.google.com
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=0
Frequency=0

I don't know why but /etc/systemd/timesyncd.conf looks like not set

[Time]
#NTP=
#FallbackNTP=time1.google.com time2.google.com time3.google.com time4.google.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#SaveIntervalSec=60

Do I need to set any value for NTP?

I also tried by enabling BR2_PACKAGE_HTPDATE=y and systemctl status htpdate.status shows:

htpdate.service - htpdate daemon
     Loaded: loaded (/usr/lib/systemd/system/htpdate.service; enabled; vendor pr
     Active: active (running) since Tue 2022-01-18 11:35:48 UTC; 22min ago
    Process: 221 ExecStart=/usr/sbin/htpdate -D -i /run/htpdate.pid $HTPDATE_ARG
   Main PID: 228 (htpdate)
      Tasks: 1 (limit: 1009)
        CPU: 26ms
     CGroup: /system.slice/htpdate.service
             └─228 /usr/sbin/htpdate -D -i /run/htpdate.pid -a -s -t https:/

Jan 18 11:35:48 br2rauc systemd[1]: Starting htpdate daemon...
Jan 18 11:35:48 br2rauc htpdate[228]: htpdate version 1.3.3 started
Jan 18 11:35:48 br2rauc htpdate[228]: www.google.com host or service unavailable
Jan 18 11:35:48 br2rauc systemd[1]: Started htpdate daemon.

As you can see above date and time is set to Jan 18. While booting Pi is not connected to internet. And I connect to internet using connmanafter system boot. But even after restarting systemd-timesyncd it's same result.

I have asked this in other forums too, but didn't get any response. Thought you may have some ideas on this.

Can you please let me know what is the issue here?

Thanks in advance.

cdsteinkuehler commented 2 years ago

The comments in /etc/systemd/timesyncd.conf show the default values. If you want to override them, you will need to create a custom configuration file. The default configuration works and properly sets the time and date for me (Central USA), so you do not need to have NTP set, timesyncd will use the fallback servers. I suspect you need to either update firewall rules between the br2rauc system and the internet or select an NTP server that is active for your region.

$ sudo timedatectl status
[59716.763216] kauditd_printk_skb: 10 callbacks suppressed
[59716.763228] audit: type=1334 audit(1649334375.219:29): prog-id=23 op=LOAD
[59716.775904] audit: type=1334 audit(1649334375.219:30): prog-id=24 op=LOAD
[59716.782945] audit: type=1334 audit(1649334375.219:31): prog-id=25 op=LOAD
Local time: Thu 2022-04-07 12:26:15 UTC
Universal time: Thu 2022-04-07 12:26:15 UTC
RTC time: n/a
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
$ sudo timedatectl timesync-status
Server: 216.239.35.0 (time1.google.com)
Poll interval: 34min 8s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 1
Reference: GOOG
Precision: 1us (-20)
Root distance: 91us (max: 5s)
Offset: -613us
Delay: 30.234ms
Jitter: 1.653ms
Packet count: 35
Frequency: -15.241ppm