Skip to content

x4prosim: X4 Pro deep sleep with ext0, ext1 and RTC timer wake - #7

Merged
prokrypt merged 1 commit into
x4prosimfrom
claude/x4prosim-deep-sleep-drtjd7
Oct 14, 2026
Merged

prokrypt merged 1 commit into
x4prosimfrom
claude/x4prosim-deep-sleep-drtjd7

Conversation

@prokrypt

Copy link
Copy Markdown
Owner

Requested by Clankmaster · project thread

Before: on the X4 Pro machine, firmware that entered deep sleep just stopped (the CPU spun forever with the log silent); Power did nothing.

After: deep sleep suspends the VM, and a Power press (ext1), the charger STAT pad (ext0) or the RTC timer wakes it into a reset with reason DEEPSLEEP, so the ROM boots again and the firmware's wake-cause code sees the real cause.

How: esp32s3_rtc_cntl treats SLEEP_EN with DIG_PWC DG_WRAP_PD_EN as deep sleep and models EXT_WAKEUP_CONF, EXT_WAKEUP1(+_STATUS) and RTC_IO EXT_WAKEUP0. The GPIO model feeds GPIO0..21 to it on new rtc-pad lines. A timer wake runs on host time (the virtual clock stops while suspended) and the RTC counter is advanced by the time asleep. x4prosim/deepsleep-test.py checks ext0, ext1 and the timer over qtest without firmware.

Checked with CrossDink 1014a (x4-pro-debug CI bin): Power sleeps (info status = suspended); a short press wakes, the firmware counts a false wake and sleeps again; a held press boots to Home with reset=DEEPSLEEP wake=EXT1, slept=21 s.

Not changed: the systimer still isn't reset by a system reset (pre-existing), so millis() carries on across a deep-sleep wake, as it already did across esp_restart().

🤖 Generated with Claude Code

https://claude.ai/code/session_01KosmddRTwNJCr1dFtsAsE1


Generated by Claude Code

SLEEP_EN with DIG_PWC DG_WRAP_PD_EN is deep sleep: the VM suspends until
ext0 (RTC_IO EXT_WAKEUP0 pad at EXT_WAKEUP0_LV), ext1 (any EXT_WAKEUP1 pad
high or low) or the RTC timer fires, then resets with reason DEEPSLEEP so
the ROM boots again; SLP_WAKEUP_CAUSE and EXT_WAKEUP1_STATUS report the
cause and pads. The GPIO model feeds GPIO0..21 to the RTC controller on
new rtc-pad lines. The RTC counter advances by the time asleep (host time,
since the virtual clock stops while suspended).

x4prosim/deepsleep-test.py checks all three wake sources over qtest.
Verified with CrossDink 1014a (x4-pro-debug): Power sleeps, a short press
wakes and re-sleeps, a held press boots to Home with reset=DEEPSLEEP
wake=EXT1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KosmddRTwNJCr1dFtsAsE1
@prokrypt prokrypt self-assigned this Oct 14, 2026
@prokrypt
prokrypt merged commit f9de8ea into x4prosim Oct 14, 2026
24 checks passed
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