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
+6 -4
View File
@@ -101,10 +101,12 @@ board_build.flash_mode = opi
board_upload.flash_size = 32MB
board_build.arduino.memory_type = opi_opi
board_build.filesystem = littlefs
; Default partition table reserves ~1.5MB for SPIFFS — not enough for three
; 960 KB setup-screen .bin files (2.88 MB minimum + LittleFS metadata).
; 16MB preset gives ~3.5 MB to the filesystem, tight but works.
board_build.partitions = default_16MB.csv
; Custom partition layout: 4 MB app slots + 24 MB LittleFS on 32 MB flash.
; The 16 MB preset's ~3.5 MB SPIFFS is too tight — three 960 KB setup
; screens + a 960 KB cached /img.bin overflows it, and LittleFS panics
; in lfs_ctz_traverse (lfs.c:2988) with an IntegerDivideByZero
; mid-write rather than returning a clean "no space" error.
board_build.partitions = partitions_13e6.csv
extra_scripts = pre:scripts/data_dir.py
build_src_filter =
+<main.cpp>