f628c3884d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
3.6 KiB
Markdown
75 lines
3.6 KiB
Markdown
---
|
|
type: report
|
|
date: 2026-10-08
|
|
---
|
|
# Time Sync and Timezone
|
|
|
|
## Result
|
|
|
|
| Item | State |
|
|
|------|-------|
|
|
| Network time | **chrony** (since 2026-10-09; was `systemd-timesyncd`), primary `ntp.nict.jp` (stratum 1) + JP pool + Ubuntu pools, over whichever uplink holds the default route |
|
|
| Timezone | `Asia/Tokyo` (was `Asia/Yakutsk`: same +09:00 and no DST either, but the wrong place) |
|
|
| Clock across power-off | **Not kept.** The RTC has no backup battery (see below) |
|
|
| GPS time | chrony refclock `GPS` (gpsd SHM 0), fallback only; used when offline with a fix |
|
|
| Boot clock without network | `fake-hwclock` restores the last saved time (replaces timesyncd's saved timestamp) |
|
|
|
|
## RTC loses time when powered off
|
|
|
|
On the 2026-10-08 cold boot, the kernel set the system clock from `rtc0` (`nvvrs-pseq-rtc`, `hctosys=1`) to **June 4**.
|
|
Then the clock was corrected in two steps:
|
|
|
|
1. ~12 s: timesyncd stepped forward to its last saved timestamp (`/var/lib/systemd/timesync/clock`). This is close, but behind by however long the board was off.
|
|
2. ~43 s: first NTP sync corrected the rest. The kernel then writes the synced time back to the RTC, which only lasts until the next power-off.
|
|
|
|
Until step 2, timestamps are wrong, and with no uplink (in the car, out of coverage) they stay wrong. The fix is hardware:
|
|
an RTC backup battery (see [BOM](../../BOM.md#rtc-backup-battery)). `rtc1` (`tegra_rtc`) isn't used for boot time and reads 1970.
|
|
|
|
## Configuration
|
|
|
|
```
|
|
sudo timedatectl set-timezone Asia/Tokyo
|
|
```
|
|
|
|
`/etc/systemd/timesyncd.conf.d/10-servers.conf` (superseded on 2026-10-09 by chrony, below; timesyncd is no longer installed):
|
|
|
|
```
|
|
# Japan-local primary (NICT, national time standard), global pool as backup.
|
|
[Time]
|
|
NTP=ntp.nict.jp
|
|
FallbackNTP=ntp.ubuntu.com 0.jp.pool.ntp.org 1.jp.pool.ntp.org 2.jp.pool.ntp.org
|
|
```
|
|
|
|
`sudo systemctl restart systemd-timesyncd`, then check with `timedatectl timesync-status` (server, stratum, offset).
|
|
|
|
## Chrony with GPS fallback (2026-10-09)
|
|
|
|
Replaced `systemd-timesyncd` (removed by the `chrony` package) so GPS can serve as an offline time source.
|
|
|
|
```
|
|
sudo apt install chrony fake-hwclock
|
|
```
|
|
|
|
`/etc/chrony/conf.d/10-yukart.conf`:
|
|
|
|
```
|
|
server ntp.nict.jp iburst prefer
|
|
pool 2.jp.pool.ntp.org iburst maxsources 2
|
|
refclock SHM 0 refid GPS precision 1e-1 offset 0.0 delay 0.5 poll 3
|
|
```
|
|
|
|
- **NTP stays primary.** The GPS refclock's generous `precision`/`delay` give it a large root distance, so any reachable NTP server wins.
|
|
It steers the clock only offline with a fix. NMEA over USB has no PPS, so GPS time is good to ~tens of ms, plenty for log timestamps.
|
|
- **`offset 0.0` is a placeholder.** Tune it once NTP and a GNSS fix are both available: `chronyc sourcestats` shows the GPS offset
|
|
against NTP.
|
|
- **`makestep 1 -1`** in `/etc/chrony/chrony.conf` (was `1 3`): step the clock whenever it's > 1 s off, not only in the first three
|
|
updates, because with no RTC battery a stale clock may only meet its first source (a late GPS fix) well into an offline drive.
|
|
chrony's config format has no inline comments; the explanation sits on its own line above.
|
|
- **`fake-hwclock`** saves the time hourly and at shutdown and restores it at boot, so an offline boot starts near the last shutdown
|
|
instead of the RTC's reset date. This replaces what timesyncd's `/var/lib/systemd/timesync/clock` did.
|
|
- gpsd must run with **`-n`** to feed SHM without a client. See the SIM7600 report: a stray gpsd started by a `gpsdctl` udev hook ran
|
|
without it, now fixed.
|
|
|
|
Check: `chronyc -n sources` (`^*` = selected NTP server, `#` = GPS refclock), `chronyc tracking`.
|
|
At setup: synced to `ntp-a3.nict.go.jp` (stratum 1); `GPS` listed with no samples (antenna detached indoors).
|