Unable to get the RTC up and running on Zymkey 4i - zkbootrtc.service inactive (dead)

Hi @Bob_of_Zymbit and @Scott_of_Zymbit

I’m unable to get the RTC up and running on Zymkey 4i.

I’ve purchased a brand new CR1025 battery, and followed the below steps, yet the zkbootrtc service remains inactive/dead.

Could you please assist ?

Below are the commands I typed, and the result:

  1. Stopped the Rpi
  2. Inserted the CR1025
  3. Rebooted the Rpi
  4. sudo timedatectl set-ntp true
  5. sudo systemctl start zkbootrtc
  6. sudo systemctl enable zkbootrtc
  7. sudo systemctl status zkbootrtc

But the zkbootrtc service is always inactive (dead)

● zkbootrtc.service - Restore System Clock from Zymkey
     Loaded: loaded (/etc/systemd/system/zkbootrtc.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Sat 2022-10-29 18:31:59 AEDT; 1s ago
    Process: 987 ExecStart=/usr/bin/zk_early_boot.sh (code=exited, status=0/SUCCESS)
   Main PID: 987 (code=exited, status=0/SUCCESS)
        CPU: 183ms

Oct 29 18:31:01 skitty systemd[1]: Starting Restore System Clock from Zymkey...
Oct 29 18:31:59 skitty systemd[1]: zkbootrtc.service: Succeeded.
Oct 29 18:31:59 skitty systemd[1]: Finished Restore System Clock from Zymkey.

Could you please advise how to fix this?

zkbootrtc just runs once at boot time, then “dies”. What makes you think it isn’t working? What do you get from,

python3 -c "import zymkey; print(zymkey.client.get_time())"

If it’s a big number like 1667076801 as soon as you boot, it’s working.

Hello @Bob_of_Zymbit

Indeed python3 -c "import zymkey; print(zymkey.client.get_time())" returns the correct EPOCH time of today.

However, when I check with timedatectl or timedatectl status, the result does not return anything related to the RTC Clock as it shows not applicable (n/a):

               Local time: Sun 2022-10-30 02:55:45 GMT
           Universal time: Sun 2022-10-30 02:55:45 UTC
                 **RTC time: n/a**
                Time zone: Africa/Abidjan (GMT, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Same with hwclock:

hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method.

Does it mean the only way for the system to know the RTC time, is by calling the Zymkey Python API?

We elected to not develop any kernel modules for the RTC and, therefore, the stock Linux components (e.g. hwclock and the RTC field in timedatectl display) won’t work with Zymkey’s RTC.

Our approach was to keep everything in user space and in systemd. During boot, systemd runs the zbootrtc script that checks zymkey for a more recent time than the last one that RPi captured and stored on disk during the last proper shutdown.

This means that the system time (GMT) should be initially set to zymkey’s time before NTP has had a chance to run. Sounds like it’s all working properly.