From 90e677170090781535448eedeec4a6f8f8ecc0bf Mon Sep 17 00:00:00 2001 From: Luxferre Date: Tue, 10 Nov 2026 14:11:00 +0200 Subject: [PATCH] Blank the cover fbdev when off and add panel diagnostics --- AGENTS.md | 2 +- CHANGELOG.md | 1 + MANUAL.md | 2 +- README.md | 2 +- .../usr/bin/bananarchy-cover-diagnose.sh | 52 ++++++++++++++++++ overlay/rootfs/usr/bin/bananarchy-cover-idle | Bin 13484 -> 13484 bytes .../usr/bin/bananarchy-cover-idle | Bin 13484 -> 13484 bytes scripts/apply-bananarchy-overlay.sh | 1 + scripts/check-rebuild.sh | 18 +++++- scripts/test-cover-idle.py | 6 ++ .../bananarchy-cover-idle.c | 48 +++++++++++++--- 11 files changed, 121 insertions(+), 11 deletions(-) create mode 100755 overlay/rootfs/usr/bin/bananarchy-cover-diagnose.sh diff --git a/AGENTS.md b/AGENTS.md index ff21f15..9135498 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -34,7 +34,7 @@ It uses a pure **X11 (`Xlibre` + `sxmo-de-dwm`)** stack (no Wayland) with **Adre - `scripts/rootfs-prune-packages.txt`: denylist of Wayland-only, Rust-based, and retired packages purged from existing rootfs trees by `bootstrap-rootfs-container.sh` and `rebuild-image.sh`. - `scripts/prune-rootfs-packages.sh`: two-phase rootfs pruner (`world` before `apk add`, `purge` after) that reads the denylist and pins `install_if` packages with negative `!pkg` world constraints plus `apk fix`; the `world` phase is required so apk can atomically replace Rust `sudo-rs` with C `sudo`. -- **Flip lid and cover daemon**: the compiled C `bananarchy-lid` (service `bananarchy-lid`) reads the current `EV_SW` switch mask from `/dev/input/event2`, follows hall edge events with an 80 ms stability window and reconciles raw gpio36/gpio92 debugfs levels every 200 ms even when switch evdev is present, because the 2720 can miss edges or leave `EVIOCGSW` stale. The main beatles panel uses 25 MHz SPI (other targets stay at 50 MHz) to prevent high-backlight PWM noise from corrupting the display at brightness levels above 10/14. It publishes `/run/bananarchy/lid-state` so a boot-open flip starts X unlocked, directly blanks/restores the main backlight and `white:kbd_backlight`, clears the lock flag and sends a trusted `CLOSE` to `locker.so` on open, and broadcasts `LID CLOSED|OPEN` to the cover IPC. The compiled C `bananarchy-cover-idle` replaces the CPU-spinning native `bananarchy-coverd` in the default runlevel: it is a 0%-CPU Unix SOCK_DGRAM server implementing the `bananarchy-coverctl` protocol and renders a 240x240 XRGB8888 clock or `TEST bars` to the 32-bpp `/dev/fb1` with `write()`/`fsync()`. It keeps the cover fully off while the flip is open, shows clock/battery/network indicators only after a trusted `BUTTON` from `bananarchy-volume-keys` while closed, and blanks again after the same `~/.config/sxmo/idle_blank_timeout` used by `dwm` (`blank_timeout = auto` in `/etc/bananarchy/cover-display.conf`). The shipping beatles DTS now includes the external panel behind `spi-mux`, so `/dev/fb1` exists for the cover renderer; `cover-panel.dtsi` is the compile-checked reference overlay for older DTBs. `scripts/test-cover-dt.py` guards the DT wiring, firmware, initramfs lists, mux modules and Xorg card0 pin. +- **Flip lid and cover daemon**: the compiled C `bananarchy-lid` (service `bananarchy-lid`) reads the current `EV_SW` switch mask from `/dev/input/event2`, follows hall edge events with an 80 ms stability window and reconciles raw gpio36/gpio92 debugfs levels every 200 ms even when switch evdev is present, because the 2720 can miss edges or leave `EVIOCGSW` stale. The main beatles panel uses 25 MHz SPI (other targets stay at 50 MHz) to prevent high-backlight PWM noise from corrupting the display at brightness levels above 10/14. It publishes `/run/bananarchy/lid-state` so a boot-open flip starts X unlocked, directly blanks/restores the main backlight and `white:kbd_backlight`, clears the lock flag and sends a trusted `CLOSE` to `locker.so` on open, and broadcasts `LID CLOSED|OPEN` to the cover IPC. The compiled C `bananarchy-cover-idle` replaces the CPU-spinning native `bananarchy-coverd` in the default runlevel: it is a 0%-CPU Unix SOCK_DGRAM server implementing the `bananarchy-coverctl` protocol and renders a 240x240 XRGB8888 clock or `TEST bars` to the 32-bpp `/dev/fb1` with `write()`/`fsync()`. It keeps the cover fully off while the flip is open (black frame, `FBIOBLANK`/`FB_BLANK_POWERDOWN` and the optional `backlight_path` sysfs node driven from `cover_is_lit()`), shows clock/battery/network indicators only after a trusted `BUTTON` from `bananarchy-volume-keys` while closed, and blanks again after the same `~/.config/sxmo/idle_blank_timeout` used by `dwm` (`blank_timeout = auto` in `/etc/bananarchy/cover-display.conf`). `usr/bin/bananarchy-cover-diagnose.sh` reports the live `/dev/fb1` state for hardware sign-off. The shipping beatles DTS now includes the external panel behind `spi-mux`, so `/dev/fb1` exists for the cover renderer; `cover-panel.dtsi` is the compile-checked reference overlay for older DTBs. `scripts/test-cover-dt.py` guards the DT wiring, firmware, initramfs lists, mux modules and Xorg card0 pin. - **Camera, volume keys and cover spi-mux**: `etc/modules-load.d/bananarchy-hardware.conf` plus `etc/local.d/10-bananarchy-hardware.start` load `msm8905-cam` (registers `/dev/video0`) and `spidev`. The demosaic sampler rotates frames 180 degrees only when `of_machine_is_compatible("nokia,beatles")`, correcting the Flip's raw V4L2 orientation without changing other targets or adding a frame copy. `scripts/busybox-sbin-applets.txt` restores the missing `/sbin` applets including `reboot`/`poweroff`. The compiled C `bananarchy-volume-keys` (OpenRC service `bananarchy-volume-keys`) handles `KEY_VOLUMEUP`/`KEY_VOLUMEDOWN` straight from evdev because the dwm passive X grab is unreliable; `sxmo_audio.sh` mirrors the logical volume into the first live PipeWire sink via `bananarchy_set_sink_volume()` and debounces double steps with `bananarchy_vol_debounce()`. `spidev@1` is disabled because `spi-mux` owns chip select 1; the external panel is now a second `panel-mipi-dbi-spi` device on `/dev/fb1`. `dc_gpio = -1` remains in `/etc/bananarchy/cover-display.conf` for the retained native spidev fallback. - **BusyBox applet completeness**: `scripts/busybox-applets.txt` is the canonical `/bin` applet list and `apply-bananarchy-overlay.sh` recreates any missing symlinks. A rootfs snapshot without `/bin/ash` (the `user` login shell) or `/bin/grep` (used by `openrc-run.sh`) breaks sshd logins and prevents the sysinit `udev` service from starting; without udev, input nodes stay root-owned and untagged, elogind gives Xorg no devices and the keypad is dead. `overlay/rootfs/etc/udev/rules.d/99-bananarchy-input-seat.rules` forces `TAG+="seat"`, `GROUP="input"`, `MODE="0660"`; restart `tinydm` after starting udev. The lk2nd `paint_boot_banner()` in `bootloader/lk2nd/nokia-beatles.patch` draws the branded RGB565 boot splash, not the old striped test pattern. - **First-boot access (2720 Flip)**: `overlay/rootfs/etc/pam.d/sshd` supplies an explicit `pam_unix` stack and `overlay/rootfs/etc/ssh/sshd_config.d/90-bananarchy-access.conf` enables password/keyboard-interactive auth, because `50-postmarketos-ui-policy.conf` sets `UsePAM yes` while the plain `/usr/sbin/sshd` rejects that directive; `overlay/rootfs/etc/conf.d/sshd` pins `/usr/sbin/sshd.pam`. `overlay/rootfs/etc/ssh/sshd_config_debug` plus `etc/local.d/20-bananarchy-sshd-debug.start` keep a USB-only (172.16.42.1:2222) PAM-free fallback login; `keys/phone_id_ed25519.pub` is pre-authorized for `user` and `root`. The shipping `extlinux.conf` must contain `quiet splash` (the pmOS initramfs defaults to `nosplash=y`); `scripts/sync-beatles-bootfs.py` restores it and `scripts/check-beatles-bootimg.py` rejects debug cmdlines. `overlay/rootfs/usr/lib/udev/rules.d/99-bananarchy-keypad.rules` and `usr/share/X11/xorg.conf.d/60-bananarchy-keypad.conf` force X to attach the GPIO matrix keypad; `usr/bin/bananarchy-keypad-diagnose.sh` collects live input state. The external 240x240 panel firmware lives in `devices/nokia-beatles/nokia,beatles-gc9305-ext-panel.bin/.txt` and is listed in both initramfs panel file lists; `devices/nokia-beatles/cover-panel.dtsi` is the compile-checked reference overlay, and `devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts` now ships the two-panel `spi-mux` layout. `scripts/check-rebuild.sh` verifies DTB/DTS sync and requires the cover wiring. The `mux-core`, `mux-gpio` and `spi-mux` modules are built and loaded. The recovered native `usr/bin/bananarchy-coverd` is retained only for diagnostics; `dc_gpio = -1` keeps it from fighting `panel-mipi-dbi-spi` for gpio110. gpio13 mux polarity, the external reset polarity and the lk2nd boot splash still need a physical sign-off on a live 2720 Flip. diff --git a/CHANGELOG.md b/CHANGELOG.md index da43ee8..ce29797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Work since `a1108` has focused on reliable 2720 Flip hardware support and a repr - **Provisioned the driver path**: `/lib/firmware/nokia,beatles-gc9305-ext-panel.bin` is now listed in `overlay/rootfs/usr/share/mkinitfs/files/00-nokia-argon-display.files` and `devices/nokia-beatles/00-nokia-beatles-display.files`, so `panel-mipi-dbi` (an initramfs module) can load it. `mux-core`, `mux-gpio` and `spi-mux` remain in `modules-load.d`/`local.d`, and `CONFIG_MULTIPLEXER`/`CONFIG_MUX_GPIO`/`CONFIG_SPI_MUX` stay `=m`. - **Rebuilt and revalidated the boot artifacts**: the DTB was recompiled from the DTS and synced to `devices/`, `overlay/rootfs/boot/` and `prebuilt/kernel-6.12.1-msm8916/dtbs/`; `scripts/repack-beatles-bootimg.py` replaced the appended DTB in the standalone boot image and `scripts/sync-beatles-bootfs.py` refreshed `boot.img` and the DTB inside the raw image's `pmOS_boot` ext2 filesystem. The pinned beatles image hashes in `check-rebuild.sh` were updated, and `check-beatles-bootimg.py` plus `sync-beatles-bootfs.py --check` still pass. `devices/nokia-beatles/cover-panel.dtsi` was rewritten to mirror the shipping wiring and remains compile-checked as a reference for older DTBs. - **Guards**: `scripts/test-cover-dt.py` validates the decompiled DTB (two displays, 25 MHz clocks, isolated gpio13, disabled spidev, stock IDs and 512 MiB memory fallback), DTB/DTS/copy consistency, initramfs firmware lists, kernel config, module loading and the Xorg card0 pin. `check-rebuild.sh` now requires the cover wiring instead of rejecting it. +- **Renderer "fully off" now uses fbdev blanking**: `bananarchy-cover-idle` calls `FBIOBLANK` with `FB_BLANK_POWERDOWN` after writing the black frame (and `FB_BLANK_UNBLANK` for a lit frame), so a real DRM fbdev powers the external connector down instead of just showing black. `cover_is_lit()` is the single source of truth for the frame, the optional `backlight_path` sysfs node and the blanking ioctl; the host state-machine test also guards these tokens. `/usr/bin/bananarchy-cover-diagnose.sh` reports `/dev/fb1`, its geometry, DRM cards, mux/panel modules, firmware, lid state and `bananarchy-coverctl STATUS` for the physical sign-off. - **Still needs a live device**: gpio13 mux polarity, external reset polarity, the external panel init stream and the lk2nd boot splash (which drives QUP directly before Linux applies the mux pinctrl) cannot be confirmed offline. The DT and renderer are shipped; the physical sign-off remains the last validation step. ### 2720 Flip cover display behaviour diff --git a/MANUAL.md b/MANUAL.md index 8b443eb..a705ac4 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -456,7 +456,7 @@ Three native X11 games (`/usr/bin/snake`, `/usr/bin/tetris`, and `/usr/bin/scoun - **X startup and keypad**: OpenRC starts independent services in parallel; `etc/init.d/local` replaces its stock `after *` dependency, which deadlocked with parallel startup on this image. `udev_settle_timeout=2` stops missing modem firmware from holding the display manager behind a long `udevadm settle`, and `bananarchy-sshd-debug` starts independently of `local.d`. A boot-open flip reads `/run/bananarchy/lid-state` and starts in `state=unlock` with no passcode screen, so the keypad is live as soon as `dwm` starts. If the keypad is dead, check `rc-service bananarchy-lid status`, `cat /run/bananarchy/lid-state`, `sxmo_state.sh get`, `/tmp/bananarchy_screen_locked`, `DISPLAY=:0 xwininfo -id 0xa00001` and `DISPLAY=:0 xinput list`. - **Display distortion above 71% brightness**: the internal panel uses 25 MHz SPI on `nokia-beatles`, rather than the 50 MHz timing used by the other targets. This keeps the link stable when the MPP2 backlight PWM duty rises above the level-10/14 operating point. The brightness range remains 1–14 with no artificial cap, and panel offsets/init registers are unchanged. The timing can be checked with `dtc -I dtb -O dts /boot/qcom-msm8905-nokia-beatles.dtb | grep -A8 'display@0'`. - **Closing the flip**: `bananarchy-lid` reads the current `EV_SW` switch mask from `/dev/input/event2`, follows hall edge events with an 80 ms stability window, and reconciles the raw gpio36/gpio92 debugfs levels every 200 ms even while evdev is present. This covers missed edges and stale `EVIOCGSW` state without a busy-polling loop. On close it blanks the main panel and keypad LED immediately, runs `sxmo_state.sh set screenoff` and tells the cover daemon `LID CLOSED`; on open it clears the lock flag, restores both backlights, sends a trusted `CLOSE` to `locker.so` and runs `sxmo_state.sh set unlock`. Check `rc-service bananarchy-lid status`, `sxmo_state.sh get` and `grep -E " gpio(36|92) " /sys/kernel/debug/gpio`. If the hall polarity is inverted on your unit, set `BANANARCHY_LID_GPIO_FILE` to a different debugfs GPIO file for the fallback path. -- **Cover display status and behaviour**: `bananarchy-cover-idle` is the compiled 0%-CPU default daemon and answers `bananarchy-coverctl` (`PING`, `STATUS`, `LID CLOSED|OPEN`, `BUTTON`, `NETWORK`, `BATTERY`, `NOTIFY`, `BLANK`/`UNBLANK`, `TEST`); the native `bananarchy-coverd` is retained only for diagnostics. With the flip **open** the external panel is fully off (all-black frame plus backlight 0) and `BUTTON` is ignored. With the flip **closed** the panel stays off until an external side key is pressed: `bananarchy-volume-keys` reads `/run/bananarchy/lid-state` and sends the trusted `BUTTON` datagram instead of changing the volume, which shows the live clock, date, battery percentage and the compact main network indicators (`4G SIG75 WIFI`-style, published by `bananarchy-cover-status.sh` from the NetworkManager dispatcher and at service start). No further button blanks the cover after exactly the same **Config -> Screen blank** timeout that `dwm` uses (`~/.config/sxmo/idle_blank_timeout`, default 300 s, `0` = never; `blank_timeout = auto` in `/etc/bananarchy/cover-display.conf` selects it, a numeric value overrides it). The daemon blocks in `poll()` with no timer while off, so idle CPU stays at 0%. The renderer uses the 32-bpp fbdev `write()` path (not `mmap()`, which raises `SIGBUS` on the DRM fbdev). The shipping DTS now registers both panels on an `spi-mux`: `display@0` keeps the verified 240x320 internal panel at 25 MHz with gpio110 as D/C (Xorg still pins `/dev/dri/card0`), while `display@1` is the 240x240 external GC9305 at 25 MHz with its own gpio21 D/C line, gpio23 reset and `write-only` framebuffer, exposed as `/dev/fb1`. gpio13 selects the mux and has a dedicated pull-down pinctrl state so the internal panel stays selected until `gpio-mux` drives it; the external panel's pinctrl group no longer touches gpio13. `spidev@1` is disabled, the `mux-core`/`mux-gpio`/`spi-mux` modules are loaded, and the external panel firmware is included in the initramfs. `bananarchy-coverctl STATUS` should now report `backend=fb`. `scripts/test-cover-idle.py` verifies the state machine with a fake framebuffer and `scripts/test-cover-dt.py` validates the DTB, firmware lists and Xorg pin; the DTB, appended boot DTB and `pmOS_boot` copy are rebuilt together. Physical sign-off of gpio13 mux polarity, external reset polarity and the lk2nd boot splash is still required on a live 2720 Flip; `devices/nokia-beatles/cover-panel.dtsi` remains a compile-checked reference for older DTBs. +- **Cover display status and behaviour**: `bananarchy-cover-idle` is the compiled 0%-CPU default daemon and answers `bananarchy-coverctl` (`PING`, `STATUS`, `LID CLOSED|OPEN`, `BUTTON`, `NETWORK`, `BATTERY`, `NOTIFY`, `BLANK`/`UNBLANK`, `TEST`); the native `bananarchy-coverd` is retained only for diagnostics. With the flip **open** the external panel is fully off (all-black frame plus backlight 0) and `BUTTON` is ignored. With the flip **closed** the panel stays off until an external side key is pressed: `bananarchy-volume-keys` reads `/run/bananarchy/lid-state` and sends the trusted `BUTTON` datagram instead of changing the volume, which shows the live clock, date, battery percentage and the compact main network indicators (`4G SIG75 WIFI`-style, published by `bananarchy-cover-status.sh` from the NetworkManager dispatcher and at service start). No further button blanks the cover after exactly the same **Config -> Screen blank** timeout that `dwm` uses (`~/.config/sxmo/idle_blank_timeout`, default 300 s, `0` = never; `blank_timeout = auto` in `/etc/bananarchy/cover-display.conf` selects it, a numeric value overrides it). The daemon blocks in `poll()` with no timer while off, so idle CPU stays at 0%. The renderer uses the 32-bpp fbdev `write()` path (not `mmap()`, which raises `SIGBUS` on the DRM fbdev). The shipping DTS now registers both panels on an `spi-mux`: `display@0` keeps the verified 240x320 internal panel at 25 MHz with gpio110 as D/C (Xorg still pins `/dev/dri/card0`), while `display@1` is the 240x240 external GC9305 at 25 MHz with its own gpio21 D/C line, gpio23 reset and `write-only` framebuffer, exposed as `/dev/fb1`. gpio13 selects the mux and has a dedicated pull-down pinctrl state so the internal panel stays selected until `gpio-mux` drives it; the external panel's pinctrl group no longer touches gpio13. `spidev@1` is disabled, the `mux-core`/`mux-gpio`/`spi-mux` modules are loaded, and the external panel firmware is included in the initramfs. `bananarchy-coverctl STATUS` should now report `backend=fb`. `scripts/test-cover-idle.py` verifies the state machine with a fake framebuffer and `scripts/test-cover-dt.py` validates the DTB, firmware lists and Xorg pin; the DTB, appended boot DTB and `pmOS_boot` copy are rebuilt together. Physical sign-off of gpio13 mux polarity, external reset polarity and the lk2nd boot splash is still required on a live 2720 Flip; `devices/nokia-beatles/cover-panel.dtsi` remains a compile-checked reference for older DTBs. Run `bananarchy-cover-diagnose.sh` on the phone to check `/dev/fb1`, its geometry, the DRM cards, the loaded mux/panel modules, the firmware, the lid state and `bananarchy-coverctl STATUS` in one report. "Fully off" is a black frame plus `FBIOBLANK`/`FB_BLANK_POWERDOWN` on the fbdev (and the optional `backlight_path` sysfs node when present). - **Camera app frozen / UI unresponsive**: check `top` for `bananarchy-volume-keys`. The daemon must be a single instance at 0% CPU; stale evdev fds are pruned by `prune_devices()`/`drop_device()` and guarded by `flock`. `rc-service bananarchy-volume-keys status` and `bananarchy-keypad-diagnose.sh` report its state. `xcamera` should return immediately and `bananarchy-photo ` should write a 600x800 JPEG. - **Camera**: `/dev/video0` is provided by the out-of-tree `msm8905-cam` module, loaded at boot by `/etc/modules-load.d/bananarchy-hardware.conf` and `etc/local.d/10-bananarchy-hardware.start`. Check with `v4l2-ctl --list-devices`; a missing node means the module did not load (previously caused by a missing `/bin/sed` breaking the `modules` service). - **Side volume keys**: the compiled evdev daemon `bananarchy-volume-keys` reads `KEY_VOLUMEUP`/`KEY_VOLUMEDOWN` directly and calls `sxmo_audio.sh vol up/down 5`; `sxmo_audio.sh` mirrors that percentage into the live PipeWire sink (the MSM8905 mainline kernel has no ALSA card yet). Press a side button and check `wpctl get-volume `; `bananarchy-keypad-diagnose.sh` reports the XKB mapping and both volume values. diff --git a/README.md b/README.md index 76b3ee1..60f182d 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 `