Repository navigation
rtc: write the RTC time only for years 2000-2099 - #105
Merged
Merged
Conversation
ZephCore writes the year as two BCD digits with no century, as y % 100. A time before 2000, accepted by a node whose clock had no time yet, was stored as a year near the end of the century and restored at the next boot above the 2025 floor: `time 900000000` (1998) came back as 2098. rtc_time_block() now fails outside 2000-2099, and zephcore_rtc_save() then logs and writes no time, for every chip; the chip keeps the time it has. An RV3028 write retry stops if its run-on time leaves the range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 7, 2026
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cancel pending RV3028 retries for out-of-range epochs to prevent stale time writes.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Restricts RTC writes to years 2000–2099 to prevent century aliasing.
Changes:
- Adds year-range validation for RTC writes and retries.
- Updates RTC configuration, API, binding, and architecture documentation.
| File | Summary |
|---|---|
zephcore/Kconfig |
Documents the supported RTC write range. |
zephcore/dts/bindings/rtc/zephcore,rtc-i2c.yaml |
Updates RTC behavior documentation. |
zephcore/adapters/clock/ZephyrRTCDiscover.h |
Documents the range-limited RTC persistence contract. |
zephcore/adapters/clock/ZephyrRTCDiscover.c |
Validates years and manages RTC writes and retries. |
docs/ARCHITECTURE.md |
Documents the RTC write restriction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+686
to
+689
| if (!rtc_time_block(d, epoch, blk)) { | ||
| LOG_WRN("RTC %s: time outside 2000-2099 not written", d->name); | ||
| return; | ||
| } |
This was referenced Oct 8, 2026
Closed
ptr727
added a commit
to ptr727/liquidraver-ZephCore
that referenced
this pull request
Oct 10, 2026
Conflicts in ZephyrRTCDiscover.c/.h, from liquidraver#105 and liquidraver#106: - the restore and rtc_identify() doc comments take dev's trimmed text; the identify comment keeps one clause for RTC_UNREAD versus -EIO; - rtc_probe_run() records PRESENT, then runs dev's 12-hour clear, so a failed clear is still reported as present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Replaces #103, cut down to the year-range check as asked in #103 (comment). #103 stays as the record of the version coordinated with Zephyr and MeshCore.
The defect. ZephCore writes the RTC year as two BCD digits with no century, as
y % 100. A time before 2000, accepted by a node whose clock had no time yet, was stored as a year near the end of the century and came back at the next boot above the 2025 floor:time 900000000(1998) was restored as 2098.The fix.
rtc_time_block()returns false outside 2000-2099.zephcore_rtc_save()then logstime outside 2000-2099 not writtenand writes no time, for every chip,rv3028-eeprom-configincluded. The chip keeps the time it has.rv3028_save_retry_fn()stops if its run-on time leaves the range.zephcore,rtc-i2cbinding anddocs/ARCHITECTURE.md.The RV3028 write sequence is unchanged: year 00h, then 00h-05h, then the year.
Other projects. Zephyr (zephyrproject-rtos/zephyr#121389) and MeshCore (meshcore-dev/MeshCore#3421) take the same 2000-2099 write range. They also write the RV3028 with an A0h year mark and one burst, which ZephCore does not take: its 2025 restore floor already rejects the year 2000 that a cut write leaves (the last test below). A mark left by either reads here as a non-BCD year, so it gives no time.
Testing. RAK4631 + RAK12002, repeater debug builds.
2026-10-07 14:17:31 UTC, and a CLItimethenrebootrestored the set time.zephcore_rtc_save()/zephcore_rtc_restore()and writes the chip's registers, 14/14 PASS:🤖 Generated with Claude Code