diff --git a/AGENTS.md b/AGENTS.md index 014bf61..fdbc7ec 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,12 +30,12 @@ It uses a pure **X11 (`Xlibre` + `sxmo-de-dwm`)** stack (no Wayland) with **Adre - `nokia-beatles` boot chain: `images/boot-lk2nd-nokia-beatles.img` is built from upstream `msm8916-mainline/lk2nd` at pinned commit `cf45aefd22d744b2bf9b39455afae697ce430063` plus `bootloader/lk2nd/nokia-beatles.patch` (see `bootloader/lk2nd/README.md`; rebuild with `scripts/build-lk2nd-beatles.sh`). It keeps the upstream QCDT layout (both `0x14b` entries `0xb/0x100` and `0x1000b/0x100` sharing one `msm8905-qrd-skub` DTB, stock `qcom,board-id` order) with a compact `/lk2nd/nokia-beatles` node injected, and **adds `/cpus` with `cpu@0`..`cpu@3` and 4-byte `device_type` to the common `lk2nd.dtsi` so every QCDT DTB has it**. The 2720's MSM8905 is a partial-goods 2-core part and its aboot `ASSERT`s at `platform/msm_shared/partial_goods.c:80` when `/cpus`, `cpu@2` or `cpu@3` is missing — that was the actual "black screen / no fastboot" crash (Sahara MEMORY_DEBUG RLOG log, see `bootloader/lk2nd/README.md` and `backup/nokia-beatles-2720/crash-20261109/aboot-log.txt`). cmdline `lk2nd lk2nd.compatible=nokia,beatles`, `lk2nd,match-panel` for all three GC9305 panel names the aboot reports, and the single `qcom,mdss_spi_gc9305_v2_qvga_cmd` (the panel the live aboot reports) `lk2nd,panel-init` stream replayed on BLSP1 QUP5 (DC GPIO 110) only when aboot did not leave continuous splash enabled (or when `lk2nd.force-panel-init` is in the cmdline), so the 240x320 RGB565 main panel is initialized even without cont-splash. `spi-display.c` also paints the branded RGB565 boot splash into the framebuffer (without flushing during init): `DISABLE_SPLASH_PARTITION=1` plus `menu.c`'s bottom-only text means upstream lk2nd otherwise pushes a nearly black frame, which is what the "KaiOS logo then blank screen" is. `lk2nd/include/lk2nd/spi-panel-init.h` is shared with the host unit test; the repo copy is `bootloader/lk2nd/spi-panel-init.h` and `check-lk2nd-beatles.py` keeps them in sync and enforces that QCDT shape. Both the normal and diagnostic images carry `lk2nd.no-display` (RAM-only framebuffer, no QUP SPI before USB) because unbounded QUP/clock register polls used to wedge lk2nd with the boot vibrator stuck on. The port now bounds those polls (`QUP_FIFO_TIMEOUT`, `CLK_POLL_TIMEOUT`) and adds `oem display-init` / `oem display-test` / `oem scan-dtb` fastboot probes that run after USB is up, plus `oem screenshot` to verify the framebuffer. Live `oem display-init` confirmed the GC9305 v2 stream and the 240x320 RGB565 frame; a chain-loaded diagnostic falls back to the QCDT panel stream when aboot tags are absent, `oem scan-dtb` stages the final DTB after lk2nd DT updates, `oem ramoops console` validates and bounds pstore data, and the QUP per-word `SPEW` log is removed. The r3 port also makes `oem read-partition` block-safe: it rounds MMC reads up to the eMMC block size, rejects unaligned offsets and stages only the requested byte count. `images/boot-lk2nd-nokia-beatles-display.img` uses `lk2nd.display=on` for boot-time panel init via the downstream GC9305 v2 `lk2nd,panel-init` stream; flash it with `--lk2nd-image`. The diagnostic image additionally has `DEBUG=2 LK2ND_FORCE_FASTBOOT=1`. `check-lk2nd-beatles.py --expect-display` guards the display variant; `scripts/test-lk2nd-beatles-port.py` runs all three. lk2nd is confirmed working over live fastboot (`lk2nd:compatible=nokia,beatles`, `model=Nokia 2720 Flip`, panel `qcom,mdss_spi_gc9305_v2_qvga_cmd`, `unlocked=yes`). `flash-edl.py` defaults to `--method lk2nd` for every target; stock aboot accepts the port and lk2nd boots Bananarchy from `userdata` via `extlinux.conf` (`fdt /qcom-msm8905-nokia-beatles.dtb`). On `nokia-beatles` the default is now the Argon shape: lk2nd in `boot`, the standalone mainline `boot.img` in `recovery` (Volume Up fallback). `--method both` remains as a fallback that writes the standalone mainline `boot.img` to both slots. `--verify` reads back every slot and `--dump-diagnostics` saves small bootloader/config partitions for secure-boot analysis. `scripts/check-lk2nd-beatles.py` validates the boot header, both 2720 QCDT entries, `/cpus` in every QCDT DTB, the device node and the GC9305 v2 panel init stream; `scripts/test-lk2nd-beatles-port.py` adds the host C parser test. The stock 2720 aboot is locked (`devinfo.is_unlocked=0`) and verifies boot images against `Nokia_beatles ROOT CA0`; `flash-edl.py` therefore defaults to setting `devinfo.is_unlocked=1` on `nokia-beatles` via `unlock_devinfo()` before writing any boot image, saves `backup/devinfo-locked-.img`, and supports `--no-unlock-bootloader` to skip. `scripts/make-unlocked-devinfo.py` produces the same patched image offline. Correction: the GPT has `keystore` but no `keymaster`, so `target_get_vb_version()` returns `VB_L=1` while `VB_M=2`; aboot therefore reads `devinfo` from eMMC, not RPMB. The 21:25 dump confirms eMMC `is_unlocked=1`, so the unlock is effective and no stock fastboot / `oem unlock-go` step is required. `--only-unlock`, `enable_oem_unlock()` and `scripts/make-oem-unlock-config.py` remain as harmless optional prerequisites, not a boot requirement. The appended DTB must carry the exact stock `qcom,msm-id = <0x14b 0>`, `qcom,board-id = <0x1000b 0x100>` and `qcom,pmic-id = <0x1000d 0 0 0>` values; older aboot revisions read only the first `qcom,board-id` pair, so an extra `0x0b 0x100` variant ahead of it makes the DTB look like a different board (the lk2nd QCDT DTB keeps upstream's `0x0b` pair first). `/memory` keeps `device_type = "memory"` and a 512 MiB `reg = <0x80000000 0x20000000>` fallback, so a bootloader that fails to patch it still gives Linux usable RAM. `scripts/repack-beatles-bootimg.py` rebuilds only the standalone Android boot.img after a DTB change; `scripts/sync-beatles-bootfs.py` updates the boot.img, DTB and extlinux.conf inside the raw image's ext2 `pmOS_boot` filesystem (never write an Android boot.img at raw offset 1 MiB). The old binary-patched headless image and `scripts/make-beatles-lk2nd-bootimg.py` are gone. `check-beatles-bootimg.py`, `check-lk2nd-beatles.py` and `sync-beatles-bootfs.py --check` are all called by `check-rebuild.sh`, which also guards the port source files. The kernel display stack (`panel-mipi-dbi-spi` + beatles firmware, `CONFIG_DRM=y`, `CONFIG_SPI_QUP=y`) is correct; the `spi-mux` modules are built and loaded, but the external cover overlay remains hardware-gated until gpio13/reset/DC routing is confirmed. The stock boot chain passes the Power-menu reboot reason in `PON_SOFT_RB_SPARE[1:0]`; the port reads those low bits and writes low-bit cookies so the visible Fastboot menu survives `Reboot to bootloader` and `fastboot reboot-bootloader`. - `bootloader/loaders/`: device-specific signed Firehose programmers; `DEVICE_LOADERS` in `flash-edl.py` maps each target codename to one (`8k.mbn` serves both `nokia-sparkler` and `nokia-leo`), and `DEVICE_LOADER_VARIANTS` maps `--variant us` on `nokia-beatles` to `2720v.mbn` (`Nokia_bts_us`). Never flash a different device's programmer: Sahara rejects the signature and `--list-loaders` shows the embedded attestation identity. - `vendor/edl/`: vendored, patched EDL client library (MIT) used by `flash-edl.py`; a local `edl/` checkout or `BANANARCHY_EDL_DIR` overrides it. -- `scripts/rootfs-packages.txt`: single source of truth for the `armv7` rootfs package set, read by both `bootstrap-rootfs.sh` and `rebuild-image.sh`. It intentionally contains no `device-*` package; `scripts/apply-bananarchy-overlay.sh` installs the per-device `devices//modules-initfs` list as `/usr/share/mkinitfs/modules/00-device-.modules` (plus its `initramfs.load` mapping) so a clean-clone bootstrap still builds the correct initramfs. `scripts/check-rebuild.sh` guards this. +- `scripts/rootfs-packages.txt`: single source of truth for the `armv7` rootfs package set, read by both `bootstrap-rootfs.sh` and `rebuild-image.sh`. It intentionally contains no `device-*` package; `scripts/apply-bananarchy-overlay.sh` installs the per-device `devices//modules-initfs` list as `/usr/share/mkinitfs/modules/00-device-.modules` (plus its `initramfs.load` mapping) so a clean-clone bootstrap still builds the correct initramfs. `scripts/check-rebuild.sh` guards this. The package set also includes `msm-firmware-loader`, its OpenRC companion and `msm-firmware-loader-wcnss`; explicit sysinit/boot links are required because packages are installed with `--no-scripts`. This mounts the stock `modem` and `persist` partitions before udev and supplies WCNSS/modem firmware plus factory Wi-Fi NV data, allowing both `wlan0` and `hci0` to enumerate. - `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 only polls raw gpio36/gpio92 debugfs levels when no switch evdev is available. 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()`. The shipping beatles DTS keeps the known-good single internal panel and `spidev@1`; `cover-panel.dtsi` is again compile-checked but hardware-gated after live testing broke the main panel/keypad path. -- **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`. `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()`. The shipping beatles DTS keeps `spidev@1` and does not apply `cover-panel.dtsi`; the external panel remains hardware-gated. `dc_gpio = -1` remains in `/etc/bananarchy/cover-display.conf` for the retained native spidev fallback. +- **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()`. The shipping beatles DTS keeps the known-good single internal panel and `spidev@1`; `cover-panel.dtsi` is again compile-checked but hardware-gated after live testing broke the main panel/keypad path. +- **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()`. The shipping beatles DTS keeps `spidev@1` and does not apply `cover-panel.dtsi`; the external panel remains hardware-gated. `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`; `devices/nokia-beatles/cover-panel.dtsi` is a compile-checked but unapplied reference; `devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts` keeps the shipping single-panel layout, and `scripts/check-rebuild.sh` verifies DTB/DTS sync and rejects an accidentally applied cover overlay. 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` and the external node's missing `dc-gpios` property keep it from fighting `panel-mipi-dbi-spi` for gpio110. gpio13 selection and external reset polarity still require a physical cover-panel sign-off. diff --git a/CHANGELOG.md b/CHANGELOG.md index 618f24e..10efb49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,372 +9,36 @@ Release versions follow the `
` format (where `2026` is `a`, --- -## Unreleased — target hostnames and verified bootloader reboot +## Unreleased -- **Target-specific hostname**: added `scripts/set-bananarchy-hostname.sh` as the single source for `/etc/hostname`, `/etc/hosts` and the OpenRC hostname runlevel link. Both the clean bootstrap and the overlay application call it, so `nokia-argon`, `nokia-beatles`, `nokia-tough`, `nokia-sparkler` and `nokia-leo` images no longer inherit the `nokia-argon` default. `check-rebuild.sh` executes the helper for all five canonical targets and guards the default `147147` unlock passcode hash generation; the locker/passcode path was left unchanged after the user confirmed it works. -- **Reboot to bootloader**: the Power menu item is now **Reboot to bootloader** and calls `sxmo_power.sh bootloader` (the `loader` alias remains). The torch module writes the low-only `FASTBOOT_MODE` cookie on the beatles stock chain and the dual low/high cookie on other targets, so both the patched beatles lk2nd and generic lk2nd can read the reboot reason. The rebuilt module keeps the `6.12.1-msm8916 SMP preempt mod_unload ARMv7 p2v8` vermagic. -- **Cookie-enabled display lk2nd**: rebuilt `images/boot-lk2nd-nokia-beatles-display.img` from the pinned upstream commit and patch. Its hash is `b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d`, the same source-built image whose visible Fastboot menu was previously live-verified. The temporary `--allow-missing-cookie` validator escape was removed; `prepare-release.sh` now rebuilds stale or missing lk2nd images before packaging. -- **Minimal image update**: patched only hostname/hosts, the dmenu label, the power/context menu text, `sxmo_power.sh` and the torch module inside both local raw images; `locker.so`, `dwm`, the X session and the known-good main-panel stack are unchanged. New local raw image hashes are `69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08` for `nokia-argon` and `f4e9b8b2b36d4ffa9ba4f74de293b14f16b5ed45bbd5ab1d62bc2023242b73b2` for `nokia-beatles`; both standalone and raw boot filesystems are unchanged. -- **Validation**: `check-rebuild.sh` passes with and without local `images/`, `sync-prebuilt-overlay.sh --check` reports zero drift, `test-lk2nd-beatles-port.py` requires the reboot cookie, `check-beatles-bootimg.py` and `sync-beatles-bootfs.py --check` pass, and `e2fsck -fn` is clean on both patched root filesystems. Both `nokia-argon` and `nokia-beatles` were rebuilt into scratch `IMAGES_DIR` outputs with `--mkinitfs`; each image has the correct hostname, menu label and rebuilt torch module, and both source-built boot images pass the boot-image validator. The exact `b554…` lk2nd image was live-verified earlier; no additional EDL/fastboot reboot loop was performed. +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. -## Unreleased — decisive known-good 2720 Flip recovery +### Nokia 2720 Flip hardware -- **Live regression**: after the final `a1108` image set, X started and SSH worked, but the user saw a garbled main panel and reported that input was unresponsive. X inspection found a viewable `dmenu` window holding the keyboard path; `xdotool key Escape` unmapped it. The fullscreen `Phone Lock` window was already unmapped. -- **One decisive recovery**: entered EDL directly from Linux with `next_reboot_mode=edl`, then performed one verified `--method lk2nd` flash from the last physically working `images-before-release` set. No fastboot/menu reboot loop was used. -- **Recovery image hashes**: - - raw `bananarchy-nokia-beatles.img`: `e2267187c58920b5c5b822d940b81e0df8f59e7788fed00e3d31dfbdb290c7fc` - - standalone `boot-bananarchy-nokia-beatles.img`: `6715abd414fd02fd21ca8c2cd621a8a21e78f46d079b2d185b38a1f7a4a3e659` - - display `boot-lk2nd-nokia-beatles-display.img`: `e1fdd8551b6393184a465638881b63ca58c04e1e8f655f092260a18379e1cbe6` - - shipping DTB remains `8a14f7bc0499c254da9fb524fba1ef3ce0a3e721afb8ee43d37d72a75b615b3b`. -- **Flash result**: `boot` and `recovery` read-back matched, `userdata` wrote successfully, the stock `system` superblock was cleared, and reset returned `18d1:d001` Linux USB with root SSH, user network, Xorg and dwm running. -- **Post-boot state**: `state=unlock`, no lock flag, backlight 14, `xset` OK, `keypad`, `gpio-keys` and `pm8941_pwrkey` enumerated by X, `fb0=240,320` at 32 bpp, `/dev/fb1` absent, no `spi_mux`/`mux_gpio`/`mux_core` loaded, and both `dmenu` and `Phone Lock` windows unmapped. The X screenshot is a normal 240x320 desktop with 12118 colors rather than a garbled or blank frame. -- **Release note**: the verified `images/` artifacts are local build outputs and are not tracked in git. `scripts/check-rebuild.sh` pins their hashes when present; `prepare-release.sh` rebuilds missing artifacts from source and copies `bootloader/lk2nd-msm8909.img` for non-beatles targets. `BA_REBUILD=1` remains the explicit forced-rebuild path. -- **Final source guard**: `dwm` is back on the known-good 350 ms wake guard, and the X session performs one startup `dmenu` close plus `Escape` to release stale keyboard grabs. The later release image is rebuilt from source and now requires the low-bit reboot cookie; `--allow-missing-cookie` was removed. -- **Cleanup**: EDL backup dumps, local lk2nd build caches, Python bytecode, stale diagnostic boot images and scratch logs were removed from the release tree. Image blobs were removed from git tracking while the local verified copies remain available for immediate packaging and flashing. Both `nokia-argon` and `nokia-beatles` images were rebuilt into scratch output directories and validated for flashability without overwriting the verified release images. +- **Wi-Fi, Bluetooth, and modem firmware**: added `msm-firmware-loader` and its OpenRC services so the phone's signed firmware and factory NV data are loaded from the stock `modem` and `persist` partitions before udev. This fixed the missing `wcnss.mdt` failure that prevented both `wlan0` and `hci0` from appearing. Wi-Fi scanning, Bluetooth discovery, and cold-boot enumeration were verified on the phone. +- **Camera**: `/dev/video0` now rotates frames 180 degrees only on `nokia-beatles`, correcting the sensor mounting for the viewfinder, saved photos, and other V4L2 consumers. Camera autoloading and the side-volume daemon were also repaired; the daemon prunes stale input descriptors instead of spinning at full CPU. +- **High-brightness display corruption**: reduced the internal panel's SPI clock from 50 MHz to 25 MHz. The full brightness range remains available, and the user confirmed that levels above the former 71% threshold no longer distort the image. Other targets and the diagnostic spidev path are unchanged. +- **Flip detection**: the compiled lid daemon combines event-driven switch handling with raw gpio36/gpio92 reconciliation every 200 ms and an 80 ms debounce. Close/open actions were verified on the phone with controlled GPIO transitions: closing blanks and locks the screen; opening restores and unlocks it. +- **Input and audio startup**: restored the complete BusyBox applet set, udev input tagging, and Xorg keypad rules so the keypad and power controls work after a clean flash. Replaced Python idle daemons with compiled ARM services, retained the known-good 350 ms wake guard, and added one-shot cleanup for stale startup keyboard grabs. +- **SSH and display startup**: fixed PAM/password/key login, retained the USB-only fallback listener, restored the release boot splash, enabled parallel OpenRC startup with bounded udev settling, and made a boot-open flip start unlocked. -## Unreleased — cover overlay rollback after live regression +### Bootloader and recovery -- **Live failure**: with the `spi-mux` cover overlay applied, X reported viewable dmenu windows and the keypad watcher logged both raw evdev and X key events, but the user still saw no dmenu and reported the keypad and main panel as unresponsive. Plymouth also disappeared from the visible boot chain. The external overlay is therefore not safe to ship on this unit. -- **Rollback**: restored the known-good single-panel beatles DTB (`8a14f7bc...`), removed the folded `spi-mux`/`gpio-mux`/external-panel nodes from `qcom-msm8905-nokia-beatles.dts`, restored `spidev@1` and kept `cover-panel.dtsi` as a compile-checked but unapplied hardware-gated reference. `check-rebuild.sh` now rejects a shipping DTB that contains the cover overlay. -- **Live state after rollback**: forced sysrq reboot with the base DTB, `/dev/fb0` is again 240x320 internal, `/dev/fb1` is absent, `bananarchy-coverctl STATUS` reports `backend=none`, `state=unlock`, backlight 14, no lock flag, and no kernel oops or RCU stall. -- **Kept fixes**: OpenRC parallel startup with the patched `local` service, bounded `udevadm settle`, independent USB fallback sshd, event-driven 80 ms lid debounce, boot-open unlock guard, compiled C daemons and 32-bpp cover renderer code remain; the 120 ms keypad wake experiment was reverted to the physically verified 350 ms guard, and the X session now releases stale `dmenu`/xlocker keyboard grabs once at startup. The cover renderer is idle until hardware exposes `/dev/fb1`. -- **Finalized release method**: the physically verified known-good raw image, standalone boot image and display lk2nd image hashes are pinned by `scripts/check-rebuild.sh`. The later release image is rebuilt from source and now requires the low-bit reboot cookie; `--allow-missing-cookie` was removed. `prepare-release.sh` packages the verified images by default; set `BA_REBUILD=1` to regenerate them from source. -- **Cleanup**: removed EDL backup dumps, local lk2nd build caches and Python bytecode from the release tree. Temporary diagnostic images and scratch logs are no longer part of the shipped release set. -- **Release state**: the raw image, standalone boot image and validators are rebuilt against the rolled-back DTB. Physical main-panel/keypad verification after this rollback is required before any further cover-panel work. +- **Reliable lk2nd port**: preserved the stock QCDT shape and exact 2720 identifiers, added the `/cpus` nodes required by the partial-goods dual-core aboot, and added the GC9305 panel init path and branded splash. The source-built normal, diagnostic, and display images are reproducible from the pinned upstream commit. +- **Visible Fastboot and safe diagnostics**: added bounded QUP/clock polling, display and DTB probes, block-safe partition reads, and the low-bit reboot cookie used by **Reboot to bootloader**. The display-enabled lk2nd image is the default; diagnostic images remain available separately. +- **Mainline boot fixes**: removed the crashing `earlycon` option, restored `/sbin/init`, preserved the exact stock DTB identifiers and 512 MiB memory fallback, and repaired the nested `pmOS_boot` ext2 filesystem and `extlinux.conf` handling. +- **Consistent boot slots**: normal startup uses lk2nd from `boot` and the mainline system from `userdata`; `recovery` holds the standalone mainline boot image for the Volume Up path. -## Unreleased — startup, keypad and cover-panel regression fixes +### Flashing and external display status -- **X startup**: measured `Xorg` starting 48.92 s after kernel boot, with an approximately 27 s gap between the early sysinit services and the default runlevel. The unbounded sysinit `udev-settle` service was the gate: missing modem firmware keeps udev events pending. `overlay/rootfs/etc/conf.d/udev-settle` pins `udev_settle_timeout=2` and `bananarchy-lid` starts before `tinydm` so the X session does not wait for the modem/network chain. A live test with `rc_parallel="YES"` moved Xorg from 48.92 s to 27.96 s, but the stock OpenRC `local` service deadlocked on its `after *` dependency. `etc/init.d/local` is now patched to `after modules udev-settle`, parallel startup is enabled, and `bananarchy-sshd-debug` is an independent default-runlevel service. -- **Boot keypad**: `bananarchy-x11-session.sh` previously always wrote `/tmp/bananarchy_screen_locked` and `state=lock`, mapping a fullscreen `Phone Lock` window that consumed keys. The flip X session now waits up to 2 s for `/run/bananarchy/lid-state`; an open lid removes the lock flag and starts `state=unlock`, while a closed lid starts `screenoff` with both backlights off. `locker.so` now accepts a trusted `CLOSE` after the root lid daemon clears the lock flag, releasing any stale keyboard grab and unmapping the lock window. -- **Lid reaction**: the 600 ms debugfs-polling debounce was replaced with an event-driven `EV_SW` switch-mask reader on `/dev/input/event2` (`SW_LID` and `SW_KEYPAD_SLIDE`), an 80 ms stability window and debugfs gpio36/gpio92 only as fallback. The daemon writes the boot state file, directly writes `brightness`/`bl_power`/keypad LED before spawning the measured 2.4 s `sxmo_state.sh set screenoff` hook, and clears the lock flag before `sxmo_state.sh set unlock`. -- **Cover display**: The cover-panel nodes are folded directly into `devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts`; `cover-panel.dtsi` remains a compile-checked reference. The shipping DTB disables the conflicting `spidev@1`, adds `gpio-mux` on gpio13 and `spi-mux` with internal `display@0` registered before external `display@1`, and omits `dc-gpios` on the external panel so `mipi_dbi_spi_init()` uses 9-bit MIPI DBI Type C Option 1 SPI instead of fighting the internal panel for gpio110. `bananarchy-cover-idle` renders `TEST bars`, `TEST solid`, `TEST off` and the clock to `/dev/fb1`; `check-rebuild.sh` verifies the final DTB contains the overlay and stock qcom IDs. Physical gpio13 selection and external reset polarity still require user sign-off. -- **Cover renderer bus error**: the shipping `/dev/fb1` is a 32-bpp DRM fbdev (`bits_per_pixel=32`, `stride=960`, `smem_len=230400`). The old 16-bpp `mmap()`/`msync()` renderer received `SIGBUS` on the first pixel write. `bananarchy-cover-idle` now reads the fbdev geometry from sysfs, renders XRGB8888 into a shadow buffer and commits it with `write()` plus `fsync()`. Live `bananarchy-coverctl STATUS` reports `backend=fb`, `TEST bars` writes a nonblank framebuffer, and the service stays started. -- **Validation state**: the connected phone was force-rebooted after the earlier `reboot -f` did not fire. OpenRC parallel startup with the patched `local` service puts Xorg at 27.38 s and `dwm` at 30.74 s, with root SSH on port 2222, `local`, `bananarchy-lid`, `bananarchy-sshd-debug` and `bananarchy-cover-display` all started. `/dev/fb0` is 240x320 internal, `/dev/fb1` is 240x240 external, and there is no kernel oops or RCU stall. A transient boot xlocker mapping was fixed with a 10 s open-lid unlock guard; after an X restart the phone is `state=unlock`, the lock window is unmapped and backlight/keypad are on. No Python daemon or network poller is present. The final raw image, standalone boot image, lk2nd images, all offline validators and `e2fsck -fn` pass. Physical keypad, flip close/open and cover-panel appearance still require user sign-off; the cover overlay was subsequently rolled back after a live regression. +- **Device-aware EDL flashing**: added the correct signed Firehose programmer for every target, including the 2720 US variant, plus loader identity listing and EDL PID detection. The 2720 flow unlocks eMMC `devinfo`, supports config/FRP preparation, verifies boot-slot reads, writes each slot from the correct image, and wipes the stock system superblock by default with `--no-wipe-system` as the opt-out. +- **External cover remains hardware-gated**: the experimental spi-mux cover overlay was rolled back after it broke the main panel/keypad path. The shipping DTB keeps the known-good internal panel and `spidev@1`; `cover-panel.dtsi` is compile-checked but not applied. The compiled cover renderer remains idle until the external panel wiring is validated. -## Unreleased — lid hall-sensor debounce +### Build and release hygiene -- Stopping the compiled lid daemon held the phone at `state=unlock`, `lock=no`, backlight 14 with both hall lines high, proving the repeated `screenoff` was caused by a momentary hall/GPIO transition rather than missing keypad events. Added `LID_STABLE_MS 600` to `bananarchy-lid`: a candidate open/closed state must remain stable for 600 ms before `sxmo_state.sh set screenoff`/`unlock` and backlight/cover IPC actions run. `check-rebuild.sh` guards against the old immediate-transition logic. -- Deployed the debounced ARM `bananarchy-lid` to the live phone and restarted the service. With both hall lines high, the phone stayed `state=unlock`, `lock=no`, backlight 14 for the full observation window, with no Python process and no network poller. The final image set was rebuilt with the debounced daemon and all offline validators pass. - -## Unreleased — keypad wake and lock-screen diagnosis - -- The keypad watcher showed 27 raw kernel key presses and 29 X key presses with matching releases: the matrix, udev, Xorg and XKB path is not dropping keys. The phone was on the fullscreen `Phone Lock` passcode screen, so xlocker intentionally consumed those events. Unlocking via the locker IPC restored `state=unlock`, removed `/tmp/bananarchy_screen_locked`, unmapped the lock window and restored the backlight. -- Reduced the post-wake input suppression in `dwm` from 350 ms key / 500 ms softkey to a 120 ms `WAKE_KEY_DEBOUNCE_MS`, and reduced locker unlock/locking suppression from 350/400/80 ms to 120/120/40 ms. This removes the "press again" feel immediately after wake or unlock while retaining a short guard against accidental wake keys. -- Rebuilt `dwm` and `locker.so`, restarted the X session and re-unlocked the live phone. State is `unlock`, the lock window is unmapped, backlight is restored, no Python process remains in the idle system, no `nmcli device monitor` poller is running and the shell-only keypad watcher was restarted. The final image set was rebuilt with the new X11 binaries and debounce guards; `check-rebuild.sh`, boot/DTB/lk2nd validators and `e2fsck -fn` pass. A fresh physical key test is still required after the unlock. - -## Unreleased — compiled idle daemons and keypad latency - -- **No Python-based idle daemons**: rewrote `bananarchy-lid`, `bananarchy-cover-idle` and `bananarchy-volume-keys` as dependency-free C ARM binaries under `src/bananarchy-daemons/`, added `scripts/build-bananarchy-daemons.sh`, removed the three `.py` daemons from the shipping overlay and switched all OpenRC services to the compiled commands. A `SIGCHLD` reaper prevents the zombie `sxmo_state.sh`/`sxmo_audio.sh` children left by the Python daemons; `poll()` loops, stale-fd pruning and `flock` singletons keep the idle CPU near zero. `check-rebuild.sh` now fails if any retired Python daemon script or service reference returns. -- **Keypad latency**: the X session now sets `xset r rate 180 30` instead of the 660 ms default auto-repeat delay, and the session hooks stop the leftover `nmcli device monitor` poller. The temporary Python physical-verification watcher was removed; a shell-only keypad watcher is used when capturing physical key events. -- **Live verification**: no `python3` process remains in the idle system, the three compiled services are started, `bananarchy-coverctl STATUS` round-trips, X reports `auto repeat delay: 180 / repeat rate: 30`, the `nmcli device monitor` poller is gone, there are zero zombie children, and a 2 s `/proc/stat` sample reports 96% idle. The final raw image was rebuilt with the compiled binaries, no retired `.py` daemon scripts and service commands pointing at the compiled ARM ELF files; `check-rebuild.sh`, boot/DTB/lk2nd validators, `sync-beatles-bootfs.py --check` and `e2fsck -fn` pass. A shell-only keypad watcher logs raw evdev and X events to `/run/bananarchy-keypad-verify.log`; the user still needs to press keys and report whether the keypad feels responsive. - -## Unreleased — lk2nd menu and release hygiene - -- **lk2nd Fastboot menu restored**: the Power menu's `sxmo_power.sh bootloader` writes `FASTBOOT_MODE` into `PON_SOFT_RB_SPARE[1:0]`, but the stock boot chain scrubs bits `[7:2]` before chain-loading lk2nd while upstream lk2nd only reads those high bits. `platform/msm_shared/reboot.c` now prefers the low-bit cookie and writes low-bit cookies for all small reboot reasons, while still accepting the high-bit `fastboot reboot-bootloader` cookie. The display-enabled image is the default for `flash-edl.py`, `check-rebuild.sh` validates it, and `prepare-release.sh` packages it. Live verification: the Power-menu cookie reaches lk2nd fastboot in 6 s, `fastboot oem screenshot` stages a 240x320 frame with the menu text, `fastboot getvar lk2nd:version` reports `bananarchy-beatles-a1109-display-r3`, and `fastboot reboot-bootloader` returns to the same lk2nd menu. Use `fastboot reboot` to return to Linux. -- **Abandoned pstore_blk diagnostics removed**: `CONFIG_PSTORE_BLK`, `CONFIG_PSTORE_ZONE` and the scratch `cache` PARTUUID settings are gone from the kernel config copies; `vmlinuz`, `System.map`, config, modules and DTBs were rebuilt from the clean config. `pstore_blk_get_config` no longer appears in either shipped `System.map`, and the stale `-debug`/`-ramoops` standalone boot images were removed. -- **Cover kernel modules built**: `scripts/build-kernel-audio.sh` now builds and exports `mux-core.ko.zst`, `mux-gpio.ko.zst` and `spi-mux.ko.zst`; `modules-load.d/bananarchy-hardware.conf` and `local.d/10-bananarchy-hardware.start` load them, and `check-rebuild.sh` guards the modules, config and release hygiene. `devices/nokia-beatles/cover-panel.dtsi` remains opt-in: gpio13 polarity and external reset/DC routing still require physical validation before it is applied to the shipping DTB. -- **Full clean rebuild**: `./rebuild-image.sh nokia-beatles --mkinitfs` was rerun against an empty scratch rootfs with the pinned `a1108` / `dejavu` release. It regenerated `images/bananarchy-nokia-beatles.img` and `images/boot-bananarchy-nokia-beatles.img`; `check-rebuild.sh`, `check-beatles-bootimg.py`, `sync-beatles-bootfs.py --check`, `build-lk2nd-beatles.sh --check`, `test-lk2nd-beatles-port.py`, Python/shell syntax checks and `e2fsck -fn` all pass. A dangling `/bin/linux32` BusyBox symlink from the fresh package set initially aborted the overlay; `apply-bananarchy-overlay.sh` now removes dangling symlinks before recreating them and `check-rebuild.sh` guards that path. -- **Final EDL flash**: the EDL menu path entered `05c6:9008`, the clean image set was flashed with `--verify`, the live `boot` partition read back as the display lk2nd image, and the post-reset `lk2nd:version` matched before `fastboot reboot` returned to Linux. Main and fallback SSH, `a1108` / `dejavu`, release `quiet splash` cmdline, loaded `mux-core`/`mux-gpio`/`spi-mux`, camera/spidev nodes, X keypad devices and idle lid/cover/volume services were verified. The abandoned `--debug-boot` flasher path was removed with its stale diagnostic images. A temporary hardware watcher now logs lid transitions to `/run/bananarchy-physical-verify.log`; the user still needs to close/open the flip and visually inspect the cover display. -- **Physical verification**: the lid daemon's close/open transitions are unit-tested and live services are idle, but final physical lid close/open and cover-panel appearance must be confirmed on the final flashed image by the user. - -## Unreleased — flip lid handling, idle cover daemon - -- **Closing the lid did not blank/lock**: `dwm` only reacts to `SW_LID` and then re-checks `EVIOCGSW` 60 ms later, but the 2720 hall sensors are effectively momentary and `EVIOCGSW` reads back 0 while the native cover daemon still reports `lid=closed`. Added `bananarchy-lid.py` (OpenRC service `bananarchy-lid`) with a singleton lock, stale-fd pruning and 0.2 s polling. It reads the raw hall levels from debugfs gpio (gpio36/gpio92 are `in high` with the flip open and go `low` on close) as the authoritative signal, with EV_SW events as a fallback; it handles both `SW_LID` and `SW_KEYPAD_SLIDE`. On close it runs `sxmo_state.sh set screenoff` (which already blanks the backlight, turns the keypad LED off and writes the lock file), forces both backlight sysfs nodes to 0 and tells the cover daemon `LID CLOSED`; on open it runs `sxmo_state.sh set unlock` and restores them. Verified live: close -> `state=screenoff`, backlight 0, keypad LED 0, lock file present; open -> `state=lock`, backlight 10, keypad LED 1. -- **Cover daemon CPU spin**: the recovered native `bananarchy-coverd` busy-loops at ~100% CPU on every backend (`none`, `sim`, `spidev` all measured ~100 ticks/s) and paints nothing because gpio110 (DC) is owned exclusively by `panel-mipi-dbi-spi`. Replaced it in the default runlevel with `bananarchy-cover-idle.py`: a 0%-CPU Unix datagram server that keeps the full `bananarchy-coverctl` protocol (PING/STATUS/LID/NOTIFY/CALL/SMS/BATTERY/TEST/REFRESH/QUIT), tracks lid state and renders a 240x240 RGB565 clock to `/dev/fb1` as soon as the kernel exposes it. Verified `STATUS`/`LID CLOSED` round-trips and all three daemons at 0% CPU. -- **Cover panel still blank**: there is no `/dev/fb1` (or usable `/dev/spidev0.1` DC line). The remaining work is kernel-side: build `mux-core`/`mux-gpio`/`spi-mux` (`CONFIG_MULTIPLEXER`/`CONFIG_MUX_GPIO`/`CONFIG_SPI_MUX` are already `=m`), wire the compile-tested `cover-panel.dtsi` into the DTB so a second `panel-mipi-dbi-spi` exposes `/dev/fb1`, and confirm how the gpio13/gpio36 switch routes DC/CS. The userspace renderer is ready and waiting. -- `check-rebuild.sh` guards the lid daemon, its debugfs fallback, the idle cover daemon and the service wiring. - -## Unreleased — volume daemon CPU-spin regression (camera app appeared hung) - -- The camera plugin was not hung: it was sleeping normally in `poll()` but starved of CPU. Two `bananarchy-volume-keys.py` instances (one from OpenRC, one left over from a debug run) were each burning ~44% CPU because destroyed uinput test devices left `(deleted)` evdev fds that `select()` reports readable forever, and the read-error path just looped. On the 2-core MSM8905 that left 0% idle and froze the whole UI. -- The daemon now: takes an exclusive `flock` singleton, prunes stale fds on every rescan, closes/forgets any fd that raises `ENODEV`/`EIO`, never passes evdev fds as `exceptfds` (real key events can be reported exceptional, which dropped the fd before reading), and sleeps briefly on errors. Verified after the fix: one daemon at 0% CPU, 95% idle. -- `apply()` used `/usr/bin/su`, which does not exist (BusyBox `su` is `/bin/su`), so injected volume events were seen but no volume change happened. It now spawns `sxmo_audio.sh` directly with `user=10000, group=10000` and an explicit session environment, falling back to `/bin/su`. -- The `bananarchy_vol_debounce()` used a lock directory released by a background subshell; replaced with a `/proc/uptime` timestamp so a stale lock can never block future volume steps. -- Verified live after the fix: injected `KEY_VOLUMEUP` moves logical 90 -> 95 and the PipeWire sink 0.90 -> 0.95; `xcamera` returns immediately and `bananarchy-photo` produces a valid 600x800 JPEG in both repeated runs. - -## Unreleased — camera, side volume keys, cover-panel spidev device - -- **Camera persistence**: `msm8905-cam.ko` is in the image but the boot-runlevel `modules` service silently skipped most of `/etc/modules` (it needs `/bin/sed`, one of the missing BusyBox applets). `modprobe msm8905-cam` registers `/dev/video0` and `v4l2-ctl --stream-mmap` captures a real 800x600 RGB3 frame. Added `etc/modules-load.d/bananarchy-hardware.conf` and a `etc/local.d/10-bananarchy-hardware.start` retry loop so `msm8905-cam` and `spidev` are always loaded; verified `/dev/video0` exists after a full reboot. Also restored the 33 missing `/sbin` BusyBox applets (`reboot`, `poweroff`, `halt`, `syslogd`, `klogd`, `mdev`, `ip-*` ...) via `scripts/busybox-sbin-applets.txt`; `/sbin/reboot` was missing, which is why the Sxmo power menu and earlier reboot attempts did nothing. -- **Volume keys actually change volume**: the side rocker (`gpio-keys` KEY_VOLUMEUP / `pm8941_resin` KEY_VOLUMEDOWN) now reaches X with the correct `XF86AudioRaiseVolume`/`XF86AudioLowerVolume` XKB symbols, but `apply_vol_out()` pinned the PipeWire sink to a fixed 100% through `pactl set-sink-volume @DEFAULT_SINK@`, which does not resolve when wireplumber has no default configured node. Added `bananarchy_set_sink_volume()` to `sxmo_audio.sh`: it finds the first live sink id from `wpctl status` and sets it to the sxmo logical percentage (falling back to `pactl`). Verified `sxmo_audio.sh vol up 5` moves the sink 0.60 -> 0.65. Because synthetic XTest/uinput keys did not always trigger dwm's passive X grab, added `bananarchy-volume-keys.py` (a dependency-free evdev reader for KEY_VOLUMEUP/KEY_VOLUMEDOWN) with an OpenRC service, plus a 300 ms `bananarchy_vol_debounce()` in `sxmo_audio.sh` so the X and evdev paths cannot double-step. Verified with injected uinput key events: logical 80 -> 85 and PipeWire sink 0.80 -> 0.85. -- **Cover display kernel path**: added `spidev@1` (`rohm,dh2228fv`, reg 1, 50 MHz) under `spi@78b9000` to the shipping DTS/DTB, the kernel patch notes, the standalone boot.img appended DTB, `prebuilt/.../dtbs/` and the raw image's bootfs. `spi-qup` has 4 native chip selects and `spi_qup_set_cs()` always toggles the single physical CS line, so `display@0` keeps driving the internal panel while the daemon gets a second logical device. After reboot `/dev/spidev0.1` exists and `bananarchy-coverd` reports `backend=spidev` (it previously reported `backend=none`). GPIO 110 (the shared DC line) is claimed exclusively by `panel-mipi-dbi-spi`, so `dc_gpio = -1` in `/etc/bananarchy/cover-display.conf` lets the spidev backend open without fighting the kernel driver; gpio13 (mux) and gpio23 (reset) are free and used by the daemon. Fully driving the cover panel's DC still requires the `spi-mux` kernel modules plus hardware confirmation of how the switch routes DC/CS; `CONFIG_MULTIPLEXER`/`CONFIG_MUX_GPIO`/`CONFIG_SPI_MUX` and the compile-tested `cover-panel.dtsi` overlay are staged for that next step. -- `check-rebuild.sh` now guards the camera auto-load, `/sbin` applet list, PipeWire sink mirroring, the evdev volume daemon and debounce, and the `spidev@1` DT node. - -## Unreleased — live boot verification: BusyBox applets, keypad, lk2nd splash - - -- Reflashed the fixed image over EDL and booted successfully. Plymouth now shows its boot splash between lk2nd and X; after that `ssh user@172.16.42.1` with `147147` and `keys/phone_id_ed25519` both work on port 22, and the USB-only fallback works on port 2222. -- **Actual SSH root cause**: the flashed rootfs was missing 35 BusyBox applet symlinks, including `/bin/ash` (the `user` login shell) and `/bin/grep`. sshd refuses an account whose shell does not exist, so `user` was rejected even though the shadow hash and PAM stack were correct; `root` (shell `/bin/sh`) always worked. Restored the full canonical applet list via `scripts/busybox-applets.txt`, made `apply-bananarchy-overlay.sh` fill in missing symlinks on any rootfs, and added an offline `debugfs` guard that fails `check-rebuild.sh` if the shipped image lacks `/bin/ash`. -- **Actual keypad root cause**: without `/bin/grep`, OpenRC's `openrc-run.sh` cannot start the `udev` service in the sysinit runlevel (`CONFIG_DEVTMPFS=y is required...` was a misleading downstream error). With no udev, `/dev/input/event*` stayed `0600 root:root` and had no `ID_INPUT_KEYBOARD`/`seat` tags, so elogind never handed them to the non-root X server and `xinput list` showed only the virtual core devices. Starting udev after restoring the applets produced `crw-rw---- root:input` nodes, added all four keyboards to seat0, and after `rc-service tinydm restart` Xorg enumerates `keypad`, `gpio-keys`, `pm8941_pwrkey` and `pm8941_resin`. Added `99-bananarchy-input-seat.rules` so the seat tag is guaranteed. -- **lk2nd boot screen**: replaced the striped RGB565 test pattern in `paint_boot_banner()` with a compact branded splash (dark background, banana crescent, `BANANARCHY` / `LINUX` wordmark from a built-in 5x7 font, and a progress bar). It uses only integer RGB565 writes, needs no image decoder or new library, and is still safe before the SPI bus is proven. All three lk2nd images were rebuilt and revalidated; the display variant was written to the phone's `boot` partition and read back byte-for-byte. -- **Cover display**: the shipped image already contained a native `bananarchy-coverd`/`bananarchy-coverctl` daemon, config, lid profile, udev rule and service that were absent from the source tree. A first attempt replaced it with a Python renderer; that has been reverted and the original ARM binaries recovered into `prebuilt/bananarchy-coverd/` and mirrored into the overlay, so clean rebuilds reproduce them. The daemon now starts (`backend=none`) and its IPC socket answers `STATUS`; it will switch to `fb` or `spidev` automatically as soon as the kernel exposes `/dev/fb1` or `/dev/spidev0.1`. That still requires the `spi-mux` kernel modules from `CONFIG_MULTIPLEXER`/`CONFIG_MUX_GPIO`/`CONFIG_SPI_MUX` plus the hardware-validated `cover-panel.dtsi` overlay; it is the one remaining hardware-gated item. -- Verified after a full power cycle: `user/147147` and key login on port 22, `/bin/{ash,grep,sed,ps}`, `udev` started, all four keyboards attached to X, `quiet splash plymouth.*` in `extlinux.conf`, and the new lk2nd image hash in `boot`. - -## Unreleased — first boot fixes: USB SSH, boot splash, keypad input, cover display - - -- **USB SSH login**: the shipped image rejected `user / 147147`. The postmarketOS drop-in sets `UsePAM yes`, which makes `/etc/init.d/sshd` select `/usr/sbin/sshd.pam`; the plain `/usr/sbin/sshd` rejects that very directive as an unsupported option, and the image's `/etc/shadow` had been hand-edited with empty aging fields (`sp_lstchg == 0`). Added an explicit `/etc/pam.d/sshd` PAM stack, `PasswordAuthentication yes` / `KbdInteractiveAuthentication yes`, `SSHD_BINARY="/usr/sbin/sshd.pam"`, proper shadow aging fields, `sshd` in the `shadow` group, and `authorized_keys` for `user` and `root` (mode 0700/0600, correct uids). A second USB-only listener (`/etc/ssh/sshd_config_debug`, port 2222 bound to 172.16.42.1) uses the non-PAM binary with no `UsePAM` directive, so a broken PAM stack can never lock the developer out. Both sshd variants were verified under ARM emulation: password `147147` and the injected key both log in. -- **Boot splash**: `scripts/sync-beatles-bootfs.py --debug-cmdline` had replaced `quiet splash` with `loglevel=8 ignore_loglevel initcall_debug panic=10` in the shipped `extlinux.conf`. The pmOS initramfs defaults to `nosplash=y` and only starts `plymouthd` when the literal `splash` parameter is present, so the screen stayed on lk2nd's blue stripes until X started. The shipping cmdline is restored to `quiet splash plymouth.ignore-serial-consoles plymouth.prefer-fbcon`; the sync tool can now restore it, and both boot-image and bootfs validators reject debug cmdlines and require `splash`. -- **Keypad input**: the DT matrix is correct (the mainline `matrix_keypad` driver cancels `gpio-activelow` against `GPIO_ACTIVE_LOW` exactly as needed), so the failure is in userspace device classification. Added `99-bananarchy-keypad.rules` (forces `ID_INPUT_KEYBOARD`, `input` group, mode 0660), an explicit Xorg `InputClass` matching `MatchProduct "keypad"` without relying on that udev tag, and `bananarchy-keypad-diagnose.sh` to dump devices, switch states, dmesg and X input state for live `evtest` diagnosis. -- **Cover display**: committed the external GC9305 firmware and init notes (`nokia,beatles-gc9305-ext-panel.bin/.txt`) that existed only inside the flashed image, enabled `CONFIG_MULTIPLEXER`, `CONFIG_MUX_GPIO` and `CONFIG_SPI_MUX` in the kernel config, added the compile-tested `devices/nokia-beatles/cover-panel.dtsi` spi-mux overlay, and recovered the native `bananarchy-coverd`/`bananarchy-coverctl` daemon, its config, lid profile, udev rule and OpenRC service from the shipped image into `prebuilt/bananarchy-coverd/` and the overlay (they were missing from the source tree, so a clean rebuild would have shipped a broken cover display). `bananarchy-cover-msg` now wraps `bananarchy-coverctl NOTIFY`. The DT overlay is deliberately **not** applied to the shipping DTB: gpio13 direction/polarity and the external reset/DC wiring still require hardware validation, and enabling it blindly would risk the working internal panel. The daemon waits for `/dev/fb1` and is inert until then. -- `check-rebuild.sh` now guards all of the above (PAM stack, auth drop-in, key files, splash cmdline, keypad rules, cover daemon syntax, DT overlay compilation and mux kernel config). - -## Unreleased — mainline kernel console crash and switch-root fixes - - -- A PM8916 hardware watchdog was armed from lk2nd for a 20-second warm reset. This preserved DRAM pstore and produced a clean kernel console plus three compressed kmsg dumps. The watchdog was pre-armed through `oem debug writepmic` and the kernel watchdog driver was blacklisted for the diagnostic boot so it could not reconfigure the PMIC reset type. -- The kernel was not hanging at `n_null_init`: it returned normally, then crashed while printing the initcall result. `__msm_console_write` faulted at the earlycon fixmap address `0xffeff008` (`console_flush_all` -> `vprintk_emit` -> `trace_initcall_finish_cb`), followed by `Attempted to kill init`. Removing `earlycon` from the cmdline eliminates this crash; `console=ttyMSM0,115200` remains safe once the real serial driver has initialized. -- With `earlycon` removed, the kernel reaches initramfs stage 2, brings up configfs USB gadget/NCM, finds and mounts `pmOS_root`, then fails at `switch_root` with exit code 127 because `/sbin/init` is missing from the ext4 root image. The rootfs has BusyBox and an OpenRC `/etc/inittab`, but no `openrc-init`; `/sbin/init` must point at `/bin/busybox`. -- Removed `earlycon` from every `devices/*/kernel-cmdline.conf`, every overlay `50-device-*.conf`, all shipped standalone 2720 boot images and the raw image's `extlinux.conf`. Added `overlay/rootfs/sbin/init -> /bin/busybox`, made `apply-bananarchy-overlay.sh` and `rebuild-image.sh` recreate it, patched the current ext4 image, and added validators to reject stale `earlycon` cmdlines or a missing init symlink. -- `check-rebuild.sh`, boot-img validation, bootfs validation, Python/shell syntax and pstore decoders all pass. The fixed image is ready for the next flash/boot test. - -## Unreleased — block-safe fastboot read-back and r3 rebuild - -- Found why boot-slot read-back dropped USB: upstream `oem read-partition` passes the requested byte count directly to `mmc_read()`, whose wrapper asserts on sizes that are not eMMC block multiples. The lk2nd boot images end with a 16-byte `SEANDROIDENFORCE` tail, so their 376848/360464-byte lengths are 16 bytes past a 512-byte boundary. -- `lk2nd/fastboot/fetch.c` now rounds the MMC read up to the device block size, rejects unaligned offsets and reads beyond the partition, and stages only the original requested byte count. The source patch has 15 sections; validators and host port tests guard the fix. -- Rebuilt normal, diagnostic and display images as `-r3`: `c6092800`, `76936751`, `26b74570`. A clean upstream worktree rebuild reproduced all three byte-for-byte. -- Prepared a one-shot scratch mainline boot image with `lk2nd.pass-ramoops=zap maxcpus=1` to clear pstore and test whether SMP secondary-CPU bringup is the remaining kernel hang. -- `fastboot reboot-bootloader` writes the `FASTBOOT_MODE` cookie and does not exercise a newly flashed boot slot; use `fastboot reboot` for that test. The separate 512 KiB `lk2nd` partition contains an older lk2nd image, so the r3 persistence probe backs it up and writes r3 to both `boot` and `lk2nd` before a normal reboot. -- Live hardware: r3 diagnostic chain-loaded from the older `a1109` normal image, the full 512 KiB `lk2nd` partition was backed up, r3 was written and read back on both `boot` and `lk2nd`, and a normal `fastboot reboot` came back as `bananarchy-beatles-a1109-diag-r3`. This confirms persistence and that `reboot-bootloader` was the earlier trap. -- The one-shot `lk2nd.pass-ramoops=zap maxcpus=1` kernel downloaded and booted OKAY but produced no USB within 50 s. SMP secondary-CPU bringup is therefore not the sole cause of the remaining hang. A warm reset with Vol Down + Power is required to read the pstore console. No successful Bananarchy userspace boot has been observed yet. -- A follow-up forced-panic one-shot (`panic=3`, `panic_on_warn=1`, `panic_print=31`, `nosmp`, shortened RCU stall timeout, `lk2nd.pass-ramoops=zap`) also produced no USB within 55 s and did not self-reboot. RAM pstore remains inconclusive until a warm reset; if it is all `0xff` again, a block-pstore kernel rebuild is needed. -- A warm reset preserved a valid `DBGC` pstore console record (`size=0x10ff6`, cumulative `start=0x110fb6`). lk2nd's `oem ramoops console` rejected the cumulative start value, but `oem ramoops raw` staged the region; host-side rotation decoded kernel logs to about 6.25 s. The last readable initcall is `calling n_null_init`; the ordered table continues with `pty_init`, `sysrq_init`, `msm_serial_init`, `ttynull_init`, IOMMU and DRM initcalls. Three compressed kmsg dumps are present but too DRAM-corrupted to inflate cleanly. -- RAM pstore proved too unreliable: a warm reset preserved a valid but bit-rotted `DBGC` console record, while the next warm reset decayed the whole region to `0xff`. The console parser also needs to accept pstore's cumulative `start` pointer. -- Rebuilt the 6.12.1-msm8916 kernel with `CONFIG_PSTORE_BLK=y`, `CONFIG_PSTORE_BLK_BLKDEV` set to the GPT `cache` PARTUUID `2c6a1773-df50-2023-26e9-2d678c0ff68d`, a 256 KiB console zone and 64 KiB kmsg zones. The resolved config, `vmlinuz`, modules and boot config were regenerated. The scratch test boot.img forces `pstore.backend=pstore_blk`, `pstore_blk.best_effort=1` and the same `PARTUUID`; it uses the new zImage with the original appended DTB and initramfs. -- The pstore_blk one-shot kernel downloaded and booted OKAY but produced no USB within 55 s. A warm reset is required to stage the `cache` partition and decode its on-eMMC console/kmsg zones. - -## Unreleased — hardware-verified lk2nd panel and final kernel DTB - -- Chain-loaded the rebuilt `-diag-r2` image without any cmdline patch. The QCDT fallback published `lk2nd:panel=qcom,mdss_spi_gc9305_v2_qvga_cmd`; `oem display-init` returned OKAY in 1.066 s, `oem display-test` in 0.264 s, and `oem screenshot` staged a 230424-byte 240x320 P6 framebuffer with exactly the three intended RGB stripe colors. The panel stream and full SPI frame flush are confirmed on the phone. -- Removed the upstream per-word QUP `SPEW` FIFO log. Earlier `DEBUG=2` builds spent about 40 s per frame and filled the 32 KiB log; the rebuilt diagnostic log has zero FIFO-status lines. `oem ramoops console` now validates the pstore signature/size/offset and reports `No valid pstore console` for decayed DRAM instead of trying to stage `0xffffffff` bytes. -- `oem scan-boot` now lets `boot_linux()` apply the final cmdline and DT updates, then returns before the kernel jump. `oem scan-dtb` staged a 41440-byte final DTB with `cpu@2`/`cpu@3` set to `status = "fail"`, `ramoops@9fa80000` with a 256 KiB console, final bootargs, and initrd addresses. The dual-core partial-goods DT fix is confirmed; the remaining Bananarchy boot stall is in the mainline kernel/userspace stage. -- Rebuilt normal, diagnostic and display images from the pinned upstream commit plus the 14-section source patch: `ba97912c`, `5f263470`, `6b7b8fff`. A clean upstream worktree rebuild reproduced all three byte-for-byte. Validators now require the final-DTB hook, chain-load panel fallback, bounded pstore console and QUP log fix. -- `fastboot flash boot` of the forced-fastboot diagnostic returned OKAY, then USB dropped and did not re-enumerate after 30 s. Power-cycle into fastboot (Vol Down + Power) or EDL, read back `boot`, then boot the ramoops-enabled mainline image and warm-reset to capture `oem ramoops console`. No successful Bananarchy userspace boot has been observed yet. - -## Unreleased — safe, probeable lk2nd display and corrected diagnostics - -- Corrections: the pmOS initramfs jumps straight to stage 2 when `/init_2nd.sh` is present (it is), so a missing `/boot/initramfs-extra` was never the cause of a boot halt. An all-`0xff` ramoops region after a hard power-off is decayed DRAM, not proof the kernel hung before pstore. A live `oem debug readl 0x70000` hit an unmapped register and dropped USB; that was a host-side probe error, not a phone fault. -- Root cause of the display wedge: `spi_qup.c` and `clock_lib2.c` spin forever in QUP FIFO / clock register polls when the QUP clock never comes up. Added `QUP_FIFO_TIMEOUT` and `CLK_POLL_TIMEOUT` bounds so a dead SPI bus cannot hang lk2nd before USB init. -- `spi-display.c` rewritten: RAM-only 240x320 RGB565 framebuffer by default (`lk2nd.no-display`), plus fastboot commands `oem display-init` (mdss_spi_init + downstream GC9305 v2 `lk2nd,panel-init` stream + striped banner + one frame flush), `oem display-test`, and `oem display-off`. `lk2nd.display=on` enables the same path at boot. All run after USB on the diagnostic image, so failures are reported/logged instead of wedging. -- Added `oem scan-dtb` to stage the exact DTB handed to the kernel (after DT updates) for offline inspection; `oem scan-boot`, `oem log`, `oem screenshot` and `oem ramoops console` complete the probe set. -- New `images/boot-lk2nd-nokia-beatles-display.img` (`lk2nd.display=on`). Normal/diagnostic/display images rebuilt (sha `aadcb85b`, `bdde06b0`, `6b2b9b5c`), reproducible byte-for-byte from a pristine clone; validator gained `--expect-display`, build script gained the display variant and `--with-display`. Docs and host tests updated. -- Confirmed offline: `qcom,msm8909-smp` is valid in mainline 6.12 `platsmp.c`; the 2720 fuse `0x58000` reads `0x30100094` (dual core). `lk2nd_partial_goods_dt_update()` sets `status = "fail"` on `cpu@2`/`cpu@3` for non-downstream boots; `oem scan-dtb` can now prove whether that reached the kernel DTB. extlinux was already proven good by `oem scan-boot`; the remaining hang is in the mainline kernel. - -## Unreleased — extlinux confirmed good; kernel console capture via ramoops - -- `oem scan-boot` run on the live device proved the boot chain: `wrp0p32p0` (pmOS_boot, 256 MiB) enumerated and mounted, `/extlinux/extlinux.conf` parsed, `vmlinuz` / `qcom-msm8905-nokia-beatles.dtb` / `initramfs` all resolved and `lk2nd_boot_label()` reached `boot_linux()` without errors. Log saved to `backup/nokia-beatles-2720/crash-20261109/scan-boot-log.txt`. **The remaining hang is the mainline kernel, not lk2nd or the boot filesystem.** -- `oem read-partition` also verified the live `userdata` MBR (`55aa`, two `0x83` partitions) and its ext2 superblock (`53ef` at 1 MiB). `fastboot boot` of the debug boot.img downloaded OKAY then produced no USB, consistent with a kernel that hangs before the initramfs brings up `usb0` RNDIS. -- `oem ramoops regions` showed `0x9fa80000` still `0xff`. Patched `lk2nd/ramoops/ramoops.c` to always inject the ramoops reserved-memory node on Linux boots (`lk2nd.pass-ramoops=zap` still clears it), so `CONFIG_PSTORE_RAM`/`CONFIG_PSTORE_CONSOLE` kernel logs survive a warm reset. Added `images/boot-bananarchy-nokia-beatles-ramoops.img` (debug boot.img + `lk2nd.pass-ramoops`). -- Rebuilt both images (normal `dab81af0…46`, diagnostic `1825a1a4…bc`), reproducible byte for byte; validator and port tests check `oem scan-boot` and the ramoops patch. `check-rebuild.sh`, bootfs/bootimg checks and syntax checks pass. -- Next hardware step: the ramoops-enabled diagnostic lk2nd was chain-loaded with `fastboot boot` and `fastboot continue` ran the real extlinux chain; the kernel hung again. Power-cycle back into fastboot (Vol Down + Power), then `fastboot oem ramoops console && fastboot get_staged console.log` to read the kernel console. - -## Unreleased — extlinux/kernel hang diagnostics from live fastboot - -- Live fastboot confirmed the port works (`lk2nd:compatible=nokia,beatles`, `model=Nokia 2720 Flip`, panel `qcom,mdss_spi_gc9305_v2_qvga_cmd`, `unlocked=yes`). Read back the live `userdata` MBR (valid 0x55aa, two 0x83 partitions at LBA 2048 / 526336) and the ext2 superblock at 1 MiB (`53ef`, dynamic rev, compatible features) with `fastboot oem read-partition`; boot filesystem is intact on-device. -- `fastboot boot images/boot-bananarchy-nokia-beatles-debug.img` downloaded and reported OKAY, then no USB appeared. The initramfs brings up `usb0` RNDIS via `setup_usb_network`, so this means the mainline kernel hangs before userspace, or lk2nd never found extlinux and fell into `boot_linux_from_mmc()`. -- Added an `oem scan-boot` fastboot command (new `lk2nd/device/2nd/scan-boot.c`): runs `lk2nd_boot()` with `lk2nd_scan_only = true`; `lk2nd_boot_label()` logs the resolved kernel/dtb/initramfs/cmdline and returns before `boot_linux()`, so lk2nd stays in fastboot and `oem log` reveals the whole extlinux scan. Both images rebuilt (normal `902bf422…77`, diagnostic `d3eacccd…82`), reproducible byte for byte; validator and port tests check the command. -- Added `images/boot-bananarchy-nokia-beatles-ramoops.img` (debug boot.img plus `lk2nd.pass-ramoops` in the cmdline) so lk2nd injects a ramoops reserved-memory node and the kernel console can be read with `fastboot oem ramoops console` after a warm reset. -- Next hardware step: re-enter EDL with a fresh Sahara HELLO, flash the diagnostic image, then `fastboot oem scan-boot` + `fastboot oem log`. If the scan succeeds, boot the ramoops kernel and read its console after rebooting into fastboot. - -## Unreleased — lk2nd confirmed over live fastboot; default image boots extlinux headless - -- Confirmed over live fastboot (`18d1:d00d`, serial `34b39986`): `lk2nd:compatible=nokia,beatles`, `lk2nd:model=Nokia 2720 Flip`, `lk2nd:panel=qcom,mdss_spi_gc9305_v2_qvga_cmd`, `unlocked=yes`. The full lk2nd RLOG log shows `Found valid DTB with 2718 bytes total`, `Detected device: Nokia 2720 Flip` and a clean `fastboot_init()`; saved to `backup/nokia-beatles-2720/crash-20261109/lk2nd-fastboot-log.txt` and `lk2nd-parsed-cmdline.txt`. -- The "still hanging on the KaiOS logo" was lk2nd sitting in the forced-fastboot diagnostic menu with a RAM-only framebuffer, not a hang. Two vibrations were aboot's and lk2nd's normal 250 ms boot pulses. -- A/B proof: display enabled hangs before USB with the boot vibrator stuck on; `lk2nd.no-display` reaches fastboot. Both shipped images now carry `lk2nd.no-display`; the normal image no longer forces fastboot, so a normal power-on runs `lk2nd_boot()` -> extlinux -> the mainline kernel. `WITH_DISPLAY=1` / `--with-display` re-enables the SPI display. -- Rebuilt both (normal `eaa50754…15`, diagnostic `43bb63cb…05`), reproducible byte for byte; all tests pass. -- `fastboot continue` was sent to exercise the real extlinux chain; USB then disappeared and the KaiOS logo stayed. Bananarchy has no default USB gadget, so this is ambiguous. Next decisive probe: re-enter EDL (Sahara HELLO is one-shot — do not consume it with a passive read), enter Firehose and `peek` lk2nd's RLOG at `0x8f655430`, or hold Volume Down at power-on to reach fastboot and pull `fastboot oem log`. - -## Unreleased — lk2nd confirmed working; default image now boots extlinux headless - -- Live fastboot (`18d1:d00d`, serial `34b39986`) confirmed the port: `lk2nd:compatible=nokia,beatles`, `lk2nd:model=Nokia 2720 Flip`, `lk2nd:panel=qcom,mdss_spi_gc9305_v2_qvga_cmd`, `unlocked=yes`. The full lk2nd RLOG log shows `Found valid DTB with 2718 bytes total`, `Detected device: Nokia 2720 Flip` and a clean `fastboot_init()`. Saved to `backup/nokia-beatles-2720/crash-20261109/lk2nd-fastboot-log.txt` and `lk2nd-parsed-cmdline.txt`. -- A/B proof: with the SPI display enabled lk2nd hangs before USB with the boot vibrator stuck on; with `lk2nd.no-display` it vibrates twice normally (aboot + lk2nd boot pulses) and reaches fastboot. The "still hangs on the KaiOS logo" was lk2nd sitting in the forced-fastboot menu with a RAM-only framebuffer, not a hang. -- Both shipped images now carry `lk2nd.no-display`. The normal image no longer forces fastboot, so a normal power-on runs `lk2nd_boot()` -> extlinux -> mainline kernel, which re-initializes the panel itself. `WITH_DISPLAY=1` / `--with-display` re-enables the early SPI display for experimentation. -- Rebuilt both (normal `eaa50754…15`, diagnostic `43bb63cb…05`), reproducible byte for byte. Validator requires `lk2nd.no-display` on the diagnostic image; build script gained `--with-display`; `check-rebuild.sh`, port tests, bootfs/bootimg checks and syntax checks all pass. -- `fastboot continue` was used to exercise the extlinux chain; USB then disappeared and did not return within two minutes. This is not proof of a hang because Bananarchy has no default USB gadget. Next decisive probe: force EDL and read lk2nd's own RLOG ring buffer at `0x8f655430` (cookie `0x474f4c52`) to see whether `extlinux.conf` was found and `boot_linux()` reached. - -## Unreleased — aboot fixed; lk2nd hangs early with the boot vibrator stuck on - -- With `/cpus` present aboot no longer ASSERTs and lk2nd starts. The phone now hangs on the aboot/KaiOS splash with **permanent vibration and no USB device**. LK turns the vibrator on in `target_init()` (`vib_timed_turn_on(250)`) and off only in `target_uninit()` (`wait_vib_timeout()`), so a hang before USB/fastboot init leaves it buzzing forever. -- Prime suspect is the SPI display init, which now executes for the first time: `mdss_spi_init()` re-clocks BLSP1 QUP5 and `paint_boot_banner()` triggers three full 240x320 RGB565 frame writes during `LK2ND_INIT`, before USB comes up. -- Added `lk2nd.no-display` to `spi-display.c`: keeps a RAM-only framebuffer (so cont-splash does not read MDP registers) with `update_start = NULL`, and skips `mdss_spi_init()` entirely. The diagnostic image now uses it together with `LK2ND_FORCE_FASTBOOT=1` and `DEBUG=2`, so the only things before USB are DTB parsing, key publishing and partition setup. -- Rebuilt both images (normal `9c13e1ba…14`, diagnostic `43bb63cb…05`), still reproducible byte for byte from a pristine clone. Validator accepts and requires `lk2nd.no-display` on the diagnostic variant; `check-rebuild.sh` and the port tests still pass. -- Next hardware step: force EDL (hold power ~10-15 s, then Vol Up + Vol Down while plugging USB), flash the diagnostic image with `--lk2nd-image --verify`, then `lsusb`. `18d1:d00d` means the SPI display init was the hang; `fastboot oem log && fastboot get_staged lk2nd.log` gives the rest. If it still hangs with vibration, re-read aboot's RLOG buffer (and lk2nd's own RLOG cookie near its BSS) for the earlier hang. - -## Unreleased — real root cause: aboot partial-goods ASSERT on missing /cpus - -- Pulled aboot's `WITH_DEBUG_LOG_BUF` ring buffer (cookie `0x474f4c52` "RLOG") from the live Sahara memory-debug dump. It contains the exact crash: - ``` - [580] target_display_init ret=0 - [590] Failed to get parent node: /cpus errno:-1 - [600] panic (caller 0x8f61aa00): ASSERT FAILED at (platform/msm_shared/partial_goods.c:80): 0 - [610] HALT: reboot into dload mode... - ``` -- The 2720's MSM8905 is a **partial-goods (2-core) part**. Its stock aboot calls `update_partial_goods_dtb_nodes()` on the QCDT-selected DTB and `ASSERT(0)`s when `/cpus`, `/cpus/cpu@2` or `/cpus/cpu@3` (with a 4-byte `device_type`) is missing; it then rewrites `device_type` from `"cpu\0"` to `"nak\0"`. Upstream lk2nd QCDT DTBs have no `/cpus` at all, so **every** lk2nd image — including the untouched `bootloader/lk2nd-msm8909.img` — crashed before lk2nd ran. This, not the QCDT table shape or the panel init, was the "black screen / no fastboot" cause. -- Fixed by adding a `/cpus` node with `cpu@0`..`cpu@3` and `device_type = "cpu"` to the common `lk2nd/device/dts/lk2nd.dtsi`, so all eight QCDT DTBs carry it. The mainline `qcom-msm8905-nokia-beatles.dtb` already has `/cpus`, so the Volume Up recovery path is unaffected. -- Rebuilt both images (normal `e747ec0d…95`, diagnostic `8ded62f0…4a`); both reproducible byte for byte from a pristine clone. `dt_size` is `22528` and the 2720 DTB is 4096 bytes — aboot demonstrably handled a larger QCDT in earlier dumps, so size was never the problem. -- `check-lk2nd-beatles.py` now checks every QCDT DTB for `/cpus/cpu@2` and `cpu@3` with a 4-byte `device_type`, and enforces both `0x14b` entries sharing one DTB; `test-lk2nd-beatles-port.py` checks the `/cpus` patch. Crash log saved as `backup/nokia-beatles-2720/crash-20261109/aboot-log.txt`. -- Next hardware step: power-cycle into plain EDL (memory-debug state refuses the Firehose programmer), reflash the diagnostic image with `--verify --dump-diagnostics`, then `lsusb`. `18d1:d00d` means lk2nd runs; `05c6:900e` again means re-read the RLOG buffer for the next ASSERT. - -## (Superseded) aboot crashes on the changed QCDT; restore upstream shape - -- Live diagnosis: after "black screen, no fastboot" the phone was in `05c6:900e` **Sahara MEMORY_DEBUG mode**, i.e. aboot crashed before lk2nd ever ran. A Sahara memory-debug dump showed aboot's BSS held the diagnostic boot.img header (`ANDROID!`, kernel 345048, `dt_size=24576`) and the cached cmdline `lk2nd lk2nd.compatible=nokia,beatles`; aboot had also built `mdss_mdp3.panel=1:spi:0:qcom,mdss_spi_gc9305_v2_qvga_cmd:1:none`. The kernel payload at `0x80008000` was byte-identical to the diagnostic image, while lk2nd's BSS at `0x80080000` was all zeros. -- Root cause: the only aboot-parsed thing changed was the **QCDT table**. The dedicated `msm8905-nokia-beatles` DTB made `dt_size` 20480 -> 24576, split the two `0x14b` entries across two different DTBs and put `0x1000b` first in `qcom,board-id`. aboot re-validates the selected DTB's root properties and crashed. Removed that DTB, restored `msm8905-qrd-skub.dts` to the exact upstream `qcom,board-id = <0x0b 0x100>, <0x1000b 0x100>` and injected only a compact `/lk2nd/nokia-beatles` node (DTB 1504 -> 1984 bytes, still one 2048-byte slot). Both `0x14b` QCDT entries again point at the same DTB and `dt_size` is back to `20480`. -- Trimmed the port to fit that slot: only the `qcom,mdss_spi_gc9305_v2_qvga_cmd` panel — the one the live aboot reports — carries `lk2nd,panel-init`; the other two are match-only nodes. Dropped the DTB `gpio-keys` and `menu-key-strings` entries. Kept model, compatible, `lk2nd,match-panel` and `lk2nd,dtb-files`. -- Rebuilt both images (normal `968ef23c…8d`, diagnostic `5eb75ca8…5ff`), still reproducible byte for byte from a pristine clone. `check-lk2nd-beatles.py` now enforces the upstream QCDT shape and rejects any separate QCDT DTB; the host C test covers the single v2 stream. -- Crash evidence saved to `backup/nokia-beatles-2720/crash-20261109/`. `devinfo` from the last dump still has `is_unlocked=1`. Next hardware step: reflash the diagnostic image with `--verify --dump-diagnostics`, then check `lsusb`; if it returns to `900e`, re-read aboot's RLOG buffer; the untouched `bootloader/lk2nd-msm8909.img` lacks `/cpus` too and is only a negative control. - -## Unreleased — diagnose the logo-then-blank screen on nokia-beatles - -- Traced the dark screen: `DISABLE_SPLASH_PARTITION=1` in lk2nd builds means `display_image_on_screen()` never loads the stock splash, and lk2nd's `menu.c` override of `display_default_image_on_screen()` only draws two version lines before `fbcon_flush()` pushes the whole 240x320 RGB565 framebuffer at `MIPI_FB_ADDR`. Upstream's fallback is a tiny 113x124 logo on black; there is no guarantee aboot left its splash at that address. `spi-display.c` now paints a striped `Bananarchy lk2nd / nokia-beatles / 240x320 RGB565` banner before that flush, so the handoff can no longer be mistaken for a hang. -- Made the panel-init replay conditional: `lk2nd,panel-init` is only replayed when aboot did not report continuous splash (`mdss_mdp3.panel=0:...`) or when `lk2nd.force-panel-init` is present in the cmdline. Re-initializing a panel aboot already owns risks disturbing the 2720's shared main/cover SPI bus. `scripts/build-lk2nd-beatles.sh --force-panel-init` builds that variant. -- Added `images/boot-lk2nd-nokia-beatles-diagnostic.img`: the same port built with `DEBUG=2 DEBUG_FBCON=1 LK2ND_FORCE_FASTBOOT=1`, so it always shows the fastboot menu, draws boot logs on the display and enumerates as USB fastboot. `flash-edl.py` gained `--lk2nd-image` to flash it without changing the default. Pull the decisive log with `fastboot oem log && fastboot get_staged lk2nd.log`. -- `scripts/build-lk2nd-beatles.sh` now builds and validates both images (`--only normal|diagnostic`, `--check`), `check-lk2nd-beatles.py` gained `--expect-fastboot` and checks the banner/conditional-replay markers, and `test-lk2nd-beatles-port.py` validates both images plus the flasher override. Both images remain reproducible byte for byte. -- No successful Bananarchy boot has been observed yet; the forced-fastboot log or UART (`ttyMSM0,115200`) is required to locate whether the failure is extlinux/`pmOS_boot` or the mainline kernel. - -## (Superseded) source-built nokia-beatles lk2nd port - -- Replaced the binary-patched, headless lk2nd workaround with a real upstream source port. `bootloader/lk2nd/nokia-beatles.patch` applies to `msm8916-mainline/lk2nd` commit `cf45aefd22d744b2bf9b39455afae697ce430063`; `scripts/build-lk2nd-beatles.sh` clones that commit, applies the patch and cross-builds `lk2nd-msm8909` in the rootless Docker toolchain image (`bootloader/lk2nd/Dockerfile`). The result is reproducible byte for byte. -- New dedicated QCDT DTB `msm8905-nokia-beatles.dts` with the exact stock 2720 IDs (`qcom,msm-id = <0x14b 0>`, `qcom,board-id = <0x1000b 0x100>`). It contains only `/lk2nd/nokia-beatles`, so aboot's best-match selection is unambiguous. The shared `msm8905-qrd-skub.dtb` keeps the `0xb/0x100` fallback entry and also carries the beatles node. -- `nokia-beatles.dtsi` adds a real device node: model `Nokia 2720 Flip`, `compatible = "nokia,beatles"`, `lk2nd,match-panel`, `lk2nd,dtb-files = "msm8905-nokia-beatles"`, menu key labels and `gpio-keys` for volume up (GPIO 90) and power/end (GPIO 98), both active low. -- Correct panel initialization: three panel subnodes match every GC9305 name the 2720 aboot can report (`gc9305_qvga_cmd`, `gc9305_v2_qvga_cmd`, `gc9305_3rd_qvga_cmd`), each with the downstream KaiOS 3.10 `qcom,mdss-spi-on-command` byte stream as `lk2nd,panel-init`. `lk2nd/include/lk2nd/spi-panel-init.h` walks the `[wait dlen payload...]` stream; `platform/msm_shared/mdss_spi.c` and `lk2nd/device/2nd/spi-display.c` replay it on BLSP1 QUP5 (DC GPIO 110), setting RGB565, the 240x320 address window, sleep-out, display-on and RAMWR. lk2nd can now bring the panel up even when aboot left no continuous splash. -- `images/boot-lk2nd-nokia-beatles.img` is the source-built image (sha256 `1b6386a2e532d52003b6c2b65f00f6860c28d50cd94d9c3b874dd93fa161baa9`), cmdline `lk2nd lk2nd.compatible=nokia,beatles`. Removed the obsolete `scripts/make-beatles-lk2nd-bootimg.py`. -- `scripts/check-lk2nd-beatles.py` now validates the boot header, both 2720 QCDT entries, both DTBs, the device node, gpio-keys and every panel init stream with a pure-Python FDT parser. `scripts/test-lk2nd-beatles-port.py` additionally compiles the shared C parser against the streams extracted from the shipped image. `check-rebuild.sh` guards the port files. - -## (Superseded) fix lk2nd headless device node and repair pmOS_boot - -- Root cause of the blank screen: `repack-beatles-bootimg.py` had written an Android `boot.img` at raw offset 1 MiB, which is the **ext2 `pmOS_boot` filesystem** inside the `userdata` MBR image. Its superblock was destroyed, so lk2nd could not mount the boot subpartition, could not find `extlinux.conf`, and reported "Bootable file system not found. Reverting to android boot." The tool no longer accepts `--raw-image`; `scripts/sync-beatles-bootfs.py` updates `/boot.img`, `/qcom-msm8905-nokia-beatles.dtb` and `/extlinux/extlinux.conf` inside the ext2 filesystem instead, with `--check` wired into `check-rebuild.sh`. -- Repaired `images/bananarchy-nokia-beatles.img` in both repos: ext2 superblock restored, DTB and boot.img refreshed, `extlinux.conf` now uses `loglevel=8 ignore_loglevel initcall_debug panic=10` instead of `quiet splash`. -- Root cause of lk2nd running the wrong hardware: the QCDT DTB only had `cat-b35` / `nokia-argon` device nodes with `lk2nd,match-panel`. `scripts/make-beatles-lk2nd-bootimg.py` now injects `/lk2nd/nokia-beatles` (`model = "Nokia 2720 Flip"`, `compatible = "nokia,beatles"`, `lk2nd,dtb-files = "qcom-msm8905-nokia-beatles"`), removes every `lk2nd,match-panel` property, and sets cmdline `lk2nd lk2nd.compatible=nokia,beatles`. lk2nd identifies the board and skips the 8110 4G panel/keypad init entirely. -- `images/boot-lk2nd-nokia-beatles.img` rebuilt in both repos; `check-lk2nd-beatles.py` now validates that only the cmdline field and the exact-2720 QCDT DTB slot differ, that the new node exists, and that no node carries `lk2nd,match-panel`. - -## Unreleased — Argon-shaped hybrid and RPMB correction - -- Correction to the previous entry: `target_get_vb_version()` returns `VB_L=1` when the GPT has no `keymaster` partition (this 2720 has `keystore` only), while `VB_M=2`. The `USE_RPMB_FOR_DEVINFO` branch is therefore not taken; `read_device_info()` uses eMMC `devinfo`. The 21:25 dump shows `is_unlocked=1`, so the eMMC unlock is effective and `fastboot oem unlock-go` is unnecessary. Stock fastboot is not required. -- The 900e crash is not a signature rejection. To match the 8110/Argon process exactly, the default `nokia-beatles` path is now a hybrid: `bootloader/lk2nd-msm8909.img` -> `boot`, `images/boot-bananarchy-nokia-beatles.img` -> `recovery`. Normal power-on is `aboot -> lk2nd -> extlinux`; Volume Up is `aboot -> recovery -> mainline boot.img`. -- `source_for(name)` gives each target partition its own source; `--verify` compares each slot against the image actually written there. The behavioural test asserts `boot=lk2nd`, `recovery=boot.img`. - -## (Superseded) RPMB devinfo is the authoritative unlock - -- After the dual-slot fix the phone still entered `05c6:900e` (Sahara memory debug). The 21:25 dumps show eMMC `devinfo` is now `is_unlocked=1`, but `diag-aboot.img` contains VERIFIED_BOOT / `USE_RPMB_FOR_DEVINFO` code: `read_device_info()` uses `read_device_info_rpmb()` when secure boot is enabled, so the eMMC patch is ignored. `boot_verifier_init()` therefore still verifies the unsigned lk2nd image and aboot crashes. -- `flash-edl.py` now patches the `config` (fallback `frp`) partition allow-unlock byte (LSB of last byte) by default on `nokia-beatles` via `enable_oem_unlock()`, with read-back verification and `backup/config-locked-.img`. -- New `--only-unlock` mode patches eMMC devinfo + config/frp, prints the exact `fastboot oem unlock-go` instructions, and exits without flashing. `--enable-oem-unlock` / `--no-enable-oem-unlock` control the config patch. -- Added `scripts/make-oem-unlock-config.py`, generated `backup/nokia-beatles-2720/config-oem-unlock.img` (only byte 524287 changes), `check-rebuild.sh` guards and a host test. - -## Unreleased — fix lk2nd dual-slot write - -- `--verify` correctly reported `read-back of 'recovery' differs`: the 2720 dual-slot `target_names = ("boot", "recovery")` was built, but the old `method == "lk2nd"` branch still wrote only `target_parts[0][1]`. `recovery` therefore kept the previous mainline boot.img while `--verify` compared it against lk2nd. -- Step 1 now loops over every `target_parts` entry with a single `source` (`bootloader_img` for lk2nd, `boot_img` otherwise), and the verify loop uses the same source. `check-rebuild.sh` guards against the single-slot regression and a host test asserts the multi-target write path. - -## Unreleased — unlock locked 2720 aboot via devinfo - -- `--dump-diagnostics` dumps from the connected 2720 show `diag-devinfo.img` with `ANDROID-BOOT!` magic and `is_unlocked=0`, `is_tampered=0`; `diag-aboot.img` contains `Nokia_beatles ROOT CA0`, secure-boot checks, `ERROR: Image Invalid! signature check failed!` and `Device is unlocked! Skipping verification...`. This is the root cause of the empty screen: aboot signature-checks every custom `boot.img` (lk2nd or mainline) and rejects it. -- `flash-edl.py` now defaults to `unlock_devinfo()` on `nokia-beatles`: it backs up the locked `devinfo` to `backup/devinfo-locked-.img`, sets byte 13 (`is_unlocked`) to 1 and clears `is_tampered`, then writes it back before flashing. `--unlock-bootloader` forces it on any target; `--no-unlock-bootloader` skips it. -- Added `scripts/make-unlocked-devinfo.py` and generated `backup/nokia-beatles-2720/devinfo-unlocked.img` from the captured dump (only byte 13 changes). `check-rebuild.sh` guards the unlock helper and defaults. -- Earlier DTB/QCDT/lk2nd fixes remain valid but were all downstream of this signature check. - -## Unreleased — lk2nd boots first on the 2720 Flip - -- `bootloader/lk2nd-msm8909.img` was re-examined: it is an Android `boot.img` with cmdline `lk2nd`, `dt_size=20480` and a QCDT v2 table after the ramdisk. Entry 13 already has the exact stock 2720 IDs (`platform_id=0x14b`, `variant_id=0x1000b`, `board_hw_subtype=0x100`, `soc_rev=0`) and points at a DTB with `/memory`, `/chosen` and `/lk2nd`. aboot therefore accepts the lk2nd boot.img on this device; the earlier "lk2nd unsupported" conclusion was wrong. -- `--method lk2nd` is again the default for every target. On `nokia-beatles` it writes lk2nd to both `boot` and `recovery`; `--verify` reads back both. lk2nd then boots Bananarchy from `userdata` via `extlinux.conf`, which names `qcom-msm8905-nokia-beatles.dtb` explicitly, so lk2nd identifying the board as an 8110 in its own menu does not affect the kernel DTB. -- `--method both` remains as a fallback that writes the standalone mainline `boot.img` to both slots, and `--method recovery` for the pmOS Volume Up route. -- Added `scripts/check-lk2nd-beatles.py`; `check-rebuild.sh` now enforces the QCDT entry and the dual-slot lk2nd write. - -## Unreleased — dual boot/recovery write and EDL diagnostics - -- (Superseded by the lk2nd-first path above.) `--method both` was the default for `nokia-beatles`: the corrected boot.img is written to both `boot` and `recovery`, because the stock locked fastboot chain may refuse an unsigned `boot` image while the pmOS-tested Volume Up recovery path still works. -- `--verify` now reads back every target partition, and `--dump-diagnostics` copies small `devinfo`, `aboot`, `tz`, `config`, `misc` and related partitions into `backup/diag-*.img` for offline secure-boot analysis. -- Completion output now tells the user to hold Volume Up if the KaiOS splash persists on a normal power-on. - -## Unreleased — 2720 Flip aboot DTB fixes - -- Replaced the mixed `qcom,board-id = <0xb 0x100 0x1000b 0x100>` with the exact stock MSM8905 QRD SKUB pair `<0x1000b 0x100>`. Older Qualcomm aboot revisions read only the first board-id pair, so the lk2nd 8110 variant prevented DTB selection and left the phone on the KaiOS splash. -- Added a 512 MiB `/memory` fallback (`reg = <0x80000000 0x20000000>`) to the beatles DTB. Stock aboot normally rewrites this from SMEM; the fallback avoids a zero-sized memory bank when it does not. -- Added `scripts/repack-beatles-bootimg.py` and `scripts/check-beatles-bootimg.py`. `check-rebuild.sh` now enforces the exact qcom IDs, memory fallback, appended-DTB pointer and boot partition size. -- Regenerated `qcom-msm8905-nokia-beatles.dtb`, the derivation patch, `images/boot-bananarchy-nokia-beatles.img` and the boot slot in `images/bananarchy-nokia-beatles.img`. - -## Unreleased — opt-in read-back verification - -- `--verify` reads back the `boot`/`recovery` partition after step 1 and - compares its leading bytes with the source image. A mismatch aborts the - flash before `userdata` is written, so a Sahara/Firehose session that never - committed cannot silently leave the phone booting stock KaiOS. - -## Unreleased — restore system superblock wipe by default - -- `resolve_wipe_system()` again zeroes the stock `system` superblock for - every flash method, as in the original Bananarchy behavior. - `--no-wipe-system` is now the opt-out; `--wipe-system` remains an explicit - (redundant) alias. The banner and step 3 report the effective choice. -- Recovery-mode completion message now warns that a normal power-on hangs on - the KaiOS logo after the wipe and that Volume Up is mandatory. -- `check-rebuild.sh` continues to guard the wipe helper. - -## Unreleased — do not wipe KaiOS system for boot/recovery methods - -- The "Powered by KaiOS" hang was the stock KaiOS kernel in `boot` trying to - mount a `system` partition whose first 64 sectors we had zeroed. With - `--method recovery`, `boot` is intentionally left alone, so a normal - power-on boots KaiOS; only Volume Up selects the flashed recovery image. -- `system` is now wiped only for the `lk2nd` method. `--wipe-system` forces - it and `--no-wipe-system` forbids it; the banner reports the choice. -- The target partition is always backed up as `-.img` - instead of reusing an existing `.img` from a different device. -- Recovery-mode completion message now states that normal power-on boots - KaiOS and Volume Up boots Bananarchy. - -## Unreleased — 2720 Flip boots from `boot` with a matched DTB - -- Root cause of the persistent boot failure: the appended device tree had no - `qcom,msm-id`, `qcom,board-id` or `qcom,pmic-id`. Qualcomm aboot selects an - appended DTB by those IDs, so it found none and fell back to Sahara - (`05c6:900e`). The IDs (`0x14b`, `0x0b/0x100 0x1000b/0x100`, `0x1000d`) - were read from the `MSM8905 QRD SKUB` DTB inside the stock 2720 recovery - image, confirmed against lk2nd's `msm8905-qrd-skub` DTB, and added to the - beatles DTS/DTB. The rebuilt `boot.img` now carries them. -- (Superseded by the lk2nd-first path above.) `--method boot` was the default - for `nokia-beatles`: the standalone `boot.img` was written to `boot`. -- (Superseded.) `--method recovery` remains available; `--method lk2nd` is now - the default for the 2720 as well. -- `check-rebuild.sh` guards the device list and method-to-partition map. - -## Unreleased — 2720 Flip recovery boot path - -- (Superseded by the lk2nd-first path above.) `lk2nd-msm8909.img` contains no - `nokia-beatles` device node; the shared `msm8905-qrd-skub` board plus the - colliding `qcom,mdss_spi_gc9305_v2_qvga_cmd` panel node make lk2nd identify - the 2720 as an 8110 4G in its own menu. The stock aboot does accept the - lk2nd boot.img via its QCDT entry. -- (Superseded.) `flash-edl.py` auto-selected `--method recovery` for - `nokia-beatles`: it flashed the standalone `boot.img` into `recovery`, left - `boot` alone, - writes the raw image to `userdata` (the pmOS initramfs - `mount_subpartitions()` exposes the nested MBR), and tells the user to - hold Volume Up at power-on. `--method lk2nd` and `--boot-image` override. -- `rebuild-image.sh` exports `images/boot-bananarchy-.img` instead of - deleting it. The exported image has the corrected beatles DTB appended and - the pmOS 2720 load addresses (`ramdisk 0x81000000`, `tags 0x80000100`). -- Flashing backs up `recovery` instead of `boot` in recovery mode. -- `check-rebuild.sh` guards the recovery device list and the boot.img export. - -## Unreleased — per-device EDL Firehose programmers - -- `flash-edl.py` now selects the Sahara/Firehose programmer from the target - device instead of always using `8110.mbn`: `8110.mbn` (`nokia-argon`), - `2720.mbn` (`nokia-beatles`), `800t.mbn` (`nokia-tough`), and `8k.mbn` - for **both** `nokia-sparkler` and `nokia-leo`. `--variant us` selects - `2720v.mbn` (`Nokia_bts_us`) for the 2720 Flip US variant. -- Added `--list-loaders`, which prints every `.mbn` with its size, embedded - attestation identity (`Nokia_beatles`, `Nokia_coconut`, `Nokia_bts_us`, - `Nokia_leo`) and device mapping. `flash-edl.sh` runs it without `sudo`. -- Selection warns when a programmer's embedded identity does not match the - expected device identity and fails with an actionable message when the - expected file is absent; `--loader PATH` still overrides everything. -- `wait_for_edl_usb()` auto-detects `05c6:9008`, `05c6:900e` and - `05c6:9006` instead of waiting only for 9008, and prints the PID it found; - `--pid` still forces a specific one. `check-rebuild.sh` guards the list. -- `check-rebuild.sh` guards the mapping and the presence of all five loaders. -- `8k.mbn` is signed `Nokia_leo` but is valid for both MSM8909 targets - (`nokia-sparkler`, `nokia-leo`); `2720v.mbn` is signed `Nokia_bts_us` - (2720 Flip US). Confirm identities with `--list-loaders` before flashing. +- Added target-specific hostnames, canonical package/prebuilt synchronization, clean-clone bootstrap checks, and guards for the radio loader, camera orientation, panel timing, and lid fallback. +- Image blobs remain local build outputs rather than tracked release history. `prepare-release.sh` rebuilds missing artifacts, while `check-rebuild.sh` validates available images and their boot filesystems. +- The final beatles image set passed rebuild preflight, DTB/boot-image/lk2nd checks, artifact-drift checks, and ext4 integrity checks. Live testing covered EDL read-back, Wi-Fi, Bluetooth, camera capture, high-brightness operation, and lid actions. ## Build `a1108` — codename `dejavu` (2026-11-08) diff --git a/MANUAL.md b/MANUAL.md index 7249239..9e97a6c 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -451,8 +451,10 @@ Three native X11 games (`/usr/bin/snake`, `/usr/bin/tetris`, and `/usr/bin/scoun ### 4.1 First-boot troubleshooting on the 2720 Flip +- **Wi-Fi and Bluetooth missing**: both radios depend on the shared WCNSS remote processor. `msm-firmware-loader` must start in sysinit before udev and mount the stock `modem` and `persist` partitions under `/run/msm-firmware-loader/mnt`; it then exposes `wcnss.mdt` and the factory `WCNSS_qcom_wlan_nv.bin` through the kernel firmware path. Check `rc-service msm-firmware-loader status`, `cat /sys/class/remoteproc/remoteproc1/state`, and `dmesg | grep -Ei 'wcnss|remoteproc|firmware'`. A `Direct firmware load for wcnss.mdt failed` message means the loader package or its sysinit link is missing, not that the Wi-Fi and Bluetooth drivers are absent. After a successful boot, `wlan0` and `hci0` enumerate automatically; Bluetooth userspace still starts on demand from the Networks/Bluetooth UI to save power. - **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`. -- **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 only polls raw gpio36/gpio92 debugfs levels when no switch evdev is available. 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. +- **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**: `bananarchy-cover-idle` is the compiled 0%-CPU default daemon and answers `bananarchy-coverctl`; the native `bananarchy-coverd` is retained only for diagnostics. The shipping DTS keeps the known-good single internal panel; `cover-panel.dtsi` is compile-tested but not applied. The expected live state is no `/dev/fb1` and `bananarchy-coverctl STATUS` reporting `backend=none`. The renderer uses the 32-bpp fbdev `write()` path for future hardware (not `mmap()`, which raises `SIGBUS` on the DRM fbdev). gpio13 selection and external reset polarity still require physical sign-off before the overlay is re-enabled. - **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). @@ -481,7 +483,7 @@ bananarchy-screenshot bananarchy-screenshot ~/my-screen.png ``` -The `msm8905-cam` kernel module drives the rear 2MP GalaxyCore `GC2395` (TA-1048), `GC2385` (TA-1059), and `GC2365` sensors through MSM8909 `CAMSS` and registers `/dev/video0` (`800x600` 24-bit `RGB3`). +The `msm8905-cam` kernel module drives the rear 2MP GalaxyCore `GC2395` (TA-1048), `GC2385` (TA-1059), and `GC2365` sensors through MSM8909 `CAMSS` and registers `/dev/video0` (`800x600` 24-bit `RGB3`). On `nokia-beatles` only, the demosaic sampler applies a 180-degree rotation while producing this frame, correcting the Flip's sensor mounting for every V4L2 consumer without an additional frame-buffer copy; the existing 90-degree portrait transform in `bananarchy-photo` and `xcamera` is unchanged. - **Using `bananarchy-photo`**: ```bash diff --git a/README.md b/README.md index 3e85670..c6d1da9 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ ### System and hardware support - **Mainline Linux 6.12 kernel**: custom patches and out-of-tree drivers for Qualcomm **Adreno 304 (`FD304`, 96 KB GMEM)** 3D GPU acceleration (`drm/msm` + `qcom-iommu`), Qualcomm QDSP6/Q6Voice audio routing, Dual-SIM modem control, the rear 2MP GalaxyCore `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`), the `SY7807` flashlight LED (`white:torch`), physical keypad/slider events, and clean PM8909 poweroff. The kernel image is built from `config-bananarchy-msm8909.armv7` with the known-good pmaports module ABI, and ships with idle-blanking power management; `BATTERY-OPTIMIZATION-ANALYSIS.md` records the measured idle state and explains why suspend-to-RAM is unavailable on this firmware (PSCI `SYSTEM_SUSPEND` missing) and why a full custom module tree rebuild is not worthwhile. Section 17 adds the `a1108` re-analysis and two low-risk wins: the active zram swap now uses `lz4` instead of `zramstart`'s `zstd` default, and `vm.compaction_proactiveness=0` removes ~2 `kcompactd0` wakeups/s. Section 18 replaces the idle `nmcli device monitor` poller with NetworkManager dispatcher hooks and records the kernel/VFS tweaks that were A/B tested and rejected. Runtime Wi-Fi listen-interval, modem DRX and DSDS secondary-SIM power policies are configurable in `/etc/bananarchy-power-policy.conf`; see `MANUAL.md`. +- **Target-correct camera orientation**: the V4L2 demosaic path rotates frames 180 degrees only on `nokia-beatles`, correcting the 2720 Flip's sensor mounting directly at `/dev/video0` for the viewfinder, saved photos, and third-party V4L2 consumers. Other Nokia targets retain their existing orientation, and the correction adds no extra frame-buffer copy. +- **High-brightness display and reliable flip handling**: the 2720 Flip internal panel uses a live-verified 25 MHz SPI clock to prevent corruption when backlight PWM exceeds the former 71% threshold, without reducing the brightness range. The compiled lid daemon combines event-driven `EV_SW` handling with 200 ms raw-hall reconciliation, so missed edges or stale switch state cannot leave the phone awake when closed. +- **Stock-signed Wi-Fi, Bluetooth, and modem firmware**: `msm-firmware-loader` mounts the phone's `modem` and `persist` partitions before udev, supplies `wcnss.mdt`, `mba.mbn`, and the device-specific WCNSS NV data to the mainline remote processors, and preserves the factory radio calibration and MAC addresses. The sysinit and boot service links are shipped explicitly so clean, `--no-scripts` image builds bring up both `wlan0`/`wcn36xx` and `hci0`/`btqcomsmd` without packaging device-specific firmware blobs. - **Alpine Linux Edge base**: full access to the Alpine package ecosystem with `< 95 MB` idle RAM usage on 512 MB devices and full local root access out of the box. - **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. **Config -> Sync net time** forces a burst manually and reports the result when autosync is slow. The status bar clock is also refreshed synchronously on unlock and by dmenu itself, so it cannot show a stale pre-lock time. See `MANUAL.md` section 5.7. - **Pure X11 graphical stack with GPU acceleration**: cross-compiled **Xlibre** (`X11Libre/xserver`) display server offloading 2D/3D screen rendering to the **Adreno 304 GPU** via **Glamor, DRI3, GLX, and Mesa Freedreno (`FD304`, OpenGL 3.1 / OpenGL ES 3.0)** over `panel-mipi-dbi` KMSRO, paired with a customized **Sxmo (`sxmo-de-dwm`)** window manager (`240x320` vertical stack layout, native `ParentRelative` desktop clock and softkey bar without Conky overhead, `< 2 ms` slider/key wake latency, and zero Wayland overhead). diff --git a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb index 8705f67..7be88b4 100644 Binary files a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb and b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb differ diff --git a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts index d607ef4..34018fb 100644 --- a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts +++ b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts @@ -1857,7 +1857,8 @@ backlight = <0x6b>; reset-gpios = <0x27 0x19 0x00>; dc-gpios = <0x27 0x6e 0x00>; - spi-max-frequency = <0x2faf080>; + /* 25 MHz avoids high-backlight PWM noise corrupting the panel link. */ + spi-max-frequency = <0x17d7840>; power-supply = <0x6c>; io-supply = <0x6d>; width-mm = <0x24>; diff --git a/overlay/rootfs/boot/qcom-msm8905-nokia-beatles.dtb b/overlay/rootfs/boot/qcom-msm8905-nokia-beatles.dtb index 8705f67..7be88b4 100644 Binary files a/overlay/rootfs/boot/qcom-msm8905-nokia-beatles.dtb and b/overlay/rootfs/boot/qcom-msm8905-nokia-beatles.dtb differ diff --git a/overlay/rootfs/boot/vmlinuz b/overlay/rootfs/boot/vmlinuz index 910cc31..14cd146 100755 Binary files a/overlay/rootfs/boot/vmlinuz and b/overlay/rootfs/boot/vmlinuz differ diff --git a/overlay/rootfs/etc/runlevels/boot/msm-firmware-loader-unpack b/overlay/rootfs/etc/runlevels/boot/msm-firmware-loader-unpack new file mode 120000 index 0000000..6d59bf2 --- /dev/null +++ b/overlay/rootfs/etc/runlevels/boot/msm-firmware-loader-unpack @@ -0,0 +1 @@ +/etc/init.d/msm-firmware-loader-unpack \ No newline at end of file diff --git a/overlay/rootfs/etc/runlevels/sysinit/msm-firmware-loader b/overlay/rootfs/etc/runlevels/sysinit/msm-firmware-loader new file mode 120000 index 0000000..9b07121 --- /dev/null +++ b/overlay/rootfs/etc/runlevels/sysinit/msm-firmware-loader @@ -0,0 +1 @@ +/etc/init.d/msm-firmware-loader \ No newline at end of file diff --git a/overlay/rootfs/usr/bin/bananarchy-lid b/overlay/rootfs/usr/bin/bananarchy-lid index b966a9f..3803674 100755 Binary files a/overlay/rootfs/usr/bin/bananarchy-lid and b/overlay/rootfs/usr/bin/bananarchy-lid differ diff --git a/prebuilt/bananarchy-daemons/usr/bin/bananarchy-lid b/prebuilt/bananarchy-daemons/usr/bin/bananarchy-lid index b966a9f..3803674 100755 Binary files a/prebuilt/bananarchy-daemons/usr/bin/bananarchy-lid and b/prebuilt/bananarchy-daemons/usr/bin/bananarchy-lid differ diff --git a/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko b/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko index e766f1d..f0b552c 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko and b/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko differ diff --git a/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko.zst b/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko.zst index fb084ba..c52af0a 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko.zst and b/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko.zst differ diff --git a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb index 8705f67..7be88b4 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb and b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb differ diff --git a/prebuilt/kernel-6.12.1-msm8916/vmlinuz b/prebuilt/kernel-6.12.1-msm8916/vmlinuz index 910cc31..14cd146 100755 Binary files a/prebuilt/kernel-6.12.1-msm8916/vmlinuz and b/prebuilt/kernel-6.12.1-msm8916/vmlinuz differ diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh index 4763caa..7947516 100755 --- a/scripts/check-rebuild.sh +++ b/scripts/check-rebuild.sh @@ -88,7 +88,8 @@ else fi for pkg in alpine-base postmarketos-ui-sxmo-de-dwm webkit2gtk-4.1 libwpe \ sudo imv-x11 fcitx5-gtk3 mesa-utils sfeed yabasic yabasic-doc \ - curl bc ed rlwrap mandoc nano less frotz tcl; do + curl bc ed rlwrap mandoc nano less frotz tcl \ + msm-firmware-loader msm-firmware-loader-openrc msm-firmware-loader-wcnss; do if ! grep -Fxq "$pkg" "$PKGS_FILE"; then fail "missing critical package: $pkg" fi @@ -105,6 +106,21 @@ else done fi +echo "[check] WCNSS firmware loader services..." +for service in \ + "$BASE_DIR/overlay/rootfs/etc/runlevels/sysinit/msm-firmware-loader" \ + "$BASE_DIR/overlay/rootfs/etc/runlevels/boot/msm-firmware-loader-unpack"; do + if [ ! -L "$service" ]; then + fail "WCNSS firmware loader runlevel link is missing: ${service#"$BASE_DIR/"}" + fi +done +if [ "$(readlink "$BASE_DIR/overlay/rootfs/etc/runlevels/sysinit/msm-firmware-loader" 2>/dev/null)" != \ + "/etc/init.d/msm-firmware-loader" ] || \ + [ "$(readlink "$BASE_DIR/overlay/rootfs/etc/runlevels/boot/msm-firmware-loader-unpack" 2>/dev/null)" != \ + "/etc/init.d/msm-firmware-loader-unpack" ]; then + fail "WCNSS firmware loader services are wired to the wrong init scripts" +fi + echo "[check] Rootfs prune list..." if [ ! -f "$PRUNE_FILE" ]; then fail "missing $PRUNE_FILE" @@ -353,8 +369,8 @@ fi echo "[check] Known-good flashable image set..." for pair in \ "69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08 images/bananarchy-nokia-argon.img" \ - "f4e9b8b2b36d4ffa9ba4f74de293b14f16b5ed45bbd5ab1d62bc2023242b73b2 images/bananarchy-nokia-beatles.img" \ - "6715abd414fd02fd21ca8c2cd621a8a21e78f46d079b2d185b38a1f7a4a3e659 images/boot-bananarchy-nokia-beatles.img" \ + "cc22a0d99972866e205bb76af37498a327e87a10d81e8341300ca3547ca4890a images/bananarchy-nokia-beatles.img" \ + "2b5c61aba307dbbda61f3b19a2ad5770f9854f41cba4e2c97e24efb7e20879f3 images/boot-bananarchy-nokia-beatles.img" \ "b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do set -- $pair want=$1 @@ -464,6 +480,13 @@ fi if ! grep -q 'msm8905-cam' "$BASE_DIR/overlay/rootfs/etc/local.d/10-bananarchy-hardware.start"; then fail "the local.d hardware fallback no longer loads the camera driver" fi +CAM_DRIVER="$BASE_DIR/src/msm8905-cam/msm8905-cam.c" +if ! grep -qF 'cam->rotate_180 = of_machine_is_compatible("nokia,beatles");' \ + "$CAM_DRIVER" || \ + ! grep -qF 'msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb, cam->rotate_180);' \ + "$CAM_DRIVER"; then + fail "the beatles-only 180-degree camera orientation correction is missing" +fi if [ ! -f "$BASE_DIR/scripts/busybox-sbin-applets.txt" ] || \ ! grep -qxF 'reboot' "$BASE_DIR/scripts/busybox-sbin-applets.txt"; then fail "the /sbin BusyBox applet list is missing reboot (Sxmo power menu)" @@ -501,6 +524,11 @@ if ! grep -q 'spidev@1' "$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beat grep -q 'spidev@1'; then fail "the cover panel spidev@1 node is missing from the shipping DTS/DTB" fi +if ! dtc -I dtb -O dts "$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb" 2>/dev/null | \ + sed -n '/display@0 {/,/^ };/p' | \ + grep -q 'spi-max-frequency = <0x17d7840>'; then + fail "the beatles main panel lost its 25 MHz high-backlight-safe SPI timing" +fi if ! grep -q '^dc_gpio = -1' "$BASE_DIR/overlay/rootfs/etc/bananarchy/cover-display.conf"; then fail "the cover daemon config would collide with the internal panel DC GPIO" fi @@ -839,8 +867,8 @@ fi echo "[check] Flip lid responsiveness..." LID_SRC="$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c" -for token in '#define LID_STABLE_MS 80' 'BA_EVIOCGSW' 'LID_STATE_FILE' \ - 'LOCKER_FIFO' 'unlink(LOCK_FLAG)'; do +for token in '#define LID_STABLE_MS 80' '#define HALL_POLL_MS 200' 'BA_EVIOCGSW' 'LID_STATE_FILE' \ + 'LOCKER_FIFO' 'unlink(LOCK_FLAG)' 'now - last_hall_poll >= HALL_POLL_MS'; do if ! grep -qF "$token" "$LID_SRC"; then fail "the compiled lid daemon lost the low-latency EV_SW/unlock path ($token)" fi @@ -883,6 +911,8 @@ for f in etc/rc.conf etc/conf.d/udev-settle \ usr/bin/bananarchy-x11-session.sh etc/init.d/bananarchy-lid \ etc/init.d/bananarchy-sshd-debug etc/init.d/local \ etc/local.d/20-bananarchy-sshd-debug.start; do + # A clean clone has no rootfs yet; rebuild-image.sh bootstraps it next. + [ -e "$BASE_DIR/rootfs/$f" ] || continue if ! cmp -s "$BASE_DIR/overlay/rootfs/$f" "$BASE_DIR/rootfs/$f"; then fail "live rootfs copy drifted from overlay: $f" fi diff --git a/scripts/rootfs-packages.txt b/scripts/rootfs-packages.txt index c7ef5d9..58327bd 100644 --- a/scripts/rootfs-packages.txt +++ b/scripts/rootfs-packages.txt @@ -52,6 +52,9 @@ linux-postmarketos-qcom-msm8916 mandoc mesa-utils modemmanager +msm-firmware-loader +msm-firmware-loader-openrc +msm-firmware-loader-wcnss nano openssh openssh-server-pam diff --git a/src/bananarchy-daemons/bananarchy-lid.c b/src/bananarchy-daemons/bananarchy-lid.c index bd52000..1d54bbc 100644 --- a/src/bananarchy-daemons/bananarchy-lid.c +++ b/src/bananarchy-daemons/bananarchy-lid.c @@ -14,6 +14,7 @@ #define LOCK_FLAG "/tmp/bananarchy_screen_locked" #define LOCKER_FIFO "/tmp/dwm_plugin_locker.fifo" #define LID_STABLE_MS 80 +#define HALL_POLL_MS 200 #define GPIO_FILE "/sys/kernel/debug/gpio" #define COVER_SOCKET "/run/bananarchy/cover.sock" #define LID_CLIENT_SOCKET "/run/bananarchy/lid-client.sock" @@ -250,6 +251,7 @@ int main(void) struct watch_list list; long long now; long long last_scan = 0; + long long last_hall_poll = 0; long long last_transition = 0; long long last_broadcast = 0; long long candidate_since; @@ -263,12 +265,13 @@ int main(void) install_reaper(); memset(&list, 0, sizeof(list)); switch_mask = current_switch_mask(&evdev_found); - if(evdev_found) + hall = hall_state(); + if(hall >= 0) + stable_closed = hall; + else if(evdev_found) stable_closed = (switch_mask & (int)CLOSED_MASK) != 0; - else { - hall = hall_state(); - stable_closed = hall >= 0 ? hall : 0; - } + else + stable_closed = 0; candidate = stable_closed; now = now_ms(); candidate_since = now; @@ -300,12 +303,14 @@ int main(void) } if(nfds > 0) read_ready(&list, fds, nfds, &switch_mask); - if(list.count > 0) { - observed = (switch_mask & (int)CLOSED_MASK) != 0; - } else { + observed = (switch_mask & (int)CLOSED_MASK) != 0; + /* EV_SW can miss edges or report a stale mask on the 2720 hall sensors. + * Reconcile with the raw lines even while evdev remains available. */ + if(now - last_hall_poll >= HALL_POLL_MS) { hall = hall_state(); - observed = hall >= 0 ? hall : - (switch_mask & (int)CLOSED_MASK) != 0; + if(hall >= 0) + observed = hall; + last_hall_poll = now; } if(observed != candidate) { candidate = observed; diff --git a/src/msm8905-cam/msm8905-cam.c b/src/msm8905-cam/msm8905-cam.c index 2c52d12..90eb492 100644 --- a/src/msm8905-cam/msm8905-cam.c +++ b/src/msm8905-cam/msm8905-cam.c @@ -171,6 +171,7 @@ struct msm8905_cam_dev { u16 chip_id; bool streaming; bool hw_initialized; + bool rotate_180; }; static struct msm8905_cam_dev *g_cam; @@ -600,17 +601,19 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam) return 0; } -static void msm8905_cam_demosaic(const u8 *raw, u8 *rgb) +static void msm8905_cam_demosaic(const u8 *raw, u8 *rgb, bool rotate_180) { u32 y, x; u32 idx = 0; for (y = 0; y < CAM_OUT_HEIGHT; y++) { - const u8 *r0 = raw + (2U * y) * CAM_RAW_STRIDE; - const u8 *r1 = raw + (2U * y + 1U) * CAM_RAW_STRIDE; + u32 src_y = rotate_180 ? CAM_OUT_HEIGHT - 1U - y : y; + const u8 *r0 = raw + (2U * src_y) * CAM_RAW_STRIDE; + const u8 *r1 = raw + (2U * src_y + 1U) * CAM_RAW_STRIDE; for (x = 0; x < CAM_OUT_WIDTH; x += 2U) { - u32 g_off = (x >> 1) * 5U; + u32 src_x = rotate_180 ? CAM_OUT_WIDTH - 2U - x : x; + u32 g_off = (src_x >> 1) * 5U; u8 b0 = r0[g_off + 0U]; u8 g0 = (u8)(((u32)r0[g_off + 1U] + (u32)r1[g_off + 0U]) >> 1); u8 r_0 = r1[g_off + 1U]; @@ -618,12 +621,21 @@ static void msm8905_cam_demosaic(const u8 *raw, u8 *rgb) u8 g1 = (u8)(((u32)r0[g_off + 3U] + (u32)r1[g_off + 2U]) >> 1); u8 r_1 = r1[g_off + 3U]; - rgb[idx + 0U] = r_0; - rgb[idx + 1U] = g0; - rgb[idx + 2U] = b0; - rgb[idx + 3U] = r_1; - rgb[idx + 4U] = g1; - rgb[idx + 5U] = b1; + if (rotate_180) { + rgb[idx + 0U] = r_1; + rgb[idx + 1U] = g1; + rgb[idx + 2U] = b1; + rgb[idx + 3U] = r_0; + rgb[idx + 4U] = g0; + rgb[idx + 5U] = b0; + } else { + rgb[idx + 0U] = r_0; + rgb[idx + 1U] = g0; + rgb[idx + 2U] = b0; + rgb[idx + 3U] = r_1; + rgb[idx + 4U] = g1; + rgb[idx + 5U] = b1; + } idx += 6U; } } @@ -723,7 +735,7 @@ static int msm8905_cam_capture_rgb(struct msm8905_cam_dev *cam, u8 *dst_rgb) return -ETIMEDOUT; } - msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb); + msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb, cam->rotate_180); cam->sequence++; return 0; } @@ -1105,6 +1117,8 @@ static int __init msm8905_cam_init(void) return -ENOMEM; mutex_init(&cam->lock); + /* The 2720 Flip sensor is mounted 180 degrees from the other Nokia targets. */ + cam->rotate_180 = of_machine_is_compatible("nokia,beatles"); cam->pdev = platform_device_register_simple("msm8905-cam", -1, NULL, 0); if (IS_ERR(cam->pdev)) { @@ -1160,8 +1174,8 @@ static int __init msm8905_cam_init(void) goto err_v4l2; g_cam = cam; - pr_info("msm8905-cam: registered /dev/video%d (GC2395/GC2385 800x600 RGB24, dma=0x%08llx)\n", - cam->vdev.num, (unsigned long long)cam->raw_dma_phys); + pr_info("msm8905-cam: registered /dev/video%d (GC2395/GC2385 800x600 RGB24, dma=0x%08llx, rotate180=%u)\n", + cam->vdev.num, (unsigned long long)cam->raw_dma_phys, cam->rotate_180); return 0; err_v4l2: