Skip to content

Diagnose battery-only startup failure on Waveshare ESP32-S3-RLCD-4.2#8

Merged
clackups merged 21 commits intomainfrom
copilot/fix-wifi-and-git-status-display
Apr 17, 2026
Merged

Diagnose battery-only startup failure on Waveshare ESP32-S3-RLCD-4.2#8
clackups merged 21 commits intomainfrom
copilot/fix-wifi-and-git-status-display

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Problem

Device does not power up when an 18650 battery is inserted without USB. Connecting USB first allows normal PWR button operation afterward. Reported in waveshareteam/ESP32-S3-RLCD-4.2#2.

Analysis

No code changes — this is a hardware-level issue on the Waveshare board, not a firmware bug.

Findings from Waveshare factory firmware review

  • The factory program (10_FactoryProgram) contains zero power management or deep-sleep code — on/off is handled entirely by a hardware power latch tied to the PWR button
  • GPIO18 (KEY) is a plain input button, not involved in power control
  • Battery voltage is read via ADC1_CH3 through a 2:1 divider — no PMIC communication over I2C or SPI
  • Draftling's standby_enter_sleep() correctly uses EXT0 wakeup on GPIO18, but this is irrelevant to the cold-start problem

Root cause

The board's power management IC (or discrete latch circuit) likely enters shipping mode on first battery insertion. In this state:

  • VBUS detection is the only way to exit shipping mode
  • PWR button presses trigger a brief load-sense probe, but the ESP32-S3 doesn't draw enough current during the probe window to keep the output enabled
  • Once USB kicks the PMIC into active mode, the latch works normally via PWR button

Recommended next steps

  • Waveshare needs to confirm which PMIC is used and whether shipping mode is the cause
  • Test with factory firmware (01_Factory_V1.bin) to rule out any firmware-specific timing differences
  • If confirmed as hardware design behavior, a small load resistor on the 3.3V rail could work around the minimum-load threshold

Copilot AI and others added 21 commits April 16, 2026 19:37
- Run wifi_manager_connect() in a background FreeRTOS task to avoid
  blocking the LVGL render loop (UI stayed on "WiFi: connecting...")
- Register WiFi state callback to update the status bar on
  connect/error/disconnect events with proper LVGL locking
- Register Git sync callback to show sync progress, success, and
  error messages on the status bar with proper LVGL locking
- Free HTTP response buffer after git sync task completes to prevent
  memory leak that could cause crash on repeated push attempts
- Increase git_sync task stack from 16KB to 32KB to prevent stack
  overflow during HTTP operations with large payloads

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/0c16c29a-785c-4840-8cbb-dca903024eef

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
- Check xTaskCreatePinnedToCore return value in git_sync_start and
  report error via callback if task creation fails
- Set s_state to GIT_SYNC_IN_PROGRESS before creating the task to
  prevent re-entrant calls and ensure proper state tracking
- Reset s_state to GIT_SYNC_ERROR in sync_task when the operation
  fails, so the state is not stuck at IN_PROGRESS
- Check git_sync_start return value in both the menu and Ctrl+G
  handlers, showing an error status when it fails instead of the
  misleading 'syncing...' message

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/f6e3b3ec-a4d8-4c0d-a3be-d6f1f4ac1620

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
…rruption on power loss

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/22b8dd44-ad17-478e-baca-7993d9b4013d

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
…RAM heap, reduce task stack to 8KB

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/d15e1fb5-d920-4ce3-affc-9ea2da19da72

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
xTaskCreatePinnedToCore allocates its stack from internal DRAM, but with
BLE + WiFi active there is not enough contiguous internal DRAM available
even for 8KB.

Switch to xTaskCreateStaticPinnedToCore with a stack buffer allocated
from SPIRAM via heap_caps_malloc(MALLOC_CAP_SPIRAM). Also enable
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y which is required by
FreeRTOS to allow task stacks in external memory.

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/f361a606-4170-4f73-a1cc-d33df52b73ce

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
…y path handling

- Strip trailing .git and slashes from repo_url (GitHub API rejects .git)
- do_push() now returns ESP_FAIL when all files fail to push
- sync_task tracks pull/push results separately; no false "sync complete"
- For GIT_SYNC_BOTH, pull 404 is non-fatal (remote dir may not exist yet)
- Pull URL avoids trailing slash when remote_path is empty

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/7e6c184d-af31-4925-b9b5-1b7ed3a2bd7a

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
…a file exists before creating it

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/c4f21365-ecaf-4ba3-8869-b451f921eac5

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
…tor before sync

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/604997b3-6c8c-49f4-a999-54393b049a38

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
Store per-file blob SHAs in .git_state after each sync. On subsequent
syncs, compare saved vs local vs remote to determine:
- Push: skip files not modified locally (local SHA == saved SHA)
- Pull: skip files not changed on remote (remote SHA == saved SHA)
- Conflict: if both local and remote changed, keep local edits

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/d6e00c03-e0e2-4d39-a15a-c3dfe88f5a43

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
After a successful git sync, if a file is open in the editor, reload
it from disk so the user sees any changes pulled from the remote.

Change Ctrl+W from connect-only to a toggle: disconnect WiFi if
already connected, connect if disconnected.

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/aa9d8592-3198-4aed-91cd-0f042fe54940

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
Physical comma -> б/Б, physical dot -> ю/Ю, physical slash -> ./,
matching the standard Ukrainian keyboard layout.

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/3368a6f9-1656-4253-983a-be987081ad37

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
Shifted number row fixes (standard Ukrainian JCUKEN layout):
- Shift+3: # -> numero sign (U+2116)
- Shift+4: $ -> ;
- Shift+6: ^ -> :
- Shift+7: & -> ?

Grave key fix:
- Normal: duplicate ghe-with-upturn -> apostrophe (essential for Ukrainian)
- Shifted: ghe-with-upturn -> hryvnia sign (U+20B4)

Note: numero sign and hryvnia sign require font range extension
to display on screen (currently outside 0x20-7F,A0-FF,400-4FF).

Agent-Logs-Url: https://github.com/clackups/draftling/sessions/efbda6a8-3203-4fc6-806a-863181f8c44e

Co-authored-by: clackups <179045798+clackups@users.noreply.github.com>
@clackups clackups marked this pull request as ready for review April 17, 2026 13:36
@clackups clackups merged commit 06119f4 into main Apr 17, 2026
2 checks passed
@clackups clackups deleted the copilot/fix-wifi-and-git-status-display branch April 17, 2026 13:36
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