From febe294a9d27380abecfe973a1a6186df83bf4b3 Mon Sep 17 00:00:00 2001 From: Jose Miguel Ochoa Date: Thu, 3 Sep 2026 21:15:15 -0500 Subject: [PATCH] t2linux-config: Sync the hardware clock at shutdown T2 Macs have one real RTC, in the EC, exposed to Linux twice: rtc0 through the legacy CMOS ports and rtc1 through the ACPI Time and Alarm Device. Only _SRT on the ACPI side actually writes it. The kernel's 11-minute NTP writeback targets the hctosys device, rtc0, and the firmware discards those writes into a volatile shadow that reads back correctly and then forgets on reboot. Nothing therefore ever sets the clock. Every boot reads a counter ticking since the last cold power-on (1970-01-28), systemd bumps that to its own build date, and the machine runs weeks in the past until chrony syncs. Journal timestamps are wrong on every boot, and PackageKit's reboot-to-install offline updates abort before rpm opens the database, because that boot has no network to correct the clock first. Add a oneshot unit that writes system time to the ACPI TAD RTC at shutdown. rtc0 reads the same EC clock, so hctosys picks the value up on the next boot. The RTC is located by ACPI000E in its name rather than hardcoded to rtc1, and the unit is a no-op on machines without one. Tested on MacBookPro16,1 (Fedora 44, kernel 7.1.9-200.t2): the boot log goes from "setting system clock to 1970-01-28T03:04:49 UTC" to the correct time, and an offline update that had failed twice completes. --- t2linux-config/t2linux-config.spec | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/t2linux-config/t2linux-config.spec b/t2linux-config/t2linux-config.spec index c633d62..68ffbaa 100644 --- a/t2linux-config/t2linux-config.spec +++ b/t2linux-config/t2linux-config.spec @@ -1,11 +1,14 @@ Name: t2linux-config -Version: 16.0.0 +Version: 17.0.0 Release: 1%{?dist} Summary: System configuration for linux on t2 macs. License: MIT URL: https://t2linux.org BuildRequires: systemd +BuildRequires: systemd-rpm-macros + +Requires: util-linux %description System configuration for linux on T2 macs. @@ -26,9 +29,28 @@ cat << EOF > 90-network-t2-ncm.conf no-auto-default=t2_ncm EOF +cat << 'EOF' > t2linux-hwclock.service +[Unit] +Description=Save system time to the hardware clock at shutdown +DefaultDependencies=no +After=local-fs.target +Before=shutdown.target +Conflicts=shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/true +ExecStop=/bin/sh -c 'for r in /sys/class/rtc/rtc*; do grep -q ACPI000E "$r/name" 2>/dev/null && exec /usr/sbin/hwclock --rtc="/dev/${r##*/}" --systohc; done' + +[Install] +WantedBy=multi-user.target +EOF + cat << EOF > 91-t2linux.preset enable get-apple-firmware.service enable t2fanrd.service +enable t2linux-hwclock.service EOF %install @@ -42,7 +64,19 @@ install -D -m 644 90-network-t2-ncm.conf %{buildroot}/usr/lib/NetworkManager/con install -D -m 644 91-t2linux.preset %{buildroot}/usr/lib/systemd/system-preset/91-t2linux.preset +install -D -m 644 t2linux-hwclock.service %{buildroot}%{_unitdir}/t2linux-hwclock.service + +%post +%systemd_post t2linux-hwclock.service + +%preun +%systemd_preun t2linux-hwclock.service + +%postun +%systemd_postun t2linux-hwclock.service + %files +%{_unitdir}/t2linux-hwclock.service /usr/lib/modules-load.d/t2linux-modules.conf /usr/lib/dracut/dracut.conf.d/t2linux-modules-install.conf %{_udevrulesdir}/90-network-t2-ncm.rules