fix(13e6): partition + SPI corruption + bootstrap stay-awake

Three problems surfaced during the first 13.3" end-to-end run:

1) LittleFS IntegerDivideByZero on 200 → write /img.bin. Cause: the
   ~3.5 MB SPIFFS in default_16MB.csv can't fit three 960 KB setup
   screens + a 960 KB cached image (~3.84 MB). Switching to a custom
   partitions_13e6.csv with 24 MB LittleFS on the 32 MB flash.

2) Yellow wash across the panel on long SPI bursts. Cause: SPI DMA
   from a PSRAM-backed scratch buffer hits a cache-coherency window —
   the CPU's writes hadn't reached PSRAM yet when DMA read it. Push
   each half in 8 KB chunks through an internal-SRAM (DMA-coherent)
   scratch, and drop the bus clock to 4 MHz to match the 7.3"
   production speed.

3) Bootstrap window (no image yet) was deep-sleeping for 15 s between
   polls — each cycle a ~5 s ROM-boot + Wi-Fi reconnect, so the user
   waited ~20 s × N retries between scanning the setup QR and seeing
   their first photo land. Now normal_operation_impl returns early
   during bootstrap and main.cpp's normal_operation loops with a
   2 s delay, keeping Wi-Fi up. Once the first image arrives, the
   normal scheduled deep sleep takes over.

   Also fixes a related bug Matt called out: a transient TLS hiccup
   during bootstrap was hitting the 5xx fallback path and painting a
   full yellow fill over the green setup QR, leaving the user with
   no claim path. Criterion is now "does /img.bin exist?" (panel has
   something worth showing with a border) rather than "is currentImgId
   set?", so a fresh device with no cached image preserves the setup
   screen through transient network errors.

Diagnostic prints in the panel driver + [op] start/code lines in
normal_operation_impl that proved invaluable during bringup; leaving
them in for now. Tests updated for the new bootstrap semantics
(deep sleep no longer arms on bootstrap-cycle 204/404/5xx); 43/43
native tests pass, 7.3" production build stays byte-identical.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 11:50:36 -04:00
parent c75e4c003d
commit 013e49d859
7 changed files with 106 additions and 43 deletions
+17
View File
@@ -0,0 +1,17 @@
# Custom partition layout for the Waveshare ESP32-S3-ePaper-13.3E6 (32 MB OPI flash).
#
# default_16MB.csv ships ~3.5 MB to SPIFFS — too small once we add a
# panel-native /img.bin (960 KB) on top of the three setup-screen .bin
# files (also 960 KB each). LittleFS panics in lfs_ctz_traverse / lfs.c
# with an IntegerDivideByZero when it runs out of blocks mid-write.
#
# This layout: 4 MB app0 + 4 MB app1 (keep OTA option open) + 24 MB
# LittleFS + 64 KB coredump on 32 MB flash. Plenty of headroom.
#
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x400000,
app1, app, ota_1, 0x410000, 0x400000,
spiffs, data, spiffs, 0x810000, 0x17E0000,
coredump, data, coredump, 0x1FF0000,0x10000,
1 # Custom partition layout for the Waveshare ESP32-S3-ePaper-13.3E6 (32 MB OPI flash).
2 #
3 # default_16MB.csv ships ~3.5 MB to SPIFFS — too small once we add a
4 # panel-native /img.bin (960 KB) on top of the three setup-screen .bin
5 # files (also 960 KB each). LittleFS panics in lfs_ctz_traverse / lfs.c
6 # with an IntegerDivideByZero when it runs out of blocks mid-write.
7 #
8 # This layout: 4 MB app0 + 4 MB app1 (keep OTA option open) + 24 MB
9 # LittleFS + 64 KB coredump on 32 MB flash. Plenty of headroom.
10 #
11 # Name Type SubType Offset Size Flags
12 nvs data nvs 0x9000 0x5000
13 otadata data ota 0xe000 0x2000
14 app0 app ota_0 0x10000 0x400000
15 app1 app ota_1 0x410000 0x400000
16 spiffs data spiffs 0x810000 0x17E0000
17 coredump data coredump 0x1FF0000 0x10000