add RTC#60
Open
gkuznik wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds RTC support to the kernel and STM32L4 machine layer so the kernel can read/write wall-clock time and persist a small amount of RTC-backed state across resets.
Changes:
- Add RTC initialization, raw RTC accessors, and backup-register access in the STM32L4 C interface.
- Expose RTC APIs through the machine abstraction and implement them for native and stub Cortex-M backends.
- Add kernel-side time helpers plus a new time thread that is started during kernel initialization.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/time.rs |
Adds kernel RTC helpers, Unix/RTC conversion logic, and the new time thread. |
src/lib.rs |
Starts the new time thread during kernel initialization. |
machine/cortex-m/st/stm32l4/interface/export.h |
Exposes new RTC and backup-register symbols to Rust bindings. |
machine/cortex-m/st/stm32l4/interface/clock.c |
Initializes RTC hardware, selects RTC clock source, and implements RTC read/write helpers. |
machine/cortex-m/src/stub.rs |
Adds stub RTC methods for the test/non-hardware backend. |
machine/cortex-m/src/native.rs |
Wires the new RTC bindings into the native Cortex-M machine implementation. |
machine/api/src/lib.rs |
Extends the machine trait with RTC and backup-register operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rename functions
thomasw04
requested changes
May 4, 2026
| unsafe { bindings::monotonic_freq() } | ||
| } | ||
|
|
||
| fn rtc_raw() -> u64 { |
Member
There was a problem hiding this comment.
If I understand correctly, you assume that every HAL exposes an rtc_raw function that returns a BCD-encoded time. I would not make this the public API. I think it makes more sense to expose POSIX time as universal format and make the conversion HAL/driver defined.
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.
No description provided.