The behavior I think I want is:
- 1. RTC to set the system clock early in the boot process
2. NTP connection to be established and used to update the system clock
3. System clock periodically used to update the RTC
3. System clock used to set the RTC right before shutdown
systemd-timesyncd only seems to be doing 2 and 3:
Immediately after booting up:
$this->bbcode_second_pass_code('', 'user@ospi ~ $ sudo timedatectl
Local time: Sun 2016-03-06 21:36:56 PST
Universal time: Mon 2016-03-07 05:36:56 UTC
RTC time: Mon 2016-02-22 14:42:16
Time zone: America/Los_Angeles (PST, -0800)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
')
A few minutes later:
$this->bbcode_second_pass_code('', 'user@ospi ~ $ sudo timedatectl
Local time: Sun 2016-03-06 21:51:59 PST
Universal time: Mon 2016-03-07 05:51:59 UTC
RTC time: Mon 2016-03-07 05:51:59
Time zone: America/Los_Angeles (PST, -0800)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
')
The initial RTC time of "Mon 2016-02-22 14:42:16" is suspiciously consistent boot to boot and also matches the time stamps I see with journalctl prior to:
$this->bbcode_second_pass_code('', '
Feb 22 06:40:27 ospi systemd[1]: Starting RPC bind service...
Feb 22 06:40:27 ospi systemd[1]: Started RPC bind service.
Feb 22 06:40:27 ospi rpc.statd[334]: Running as root. chown /var/lib/nfs to choose different user
Feb 22 06:40:28 ospi systemd[1]: Started NFS status monitor for NFSv2/3 locking..
Mar 06 21:35:08 ospi systemd[1]: Time has been changed
Mar 06 21:35:08 ospi systemd[1]: Mounted /mnt/nas/ospi.
Mar 06 21:35:08 ospi systemd[1]: Started Open Sprinkler (Unified) Raspberry Pi.
Mar 06 21:35:08 ospi systemd[1]: Reached target Multi-User System.
')
Somewhat suspicious:
$this->bbcode_second_pass_code('', '
Feb 22 06:40:16 ospi kernel: usbcore: registered new interface driver rtl8192cu
Feb 22 06:40:16 ospi kernel: bcm2835-rng 3f104000.rng: hwrng registered
Feb 22 06:40:16 ospi systemd[1]: Found device /dev/ttyAMA0.
Feb 22 06:40:17 ospi kernel: i2c i2c-1: Failed to register i2c client ds1307 at 0x68 (-16)
Feb 22 06:40:17 ospi kernel: gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
Feb 22 06:40:17 ospi kernel: i2c i2c-1: Failed to register i2c client ds1307 at 0x68 (-16)
Feb 22 06:40:17 ospi kernel: rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc0
Feb 22 06:40:17 ospi kernel: rtc-ds1307 1-0068: 56 bytes nvram
Feb 22 06:40:16 ospi systemd[1]: Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch.
Feb 22 06:40:16 ospi systemd[1]: Reached target Sound Card.
')
Per this, I am creating the RTC device with
$this->bbcode_second_pass_code('', '
user@ospi /etc/udev/rules.d $ more /etc/udev/rules.d/99-i2c-rtc.rules
ACTION=="add", SUBSYSTEM=="i2c", ATTR{name}=="3f804000.i2c", ATTR{new_device}="ds1307 0x68"
')
With the network disconnected, the RTC time is correct, but the system clock is wrong:
$this->bbcode_second_pass_code('', '
Local time: Mon 2016-02-22 06:40:36 PST
Universal time: Mon 2016-02-22 14:40:36 UTC
RTC time: Mon 2016-03-07 07:04:10
Time zone: America/Los_Angeles (PST, -0800)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
')
But if you wait about a minute, the system clock decides it's correct and overwrites the RTC:
$this->bbcode_second_pass_code('', ' Local time: Mon 2016-02-22 06:41:58 PST
Universal time: Mon 2016-02-22 14:41:58 UTC
RTC time: Mon 2016-02-22 14:41:58
Time zone: America/Los_Angeles (PST, -0800)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
')
This makes me think that the system clock is what "wants" to be set to 2016-02-22, that the RTC is set from the system clock early in the boot (if there's a network connection), the system clock is then corrected by NTP (if NTP is available), and the RTC is eventually set to system time. But how to fix it?
Do I need to move away from systemd-timesyncd? To what? Is the RTC misconfigured?