Draft
Conversation
ee402c7 to
691af11
Compare
cfab0df to
b59e974
Compare
A new API to configure RTC alarm aligned with second change, with an optional callback. Useful for systems where RTC is not used to configure RTOS wake-ups, meaning RTOS and RTC are not in sync. Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Time in PebbleOS is a bit of a mess (lol). Regular timer, derived from New Timer, together with RTC comparison logic is used to trigger "tick events", however, this is fragile. First, if RTOS is not clocked with the same timer as RTC, there is a chance both drift over time. In PT2/PR2 (SiFli with RC10K) this is partially true, RC10K is used for RTC and for LPTIM when system is in deepsleep (not while ON, though, where HXT48/RC48 is used). In old devices, things likely worked because RTC was clocked with a precise crystal, so, the hacks in regular timer init (first NT fire to align, then setup a repeating one) likely stayed valid for a long time and corrections/hacks in there did the job. This is not the case for SiFli, RC10K is not precisely precise. In this patch, we modify tick timer to use second-aligned IRQs from RTC, so that we make sure that the tick event is posted after RTC time changes. This way RTC missed updates should be rare, unless IRQ is served in > 1s (which means we may have a problem elsewhere!). Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Collaborator
|
ready to merge? |
Member
Author
The main issue was actually due to #1084. With this PR, what you get is perfectly aligned tick events and an actual RTC clock, but in reality we do not need that. That also comes at a cost of extra RTC wake-ups (because we're no longer relying on OS ticks). I'm waiting for SiFli feedback as well because it seems the need for other PR is not well understood/documented. |
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.
Note that RTC is not used as an RTOS "wake-up alarm" because some issues are observed like longer than expected wake-up (in discussion with SiFli). Because of that, RTC/RTOS are not in sync, causing issues. However, it is a good idea to have a clear split between RTC-based timers (like, e.g., CLOCK_REALTIME in POSIX) and others that just follow OS tick rate (regular timer API does not offer any guarantees about RTC time...)
Fixes FIRM-1377