Skip to content

fix(esp32): skip RTC timer wake on user shutdown; TAP V2 OCV and partition#10739

Merged
thebentern merged 3 commits into
meshtastic:developfrom
Ethan-chen1234-zy:feature/add_rak_new_variants
Jun 18, 2026
Merged

fix(esp32): skip RTC timer wake on user shutdown; TAP V2 OCV and partition#10739
thebentern merged 3 commits into
meshtastic:developfrom
Ethan-chen1234-zy:feature/add_rak_new_variants

Conversation

@Ethan-chen1234-zy

Copy link
Copy Markdown
Contributor

fix(esp32): skip RTC timer wake on user shutdown; TAP V2 OCV and partition

Summary

This PR addresses WisMesh TAP V2 field reports where devices could not power on with the power button after long storage following factory UI shutdown.
Two classes of changes:

  1. ESP32 (all boards): User shutdown no longer arms an RTC timer wake (~49.7 days).
  2. TAP V2 variant: Battery OCV curve aligned with WisMesh Tag; 16 MB flash partition.

Problem

ESP32 user shutdown

UI shutdown calls doDeepSleep(DELAY_FOREVER) where DELAY_FOREVER is portMAX_DELAY (UINT32_MAX ms ≈ 49.7 days). cpuDeepSleep() always called esp_sleep_enable_timer_wakeup(), so shutdown was timed deep sleep, not true power-off.
After the timer fires, the device cold-boots, does not shut down again, and can drain the battery while stored (e.g. factory UI shutdown → ship → customer first use weeks later). On TAP V2 TFT (HAS_TFT, no PMIC), wake current is ~120 mA screen-off.

TAP V2 battery SOC

TAP V2 had no OCV_ARRAY in variant.h, so SOC used a generic curve and could jump under load (e.g. 68% → 83% within minutes in channel testing).

Fix

src/platform/esp32/main-esp32.cpp

Only call esp_sleep_enable_timer_wakeup() when msecToWake != portMAX_DELAY.
Timed deep sleep (sds_secs, telemetry night sleep, etc.) is unchanged.

variants/esp32s3/rak_wismesh_tap_v2/variant.h

Add OCV_ARRAY matching WisMesh Tag / Pod / Pocket:
4160, 4020, 3940, 3870, 3810, 3760, 3740, 3720, 3680, 3620, 2990

variants/esp32s3/rak_wismesh_tap_v2/platformio.ini

Use 16 MB partition scheme (default_16MB.csv) for TAP V2 hardware.

Testing

  • Pre-fix repro: TAP V2 TFT with 15 s accelerated timer on portMAX_DELAY — UI shutdown auto-rebooted in ~26 s with ESP_SLEEP_WAKEUP_TIMER.
  • Post-fix: UI shutdown does not auto-wake after 60+ s; power button wake still works.
  • Regression: Finite doDeepSleep() durations still wake on timer as before.
  • SOC: Battery % more stable vs pre-OCV on TAP V2 under charge/light load.
    Shutdown deep-sleep current (~20 µA on battery path) was already correct; the issue is long-term timer wake, not leakage.

Scope / impact

Area Impact
ESP32 UI shutdown All ESP32/ESP32-S3 boards — fixes silent timer wake

| TAP V2 OCV / partition | TAP V2 only |
Boards with AXP/PPM shutdown() on portMAX_DELAY remain compatible; this change closes the gap for boards without PMIC.

Files changed

  • src/platform/esp32/main-esp32.cpp
  • variants/esp32s3/rak_wismesh_tap_v2/variant.h
  • variants/esp32s3/rak_wismesh_tap_v2/platformio.ini

Do not arm esp_sleep_enable_timer_wakeup when msecToWake is portMAX_DELAY (UI shutdown), matching nRF52 system_off semantics.

fix(rak_wismesh_tap_v2): Tag OCV curve and 16MB partition

Add OCV_ARRAY matching WisMesh Tag for accurate SOC. Use 16MB flash partition scheme for TAP V2 hardware.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (24)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-07-18. Updated for 27d5e30.

@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Firmware Size Report

22 targets | vs develop: 1 increased, net +16

Target Size vs develop
tlora-c6 2,348,192 📈 +16
elecrow-adv-35-tft 3,395,712 0
heltec-ht62-esp32c3-sx1262 2,114,768 0
heltec-v3 2,243,024 0
heltec-v4 2,263,536 0
Show 17 more target(s)
Target Size vs develop
heltec-vision-master-e213-inkhud 2,203,680 0
pico 765,480 0
pico2 753,424 0
pico2w 1,202,776 0
picow 1,226,236 0
rak11200 1,839,968 0
rak11310 788,104 0
rak3172 181,028 0
rak3312 2,250,240 0
seeed-xiao-s3 2,254,176 0
seeed_xiao_rp2040 763,680 0
seeed_xiao_rp2350 751,576 0
station-g2 2,254,208 0
station-g3 2,244,928 0
t-deck-tft 3,789,392 0
t-eth-elite 2,469,696 0
wio-e5 233,220 0

Updated for f2c0089

@thebentern thebentern requested a review from Copilot June 18, 2026 14:35

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes ESP32 “user shutdown” behavior so it no longer arms an RTC timer wake (preventing unintended wake/drain after long storage) and aligns the TAP V2 variant config with its hardware (battery OCV curve + 16 MB flash partitioning).

Changes:

  • Avoid enabling ESP32 deep-sleep timer wake when shutdown requests an indefinite sleep (portMAX_DELAY).
  • Add TAP V2-specific battery OCV curve (OCV_ARRAY) for more stable SOC estimation.
  • Switch TAP V2 PlatformIO configuration to a 16 MB partition scheme.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/platform/esp32/main-esp32.cpp Skips RTC timer wake configuration for “forever” sleeps to behave like true shutdown.
variants/esp32s3/rak_wismesh_tap_v2/variant.h Defines TAP V2 OCV curve to improve battery SOC stability.
variants/esp32s3/rak_wismesh_tap_v2/platformio.ini Moves TAP V2 to 16 MB partition layout and metadata.

Comment thread src/platform/esp32/main-esp32.cpp
Comment thread variants/esp32s3/rak_wismesh_tap_v2/platformio.ini
Comment thread variants/esp32s3/rak_wismesh_tap_v2/platformio.ini
Comment thread variants/esp32s3/rak_wismesh_tap_v2/variant.h
@thebentern thebentern merged commit 9358b2c into meshtastic:develop Jun 18, 2026
1 check passed
thebentern added a commit that referenced this pull request Jun 18, 2026
…ition (#10739)

* fix(esp32): skip RTC timer wake on user shutdown

Do not arm esp_sleep_enable_timer_wakeup when msecToWake is portMAX_DELAY (UI shutdown), matching nRF52 system_off semantics.

fix(rak_wismesh_tap_v2): Tag OCV curve and 16MB partition

Add OCV_ARRAY matching WisMesh Tag for accurate SOC. Use 16MB flash partition scheme for TAP V2 hardware.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Trunkt

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
raghumad pushed a commit to raghumad/mezulla-firmware that referenced this pull request Jun 25, 2026
…ition (meshtastic#10739)

* fix(esp32): skip RTC timer wake on user shutdown

Do not arm esp_sleep_enable_timer_wakeup when msecToWake is portMAX_DELAY (UI shutdown), matching nRF52 system_off semantics.

fix(rak_wismesh_tap_v2): Tag OCV curve and 16MB partition

Add OCV_ARRAY matching WisMesh Tag for accurate SOC. Use 16MB flash partition scheme for TAP V2 hardware.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Trunkt

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants