- Fix Combined EPS/IMSI (cs_attach=1) false 4G-only IMS activation in ims_qrtr.h, close idle QRTR sockets, bound child/baseband retries, and deduplicate state.env writes in bananarchy-imsd.c - Skip inactive DHCP/connectivity IMS notifications in 40-bananarchy-ims.sh and add capped exponential registration backoff (5s-300s) plus openCtlSocket() rebind guard in bananarchy-vowifi - Sync CPU scaling_governor and idempotent screenoff/screenon policy across bananarchy-display-power-sync, locker.so, and bananarchy-power-policy.sh (standby.mode + rat_timer.pid), and gate noisy change events when dark in 30-bananarchy-network-status.sh - Fix bananarchy-dsds --sig-hysteresis QMI NAS wire opcodes to 0x0045 (1-byte sub bind) and 0x0050 (RSSI/RSCP/RSRP/LTE report threshold config) - Remove static 200 mA regulator-system-load on PM8909 l11 across all 6 DTS files and recompile all 5 shipping DTBs - Extend test-imsd-volte.py, test-standby-power-policy.py, check-rebuild.sh, BATTERY-OPTIMIZATION-ANALYSIS.md (Section 24), AGENTS.md, and Unreleased CHANGELOG.md notes + rebuilt image SHA-256 checksums (--mkinitfs)
19 KiB
19 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
a1120/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-lk2nd-sparkler.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
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,BANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-coconut --mkinitfs, andBANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-sparkler --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 = dual,PairableTimeout = 0, andClass = 0x5a020c(btmgmt -i hci0 class 2 3,bredr on,ssp on,linksec on,bondable on,advertising off,le on) inetc/bluetooth/main.confandbananarchy-bt-le-enable.sh; BlueZ 5.87 rejects LE-only HOGP inbredrmode, anda2dp_sourcemust stay out of50-bluetooth.confso paired Android phones recognize Object Push rather than an audio sink. KeepUserspaceHID=true,LEAutoSecurity=true,ClassicBondedOnly=false, andIdleTimeout=0ininput.conf.bananarchy-bt-obexmust register a persistent"KeyboardDisplay"Agent1(never"NoInputNoOutput") with/run/bananarchy/bt-obex/pair_{prompt,decision}.tsvandxnetworksBtPairingPromptUI (auto-confirming Classic Audio headsets, prompting user confirmation/PIN/passkey for phones/keyboards,50 sPairtimeout,--async-uinon-blocking operations, phoneis_phone_or_computer_propsvs audio separation), power on, enable LE/SSP, select the LE bearer (PreferredBearer = "le") for HID-over-GATT devices, select the BR/EDR bearer (PreferredBearer = "bredr", public address preference,ConnectProfilefallback) for Classic Audio / dual-mode BT 5.x/6.x headsets, pair unbonded devices, forward(AVRCP)media keys toxmusic, handle both L2CAPSOCK_SEQPACKETand RFCOMM viaObexPacketReaderwithxnetworksincoming confirmation / target folder (~/.config/sxmo/bt_obex_dir) IPC, and keep discoverability hidden-by-default with a 60 s timeout (bt_discoverable=0, neverdiscoverable-timeout 0). Keep all four50-bluetooth.confcopies synced withbluez5.roles = [ a2dp_sink hsp_hs hfp_hf ],bluez5.enable-msbc = false,bluez5.enable-lc3-a127 = false,bluez5.dummy-avrcp-player = true, andbluez5.a2dp.ldac.quality = "auto"(noa2dp_source,bap_*,hsp_ag,hfp_ag, orlc3— WCN3620 SCO routes internally at 8 kHz CVSD to QDSP6INTERNAL_BT_SCO_RX/TX). Keepetc/conf.d/bluetooth(supervisor=supervise-daemon,retry="TERM/3/KILL/1",--noplugin=hfp,bap,bass,mcp,vcp,micp,csip,ccp,tmap,gmap,asha,midi,neard), exclude gateway UUIDs (0000111f-/00001112-/0000110a-) fromReconnectUUIDs, keepduplicate-data offinbananarchy-bt-scan.sh, cleanly disconnect/btmgmt power offinsxmo_bluetoothtoggle.sh off, and usebananarchy-bt-obex's single-shotObjectManagercache (/run/bananarchy/bt-obex/bt_state.tsv+dump-state, filteringEPHEMERAL_DEV_PROPS) innetworks.soinstead of per-devicebluetoothctlstorms sobluetoothdnever enters EOF/dual-bearer busy loops.util-linux-miscandbluez-btmgmtsupport the live PTY scan wrapper; guardscripts/test-bluetooth-{hid,scan,live-scan,headset,obex}.py. - 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. Keeprc-manager=file+dns=dnsmasqin20-bananarchy-dns.conf, baselineoverlay/rootfs/etc/resolv.conf,0600USB_Networking.nmconnection(never-default=true,ignore-auto-dns=true),loopbackinboot, non-blocking50-dns-filter.sh(dhcp4-change/dhcp6-change/dns-change, nologger -iorsleeploops), non-leaking VPN/etc/resolv.confpinning (bananarchy-privacy-ctl sync-dnswithout127.0.0.1), andscripts/test-dns-resolution.py. 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,bananarchy-imsctl,bananarchy-imsd) alongsidebananarchy-vowifi, 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(QMI_NAS 0x0045+0x0050RSSI/RSCP/RSRP/LTE report),bananarchy-display-power-sync(CPU_GOV_PATH+sync_standby_policyscreenoff/screenonacross dark/cover-lit/open), idempotentstandby.mode+rat_timer.pidinbananarchy-power-policy.sh,locker.soblankScreenBacklight/wakeScreenBacklightpower-policy sync,30-bananarchy-network-status.shdark-screen dispatcher gating,scripts/test-cover-idle.py,scripts/test-dsds-daemon.py, andscripts/test-standby-power-policy.py. - Keep IMS, VoLTE, VoWiFi, and mobile data (
wwan0) invariants:/etc/bananarchy/ims.confmust ship withvolte_mode=autoandvowifi_mode=auto(disabled at 0% idle CPU unless connected to a strictly PS-only 4G-only network excluding Combined EPS/IMSIcs_attach == 1, or explicitly enabled by the user),QMI_IMSDCM(0x0302) and QRTR (close_qrtr(), bounded child sync/check retries, parked/inactive Wi-Fi event skip, and40-bananarchy-ims.shinactive DHCP/connectivity early exit) must stay closed/idle at 0% CPU alongside dedicated QRTR socket isolation +g_pdc_loaded_iddeduplication inbananarchy-imsd,bananarchy-ims-bearer.shmust remain isolated fromwwan0,QMI_UIMAPDU lock serialization + exponential registration backoff inbananarchy-vowifi, emergency calls (112/911) prioritizing cellular CS/VoLTE before VoWiFi fallback, Duress Mode gating inbananarchy-imsctl/modem.so/files.so,/etc/init.d/modemmanagerandmsm-modem-uim-selectionpreloadinglibmm-wds-bind.so(PRIMARYQMI_WDSbinding without callingQMI_DSD 0x004E),mobile-data-prep/10-bananarchy-dpm.shrestore-dsdshandling stickycs-onlyDual-SIM pausing, andscripts/test-{lte-mobile-data,ims-mbn,imsd-volte,vowifi-swu-ims}.pypassing underscripts/check-rebuild.sh. - 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/l11/l12across DTS/DTBs with no staticregulator-system-loadonl11), 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; keeplk2nd/device/menu/menu.cfree ofLK2ND_VERSIONboot/Fastboot screen text and keepLK2ND_VERSIONOS-version-neutral acrossscripts/build-lk2nd-{beatles,coconut,sparkler}.sh.check-lk2nd-{beatles,coconut,sparkler}.py,test-lk2nd-{beatles,coconut,sparkler}-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. - Keep
quagr(quagr.so/xquagr) receiver autostart strictly gated onautostart_rx=1plus a valid Rx passphrase or 64-char hex key, closed-flipQUAGRcover alerts dismissing on any side button (scripts/test-quagr.py),msm8905-cam.c180-degree rotation enabled fornokia,beatles,nokia,sparkler, andnokia,leoalongside cachedrow_bufRAW10 demosaic; keeppatches/kernel/0013-msm8909-early-scm-smp-cpufreq.patch(4-core SMP +cpufrequp to1.267 GHz), disabledvibrator@c000+ volume-independent calibrated157.0 Hzhaptic audio (sxmo_vibrate.c,libpulse+SND_PCM_FORMAT_FLOAT_LE,HAPTIC_REF_RX3_VOL = 84),DEFAULT_USB_TIMEOUT_MS = 30000(--usb-timeout), andsxmo_timer.sh/dmenu.ckeypad cancellation (scripts/test-timer.py,scripts/test-sparkler-port.py,scripts/test-edl-firehose-read.py,scripts/test-quagr.py). - 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.