- Scope WirePlumber 50-bluetooth.conf roles to [ a2dp_sink hsp_hs hfp_hf ], lock HFP to 8 kHz CVSD for QDSP6 INTERNAL_BT_SCO, enable dummy AVRCP player, and set LDAC ABR quality. - Select BR/EDR bearer and ConnectProfile fallback for Classic Audio headsets while preserving LE bearer for HOGP devices, forward AVRCP media keys to music.so, bound discoverability to 60 s, fix SCO keepalive teardown/readiness and ATA call state sync, and suppress nokia-sparkler speaker haptic audio during BT SCO. - Advertise Smartphone Class of Device (0x5a020c / btmgmt class 2 3), handle OBEX over both L2CAP SOCK_SEQPACKET and RFCOMM SOCK_STREAM via ObexPacketReader, and add NeoUI incoming file Accept/Reject dialog and configurable target folder picker in networks.so. - Add scripts/test-bluetooth-headset.py and scripts/test-bluetooth-obex.py, and rebuild/pin verified a1120 (cocojamboo) images and release archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler.
16 KiB
16 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-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 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,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 = dualandClass = 0x5a020c(btmgmt -i hci0 class 2 3) 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 power on, enable LE, 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).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. 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. - 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.