Skip to content

rtc: write the RX8130CE weekday one-hot - #45

Closed
ptr727 wants to merge 8 commits into
devfrom
work/rx8130ce-week-one-hot
Closed

ptr727 wants to merge 8 commits into
devfrom
work/rx8130ce-week-one-hot

Conversation

@ptr727

@ptr727 ptr727 commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Fork iteration PR for the RX8130CE weekday fix (fork issue #39). It stays open as the iteration record; upstream sees only a squashed clean branch, and only once Pieter says so.

The defect (#39): zephcore_rtc_save() writes the weekday as a binary 0-6 (Sunday 0). The RX8130CE's WEEK register (13h) is one-hot: Epson ETM50E-10 §14.1.2, Table 15, p. 27, Sunday 01h to Saturday 40h, "Do not set '1' to more than one day at the same time". So a Sunday was written as no day, a Monday as Sunday, and Wednesday, Friday and Saturday as two days at once, after every sync. ZephCore never reads the weekday back, so its time and date were unaffected.

The fix, the same encoding as meshcore-dev/MeshCore#3550 and Zephyr's own rtc_rx8130ce.c (wday2rtc(), 1 << wday):

  • A new boolean weekday-one-hot descriptor property, set on the RX8130CE node in rtc-i2c.dtsi. Every board with an RX8130CE (muziworks_r1neo, thinknode_m1/m3/m6, lilygo_techo, thinknode_m9) gets it from there.
  • The save writes BIT(dow) when it is set, dow otherwise. The DS3231, PCF8563 and RV3028 keep 0-6, as Zephyr's own drivers for them write it.
  • The binding header names the weekday encoding as a per-part field alongside date-index.

Not changed, needs its data sheet: meshtracker_x1's own rtc-ysn8900@32 node (RX8900 layout) still writes 0-6. Nothing in the tree states the RX8900's WEEK encoding, so it stays open on #39 rather than being guessed.

Testing

  • thinknode_m1 companion, muziworks_r1neo repeater, meshtracker_x1 companion and rak4631 repeater build with no warnings. The generated devicetree has weekday_one_hot = 1 on the RX8130CE node and 0 on the DS3231, PCF8563, RV3028 and ysn8900 nodes.
  • The RX8130CE zero-mask (byte 3 = 80h) accepts every one-hot value 01h-40h, so identification is unchanged.
  • Not run on hardware: no RX8130CE board here.

Local review passes on each commit. They found the binding header's "only the day-of-month offset varies" and "7-byte BCD block" wording, and that the DS3231 family defines its weekday as 1-7 while ZephCore (like Zephyr's rtc_ds3231.c) writes 0-6. All of that is fixed, and the header now says what ZephCore writes. Copilot's first round raised the same BCD wording (fixed) and a DT_PROP on an absent boolean, disproved in its thread.

🤖 Generated with Claude Code

ptr727 and others added 2 commits October 5, 2026 08:35
zephcore_rtc_save() wrote the weekday as a binary 0-6 (Sunday 0) into
whichever time-block byte the date does not use. The RX8130CE's WEEK
register (13h) is one-hot: Epson ETM50E-10 14.1.2, Table 15, p. 27,
gives Sunday 01h to Saturday 40h and says not to set more than one bit.
So a Sunday was written as no day, a Monday as Sunday, and Wednesday,
Friday and Saturday as two days at once, after every sync. ZephCore
never reads the weekday back, so its time and date were unaffected;
only the chip's week counter, and anything that reads it, was wrong.

A new boolean weekday-one-hot descriptor property, set on the RX8130CE
node in rtc-i2c.dtsi, makes the save write BIT(dow). The other chips
keep the 0-6 encoding, as Zephyr's own DS3231, PCF8563 and RV3028
drivers write it.

The same encoding as meshcore-dev/MeshCore#3550. Fixes fork issue
#39.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Local review: the header said only the day-of-month offset varies
between parts, so someone adding a chip with a one-hot weekday (Zephyr's
rv8803 driver writes one) would not look for the property.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 5, 2026 15:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Missing optional-property handling can break RTC-enabled builds.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Fixes RX8130CE weekday persistence by encoding weekdays as one-hot values while preserving binary encoding for other RTCs.

Changes:

  • Adds the weekday-one-hot devicetree property.
  • Marks RX8130CE descriptors as one-hot.
  • Selects the configured encoding during RTC saves.
File Summary
zephcore/​dts/​bindings/​rtc/​zephcore,rtc-i2c.yaml Defines weekday encoding metadata; its BCD comment should distinguish chip-specific weekday encoding.
zephcore/​boards/​common/​rtc-i2c.dtsi Marks RX8130CE descriptors as one-hot.
zephcore/​adapters/​clock/​ZephyrRTCDiscover.c Applies the configured weekday encoding; optional properties must be handled safely to avoid build failures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread zephcore/adapters/clock/ZephyrRTCDiscover.c
Comment thread zephcore/dts/bindings/rtc/zephcore,rtc-i2c.yaml Outdated
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f86dd0fa-bbec-4035-9078-6b9331012579
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

ptr727 and others added 2 commits October 5, 2026 08:43
Copilot on fork #45: the header described the whole 7-byte block as
BCD, which a one-hot weekday is not. It now says every field but the
weekday is BCD, and that the weekday is a number 0-6 or one bit per day.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… define

The DS3231 family defines its weekday register as 1-7, but ZephCore,
like Zephyr's own rtc_ds3231.c, writes 0-6; the header now states the
encoding ZephCore writes rather than claiming it for every chip. The
time-reg description no longer calls the block BCD either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The only remaining finding is a minor documentation nit.

Review effort: Lite
Findings: None

Resolved since last review (2)

@ptr727

ptr727 commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

On Copilot's overview of 4410885 ("Findings: None"):

The only remaining finding is a minor documentation nit.

Nothing to act on. The round names no finding, opens no thread, and lists only the two earlier threads as resolved, so there is no nit to answer.

ptr727 and others added 2 commits October 5, 2026 12:12
liquidraver#98 moved the time block into rtc_time_block(), shared by the save and
the RV3028 write retry, so the one-hot weekday ternary moves there. Both
descriptor fields and binding properties are kept, and the block's
comment no longer calls the weekday byte BCD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RX8130CE weekday is now written one-hot, which is not BCD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

Opened upstream as liquidraver#101 from clean branch rx8130ce-week-one-hot (0e93948), on Pieter's go. dev (liquidraver#98) was merged in at af2ebf4, which moved the ternary into rtc_time_block(). Local review round 1 found one issue: the file header still called the whole block BCD. That is fixed in 23228ba. It also raised a YSN8900 lead, now on #39. Its prose-lint comment rules are fleet rules that do not govern this repository, so they were declined. Round 2 found nothing. Builds: thinknode_m1, muziworks_r1neo, meshtracker_x1 and rak4631, with no compiler warnings.

ptr727 and others added 2 commits October 5, 2026 12:33
The YSN8900 is an RX8900 second source, and the board already uses the
RX8900 register map for it. The RX8900's WEEK register (03h) is one-hot:
Epson RX8900 Application Manual ETM45E-11, 8.2.2, Table 15, p. 16,
Sunday 01h to Saturday 40h. The YSN8900's own data sheet is a one-page
brief with no register map, and its programming guide is not available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

Folded in the meshtracker_x1 YSN8900 (44ed7e3), on Pieter's go, after merging dev at d1cc647 (liquidraver#100 merged). Local review found nothing. The clean branch is re-squashed to 2621782 and force-pushed with a lease. The liquidraver#101 title and body are updated. Copilot's round on liquidraver#101 repeated the DT_PROP-on-absent-boolean finding, and the thread has the same disproof as here. All four boards build at this head with no compiler warnings.

@ptr727

ptr727 commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

Merged upstream as liquidraver#101 (2026-10-06), from the clean branch rx8130ce-week-one-hot at 2621782. Closing this iteration PR unmerged; the branches are deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants