Time zone set correctly, but time and date are wrong; hwclock: Cannot access the Hardware Clock via any known method

As stated in the title, for some reason my system runs in its own little world, outside of regular time conventions. As of right now the system time is:

$ timedatectl 
               Local time: Sun 2022-03-13 06:09:05 CET
           Universal time: Sun 2022-03-13 05:09:05 UTC
                 RTC time: n/a
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

which is … not exactly correct and it might be related to another issue I’m trying to fix. Most of the answers I find, mention hwclock as well, but I’m not sure if that is applicable to a Raspberry Pi. I’m grasping straws here and I really don’t quite know what I’m doing, but I’m just going to list a few outputs, I received while trying various solutions from the net:

$ ntpq -p
ntpq: read: Connection refused
$ strace ntpq -pn ::1|& grep -i conn
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_INET6, sin6_port=htons(123), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, 28) = 0
recvfrom(3, 0x7ff4d86c80, 516, 0, NULL, NULL) = -1 ECONNREFUSED (Connection refused)
write(2, ": Connection refused\n", 21: Connection refused
$ netstat -taupn|grep udp|grep ntp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)

$ netstat -taupn|grep udp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
udp        0      0 0.0.0.0:21027           0.0.0.0:*                           354/syncthing       
udp        0      0 0.0.0.0:42076           0.0.0.0:*                           354/syncthing       
udp        0      0 224.0.0.251:5353        0.0.0.0:*                           1269/chromium --fla 
udp        0      0 0.0.0.0:5355            0.0.0.0:*                           -                   
udp        0      0 127.0.0.54:53           0.0.0.0:*                           -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           -                   
udp        0      0 192.168.178.53:68       192.168.178.1:67        ESTABLISHED -                   
udp6       0      0 fe80::6b05:78a8:cbe:546 :::*                                -                   
udp6       0      0 :::21027                :::*                                354/syncthing       
udp6       0      0 :::5355                 :::*                                -                   
udp6       0      0 :::22000                :::*                                354/syncthing       
udp6       0      0 :::59835                :::*                                354/syncthing       
udp6       0      0 2003:cf:6f46:2f00:43865 2a00:1450:4001:82f::443 ESTABLISHED 1308/chromium --typ
$ ntpq -pn 127.0.0.1
ntpq: read: Connection refused
$ ntpq -pn -4
ntpq: read: Connection refused
$ ntpq start
Name or service not known
ntpq>
$ hwclock --verbose
hwclock from util-linux 2.37.4
System Time: 1647148267.078376
Trying to open: /dev/rtc0
Trying to open: /dev/rtc
Trying to open: /dev/misc/rtc
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

System info:

$ inxi --admin --verbosity=7 --filter --width
System:
  Kernel: 5.15.28-2-rpi-ARCH aarch64 bits: 64 compiler: N/A
    parameters: coherent_pool=1M 8250.nr_uarts=0
    snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1
    video=HDMI-A-1:3840x2160M@30 smsc95xx.macaddr=E4:5F:01:35:7E:B0
    vc_mem.mem_base=0x3eb00000 vc_mem.mem_size=0x3ff00000
    root=UUID=f326cfcd-b160-4739-af20-4ab92b4028b3 rw rootwait
    console=ttyS0,115200 console=tty1 selinux=0 plymouth.enable=0
    smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 kgdboc=ttyS0,115200
  Console: pty pts/0 DM: LightDM 1.30.0 Distro: EndeavourOS base: Arch Linux
Machine:
  Type: ARM System: Raspberry Pi 4 Model B Rev 1.4 details: BCM2835
    rev: d03114 serial: <filter>
Battery:
  Message: No system battery data found. Is one present?
Memory:
  RAM: total: 7.71 GiB used: 1.62 GiB (21.1%) gpu: 512 MiB
  RAM Report:
    unknown-error: Unknown dmidecode error. Unable to generate data.
CPU:
  Info: model: ARMv8 v8l variant: cortex-a72 bits: 64 type: MCP arch: v8l
    family: 8 model-id: 0 stepping: 3
  Topology: cpus: 1x cores: 4 smt: N/A cache: N/A
  Speed (MHz): avg: 1100 min/max: 600/2000 scaling: driver: cpufreq-dt
    governor: schedutil cores: 1: 1100 2: 1100 3: 1100 4: 1100 bogomips: 432
  Features: asimd cpuid crc32 evtstrm fp
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: spec_store_bypass status: Vulnerable
  Type: spectre_v1 mitigation: __user pointer sanitization
  Type: spectre_v2 status: Vulnerable
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: bcm2711-vc5 driver: vc4_drm v: N/A bus-ID: N/A chip-ID: brcm:gpu
    class-ID: gpu
  Device-2: bcm2711-hdmi0 driver: N/A bus-ID: N/A chip-ID: brcm:soc
    class-ID: hdmi
  Device-3: bcm2711-hdmi1 driver: N/A bus-ID: N/A chip-ID: brcm:soc
    class-ID: hdmi
  Display: server: X.org v: 1.21.1.3 driver: X: loaded: modesetting
    alternate: fbdev
    gpu: vc4-drm,vc4_crtc,vc4_dpi,vc4_dsi,vc4_firmware_kms,vc4_hdmi,vc4_hvs,vc4_txp,vc4_v3d,vc4_vec
    tty: 137x74
  Monitor-1: HDMI-A-1 model: LG (GoldStar) ULTRAGEAR serial: <filter>
    built: 2021 res: 2560x1440 dpi: 93 gamma: 1.2 size: 697x392mm (27.4x15.4")
    diag: 800mm (31.5") ratio: 16:9 modes: max: 3840x2160 min: 640x480
  Message: GL data unavailable in console. Try -G --display
Audio:
  Device-1: bcm2835-audio driver: bcm2835_audio bus-ID: N/A
    chip-ID: brcm:bcm2835_audio class-ID: bcm2835_audio
  Device-2: bcm2711-hdmi0 driver: N/A bus-ID: N/A chip-ID: brcm:soc
    class-ID: hdmi
  Device-3: bcm2711-hdmi1 driver: N/A bus-ID: N/A chip-ID: brcm:soc
    class-ID: hdmi
  Sound Server-1: ALSA v: k5.15.28-2-rpi-ARCH running: yes
  Sound Server-2: PulseAudio v: 15.0 running: no
  Sound Server-3: PipeWire v: 0.3.48 running: yes
Network:
  Device-1: bcm2835-mmc driver: mmc_bcm2835 v: N/A port: N/A bus-ID: N/A
    chip-ID: brcm:fe300000 class-ID: mmcnr
  IF: wlan0 state: up mac: <filter>
  IP v4: <filter> type: dynamic noprefixroute scope: global
    broadcast: <filter>
  IP v6: <filter> type: dynamic noprefixroute scope: global
  IP v6: <filter> type: noprefixroute scope: link
  Device-2: bcm2711-genet-v5 driver: bcmgenet v: N/A port: N/A bus-ID: N/A
    chip-ID: brcm:fd580000 class-ID: ethernet
  IF: eth0 state: down mac: <filter>
  WAN IP: <filter>
Bluetooth:
  Device-1: pl011 driver: uart_pl011 bus-ID: N/A chip-ID: arm:fe201000
    class-ID: serial
  Report: bt-adapter ID: hci0 rfk-id: 1 state: up address: <filter>
  Device-2: pl011 driver: N/A bus-ID: N/A chip-ID: arm:serial0
    class-ID: serial
Logical:
  Message: No logical block device data found.
RAID:
  Message: No RAID data found.
Drives:
  Local Storage: total: 931.51 GiB used: 11.84 GiB (1.3%)
  ID-1: /dev/sda maj-min: 8:0 type: USB vendor: Samsung model: PSSD T7
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B type: SSD
    serial: <filter> scheme: GPT
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
  Message: No optical or floppy data found.
Partition:
  ID-1: / raw-size: 931.31 GiB size: 915.62 GiB (98.32%)
    used: 11.79 GiB (1.3%) fs: ext4 dev: /dev/sda2 maj-min: 8:2 label: N/A
    uuid: f326cfcd-b160-4739-af20-4ab92b4028b3
  ID-2: /boot raw-size: 200 MiB size: 199.8 MiB (99.88%)
    used: 51.5 MiB (25.8%) fs: vfat dev: /dev/sda1 maj-min: 8:1 label: N/A
    uuid: 49D4-ED9B
Swap:
  Alert: No swap data was found.
Unmounted:
  Message: No unmounted partitions found.
USB:
  Hub-1: 1-0:1 info: Hi-speed hub with single TT ports: 1 rev: 2.0
    speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
  Hub-2: 1-1:2 info: VIA Labs Hub ports: 4 rev: 2.1 speed: 480 Mb/s
    power: 100mA chip-ID: 2109:3431 class-ID: 0900
  Hub-3: 1-1.4:3 info: Genesys Logic Hub ports: 4 rev: 2.0 speed: 480 Mb/s
    power: 100mA chip-ID: 05e3:0610 class-ID: 0900
  Device-1: 1-1.4.1:4 info: Holtek Wired Keyboard (78/79 key) [RPI 5]
    type: Keyboard,HID driver: hid-generic,usbhid interfaces: 2 rev: 2.0
    speed: 1.5 Mb/s power: 100mA chip-ID: 04d9:0006 class-ID: 0300
  Device-2: 1-1.4.4:5 info: Pixart Imaging Optical Mouse type: Mouse
    driver: hid-generic,usbhid interfaces: 1 rev: 1.1 speed: 1.5 Mb/s
    power: 100mA chip-ID: 093a:2510 class-ID: 0301
  Hub-4: 2-0:1 info: Super-speed hub ports: 4 rev: 3.0 speed: 5 Gb/s
    chip-ID: 1d6b:0003 class-ID: 0900
  Device-1: 2-2:2 info: Samsung PSSD T7 type: Mass Storage driver: uas
    interfaces: 1 rev: 3.2 speed: 5 Gb/s power: 896mA chip-ID: 04e8:4001
    class-ID: 0806 serial: <filter>
Sensors:
  System Temperatures: cpu: 36.5 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 178 Uptime: 2h 8m Init: systemd v: 250 tool: systemctl Compilers:
  gcc: 11.2.0 clang: 13.0.1 Packages: pacman: 807 lib: 201 Shell: Bash
  v: 5.1.16 running-in: pty pts/0 (SSH) inxi: 3.3.13

I’d appreciate any tips. Something I should probably mention, although I’m not sure it’s of any concern: I do turn off that Raspberry Pi once, I’m done for the night. shutdown now, wait for it to shut down and then unplug the power supply.

1 Like

You need root privileges to change hardware settings.
Here:
https://wiki.archlinux.org/title/System_time#Set_hardware_clock_from_system_clock

1 Like

Raspberry Pi 4b devices do not have a hardware clock, hence no coin shaped battery.

 ls -l /etc/localtime

should show a symlink to the set time zone such as:

lrwxrwxrwx 1 root root 31 Jan 17 14:04 /etc/localtime -> /usr/share/zoneinfo/US/Mountain

In my case United States Mountain Time.

As @petsam pointed out, system settings usually need sudo or root permissions.

sudo timedatectl set-ntp true
sudo timedatectl timesync-status 

should set the proper time. You might have to reboot for this to take place.
Every time the device is booted up, if the internet is available, NTP will adjust the time.

I hope you are enjoying your ARM experience.

Pudge

3 Likes

It does show something, but it’s all out of whack.

$ ls -l /etc/localtime                          
lrwxrwxrwx 1 root root 33 Mar  9 16:40 /etc/localtime -> /usr/share/zoneinfo/Europe/Berlin

I tried your other two commands—no output for the first one:

$ sudo timedatectl set-ntp true
$ sudo timedatectl timesync-status 
       Server: n/a (n/a)
Poll interval: 0 (min: 32s; max 34min 8s)
 Packet count: 0

Afterwards the time is still wrong. Server: n/a (n/a) can’t be good, either, huh? Something’s borked here …

$ timedatectl 
               Local time: Sun 2022-03-13 06:35:51 CET
           Universal time: Sun 2022-03-13 05:35:51 UTC
                 RTC time: n/a
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

Do you have a connection to the internet? Do you block port 123 (ntp) in your firewall?

Can you change the time manualy? - e.g.

sudo date -s "20 MAR 2022 20:00:00"

What is content of your /etc/ntp.conf file? Did you specify the a server or a server pool (server 0.arch.pool.ntp.org)?

Yes:

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=28.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=119 time=31.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=119 time=32.6 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=119 time=36.1 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 28.937/32.406/36.147/2.563 ms

Yes:

$ sudo date -s "20 MAR 2022 20:01:00"
[sudo] password
Sun Mar 20 08:01:00 PM CET 2022
$ timedatectl 
               Local time: Sun 2022-03-20 20:01:07 CET
           Universal time: Sun 2022-03-20 19:01:07 UTC
                 RTC time: n/a
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

I did not specify anything within this file myself, as far as I’m aware.

$ cat /etc/ntp.conf 
# Please consider joining the pool:
#
#     http://www.pool.ntp.org/join.html
#
# For additional information see:
# - https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon
# - http://support.ntp.org/bin/view/Support/GettingStarted
# - the ntp.conf man page

# Associate to Arch's NTP pool
server 0.arch.pool.ntp.org
server 1.arch.pool.ntp.org
server 2.arch.pool.ntp.org
server 3.arch.pool.ntp.org

# By default, the server allows:
# - all queries from the local host
# - only time queries from remote hosts, protected by rate limiting and kod
restrict default kod limited nomodify nopeer noquery notrap
restrict 127.0.0.1
restrict ::1

# Location of drift file
driftfile /var/lib/ntp/ntp.drift

I cannot see the problem yet. Do you know which program is handling the time synchronisation on your system?

Is for example systemctl status systemd-timesyncd.service active?
Can you also show output of timedatectl timesync-status and timedatectl show-timesync?

Can you ping NTP server - for example 2.arch.pool.ntp.org?

Not gonna lie: I know nothing. I’m grasping for straws here, because this seems like such a basic issue, but I can’t figure it out.

I’ll give all that a try:

$ systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-03-13 06:32:38 CET; 1 week 0 days ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 332 (systemd-timesyn)
     Status: "Daemon is running"
      Tasks: 1 (limit: 8540)
        CPU: 120ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─332 /usr/lib/systemd/systemd-timesyncd

Mar 13 02:24:20 radonite systemd[1]: Starting Network Time Synchronization...
Mar 13 02:24:20 radonite systemd-timesyncd[332]: System clock time unset or jumped backwards, restoring from recorded timestamp: Sun 202>
Mar 13 06:32:38 radonite systemd[1]: Started Network Time Synchronization.

As above:

$ timedatectl timesync-status
       Server: n/a (n/a)
Poll interval: 0 (min: 32s; max 34min 8s)
 Packet count: 0
$ timedatectl show-timesync
FallbackNTPServers=0.arch.pool.ntp.org 1.arch.pool.ntp.org 2.arch.pool.ntp.org 3.arch.pool.ntp.org
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=0
Frequency=0

Yes.

$ ping 2.arch.pool.ntp.org
PING 2.arch.pool.ntp.org(2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47)) 56 data bytes
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=1 ttl=56 time=43.8 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=2 ttl=56 time=50.5 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=3 ttl=56 time=44.2 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=4 ttl=56 time=46.8 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=5 ttl=56 time=47.2 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=6 ttl=56 time=46.9 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=7 ttl=56 time=46.5 ms
64 bytes from 2001:620:0:fffc::123:47 (2001:620:0:fffc::123:47): icmp_seq=8 ttl=56 time=46.2 ms
^C
--- 2.arch.pool.ntp.org ping statistics ---
9 packets transmitted, 8 received, 11.1111% packet loss, time 8010ms
rtt min/avg/max/mdev = 43.821/46.513/50.510/1.922 ms

You can check timedatectl show and if NTP is not yes then you can enable it with sudo timedatectl set-ntp true. But if the doesn’t work I am not sure what will work.
Everything looks in order only that you do not have an information about server in your outputs. Unless you block in/out communication on UDP port 123 I am not sure what could cause that.

timedatctl show already shows NTP as yes:

$ timedatectl show
Timezone=Europe/Berlin
LocalRTC=no
CanNTP=yes
NTP=yes
NTPSynchronized=no
TimeUSec=Sun 2022-03-20 21:46:47 CET

The time is correct right now, because I set it earlier and had the RPI running ever since. I’m going to turn it off now and see what the time says tomorrow after work. Either it now works for whatever reason, or the time will be wrong again.

If it still doesn’t work you may check these links:
https://serverfault.com/questions/948974/force-systemd-timesyncd-to-sync-time-with-ntp-server-immediately/972336#972336

https://wiki.archlinux.org/title/System_time#Time_synchronization

https://wiki.archlinux.org/title/Network_Time_Protocol_daemon

I think OP problem is about ARM/RPi HW specific.
@fhonb has to ask HW vendor or ARM specific support for help…

Turning on the RPI today, its time and date is exactly where it was shut down last night. According to my RPI it is Sun 2022-03-20 23:09:09 CET right now:

$ timedatectl 
               Local time: Sun 2022-03-20 23:09:09 CET
           Universal time: Sun 2022-03-20 22:09:09 UTC
                 RTC time: n/a
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

This would obviously be caused by the whole System clock synchronized: no business, even though NTP is active. Now to figure out, why the synchronization won’t turn on …

I’m not sure if I’m doing this right, so please correct me if necessary, but it seems like nothing is listening on port 123 at all, if I’m to believe this:

$ ss -lnu
State        Recv-Q       Send-Q                                 Local Address:Port                Peer Address:Port       Process       
UNCONN       0            0                                         127.0.0.54:53                       0.0.0.0:*                        
UNCONN       0            0                                      127.0.0.53%lo:53                       0.0.0.0:*                        
UNCONN       0            0                                            0.0.0.0:21027                    0.0.0.0:*                        
UNCONN       0            0                                            0.0.0.0:41584                    0.0.0.0:*                        
UNCONN       0            0                                            0.0.0.0:5355                     0.0.0.0:*                        
UNCONN       0            0                                               [::]:45318                       [::]:*                        
UNCONN       0            0                  [fe80::6b05:78a8:cbe9:178f]%wlan0:546                         [::]:*                        
UNCONN       0            0                                               [::]:21027                       [::]:*                        
UNCONN       0            0                                               [::]:5355                        [::]:*                        
UNCONN       0            0                                                  *:22000                          *:*

If EOS ARM doesn’t come with a pre-installed firewall, then there’s none on my system anyway, because I haven’t had the time to set up this system properly and install one yet. So I don’t really know what should be blocking port 123 in the first place.

I’ll keep googling around, but maybe someone here has another idea. :v:

So, I finally figured it out. Probably just a bunch derps on my part:
1st: systemd-timesyncd wasn’t running, as seen via systemctl status systemd-timesyncd. This is usually started when you issue timedatectl set-ntp true, but for some reason it was inactive, even though I had invoked set-ntp true a couple of times already … no clue why. It’s active now, so I’m good, I think.

$ systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-03-21 16:25:18 CET; 19min ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 330 (systemd-timesyn)
     Status: "Daemon is running"
      Tasks: 1 (limit: 8540)
        CPU: 86ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─330 /usr/lib/systemd/systemd-timesyncd

Mar 13 02:24:20 radonite systemd[1]: Starting Network Time Synchronization...
Mar 13 02:24:20 radonite systemd-timesyncd[330]: System clock time unset or jumped backwards, restoring from recorded timestamp: Mon 202>
Mar 21 16:25:18 radonite systemd[1]: Started Network Time Synchronization.

2nd: No drop-ins for /etc/systemd/timesyncd.conf existed and no NTP servers were set up in the “main” config file. I now manually set up four NTP servers in timesyncd.conf:

[Time]
NTP=0.arch.pool.ntp.org 1.arch.pool.ntp.org 2.arch.pool.ntp.org 3.arch.pool.ntp.org

3rd: This one was probably my biggest dumb-dumb—chronyd was installed, but not enabled.

sudo systemctl enable --now chronyd

After this, the time synchronization is now active:

$ timedatectl 
               Local time: Mon 2022-03-21 16:41:12 CET
           Universal time: Mon 2022-03-21 15:41:12 UTC
                 RTC time: n/a
                Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Problem solved. Thank you all for your help, ideas, and patience. :heart:

3 Likes

Duly noted. Thanks to all who helped with this problem.

Pudge

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