Skip to content

fw/drivers/rtc: bound RSF sync wait in rtc_get_time_ms#1716

Open
jplexer wants to merge 1 commit into
coredevices:mainfrom
jplexer:jp/firm-3403-rtc-rsf-bounded-wait
Open

fw/drivers/rtc: bound RSF sync wait in rtc_get_time_ms#1716
jplexer wants to merge 1 commit into
coredevices:mainfrom
jplexer:jp/firm-3403-rtc-rsf-bounded-wait

Conversation

@jplexer

@jplexer jplexer commented Jul 15, 2026

Copy link
Copy Markdown
Member

The wait for RTC shadow-register synchronization spun forever if RSF never set. On FIRM-3403 a wedged low-power domain left RSF stuck low, so rtc_get_time_ms hung the system task and tripped the task watchdog ("stuck task" reboot 9 s after boot on v4.23.0).

Bound the wait at 1M iterations (~40-200 ms depending on HCLK, vs ~0.5 ms genuine sync time) and fall back to the last-synced shadow values, degrading to stale time instead of a watchdog reboot loop. The timeout is logged once; the guard flag is set before logging because PBL_LOG timestamps re-enter rtc_get_time_ms.

Related to FIRM-3403.

The wait for RTC shadow-register synchronization spun forever if RSF
never set. On FIRM-3403 a wedged low-power domain left RSF stuck low,
so rtc_get_time_ms hung the system task and tripped the task watchdog
("stuck task" reboot 9 s after boot on v4.23.0).

Bound the wait at 1M iterations (~40-200 ms depending on HCLK, vs
~0.5 ms genuine sync time) and fall back to the last-synced shadow
values, degrading to stale time instead of a watchdog reboot loop.
The timeout is logged once; the guard flag is set before logging
because PBL_LOG timestamps re-enter rtc_get_time_ms.

Related to FIRM-3403.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Joshua Jun <lets@throw.rocks>
@jplexer
jplexer requested a review from gmarull as a code owner July 15, 2026 19:19
@gmarull
gmarull requested a review from rabbitsaviola July 15, 2026 21:23
@gmarull

gmarull commented Jul 15, 2026

Copy link
Copy Markdown
Member

@rabbitsaviola please check

@gmarull

gmarull commented Jul 16, 2026

Copy link
Copy Markdown
Member

It may be worth panicking if this happens, because a bad RTC can then cause all sorts of random bugs that are very difficult to trace. But let's wait for @rabbitsaviola feedback.

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