Pocket Reform is not keeping time anymore

After my pocket ran out of battery once and died it is not able to keep the time anymore. Every time I reboot it resets the time to a few days back.

Currently I sync the time after every restart manually with

sudo ntpdate pool.ntp.org

Anyone else with the same issue? Any idea how to fix it?

Perhaps you have to set the hardware clock manually once:

sudo hwclock --systohc

hwclock can also help you debug the issue with some status info about the hardware clock.

3 Likes

Thanks that actually worked!

As you pointed out in the irc channel people may need to install hwclock via

sudo apt install util-linux-extra
5 Likes

General context: TTBOMK on a modern distro, systemd-timesyncd or ntpd should tell the kernel that the time is in sync, and the kernel should update rtc0 during shutdown.

If that doesn’t work, either of these things can be broken. hwclock can be a workaround, but it feels a bit like “the 80ies are calling” :sunglasses:

@zeha If the system is shut down what keeps track of time? My understanding is that most SoM type systems like Raspberry Pi and Rockchip don’t have RTC so they are dependent on their power source or a network connection to keep time accurate. The pocket does have an RTC (PCF8523T) so we might as well use it.

That said, we should still probably look into why the time isn’t updating for folks if network is connecting on boot. It was consistently a problem for me with both the imx8 and rk3588.

The RTC should keep the time. That is its job.
If hwclock works, then the question is: why does it not work out of the box, without hwclock.

So i did some testing and there definitely seems to be an issue with ntpd. I suspect that apparmor is the problem, but i still couldnt get it working and get time to sync. When i would do ntpq -p it would show all the servers but there wouldn’t be an * near any of them, but sudo ntpdate pool.ntp.org would update manually just fine.

I couldnt find a solution even after changing some of the apparmor settings. I ended up switching to chrony and that at least was functioning fine on its own as a service.

Here is /etc/apparmor.d/usr.sbin.ntpd if anyone is interested. I added additional network lines.

#include <tunables/global>
#include <tunables/ntpd>
/usr/sbin/ntpd flags=(attach_disconnected) {
  #include <abstractions/base>
  #include <abstractions/nameservice>
  #include <abstractions/openssl>
  #include <abstractions/user-tmp>

  capability ipc_lock,
  capability net_admin,
  capability net_bind_service,
  capability setgid,
  capability setuid,
  capability sys_chroot,
  capability sys_resource,
  capability sys_time,
  capability sys_nice,

  # ntp uses AF_INET, AF_INET6 and AF_UNSPEC
  network dgram,
  network stream,
  network inet udp,
  network inet6 udp, 

  @{PROC}/net/if_inet6 r,
  @{PROC}/*/net/if_inet6 r,
  @{NTPD_DEVICE} rw,
  # pps devices are almost exclusively used with NTP
  /dev/pps[0-9]* rw,

  /{,s}bin/      r,
  /usr/{,s}bin/  r,
  /usr/local/{,s}bin/  r,
  /usr/sbin/ntpd rmix,

  /etc/ntpsec/ntp.conf r,
  /etc/ntpsec/ntp.d/ r,
  /etc/ntpsec/ntp.d/*.conf r,
  /run/ntpsec/ntp.conf.dhcp r,

  /etc/ntpsec/cert-chain.pem r,
  /etc/ntpsec/key.pem r,
  /etc/ntpsec/ntp.keys r,

  /var/lib/ntpsec/ntp.drift rw,
  /var/lib/ntpsec/ntp.drift-tmp rw,
  /var/lib/ntpsec/nts-keys rw,
  /var/lib/ntpsec/nts-keys-tmp rw,
  /usr/share/zoneinfo/leap-seconds.list r,

  /var/log/ntp w,
  /var/log/ntp.log w,
  /var/log/ntpd w,
  /var/log/ntpsec/clockstats* rwl,
  /var/log/ntpsec/loopstats*  rwl,
  /var/log/ntpsec/peerstats*  rwl,
  /var/log/ntpsec/protostats* rwl,
  /var/log/ntpsec/rawstats*   rwl,
  /var/log/ntpsec/sysstats*   rwl,
  /var/log/ntpsec/usestats*   rwl,

  /{,var/}run/ntpd.pid w,

  # to be able to check for running ntpdate
  /run/lock/ntpsec-ntpdate wk,

  # To sign replies to MS-SNTP clients by the smbd daemon /var/lib/samba
  /var/lib/samba/ntp_signd/socket rw,

  # For use with clocks that report via shared memory (e.g. gpsd),
  # you may need to give ntpd access to all of shared memory, though
  # this can be considered dangerous. See https://launchpad.net/bugs/722815
  # for details. To enable, add this to local/usr.sbin.ntpd:
  #     capability ipc_owner,

  # Site-specific additions and overrides. See local/README for details.
  #include <local/usr.sbin.ntpd>
}

I had noticed my system was also starting up with an RTC several days out of date and then seeming to struggle to sync with NTP. I’ve now installed hwclock and followed the steps here, lets see if this gets any better.

1 Like