The lid daemon re-derived "observed" from a stale EV_SW mask on every 100 ms iteration and only read the raw hall lines every 200 ms, so the candidate oscillated and the 80 ms debounce almost never completed. A controlled hall transition on the live phone took over 2.2 s to blank and lock the main panel. The hall reading is now sticky, every EV_SW edge forces an immediate hall re-read, the loop and debounce are 20 ms, and the daemon writes the lid state, lock flag, Sxmo state and both backlights synchronously in C before spawning hooks. A direct xset DPMS off/on stops or resumes Xorg's SPI flushes at once. bananarchy-lid-state.sh guards the asynchronous hooks by lid state and a transition generation counter, so a late screenoff cannot re-lock a flip that was just opened. bananarchy-lid-gate.sh now gates sxmo_wm.sh display on, the screen-wake helper, the backlight udev helper, sxmo_state.sh set unlock (dwm calls it directly) and both input handler copies. While the flip is closed it blocks the main panel and keypad backlight, forces brightness/kbd/DPMS off against stray writes, and forwards a WAKE datagram to the cover display. Ring, notification and call-state hooks publish to the cover, and the cover daemon gained WAKE, event wakes, immunity to repeated LID CLOSED rebroadcasts and a bounded retry for a DPMS-deferred draw. Live verification with controlled hall transitions and uinput switch/key injection: close blanks and locks in ~45-90 ms (hall-poll fallback ~100-220 ms), open restores brightness, keypad backlight, unlock and DPMS in ~10-130 ms with no stale-hook re-lock. All three external keys and an incoming call leave brightness=0, kbd_backlight=0 and DPMS=Off while the cover reports backend=spidev visible=1; opening returns mux=open. Rebuilt the a1108/dejavu nokia-beatles image and pinned the verified hash 0f33aa6e9fc70022574b453aaafb9307c4d185431d3be272782c8403dd0fb291 in check-rebuild.sh. e2fsck -fn passed on both partitions, debugfs confirms twelve updated rootfs files byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight all pass. This is an intermediate checkpoint: eyes-on cover illumination and the remaining polarity/CS fixes are still required.
8.9 KiB
8.9 KiB
Bananarchy Linux — agent guide
Keep this file short. Full details live in README.md, MANUAL.md, SDK.md, CHANGELOG.md,
BATTERY-OPTIMIZATION-ANALYSIS.md, bootloader/lk2nd/README.md, and scripts/check-rebuild.sh.
Project scope
- Bananarchy is an
armv7Alpine/postmarketOS hardfork for MSM8905/MSM8909 keypad feature phones with 240x320 non-touch SPI displays:nokia-argon,nokia-beatles,nokia-tough,nokia-sparkler, andnokia-leo. - The stack is X11-only: Xlibre, patched
sxmo-de-dwm, preloaded C/C++ DWM plugins, NeoUI,fcitx5-t9, and Adreno 304 Glamor/DRI3/GLX overpanel-mipi-dbi. No Wayland compositor, backend, or viewer is shipped. - Design targets are keypad-first 240x320 UI, <2 ms wake latency, and <95 MB idle RAM on 512 MB devices. The pinned
release is
a1108/dejavu;scripts/version.shandscripts/check-rebuild.share authoritative.
Source of truth and workflow
- Treat
prebuilt/as the single source of truth for compiled artifacts andscripts/rootfs-packages.txtas the single source of truth for packages.overlay/rootfs/is a generated mirror; never hand-edit binaries there. Run./scripts/sync-prebuilt-overlay.shafter artifact changes. - Treat
images/,rootfs/, and build caches as local, gitignored outputs. Clean clones rebuild them from source;scripts/check-rebuild.shpins physically verified hashes only when those local artifacts exist. - Run
./scripts/check-rebuild.sh, relevantscripts/test-*.pytests,./scripts/sync-prebuilt-overlay.sh --check, andgit diff --checkbefore claiming a source, artifact, docs, or release change is complete. - Cross-compile inside rootless Docker. Main builders are
scripts/build-sxmo-x11.sh,build-dmenu.sh,build-bananarchy-daemons.sh,build-kernel-audio.sh,build-lk2nd-beatles.sh,build-games.sh,build-fcitx5-t9.sh, andbuild-xlibre.sh. - Use
scripts/build-dmenu.shfor dmenu-only changes. Do not run a fullbuild-sxmo-x11.shcasually: the shippeddwmbinary contains cover IPC strings absent from source, so a full rebuild driftsdwm; restore or reconcile it. - Rootfs/image tools are
scripts/bootstrap-rootfs.sh,scripts/apply-bananarchy-overlay.sh,scripts/compile-gsettings-schemas.sh,rebuild-image.sh,scripts/sync-beatles-bootfs.py --check,prepare-release.sh, andflash-edl.sh. - Rebuild the verified 2720 image with
BANANARCHY_VERSION=a1108 BANANARCHY_CODENAME=dejavu ./rebuild-image.sh nokia-beatles. After a verified rebuild, update the raw hash inscripts/check-rebuild.shandCHANGELOG.md; verify withe2fsck -fn,debugfs, bootfs sync, artifact sync, andcheck-rebuild.sh. - Do not push to
originunless explicitly requested. Do not update pinned hashes or release claims without actual verification.
Critical invariants
- Bluetooth requires
ControllerMode = dualinetc/bluetooth/main.conf; BlueZ 5.87 rejects LE-only HOGP inbredrmode. KeepUserspaceHID=true,LEAutoSecurity=true,ClassicBondedOnly=false, andIdleTimeout=0ininput.conf.bananarchy-bt-obexmust power on, enable LE, select the LE bearer for HID-over-GATT devices, and pair unbonded devices.util-linux-miscandbluez-btmgmtsupport the live PTY scan wrapper. - WebKit requires explicit
glibandgsettings-desktop-schemaspackages. Because apk uses--no-scripts,apply-bananarchy-overlay.shmust runcompile-gsettings-schemas.sh; withoutgschemas.compiled, the WebKit network process aborts. Keep the Webarchy renderer fallback. - Do not change
CONFIG_PREEMPT*,CONFIG_PM_SLEEP/CONFIG_SUSPEND,CONFIG_SMP,CONFIG_MODVERSIONS,CONFIG_MODULE_UNLOAD,CONFIG_ENERGY_MODEL,CONFIG_PERF_EVENTS,CONFIG_FUNCTION_GRAPH_TRACER, orCONFIG_HZwithout rebuilding every pmaports module.CONFIG_SUSPENDstays off; deep suspend and long-lived pollers are intentionally not planned. - Keep package and image hygiene: no top-level Rust packages such as
sudo-rs, no Wayland UI, no on-device compiler (gcc,g++,musl-dev,make), no Janet runtime, no targetpkilldependency, noapkcall afterrebuild-image.shstrips caches, and no__pycache__underoverlay/rootfs/. - Keep the core tools and runtime dependencies guarded by
check-rebuild.sh. On-device scripting uses the Yabasic FFI SDK, soyabasic,libffi,libneoui.so, andlibcurl.so.4must remain; Perl, Lua, optional Tcl extensions, and the sqlite CLI stay excluded. - Keep power/network behaviour event-driven:
superctl disable sxmo_networkmonitor, no longnmcli device monitor, no infinite wakelocks, no forcedsxmo.noidle/sxmo.nosuspend, lz4 zram via/usr/bin/zramstart, andvm.compaction_proactiveness=0. GPS resolves throughbananarchy-gps-modem.sh, nevermmcli -m any. - Keep idle daemons as compiled C ARM ELF binaries (
bananarchy-lid,bananarchy-cover-idle,bananarchy-volume-keys), not Python. Preserve/run/bananarchy/lid-state, the cover socket protocol,FBIOBLANK, cover diagnostics, andscripts/test-cover-idle.py. - Keep the zero-lag plugin model: preloaded resident daemons guarded by lock/FIFO,
poll()at 0% CPU, offscreen240x296Pixmaps atY=24,PluginTheme,RELOAD_THEME, idle blank/lock helpers, the 350 msdwmwake guard, and startup keyboard-grab cleanup without a background poller. - Draw Pango/Xft wrapped text line by line with clipping and matching render rows for link focus. Use
smsTextMetrics()for GSM-7/UCS-2 accounting; strip[SIM n]tags withparseSmsHeaderLine()and never write them back tosms.txt.
Hardware and release caveats
- The shipping 2720 Flip DTS/DTB is single-panel. The two-panel
/dev/fb1layout is opt-in viascripts/build-beatles-cover-panel.py; rollback isscripts/build-beatles-no-cover-dtb.py. Do not make it default until gpio13 mux polarity and gpio21/gpio23 D/C/reset polarity are physically probed: a live test darkened both screens. The shipping image drives the external GC9305 from userspace over/dev/spidev0.1while the flip is closed only (bananarchy-cover-idle); never claim gpio13/21/23 or send SPI traffic while the flip is open, and gate activation on the main panel being DPMS-off; always restore the mux to the internal panel onLID OPEN. - Keep the internal beatles panel at 25 MHz,
dc_gpio = -1for the spidev fallback, external-panel firmware and initramfs module lists, the Xorgcard0pin,bananarchy-cover-diagnose.sh, and thescripts/test-cover-dt.py/scripts/test-cover-spidev.pyguards. - Keep the 2720 Flip lid handling event-driven and instant: sticky hall state, immediate hall re-read on
EV_SWedges, 20 ms debounce, and synchronous lid-state/lock/backlight/DPMS writes inbananarchy-lid.c. Every main-panel wake path must callbananarchy-lid-gate.sh; a closed flip may only light the cover.sxmo_state.sh set unlockis gated too becausedwmcalls it directly. Guardscripts/test-lid-gate.py. - Build the lk2nd display image from pinned
bootloader/lk2nd/nokia-beatles.patch. Exact stock IDs, 512 MiB memory fallback, appended DTB,quiet splash, and the low-bit reboot cookie matter.check-lk2nd-beatles.py,test-lk2nd-beatles-port.py,check-beatles-bootimg.py,sync-beatles-bootfs.py --check, andcheck-rebuild.shguard the boot chain. - Flash with
flash-edl.py's default--method lk2nd; stocksystemis wiped by default, so recovery-mode 2720 boots need Volume Up. Keep the signed per-device Firehose programmers and do not mix them. - Keep first-boot access intact:
keys/phone_id_ed25519.pubforuser/root, PAM/sshd configs, USB-only SSH fallback, keypad udev/Xorg rules, BusyBox applet lists, andscripts/set-bananarchy-hostname.sh. - The Power menu label is Reboot to loader and still calls
sxmo_power.sh bootloader. Keep the compact label indmenu.c,dmenu.so,sxmo_appmenu.sh, and the context-menu hook. - Bluetooth HOGP config and plugin load are verified, but full hardware sign-off still needs a wake-up paired keyboard and Connect Device to confirm real HID key events.
Coding and documentation rules
- Use 2-space indentation in C, C++, Python, Yabasic, and shell; tabs only in Makefiles and TSV. No emojis in code, UI strings, logs, or commit messages; use Nerd Font PUA icons. Use sentence case in all docs.
- Keep
README.md,MANUAL.md,SDK.mdfor API/SDK changes,CHANGELOG.md, and this guide synchronized with user-facing features, keybindings, build changes, and verified image changes. Do not leave third-party.mdfiles insrc/oredl/. - Treat
.bantam.cfgas local, gitignored credential data: never read, edit, commit, or unignore it. Keep other agent scratch files outside the repo. - Consult
SDK.md,MANUAL.md,X_KEYPAD_MAPPING.md,BATTERY-OPTIMIZATION-ANALYSIS.md,bootloader/lk2nd/README.md, andCHANGELOG.mdfor APIs, keymaps, flashing details, power tradeoffs, bootloader history, and release rationale.