0

I have built a custom Linux OS for Raspberry Pi CM4 using Buildroot. I am able to boot it but my system clock is not synchronized. 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 connman after system boot. But again after restarting systemd-timesyncd it's same result.

Can anyone please let me know how to properly synchronize the system clock?

Your help will be much appreciated.

thanks in advance

P.S: Please let me know if any info is missing here.

Preeti
  • 131
  • 5
  • sudo timedatectl shows that something has set your clock to the correct time. So what's your question? – Dougie Apr 14 '22 at 20:24
  • Hello @Dougie, as you can see above, both local time and Universal time is set to 2022-01-18 but I have posted this yesterday so I expect it to be 2022-04-14. But I could change the time zone to CET from UTC in Buildroot. But after boot date is still the same. – Preeti Apr 15 '22 at 07:10
  • If your RPi (any version) is running RaspiOS and is connected to the public internet then there's a process built-in to periodically sync the clock to an internet time server. There's also fake-hwclock which records the time at 17 minutes past every hour and automatically resets the clock to that when it boots. If you don't have an internet connection you will need extra RTC hardware. – Dougie Apr 15 '22 at 14:29
  • The main thing to note is that Raspberry Pis don't have a built-in hardware clock like regular computers (PCs). – user68186 Apr 15 '22 at 15:12

0 Answers0