- Migrate nokia-tough to canonical nokia-coconut while keeping CLI aliases, add layered bootloader/lk2nd/nokia-coconut.patch, bootfs/bootimg validators, and offline scripts/inspect-stock-msm8905-dump.py - Complete nokia-coconut Stage 2 hardware bring-up: wire 6-column 22-key keypad (gpio0, gpio3, gpio7, gpio99, gpio6, gpio1), gpio98 KEY_POWER, and pon@800:resin KEY_DOWN (0x6c); split leds-msm8905-torch into GPIO_13 white:torch (dedicated top-edge flashlight) and GPIO_32 camera:flash (rear camera flash for camera.so and bananarchy-photo) - Restore sdhci@7864000 non-removable across all six DTS/DTB targets, remove unwired gpio38 cd-gpios/sdc2-cd-* states, and harden sxmo_sdcard.sh under flock - Register upcoming build a1120 (cocojamboo) in scripts/version.sh, scripts/check-rebuild.sh, CHANGELOG.md, AGENTS.md, README.md, and MANUAL.md with verified hashes across nokia-argon, nokia-beatles, and nokia-coconut
14 KiB
14 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-coconut,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 current
public release is
a1114/carbonaraand the upcoming target build isa1120/cocojamboo;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-dwm-plugins.sh,build-bananarchy-daemons.sh,build-kernel-audio.sh,build-lk2nd-beatles.sh,build-lk2nd-coconut.sh,build-games.sh,build-fcitx5-t9.sh, andbuild-xlibre.sh. - Use
scripts/build-dmenu.shfor dmenu-only changes andscripts/build-dwm-plugins.shfor NeoUI/plugin rebuilds. 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 target images for upcoming build
a1120/cocojamboowithBANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-argon --mkinitfs,BANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-beatles --mkinitfs, andBANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-coconut --mkinitfs, and package release archives withBANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./prepare-release.sh <target>. After a verified rebuild, update the pinned hashes 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 and autostart daemons as compiled C ARM ELF binaries (
bananarchy-lid,bananarchy-cover-idle,bananarchy-volume-keys,bananarchy-dsds,bananarchy-modemmonitor,bananarchy-soundmonitor,bananarchy-notifmonitor,bananarchy-run-aligned,bananarchy-session-loop), not Python or/bin/shloops. Preserve/run/bananarchy/lid-state, the cover socket protocol,FBIOBLANK, cover diagnostics,should_skip_while_dark(),bananarchy-dsds --sig-hysteresis,scripts/test-cover-idle.py,scripts/test-dsds-daemon.py, andscripts/test-standby-power-policy.py. - Keep standby battery invariants from
0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patchandbananarchy-power-policy.conf:CPU_RPM_SLEEP=0,CPU_L2_SLEEP=0,MODEM_DRX_MODE=0,WIFI_LISTEN_INTERVAL=8,WIFI_STANDBY_RAT=gsm,msm8916-wcd-analogs2gating,pm8916_bms_vmscreen_offS3 OCV mode,sdhci-msmvmmc/vqmmcset_load(regulator-allow-set-load;onl8/l12across DTS), andmsm8905-cam.cRPMl6/l17regulator consumer voting (regulator_get_optional, never raw APSS SPMI writes on RPM LDOs). - 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 routing are physically probed: a live test darkened both screens. gpio13 polarity is now TE-probed (high = cover, low = internal), but the two-panel DT remains opt-in. The shipping image drives the external GC9305 through the kernelpanel-mipi-dbi-spidriver while the flip is closed only (bananarchy-cover-idle); never claim gpio13/23 or send cover SPI traffic while the flip is open, gate initial activation on the main panel being DPMS-off, and always restore the mux onLID OPEN. - The KaiOS 3.10 DTS and kernel driver give both panels shared CS0, gpio110 D/C and one active-high PMIC MPP2 PWM
backlight (
kernel_backlight_invert = 0,kernel_backlight_level = 14); gpio21 is TE and gpio23 is the external reset. Because the internal 240x320 TN panel is normally-white while the external 240x240 panel is normally-black,cover_kernel_drawwakes DRM with gpio13 low, paints the internal panel solid black via an X11override_redirectcover window plus/dev/fb0, and leaves the internal GC9305 scanning black GRAM (kernel_internal_sleep = 0) behind gpio13 high so it blocks the shared backlight while the cover is lit. Keep the exact vendor external init firmware, the debugfs command replay, the gpio23 reset pulse,/run/bananarchy/cover-backlight(0= GRAM prep dark,1= cover lit, absent = dark/DPMS Off),kernel_power_sync_helperand/run/bananarchy/cover-bl-force. Plain udev events must stay idempotent; only the daemon'sforcemode may do the two-step PWM update, and everyxset dpms forcecall must be bounded withtimeout 1or a hung X client will flicker the active panel. On open, restore gpio13 low, duty 14,bl_power=0, DPMS On and re-init the internal panel. The legacy 8-bit/9-bit userspace paths,PROBEandbananarchy-cover-probe.shremain rollback/sign-off tooling.SET mux_closed_level 0selects the internal panel, not the cover;SET kernel_backlight_invert 0|1andSET kernel_internal_sleep 0|1remain runtime knobs. - Keep the internal beatles panel at 25 MHz,
dc_gpio = -1for the spidev fallback, external-panel firmware and initramfs module lists,/etc/boot-deploy/hooks/10-initramfs-depmod.sh(per-initramfsdepmod -b),.ko.zst-only module installs, the Xorgcard0pin,bananarchy-cover-diagnose.sh, and thescripts/test-cover-dt.py/scripts/test-cover-spidev.pyguards. - The shipping cover backend is
backend = kernel: keepbananarchy-cover-dpms.sh reinit, the gpio13 mux claim, the centered 240x240 X11//dev/fb0cover frame, the 1 s repaint against Xorg,kernel_backlight_invert = 0,kernel_internal_sleep = 0,kernel_backlight_level = 14, shared Config -> Screen blank timeout reload (wake_blank_timeout = 8for passive wakes), closed-flipCALLcover UI (cover_hold_awake,BUTTON VOLUP/VOLDOWN->mute-ring,BUTTON POWER->hangup-call, delayedCALL mutedguard), cleanSIGTERMcover blanking, live timezone refresh (ba_refresh_tz/REFRESH),scripts/test-cover-kernel.py,scripts/test-time-timezone-sync.py, and thespidev/fb/nonerollback backends. The daemon must restore the internal panel onLID OPENeven after a stale high gpio13 survives a restart. - Keep the 2720 Flip lid handling event-driven and instant: sticky hall state, immediate hall re-read on
EV_SWedges, 20 ms debounce,SW_LIDmirroring (sync_sw_lid) sodwmtracks the hall sensor, and synchronous lid-state/lock/backlight/DPMS writes inbananarchy-lid.c. Closing locks the desktop; opening must keep the lock flag and wake to the passcode lockscreen (never auto-unlock) while sendingRAISEtocallscreenand keepingsxmo_hook_lock.sh/locker.sofrom hanging up incoming/active calls (UNGRAB). 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.apply-bananarchy-overlay.shwrites/usr/share/bananarchy/lid-profileper target (slideronnokia-argon,fliponnokia-beatles,noneelsewhere) and disablesbananarchy-{lid,cover-display,volume-keys}, cover udev/config, and mux modprobes on non-flip builds sonokia-argonkeeps pure sliding-lid behaviour. 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;Logoutis removed fromdmenu.c,dmenu.so,sxmo_appmenu.sh, andsxmo_hook_contextmenu.sh. Keep the compact Power menu layout synchronized. - 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.