Skip to content

rtc: write the RX8130CE and YSN8900 weekday one-hot - #101

Merged
liquidraver merged 1 commit into
liquidraver:devfrom
ptr727:rx8130ce-week-one-hot
Oct 6, 2026
Merged

liquidraver merged 1 commit into
liquidraver:devfrom
ptr727:rx8130ce-week-one-hot

Conversation

@ptr727

@ptr727 ptr727 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

The MeshCore counterpart is meshcore-dev/MeshCore#3550.

Code links are permalinks: dev at d1cc647, this PR's commit 2621782.

The defect

rtc_time_block() writes the weekday as a binary 0-6 (Sunday 0) for every RTC. 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 on every sync, Sunday was written as no day, Monday as Sunday, and Wednesday, Friday and Saturday as two days at once. 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 descriptor property. weekday-one-hot is a boolean, 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 time block. rtc_time_block() writes BIT(dow) when it is set, and dow otherwise. That covers the sync write and the RV3028 write retry. The DS3231, PCF8563 and RV3028 keep 0-6, as Zephyr's own drivers for them write it.
  • The binding. Its header says the weekday is the one field that is not BCD, and how ZephCore writes it.

The meshtracker_x1 YSN8900 too. Its rtc-ysn8900@32 node already uses the RX8900 register map, and 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 node now sets weekday-one-hot as well. The YSN8900's own data sheet is a one-page brief with no register map, and its programming guide isn't available, so this rests on it being an RX8900 second source, as the board's DTS comment says.

Testing

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

Fork issue: ptr727#39. Iteration history and review: ptr727#45.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

The optional property is accessed as required, causing non-RX8130CE builds to fail preprocessing.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Updates RTC synchronization to encode RX8130CE weekdays as one-hot values while preserving other RTC formats.

Changes:

  • Adds the weekday-one-hot Devicetree binding.
  • Enables it for RX8130CE devices.
  • Applies per-RTC weekday encoding during writes.
File Description
zephcore/​dts/​bindings/​rtc/​zephcore,rtc-i2c.yaml Documents the optional weekday encoding property.
zephcore/​boards/​common/​rtc-i2c.dtsi Enables one-hot encoding for RX8130CE.
zephcore/​adapters/​clock/​ZephyrRTCDiscover.c Selects binary or one-hot weekday writes.

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

.zero = COND_CODE_1( \
DT_NODE_HAS_PROP(node, zero_mask), \
(RTC_ZERO_NAME(node)), (NULL)), \
.week_one_hot = DT_PROP(node, weekday_one_hot), \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Disproven. A type: boolean property declared in a binding is always generated, with the value 0 on a node that omits it, so DT_PROP() is defined for every node of the compatible.

  • Zephyr says so: include/zephyr/devicetree.h: "Boolean properties defined for a compatible node always exist, as they are generated with a value of 0 when not present on a node."
  • The build agrees: at this head, the generated devicetree_generated.h for thinknode_m1 has rtc_ds3231_68_P_weekday_one_hot 0, rtc_pcf8563_51_P_weekday_one_hot 0, rtc_rv3028_52_P_weekday_one_hot 0 and rtc_rx8130ce_32_P_weekday_one_hot 1. For meshtracker_x1 it has rtc_ysn8900_32_P_weekday_one_hot 1.
  • The builds pass: thinknode_m1, meshtracker_x1, muziworks_r1neo and rak4631 compile with no compiler warnings. rak4631 has no node with the property at all.

DT_PROP_OR(..., false) would behave the same and adds nothing.

rtc_time_block() wrote the weekday as a number 0-6 (Sunday 0) for every
RTC. The RX8130CE's WEEK register (13h) is one-hot: Epson ETM50E-10
14.1.2, Table 15, p. 27, Sunday 01h to Saturday 40h, with no more than
one bit set. So each sync wrote Sunday as no day, Monday as Sunday, and
Wednesday, Friday and Saturday as two days at once. ZephCore never
reads the weekday back, so its time and date were unaffected.

A new boolean descriptor property, weekday-one-hot, is set on the
RX8130CE node in rtc-i2c.dtsi, and rtc_time_block() writes BIT(dow)
where it is set. That is the encoding of Zephyr's rtc_rx8130ce.c. The
DS3231, PCF8563 and RV3028 keep 0-6, as Zephyr's drivers for them
write it. The binding and comments no longer call the whole block BCD.

meshtracker_x1's YSN8900 sets it too. The board already uses the RX8900
register map for it, and the RX8900's WEEK register (03h) is one-hot:
Epson ETM45E-11 8.2.2, Table 15, p. 16. The YSN8900's own data sheet
has no register map, and its programming guide is not available.

The same defect and fix as meshcore-dev/MeshCore#3550.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727
ptr727 force-pushed the rx8130ce-week-one-hot branch from 0e93948 to 2621782 Compare October 5, 2026 19:35
@ptr727 ptr727 changed the title rtc: write the RX8130CE weekday one-hot rtc: write the RX8130CE and YSN8900 weekday one-hot Oct 5, 2026
@liquidraver
liquidraver merged commit 5cb319b into liquidraver:dev Oct 6, 2026
1 check passed
@ptr727
ptr727 deleted the rx8130ce-week-one-hot branch October 10, 2026 22:11
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.

3 participants