The previous battery pass rebuilt the kernel image from a retuned config and produced an image stuck on the lk2nd logo. Two incompatibilities with the linux-postmarketos-qcom-msm8916 module tree (which this repo does not rebuild) were identified: 1. Vermagic: CONFIG_PREEMPT_VOLUNTARY removes CONFIG_PREEMPT_BUILD, so the rebuilt kernel reported "6.12.1-msm8916 SMP mod_unload ARMv7 p2v8" while every package module reports "6.12.1-msm8916 SMP preempt mod_unload ARMv7 p2v8". modprobe refuses all of them, including panel-mipi-dbi, so the display never initialises. 2. Struct layout: CONFIG_SUSPEND selects CONFIG_PM_SLEEP, which adds fields to struct dev_pm_info. Modules built without it use wrong dev->power offsets, so matching vermagic alone is not enough. Restored the known-good kernel config, the serial-console cmdline and the DTB wakeup-source additions. The kernel image is still cross-compiled by build-kernel-audio.sh but from the original config, so vermagic and struct layouts match every module in the rootfs. Reverted the config-level items K1, K6, K7, K8, K13 and K14; implementing them requires vendoring and rebuilding the entire pmaports kernel module tree. Kept: K2 clock-latency-ns, K3/K4/K5 via patch 0006 (rebuilt with the original config), K10 IPv6 sysctl, and all U1-U14 userspace changes. Rebuilt the kernel image/modules/DTBs and images/bananarchy-nokia-argon.img with --mkinitfs. Verified: all modules (package + rebuilt) now report identical vermagic, boot.img contains the new zImage + DTB byte-for-byte, the console cmdline is restored, check-rebuild.sh passes and artifact drift is 0. Docs: CHANGELOG.md (recovery section), MANUAL.md, README.md, AGENTS.md, BATTERY-OPTIMIZATION-ANALYSIS.md (section 11).
16 KiB
Bananarchy Linux — agent guide (AGENTS.md)
1. Project overview
Bananarchy is a keypad-first Linux distribution (armv7 / Alpine edge / postmarketOS v26.06 hardfork) for Qualcomm MSM8905 (Snapdragon 205) and MSM8909 (Snapdragon 210) smart feature phones with 240x320 QVGA non-touch SPI displays and 12-key T9 keypads (nokia-argon, nokia-beatles, nokia-tough, nokia-sparkler, nokia-leo).
It uses a pure X11 (Xlibre + sxmo-de-dwm) stack (no Wayland) with Adreno 304 (FD304) Glamor + DRI3 + GLX GPU acceleration over panel-mipi-dbi KMSRO, optimized for < 2 ms UI wakeup latency and < 95 MB idle RAM on 512 MB devices.
2. Repository layout
src/sxmo-dwm/: patcheddwmwindow manager (240x320verticalbstacklayout, 24px Pango status bar, nativeParentRelativedesktop clock and"Menu"/"Names"softkey bar, C-levelevdevSW_LIDslider and universal key wake handling,*+#screenshot chord viabananarchy-screenshot, live.Xresourcesreload, and.soplugin loader viadwm_plugin.h).src/sxmo-dmenu/: zero-lag resident DWM menu plugin (dmenu.so) and/tmp/dwm_plugin_dmenu.sockclient (dmenu/xdmenu), featuring built-in Sxmo menus (sys,applications,scripts,modem,config,power,audio,notifications,wm,timezone,games,st,nano,sthotkeys) andfcitx5-t9XIM input.src/neoui/: NeoUI240x320UI SDK (neoui.h->/usr/include/neoui.h,neoui.cpp->/usr/lib/libneoui.so) providing both a C-compatible FFI (neoui_*) and C++20 classes (ThemeSpec,PluginTheme,NeoWindow) for.Xresources/~/.xthemes/*.xththeme resolution, Xlib/Xft/Pango window and offscreenPixmapdouble buffering, standardized OS shell widgets, keypad/softkey chord handling, and multi-tap input (paired with Yabasic FFI librariesneoui.yabandneonet.yab+ examplesneoui_demo.yab,neonet_demo.yab, andbulls_cows.yabinoverlay/rootfs/home/user/Projects/).src/dwm-plugins/: preloaded C++20240x320DWM plugins linked againstlibneoui.soand shared headers:theme.h: header forwarding to../neoui/neoui.hfor unified.Xresources/~/.xthemes/*.xthparsing, proportional font sizing (theme.baseFontSize), automatic shade derivation, and live Xft/Pango theme reloading (PluginTheme).phone_data.h: shared X11 geometry (240x296below the 24px bar), FIFO IPC (/tmp/dwm_plugin_<name>.fifo), softkey chord detection, Sxmo TSV contact/call/SMS parsers (parseSmsHeaderLine()/stripSmsSimTag()tolerate the QMI WMS[SIM n]header tag), andlibjpeg/libpnghelpers.net_tls.h: shared C++20 TCP + OpenSSL TLS + STARTTLS socket class (NetStream), HTTP/HTTPSGETclient (httpGet), MD5/CSPRNG helpers, and RFC 2047 / Base64 / Quoted-Printable MIME decoders.pjsip_media.h: PJSIP (pjproject/pjmedia-codec/g722&pjmedia/alaw_ulaw) ITU-T G.722 wideband 16 kHz SB-ADPCM and G.711 PCMU/PCMA codec implementation forsip.so.monotone.h+bananarchy_melody.cpp(/usr/bin/bananarchy-melody): Nokia RTTTL (.nrt,.rtttl,.rtx), Ericsson eMelody (.emy), and IrDA iMelody (.imy) monophonic ringtone parser and 48 kHz WAV synthesizer.locker_plugin.cpp(locker.so/xlocker) +verify_passcode.c(/usr/bin/bananarchy-verify-passcode),passcode_plugin.cpp(passcode.so/xpasscode),dialer_plugin.cpp(dialer.so/xdialer),calllog_plugin.cpp(calllog.so/xcalllog),callscreen_plugin.cpp(callscreen.so/xcallscreen),contacts_plugin.cpp(contacts.so/xcontacts),sms_plugin.cpp(sms.so/xsms),files_plugin.cpp(files.so/xfiles),camera_plugin.cpp(camera.so/xcamera),themes_plugin.cpp(themes.so/xthemes),modem_plugin.cpp(modem.so/xmodem),networks_plugin.cpp(networks.so/xnetworks/xbluetooth),ringtones_plugin.cpp(ringtones.so/xringtones),wallpapers_plugin.cpp(wallpapers.so/xwallpapers/xbackground),music_plugin.cpp(music.so/xmusic/xplayer),sip_plugin.cpp(sip.so/xsip),email_plugin.cpp(email.so/xemail/xmail),irc_plugin.cpp(irc.so/xirc),tox_plugin.cpp(tox.so/xtox),smallweb_plugin.cpp(smallweb.so/xkopher/kopher/xsmallweb),webarchy_plugin.cpp(webarchy.so/webarchy/xwebarchy),gps_plugin.cpp(gps.so/xgps/xmaps/xnav),privacy_plugin.cpp(privacy.so/xprivacy/privacy),engmenu_plugin.cpp(engmenu.so/xengmenu).dwm_plugin_runner.c: lightweight/usr/bin/dwm-pluginlauncher symlinked byxlocker,xpasscode,xdrawer,xdialer,xcalllog,xcallscreen,xcontacts,xsms,xfiles,xcamera,xthemes,xmodem,xnetworks,xbluetooth,xringtones,xwallpapers,xbackground,xmusic,xplayer,xsip,xemail,xmail,xirc,xtox,xkopher,kopher,xsmallweb,webarchy,xwebarchy,xgps,xmaps,xnav,xprivacy,privacy,xengmenu,dmenu, andxdmenu.sms_plugin.cpp(sms.so/xsms): threaded conversation view whose message bodies are drawn line by line and clipped to the bubble byrenderLayoutLines(), with a per-message scroll offset (msgScrollPx) and right-edge scrollbar;smsTextMetrics()accounts GSM-7 septets versus UCS-2 UTF-16 units and concatenated part limits. Readssms.txtlogs written by the QMI WMS daemon after 8-bit/16-bit concatenated SMS reassembly.
src/xdrawer/: global phone controls overlay (xdrawer.so/xdrawer), toggled by pressing both softkeys simultaneously.src/sxmo-st/: patchedstterminal with HarfBuzz OpenType ligatures (Fira Code),XIM(fcitx5-t9), and liveSIGUSR1.Xresourcesreload.src/fcitx5-t9/: 6-mode keypad input method (abc,Abc,ABC,Sym,Ctl,123+*long-pressCtrl+latch) with fixed bottom preedit bar (Y=290, H=30).src/games/: standalone keypad-driven240x320X11 games and emulators (snake.cpp->/usr/bin/snake,tetris.cpp->/usr/bin/tetris,scoundrel.cpp->/usr/bin/scoundrel,gambatte_phone.cpp+gambatte/->/usr/bin/gambatte//usr/bin/gbemu, andremedy/->/usr/bin/remedy//usr/bin/j2meJ2ME MIDP 2.0 / CLDC 1.1 + JSR-184 M3G 3D emulator) with built-in 5x7 bitmap fonts, NeoUI integration,timerfd-driven pacing, and offscreenPixmap/ EGL double buffering.src/msm8905-cam/&src/leds-msm8905-torch/: out-of-tree Linux6.12.1-msm8916kernel modules for the rearGC2395/GC2385/GC2365camera (/dev/video0) andSY7807torch LED (white:torch) / WCD codec init / PM8909PONshutdown.overlay/rootfs/: system configuration overlay applied over the target rootfs (kept in sync withprebuilt/).prebuilt/: cross-compiledarmv7binaries and kernel modules (sxmo-x11,fcitx5-t9,xlibre,kernel-6.12.1-msm8916,bantam,games,gsocket).devices/&patches/: device trees (.dts/.dtb), MIPI-DBI panel init sequences, and upstream patch sets.vendor/edl/: vendored, patched EDL client library (MIT) used byflash-edl.py; a localedl/checkout orBANANARCHY_EDL_DIRoverrides it.scripts/rootfs-packages.txt: single source of truth for thearmv7rootfs package set, read by bothbootstrap-rootfs.shandrebuild-image.sh.scripts/rootfs-prune-packages.txt: denylist of Wayland-only, Rust-based, and retired packages purged from existing rootfs trees bybootstrap-rootfs-container.shandrebuild-image.sh.scripts/prune-rootfs-packages.sh: two-phase rootfs pruner (worldbeforeapk add,purgeafter) that reads the denylist and pinsinstall_ifpackages with negative!pkgworld constraints plusapk fix; theworldphase is required so apk can atomically replace Rustsudo-rswith Csudo.
3. Build and image generation commands
All cross-compilation scripts run inside rootless Docker (alpine:3.24 armv7 sysroot) and write to prebuilt/; build-sxmo-x11.sh, sync-prebuilt-overlay.sh, and rebuild-image.sh mirror those artifacts into overlay/rootfs/ (and build-sxmo-x11.sh also refreshes rootfs/ when present):
./scripts/build-sxmo-x11.sh— buildslibneoui.so,st,dmenu.so,dwm,dwm-plugin,bananarchy-verify-passcode,bananarchy-melody,sxmo_vibrate, and all C++.soplugins (locker,passcode,xdrawer,dialer,calllog,callscreen,contacts,sms,files,camera,themes,modem,networks,ringtones,wallpapers,music,sip,email,irc,tox,smallweb,webarchy,gps,privacy,engmenu)../scripts/build-gsocket.sh— fetches and cross-compilesgsocket(gs-netcat,gsocket,gs-sftp,gs-mount,blitz) forarmv7../scripts/build-dmenu.sh— rebuilds onlydmenu.so,stest,dmenu_path, anddmenu_run../scripts/build-games.sh— builds standalone X11 games and emulators insrc/games/(snake,tetris,scoundrel,gambatte/gbemu,remedy/j2me)../scripts/build-fcitx5-t9.sh— buildssrc/fcitx5-t9(libt9.so/t9.so)../scripts/build-kernel-audio.sh— builds6.12.1-msm8916Adreno 304drm/msm, QDSP6 audio, torch LED, camera.komodules, device.dtbfiles, and thezImagekernel image frompatches/kernel/config-bananarchy-msm8909.armv7(exported asoverlay/rootfs/boot/vmlinuz,config,System.map). The resolved.configis written back to the config file so the module build and the shipped kernel never drift. Never changeCONFIG_PREEMPT*,CONFIG_PM_SLEEP/CONFIG_SUSPEND,CONFIG_SMP,CONFIG_MODVERSIONSorCONFIG_MODULE_UNLOADin that config without also rebuilding every module from the pmaports kernel package: vermagic andstruct dev_pm_infolayout must match the untouched package modules../scripts/build-xlibre.sh— builds XlibreXorg,libglamoregl.so,libglx.so, andmodesetting/libinput/fbdevDDX drivers../scripts/build-bantam.sh— fetches and cross-compiles thebantamAI agent../scripts/generate-artwork.py— regenerates wallpapers, splashes, and icons fromartwork/icon-large.png../scripts/version.sh [--print | target_rootfs]— computes the date-based release version (<year-letter><MM><DD>with2026 = a) and substitutes@BANANARCHY_VERSION@inetc/os-release,etc/issue, andetc/motd(invoked automatically during overlay application and image builds)../chroot-shell.sh— opens anarmv7container shell to manage packages inrootfs/(pkg-add,pkg-del,pkg-search); bootstrapsrootfs/first if needed../rebuild-image.sh <device> [--mkinitfs]— verifies the clone, syncsprebuilt/intooverlay/rootfs/, bootstrapsrootfs/from scratch when missing, applies the overlay, and produces flashable images inimages/../scripts/bootstrap-rootfs.sh [rootfs-dir] [device] [--force|--check]— creates a completearmv7rootfs fromscripts/rootfs-packages.txtinside rootless Docker; idempotent viaetc/bananarchy/rootfs-bootstrap.done../scripts/prune-rootfs-packages.sh <rootfs-dir> world|purge— removes Wayland-only, Rust-based, and retired packages from a target rootfs inside the build container../scripts/check-rebuild.sh— offline preflight for a clean clone (syntax, package list, plugin artifacts, overlay sync, SMS long-message rendering guard, ignored local agent config, Docker, version helper)../scripts/sync-prebuilt-overlay.sh [--check]— mirrorsprebuilt/artifacts intooverlay/rootfs/;--checkonly reports drift../scripts/bootstrap-flash-deps.sh— installspyusbandpyserialinto the gitignored.flash-deps/directory forflash-edl.py.sudo ./flash-edl.sh [device]— flasheslk2ndand the system image over Qualcomm USB EDL (05c6:9008), using the vendoredvendor/edl/library and auto-installed host dependencies.
4. Coding and architecture conventions
- Indentation: always use 2-space indentation in C, C++, Python, Yabasic, and shell scripts (tabs only in Makefiles and TSV files).
- No emojis: never use emojis in source code, UI strings, logs, or commit messages (use Nerd Font PUA codepoints defined in
neoui.h/phone_data.h/dmenu.cfor UI icons). - Unified theming: never hardcode UI colors or font sizes in
dwm,dmenu,st, or any DWM plugin. Read colors and proportional font sizes fromPluginTheme(src/neoui/neoui.h/src/dwm-plugins/theme.h) /.Xresources(theme.*), and handleRELOAD_THEMEon the plugin FIFO. - Zero-lag plugin model: phone UI apps must run as preloaded resident daemons (
--preload) guarded by/tmp/dwm_plugin_<name>.lock, sleeping at 0% CPU onpoll()overConnectionNumber(dpy)and/tmp/dwm_plugin_<name>.fifo, and rendering into an offscreenPixmap(240x296atX=0, Y=24) copied withXCopyAreato prevent flicker. - Multiline text rendering: on the target Pango/Xft stack
pango_xft_render_layout()only paints the first line of a long multiline layout, so wrapped bodies must be drawn line by line withpango_xft_render_layout_line()using a scroll offset and a bounded visible line count (seesms_plugin.cpp,dialer_plugin.cpp,modem_plugin.cpp, andneoui_draw_text_wrapped()). Where the widget has a fixed rectangle, clip withXftDrawSetClipRectangles()and reset the clip afterwards so the softkey bar still draws; keep measurement and rendering at the same layout width.scripts/check-rebuild.shguardssms_plugin.cpp. - SMS text accounting: never treat
std::string::size()(UTF-8 bytes) as an SMS character count. Use code-point-aware logic such assmsTextMetrics(): GSM-7 septets (160 per part, 153 when concatenated) or UCS-2 UTF-16 units (70 per part, 67 when concatenated). SMS log headers are parsed byparseSmsHeaderLine(), which strips[SIM n]tags; do not write those tags back intosms.txt. - Documentation: keep
README.md,MANUAL.md,SDK.md, andCHANGELOG.mdsynchronized with any new user-facing features, SDK functions, or keybindings, and do not leave third-party.mdfiles insidesrc/oredl/. - Artifact sources:
prebuilt/is the single source of truth for compiled artifacts andscripts/rootfs-packages.txtfor thearmv7package set. Never editoverlay/rootfs/copies of binaries by hand; run./scripts/sync-prebuilt-overlay.shafter changingprebuilt/. - Package hygiene: keep
scripts/rootfs-packages.txtfree of Rust-based top-level packages (use Csudo, neversudo-rs) and Wayland-purpose packages;libwpeand thewayland-libs-*shared libraries stay because GTK3/WebKitGTK link them directly, but no Wayland compositor, backend, or viewer is shipped.scripts/check-rebuild.shenforces this. - Power management: idle blanking is
bananarchy-idle-blank.sh+sxmo_hook_unlock.sh'sidle_locker(SXMO_UNLOCK_IDLE_TIME, default 60 s;~/.cache/sxmo/sxmo.noidleopts out). Deep standby isbananarchy-suspend.sh/bananarchy-deep-standby.sh/sxmo_autosuspend.sh/sxmo_suspend.sh, gated by/etc/bananarchy-no-deep-standby(shipped present = disabled) and inert until a full custom kernel module tree is shipped. Never forcesxmo.noidle/sxmo.nosuspendfrom the session scripts and never reintroduce the infinitesxmo_not_suspendablewakelock./etc/bananarchy/is root-only. - Image residue:
rebuild-image.shstrips/var/cache/apk, allapk.log*files, and unused gettext locale trees beforemke2fsand aborts the build if any apk cache/log remains; never add anapkcall after that guard. - No on-device compiler:
scripts/rootfs-packages.txtships nogcc/g++/musl-dev/makeand no Janet runtime (janet,janet-dev,jpm); cross-compile native code withscripts/build-*.sh. On-device development uses the Yabasic FFI SDK (neoui.yab/neonet.yab), which requiresyabasic,libffi,libneoui.so, andlibcurl.so.4— never remove those.scripts/check-rebuild.shguards both sides. - Core tools:
curl,bc,ed,rlwrap,mandoc,nano,less, andfrotzare pinned core tools asserted byscripts/check-rebuild.sh. Perl, Lua, optional Tcl extensions, and thesqliteCLI are excluded, whiletcl,python3,bash,luajit,gawk,jq,gojq, andquickjsremain as hard runtime dependencies. - Local agent config:
.bantam.cfgis a local, gitignored credential file. Never read, edit, commit, or unignore it;scripts/check-rebuild.shverifies that its ignore rule stays in place. - Sentence case: always use sentence case in subheadings and list items across all documentation files (
README.md,MANUAL.md,SDK.md,CHANGELOG.md,AGENTS.md).