From 5f8b7c88ac182903033b0481fdeed5e295b89e35 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Tue, 10 Nov 2026 20:56:42 +0200 Subject: [PATCH] Fix the missing cover-panel reaction with a 9-bit panel path and sign-off probe Live diagnosis with the flip physically closed showed the wake chain is intact: bananarchy-coverctl BUTTON/WAKE, the lid gate and sxmo_state.sh set unlock all reached backend=spidev visible=1 mux=closed, with the daemon holding /dev/spidev0.1, the gpiochip and its line handles. The outer panel itself never reacted. Register reads over SPI return zeros (write-only panels), gpio21 stays static, and a reversible panel-mipi-dbi-spi/spidev rebind on spi0.0 showed the shared gpio110 D/C path is also unreadable, so the missing piece is the panel framing: the KaiOS downstream DTS labels gpio21 TE, not D/C, and Qualcomm MDSS SPI carries D/C as the ninth bit. bananarchy-cover-idle now defaults to 9-bit MIPI DBI: it releases gpio21, claims only the reset line, and frames every command and pixel as a little-endian 9-bit word with D/C in bit 8. spi_word_bits = 8 keeps the old D/C-GPIO path. A PROBE command walks twelve combinations of word width, gpio13 mux level, reset/D-C polarity and 25 MHz / 5 MHz clock, re-initialising the panel and drawing TEST bars; STATUS reports bits= and probe=case N/12. bananarchy-cover-probe.sh drives all twelve cases with a three-second hold so the working wiring can be written back to cover-display.conf. wanted_device() in common.h now also matches KEY_POWER, so the pm8941_pwrkey device (KEY_POWER only) is no longer invisible to bananarchy-volume-keys and all three outer buttons can produce a cover wake. Rebuilt the a1108/dejavu nokia-beatles image and pinned the verified hash 57d140e9cdf05631a6620b639d143350b9984b2170592fb927c93bfb18f67a2b in check-rebuild.sh. e2fsck -fn passed on both partitions, debugfs confirms seven updated rootfs files byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight all pass. Eyes-on confirmation of which case lights the cover, and the cover backlight source, are still required; this is an intermediate checkpoint. --- AGENTS.md | 1 + CHANGELOG.md | 9 + README.md | 2 +- .../rootfs/etc/bananarchy/cover-display.conf | 9 + .../usr/bin/bananarchy-cover-diagnose.sh | 5 +- overlay/rootfs/usr/bin/bananarchy-cover-idle | Bin 21676 -> 21676 bytes .../rootfs/usr/bin/bananarchy-cover-probe.sh | 29 ++++ overlay/rootfs/usr/bin/bananarchy-volume-keys | Bin 9440 -> 9440 bytes .../usr/bin/bananarchy-cover-idle | Bin 21676 -> 21676 bytes .../usr/bin/bananarchy-volume-keys | Bin 9440 -> 9440 bytes scripts/check-rebuild.sh | 10 +- scripts/test-cover-spidev.py | 31 +++- scripts/test-lid-gate.py | 14 +- .../bananarchy-cover-idle.c | 162 ++++++++++++++++-- src/bananarchy-daemons/common.h | 8 +- 15 files changed, 252 insertions(+), 28 deletions(-) create mode 100755 overlay/rootfs/usr/bin/bananarchy-cover-probe.sh diff --git a/AGENTS.md b/AGENTS.md index b2abaa5..900e14d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -75,6 +75,7 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, ` screens. The shipping image drives the external GC9305 from userspace over `/dev/spidev0.1` while the flip is **closed only** (`bananarchy-cover-idle`); never claim gpio13/21/23 or send SPI traffic while the flip is open, and gate activation on the main panel being DPMS-off; always restore the mux to the internal panel on `LID OPEN`. +- The cover panel's D/C wiring is unsigned-off: gpio21 is TE in the KaiOS DTS, not necessarily D/C. Keep both 8-bit (`spi_word_bits = 8`) and 9-bit MIPI DBI (`9`) paths, `bananarchy-coverctl PROBE` and `bananarchy-cover-probe.sh`. Do not claim a winner without eyes-on confirmation. - Keep the internal beatles panel at 25 MHz, `dc_gpio = -1` for the spidev fallback, external-panel firmware and initramfs module lists, the Xorg `card0` pin, `bananarchy-cover-diagnose.sh`, and the `scripts/test-cover-dt.py` / `scripts/test-cover-spidev.py` guards. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d02124..a63a97a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,15 @@ Release versions follow the `
` format (where `2026` is `a`, Work since `a1108` has focused on reliable 2720 Flip hardware support and a reproducible boot/flash path. Earlier incremental and superseded diagnostic entries are consolidated here. +### Cover panel hardware sign-off path after the button regression + +- **Live diagnosis**: with the flip physically closed, `bananarchy-coverctl BUTTON`, `WAKE`, `bananarchy-lid-gate.sh wake` and `sxmo_state.sh set unlock` all reached `backend=spidev visible=1 mux=closed`, and the daemon held `/dev/spidev0.1`, the gpiochip and two line handles. So the wake chain is intact; the outer panel itself never reacts to the frames. Register-ID reads over SPI return zeros for both chip selects (the panels are write-only), and gpio21 stays static, so readback/TE cannot be used to confirm wiring. A reversible `panel-mipi-dbi-spi`/`spidev` rebind on `spi0.0` proved CS0 + the kernel-owned gpio110 D/C path is also unreadable; the phone was fully restored (`/dev/dri/card0`, `/dev/fb0`, Xorg and dwm back). +- **Wiring gap**: the KaiOS downstream DTS labels gpio21 as **TE**, not D/C, and Qualcomm MDSS SPI carries D/C as the ninth bit. The cover daemon therefore gained a **9-bit MIPI DBI mode**: when `spi_word_bits = 9` it releases gpio21, frames every command and pixel as a little-endian 9-bit word with D/C in bit 8, and claims only the reset line. 9-bit is the default because the vendor DTS has no external D/C GPIO; `spi_word_bits = 8` restores the earlier D/C-GPIO path until physical sign-off. +- **Sign-off tooling**: `bananarchy-coverctl PROBE` walks twelve combinations of word width (8/9), gpio13 mux level, reset polarity, D/C polarity and SPI clock (25 MHz / 5 MHz), re-initialising the panel and drawing `TEST bars` each time; `STATUS` reports `bits=` and `probe=case N/12`. `bananarchy-cover-probe.sh` drives the twelve cases with a three-second hold, and `bananarchy-cover-diagnose.sh` prints the active keys. `SET spi_word_bits 8|9` toggles the mode at runtime. Once the working case is known it goes into `/etc/bananarchy/cover-display.conf`. +- **Button gap**: `wanted_device()` in `common.h` only watched devices with `KEY_VOLUMEUP`/`KEY_VOLUMEDOWN`, so the `pm8941_pwrkey` device (KEY_POWER only) was invisible to `bananarchy-volume-keys`. It now also matches `KEY_POWER`, so all three outer keys can produce a cover wake even when X/dwm does not forward one. +- **Still unverified**: eyes-on confirmation of which case lights the cover, and the cover backlight source (no separate backlight/LED node exists in the DT). +- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu` with the 9-bit default, PROBE tooling and KEY_POWER fix; verified raw hash `57d140e9cdf05631a6620b639d143350b9984b2170592fb927c93bfb18f67a2b`, pinned by `scripts/check-rebuild.sh`. `e2fsck -fn` passed on both partitions, `debugfs` confirms the rebuilt daemons and all sign-off scripts/config byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight pass. The standalone boot image hash is unchanged. + ### Instant flip lid switching and closed-flip event routing - **Root cause of the close lag**: `bananarchy-lid.c` recomputed `observed` from a stale `EV_SW` mask on every 100 ms iteration and only consulted the raw hall lines every 200 ms, so `candidate` oscillated open/closed and the 80 ms debounce rarely completed. With a controlled hall-file transition on the live phone a close took over 2.2 s to blank the main panel. The hall reading is now sticky, any `EV_SW` edge forces an immediate hall re-read, the loop/debounce are 20 ms, and the daemon writes the lid state, lock flag, Sxmo state and all backlights synchronously in C before spawning hooks. A direct `xset dpms force off/on` stops or resumes Xorg's SPI flushes immediately; the Sxmo hooks run through `bananarchy-lid-state.sh`, which refuses stale spawns by lid state and a transition generation counter so a late screenoff hook cannot re-lock a just-opened flip. diff --git a/README.md b/README.md index 54565ba..358c453 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Instead of spawning slow shell scripts for everyday phone tasks, Bananarchy runs - **Kopher SmallWeb browser (`xkopher` / `kopher` / `xsmallweb` / `smallweb.so`)**: multi-protocol SmallWeb client for **Gopher** (`gopher://`) with optional TLS (`gophers://`), **Gemini** (`gemini://`), **Spartan** (`spartan://`), and **Nex** (`nex://`), featuring WAP-style default keypad controls from [Kopher](https://code.luxferre.top/luxferre/kopher.git), user-adjustable keybindings (`~/.config/sxmo/smallweb_controls.tsv`), 10 bookmarks, custom homepage support, and link focus that always scrolls the viewport to the focused link in both wrapped and unwrapped modes. - **Webarchy Web browser (`webarchy` / `xwebarchy` / `webarchy.so`)**: full-featured HTML5/CSS3/JS web browser built on WPE / WebKit (`webkit2gtk-4.1` + `libwpe-1.0`) with Adreno 304 hardware acceleration (`WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS`, WebGL, accelerated 2D canvas, and 512 MB RAM pressure tuning), default KaiOS 4.0 User-Agent (`Mozilla/5.0 (Mobile; rv:123.0) Gecko/123.0 Firefox/123.0 KAIOS/4.0`) with preset and custom User-Agent override (`~/.config/sxmo/webarchy_ua.txt`), `UTF-8` default encoding fallback, `Noto Sans` / `Noto Serif` (`font-noto` + `font-noto-emoji`) as the default non-monospace browser fonts and `Fira Code` with OpenType ligatures as the monospace font, full GStreamer multimedia (`MediaSource` / MSE, WebAudio, inline HTML5 `