Skip to content

jetson: prevent invalid RTC from rewinding host clock#1807

Merged
brianmcgillion merged 1 commit intotiiuae:mainfrom
vadika:jetson-rtc-timesync-fix
Mar 13, 2026
Merged

jetson: prevent invalid RTC from rewinding host clock#1807
brianmcgillion merged 1 commit intotiiuae:mainfrom
vadika:jetson-rtc-timesync-fix

Conversation

@vadika
Copy link
Copy Markdown
Contributor

@vadika vadika commented Mar 6, 2026

Summary

  • Prevent boot-time wall-clock rewind on Jetson Orin by disabling kernel RTC hctosys (RTC_HCTOSYS=n) for this hardware path.
  • Add a udev-triggered one-shot (ghaf-seed-time-from-rtc@) that optionally seeds system time from rtc0 only when the RTC value is plausible relative to /var/lib/systemd/timesync/clock (not behind anchor, not more than 180 days ahead, and above minimum epoch).
  • Keep native systemd-timesyncd workflow and persisted timesync anchor

Why This Fixes Root Cause

nvvrs-pseq-rtc can register as rtc0 early at boot and provide an invalid epoch-like value that rewinds wall clock time. Disabling kernel hctosys prevents this early rewind path. Time recovery remains native: optional bounded RTC seeding when rtc0 appears and then normal systemd-timesyncd synchronization.

Manual Testing Steps

  1. Build and flash image:
    • nix build .#nvidia-jetson-orin-agx-debug-from-x86_64-flash-script
    • Flash and boot Jetson host.
  2. Verify udev trigger and RTC seeding behavior:
    • udevadm info -q property -p /sys/class/rtc/rtc0 | grep -E 'DEVNAME|SUBSYSTEM|SYSTEMD_WANTS'
    • systemctl status ghaf-seed-time-from-rtc@rtc0.service --no-pager -l
    • journalctl -b -u ghaf-seed-time-from-rtc@rtc0.service --no-pager
  3. Verify native timesync path:
    • systemctl status systemd-timesyncd.service --no-pager -l
    • ls -ld /var/lib/systemd/timesync && stat /var/lib/systemd/timesync/clock
    • timedatectl show -p NTPSynchronized -p TimeUSec
  4. Verify boot logs for RTC regression symptoms:
    • journalctl -b --no-pager | grep -E 'nvvrs-pseq-rtc|setting system clock|Time jumped backwards|RTC seed'

Verification

On host:

  • Udev trigger present for rtc0:
    • DEVNAME=/dev/rtc0
    • SUBSYSTEM=rtc
    • SYSTEMD_WANTS=ghaf-seed-time-from-rtc@rtc0.service
  • RTC seed unit executed and skipped invalid RTC safely:
    • RTC seed skipped: RTC epoch 47 below minimum 1704067200
  • systemd-timesyncd active and synchronized:
    • Initial clock synchronization to Fri 2026-03-06 ... UTC
    • NTPSynchronized=yes
  • Timesync anchor writable and updated:
    • /var/lib/systemd/timesync/clock owned by systemd-timesync:systemd-timesync
    • mtime updated after sync.
  • Boot log check:
    • nvvrs-pseq-rtc ... registered as rtc0 observed.
    • No setting system clock to 1970... observed in this boot.
    • No startup-critical backward-jump churn observed in captured logs.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Jetson Orin boot-time wall-clock rewinds caused by an early-registered, invalid rtc0 value by disabling kernel RTC hctosys and adding a guarded, udev-triggered time seeding path that only applies an RTC-derived time when it’s considered plausible.

Changes:

  • Disable kernel RTC_HCTOSYS for the Jetson Orin hardware path to prevent early boot-time clock rewinds.
  • Add a udev-triggered ghaf-seed-time-from-rtc@ oneshot service to optionally seed system time from /sys/class/rtc/rtc0/since_epoch using plausibility checks.
  • Document Jetson-specific boot-time clock behavior and the intended time seeding workflow.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
modules/reference/hardware/jetpack/nvidia-jetson-orin/jetson-orin.nix Disables kernel hctosys and adds udev-triggered RTC seeding service with plausibility checks.
docs/src/content/docs/ghaf/dev/ref/build_and_run.mdx Adds documentation note explaining Jetson RTC behavior and Ghaf’s mitigation approach.

@vadika
Copy link
Copy Markdown
Contributor Author

vadika commented Mar 7, 2026

Implemented copilot-requested safety check.

@leivos-unikie
Copy link
Copy Markdown
Contributor

Tested on Orin AGX
(nix build .#nvidia-jetson-orin-agx-debug-from-x86_64-flash-script)

PR1807_checks.txt

@leivos-unikie leivos-unikie added bug on Orin AGX Cross Issues found on NVIDIA Jetson AGX Orin cross-compiled while checking this PR Tested on Orin AGX Cross This PR has been tested on NVIDIA Jetson AGX Orin cross-compiled and removed Needs Testing CI Team to pre-verify bug on Orin AGX Cross Issues found on NVIDIA Jetson AGX Orin cross-compiled while checking this PR labels Mar 11, 2026
@leivos-unikie
Copy link
Copy Markdown
Contributor

Ran 'Manual Testing Steps' on Orin NX. Functionality is as expected.

@leivos-unikie leivos-unikie added the Tested on Orin NX Cross This PR has been tested on NVIDIA Jetson NX Orin cross-compiled label Mar 12, 2026
@vadika vadika closed this Mar 12, 2026
Signed-off-by: vadik likholetov <vadikas@gmail.com>
@vadika
Copy link
Copy Markdown
Contributor Author

vadika commented Mar 12, 2026

Superseded by the following comment (this one was posted with shell-escaped formatting issues).

@vadika
Copy link
Copy Markdown
Contributor Author

vadika commented Mar 12, 2026

Addressed all open review suggestions from the previous CHANGES_REQUESTED pass and resolved the related threads.

Also squashed the branch history into a single signed commit:

Validation run:

  • nix fmt -- --fail-on-change (pass)
  • nix flake check --accept-flake-config --keep-going --print-build-logs --show-trace (terminated with status 137 in nixos-dev container)

@brianmcgillion brianmcgillion merged commit 0968408 into tiiuae:main Mar 13, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tested on Orin AGX Cross This PR has been tested on NVIDIA Jetson AGX Orin cross-compiled Tested on Orin NX Cross This PR has been tested on NVIDIA Jetson NX Orin cross-compiled

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants