Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for save/restore system clock from file #796

Merged
merged 11 commits into from
Nov 5, 2024
Merged

Support for save/restore system clock from file #796

merged 11 commits into from
Nov 5, 2024

Conversation

troglobit
Copy link
Contributor

@troglobit troglobit commented Nov 3, 2024

Description

This PR mainly addresses issues with malfunctioning RTC devices. A few minor "infra" changes have also been included, listed at the end:

Major:

  • Disable RTC on Styx boards, can return time in the future, and no battery backup
  • Backport upstream Finit patches to support saving and restoring system clock from a file
  • Enable Finit RTC fallback to disk file and set fixed RTC fallback value in all defconfigs
  • Fix finit.mk handling of .config string values

Minor:

  • mnt script, add missing -n to test
  • Hide "use persistent /var ..." section in qemu.sh -c when disk image is selected
  • Prevent disk image from being recreated every time qemu.sh is started
  • Fix misaligned grub menu when booting disk image in qemu.sh
  • Add support for tweaking emulated RTC behavior in qemu.sh

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@troglobit troglobit requested a review from wkz November 3, 2024 20:14
@troglobit troglobit linked an issue Nov 3, 2024 that may be closed by this pull request
@troglobit troglobit added this to the Infix v24.10.2 milestone Nov 3, 2024
@troglobit troglobit self-assigned this Nov 3, 2024
@troglobit
Copy link
Contributor Author

@wkz pretesting Finit patches, I'll make sure to add a ChangeLog update and a better PR description tomorrow.

The RTC in the CN913x series does not have any "valid" bit, and this
board (all revs) does not have any backup power connected, so it will
return garbage values after every vold boot.

It was therefore decided to disable the RTC completely and set system
time manually, or using an NTP client.  This way any time skips would
only ever be forward, never backwards.

Signed-off-by: Joachim Wiberg <[email protected]>
This fixes an annoying problem with `make run` when set to boot with a
qcow2 disk image.  By default the disk image was recreated every time
the qemu.sh script was called.

Also, add image check to enforce regen if broken.

Signed-off-by: Joachim Wiberg <[email protected]>
Creating/Recreating the qcow2 image now logs to stdout, as does the check
using qemu-img, which looks funny in raw mode.  So let's delay the start
of raw mode until just before starting qemu.

Signed-off-by: Joachim Wiberg <[email protected]>
The string variable handling in configuring Finit did not follow the
Buildroot best practises.  This patch adds stripping quotes from all
string variables before adding them as configure arguments.

This fixes issue with, e.g., this sneaky bastard:

    configure --with-rtc-date=""2024-10-12 12:34:56""

Signed-off-by: Joachim Wiberg <[email protected]>
Backport support for saving and restoring system time from a file on
systems with broken RTC that reset to the future.

With this support a system can be sure time only ever moves forward.

Fix #794

Signed-off-by: Joachim Wiberg <[email protected]>
Signed-off-by: Joachim Wiberg <[email protected]>
@troglobit
Copy link
Contributor Author

@mattiaswal maybe you can focus your review on the non RTC-related changes? (If you're pressed for time, that is.)

Copy link
Contributor

@mattiaswal mattiaswal left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

@wkz wkz left a comment

Choose a reason for hiding this comment

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

🎉

board/common/rootfs/usr/libexec/infix/mnt Show resolved Hide resolved
@troglobit troglobit merged commit c81b03e into main Nov 5, 2024
6 checks passed
@troglobit troglobit deleted the rtc branch November 5, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Handle broken RTC
3 participants