From e549ccbeadf41f4436f7961a44ce96f790c8d5c4 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 2 Nov 2026 10:09:41 +0100 Subject: [PATCH 01/21] device/dipper: add Xiaomi Mi 8 support Add Dipper device metadata, support package and firmware staging. Record non-A/B safety rules and hardware evidence without owner network identities. Keep local SSH settings out of the public tree. --- AGENTS.md | 25 +- device/dipper/FLASH-RUNBOOK.md | 135 +++++ device/dipper/HANDOFF.md | 39 ++ device/dipper/NOTES.md | 123 ++++ device/dipper/STATE.md | 392 +++++++++++++ device/dipper/WIFI-PLAN.md | 545 ++++++++++++++++++ device/dipper/device.conf | 33 ++ device/dipper/kernel.config | 91 +++ initramfs/init | 63 ++ packages/mesa/.SRCINFO | 4 +- packages/mesa/PKGBUILD | 12 +- packages/mesa/README.md | 14 +- packages/omamobile-device-dipper/LICENSE | 21 + packages/omamobile-device-dipper/PKGBUILD | 27 + packages/omamobile-device-dipper/README.md | 19 + .../bin/omamobile-dipper-identity | 84 +++ .../bin/omamobile-tailscale-join | 46 ++ packages/omamobile-device-dipper/build | 8 + packages/omamobile-device-dipper/device.conf | 33 ++ .../etc/omamobile-mirrorlist | 18 + .../etc/omamobile/tailscale.conf.example | 18 + packages/omamobile-device-dipper/install | 38 ++ .../omamobile-device-dipper.install | 33 ++ packages/omamobile-device-dipper/test/all | 106 ++++ .../conf.d/10-omamobile-usb.conf | 5 + .../logind.conf.d/10-omamobile-power-key.conf | 7 + .../systemd/network/20-usb-gadget.network | 19 + .../system.conf.d/10-omamobile-watchdog.conf | 20 + .../system/omamobile-dipper-identity.service | 15 + .../system/omamobile-tailscale-join.service | 17 + .../udev/rules.d/10-omamobile-storage.rules | 10 + packages/omamobile-device-dipper/version | 1 + packages/pd-mapper/PKGBUILD | 31 + packages/qrtr/PKGBUILD | 31 + packages/rmtfs/PKGBUILD | 38 ++ packages/rmtfs/udev.rules | 1 + packages/tqftpserv/PKGBUILD | 33 ++ rootfs/build-inside | 22 +- tools/build-packages | 2 +- tools/build-rootfs | 9 +- tools/dipper/apply-identity | 65 +++ tools/dipper/backup-stock | 70 +++ tools/dipper/bringup-patch-init.py | 87 +++ tools/dipper/build | 128 ++++ tools/dipper/build-board-2.py | 124 ++++ tools/dipper/build-boot.py | 153 +++++ tools/dipper/extract-firmware | 56 ++ tools/dipper/extract-identity | 71 +++ .../dipper/identity/omamobile-dipper-identity | 84 +++ .../omamobile-dipper-identity.service | 15 + tools/dipper/identity/test-identity.sh | 53 ++ tools/dipper/initramfs-inside.sh | 131 +++++ tools/dipper/pil-squash.py | 64 ++ tools/dipper/prune-modules.py | 72 +++ tools/dipper/push-verified | 78 +++ tools/dipper/test-board-2.py | 63 ++ tools/dipper/test-build-boot.py | 93 +++ tools/phone-ssh | 3 +- 58 files changed, 3578 insertions(+), 20 deletions(-) create mode 100644 device/dipper/FLASH-RUNBOOK.md create mode 100644 device/dipper/HANDOFF.md create mode 100644 device/dipper/NOTES.md create mode 100644 device/dipper/STATE.md create mode 100644 device/dipper/WIFI-PLAN.md create mode 100644 device/dipper/device.conf create mode 100644 device/dipper/kernel.config create mode 100644 packages/omamobile-device-dipper/LICENSE create mode 100644 packages/omamobile-device-dipper/PKGBUILD create mode 100644 packages/omamobile-device-dipper/README.md create mode 100755 packages/omamobile-device-dipper/bin/omamobile-dipper-identity create mode 100755 packages/omamobile-device-dipper/bin/omamobile-tailscale-join create mode 100755 packages/omamobile-device-dipper/build create mode 100644 packages/omamobile-device-dipper/device.conf create mode 100644 packages/omamobile-device-dipper/etc/omamobile-mirrorlist create mode 100644 packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example create mode 100755 packages/omamobile-device-dipper/install create mode 100644 packages/omamobile-device-dipper/omamobile-device-dipper.install create mode 100755 packages/omamobile-device-dipper/test/all create mode 100644 packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf create mode 100644 packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf create mode 100644 packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network create mode 100644 packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf create mode 100644 packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service create mode 100644 packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service create mode 100644 packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules create mode 100644 packages/omamobile-device-dipper/version create mode 100644 packages/pd-mapper/PKGBUILD create mode 100644 packages/qrtr/PKGBUILD create mode 100644 packages/rmtfs/PKGBUILD create mode 100644 packages/rmtfs/udev.rules create mode 100644 packages/tqftpserv/PKGBUILD create mode 100755 tools/dipper/apply-identity create mode 100755 tools/dipper/backup-stock create mode 100755 tools/dipper/bringup-patch-init.py create mode 100755 tools/dipper/build create mode 100755 tools/dipper/build-board-2.py create mode 100755 tools/dipper/build-boot.py create mode 100755 tools/dipper/extract-firmware create mode 100755 tools/dipper/extract-identity create mode 100755 tools/dipper/identity/omamobile-dipper-identity create mode 100644 tools/dipper/identity/omamobile-dipper-identity.service create mode 100755 tools/dipper/identity/test-identity.sh create mode 100755 tools/dipper/initramfs-inside.sh create mode 100755 tools/dipper/pil-squash.py create mode 100755 tools/dipper/prune-modules.py create mode 100755 tools/dipper/push-verified create mode 100755 tools/dipper/test-board-2.py create mode 100755 tools/dipper/test-build-boot.py diff --git a/AGENTS.md b/AGENTS.md index 0d80253c1..23c8689bb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,9 +7,32 @@ Omarchy Mobile runs native Omarchy (Arch Linux ARM, Hyprland, Omarchy's packages ## 1. Safety rules (non-negotiable) +### Xiaomi Mi 8 (`dipper`) exception + +`dipper` is non-A/B and has no stock slot to fall back to. This device-specific +rule overrides the A/B Pixel rules below. Do not use the shared +Pixel installer or unsuffixed flash flow. Follow [dipper STATE](device/dipper/STATE.md) +and [FLASH-RUNBOOK](device/dipper/FLASH-RUNBOOK.md). Never erase or format `userdata` +without a separate explicit decision: it contains Android's user data. Before modem, +Wi-Fi or other radio bring-up, verify the off-device stock backup and keep a live log; +do not enable a radio service or reboot the phone as part of a build task. + +For an unfinished Dipper session, read `device/dipper/HANDOFF.md`, +`device/dipper/STATE.md` and `device/dipper/WIFI-PLAN.md` before touching the +phone; they record the current hardware state and next safe step. Owner Wi-Fi +credentials stay in ignored local provisioning settings; never print, log, commit +or copy their values into an image. + +#### Dipper diagnostics over USB + +- Prefix host shell commands with `rtk`. Use `tools/phone-ssh --fresh -- ''` to test a new SSH session and collect phone state; check `systemctl`, `findmnt`, `/sys/class/drm/*/status`, `/proc/asound/cards`, and narrowly filtered `dmesg` output. Do not dump the full kernel command line, device identifiers or private partition contents. +- When SSH is down during an authorized RAM/NFS boot, inspect the host side first: `ip -brief link`, USB interface byte counters, `fastboot devices | wc -l` (never print device serials), and the disposable NFS root's journal with `sudo journalctl --directory=/var/log/journal -b`. If that boot's NFS trigger service is confirmed active, `/run-cmd` on the scratch root runs a host-staged script and writes `/run-cmd.out`; limit it to read-only status checks and verify the marker was consumed before relying on output. `/reboot-now` triggers an immediate forced reboot; use it only when a reboot is intended. +- Use `fastboot boot ` only for a RAM test after checking its hash. Never use `fastboot flash` or write to phone block devices during diagnostics. Keep the NFS export limited to the phone's USB network address and put all experimental rootfs changes under a host-side disposable scratch root. +- If a driver operation could interrupt USB or display, capture logs on the host and arm an automatic rollback/watchdog first. Prefer a clean RAM reboot over reloading display drivers after a failed attach. Confirm screen and sound physically; DRM connector state and ALSA card enumeration alone do not prove visible output or audible playback. + - **Ask the human before every reboot, flash, `push`, overlay boot or irreversible write.** That includes RPMB writes, a first `storageproxyd` run, `devinfo` and anything under `/dev/sd*`. The phone is real hardware with calibration data that can't be replaced, and a human has to be ready to recover it. - **The phone is shared with a human. Announce anything that affects the screen or the feel of the phone before you run it**: DPMS, display modes and refresh rate, brightness, `bl_power`, haptics, the torch, the shell restarting, rotation. Otherwise they think the phone is broken, or it buzzes in their hand. -- **Only slot B and `userdata` are ours.** Write only `boot_b`, `init_boot_b`, `vendor_boot_b`, `vendor_kernel_boot_b` and `dtbo_b`, and only through `bin/omamobile flash|push`. Never touch bootloader, radio, `devinfo`, `persist`, `efs*`, `modem*` or `vbmeta`, and never run an unsuffixed `fastboot flash`, with one exception: `userdata`, and only through `tools/install-phone` (serial pinned, codename typed, allowlist, dry run first). Slot A's stock Android is the way back. +- **On A/B Pixel devices, only slot B and `userdata` are ours.** Write only `boot_b`, `init_boot_b`, `vendor_boot_b`, `vendor_kernel_boot_b` and `dtbo_b`, and only through `bin/omamobile flash|push`. Never touch bootloader, radio, `devinfo`, `persist`, `efs*`, `modem*` or `vbmeta`, and never run an unsuffixed `fastboot flash`, with one exception: `userdata`, and only through `tools/install-phone` (serial pinned, codename typed, allowlist, dry run first). Slot A's stock Android is the way back. - **Qualcomm A/B phones (Pixel 4 family) keep the slot flags in GPT attributes,** so slot B can only be marked bootable by writing the partition table. That write is a narrow, named exception, never automatic: by hand, once per install of slot B's boot image, and only for a device whose entry in [CONTRIBUTING](CONTRIBUTING.md) §3.1 names the LUN, the four sectors (LBAs 1, 2, last-1 and last), the attribute bit and the CRCs it rewrites. That device's plan must also record the slot flags before and after, the rollback for a corrupted GPT, and the way back: stock restored on slot A first, or the owner's explicit acceptance of buttons-only recovery. The storage guard can't block this write, so it never runs from a service or at boot. - **Never weaken the storage guard.** Don't `blockdev --setrw` a partition or recreate `/dev/sda`. Don't mount Android partitions read-write, and don't add names to the `UFS_RW` allowlist without the human's say-so. The guard is what keeps a bad command from erasing the IMEI. - **Check backups before radio, PMIC, AoC or Trusty work.** Run the checksum check of `efs`, `efs_backup`, `modem_userdata`, `persist` and `modem_a/b` against the off-repo backup first ([MODEM-PLAN.md](device/cheetah/MODEM-PLAN.md) M0.1). If there's no backup, stop. Find each partition by `PARTNAME` in `/sys/class/block/*/uevent`: the Arch root has no `/dev/disk/by-partlabel`. **Take a fresh read-only backup after any stock Android boot** (a slot A fallback counts): stock's modem stack writes `efs`, `persist` and `modem_userdata`, so the old checksums stop matching and the next check can't tell a change of ours from stock's. diff --git a/device/dipper/FLASH-RUNBOOK.md b/device/dipper/FLASH-RUNBOOK.md new file mode 100644 index 000000000..9db7b8209 --- /dev/null +++ b/device/dipper/FLASH-RUNBOOK.md @@ -0,0 +1,135 @@ + +# dipper (Xiaomi Mi 8) — first-light runbook + +**Read §0 first. dipper is not a Pixel and the shared safety model does not apply to it.** + +## 0. Why this device needs its own runbook + +The project's safety model is "stock Android stays on slot A, we only ever write slot B". +**dipper has no second OS slot.** Measured on the phone: one `boot` (64 MiB), one +`recovery` (64 MiB), one `system`, one `vendor`, one `userdata` (113 GiB). Only the +bootloader chain is slotted (`xbl`, `abl`, `tz`, `hyp`, `aop`, `cmnlib`, `devcfg`, +`keymaster`, `qupfw`, `storsec`), and this port never writes any of it. + +Consequences, stated plainly: + +- **A bad `boot` image means a bootloop with nothing to fall back to.** The way out is + physical: power off, hold **Volume Down + Power** until "FASTBOOT" appears, then + `fastboot flash boot boot.img` with the stock image from the backup. +- **`fastboot` is USB-only.** There is no fastboot over a network. Tailscale and SSH + reach the *running* phone; they are not a recovery path. **Do not attempt any of + this without the phone in hand and a cable.** +- So: **step 2 below boots from RAM and writes nothing.** Do not flash until that has + worked. + +## 1. Before anything: a verified stock backup + +```sh +tools/dipper/backup-stock # boot, recovery, dtbo, vbmeta, persist, + # modemst1/2, fsg, fsc, devinfo, misc, frp, + # logo, splash (~460 MiB) +tools/dipper/backup-stock --with-firmware # adds modem (192 MiB) and dsp (32 MiB) +``` + +It reads each partition over SSH and compares a `sha256sum` taken **on the phone** +against one taken locally; a mismatch deletes the file and fails the run. Keep the +output and checksums in an operator-controlled backup location outside the repository. + +`persist` and `modemst1`/`modemst2` hold per-device calibration and the modem's NV. +They cannot be downloaded from anywhere. Keep this backup even if you never flash. + +## 2. Build, then boot from RAM — nothing is written + +```sh +# kernel (once): mainline 7.3-rc6 tree + our fragment +make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j"$(nproc)" Image.gz dtbs modules +make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- qcom/sdm845-xiaomi-dipper.dtb + +# initramfs (aarch64 container) + the Android v1 boot image +tools/dipper/build + +# full Arch/Omarchy root image (keep the signed source packages and local key private) +tools/fetch-published out/dipper/published +tools/build-packages --local dipper --import out/dipper/published \ + packages/qrtr packages/pd-mapper packages/tqftpserv packages/rmtfs \ + packages/omamobile-device-dipper +KERNEL_OUT=../out/dipper DEVICE=dipper tools/build-rootfs --local dipper +``` + +The host needs `zopfli` for the smaller kernel gzip stream that fits dipper's ABL +limit; `tools/dipper/build` uses it when available and `build-boot.py` refuses an +oversized kernel. The build also stages the private modem/WLAN firmware and the +module archive under `out/dipper/` for the root image. + +Then, phone powered off, **Volume Down + Power** until "FASTBOOT" shows: + +```sh +fastboot getvar unlocked # must say yes. Android's props on this phone are + # spoofed and cannot be trusted for this. +fastboot boot out/dipper/images/boot.img +``` + +`fastboot boot` runs the image from RAM. **It does not touch `boot`.** A power cycle +returns the phone to stock, whatever happens. This is the only step that is safe to +repeat freely, so iterate here. + +What success looks like: a USB network device appears on the laptop +(`Xiaomi Mi 8 Omarchy`, CDC NCM plus an ACM console), and + +```sh +tools/phone-ssh --fresh -- 'id' +``` + +gets a shell from the initramfs. The rescue sshd is bound to `172.16.42.1` only — +never to Wi-Fi. There is no display yet at this stage: the console is the USB link. + +If nothing appears: the ACM console (`/dev/ttyACM0`, 115200) carries the kernel log. +If not even that, the kernel did not reach the initramfs; power-cycle and read §4. + +## 3. Only then: flash + +Do not do this until §2 has booted and you have §1's backup verified. + +```sh +fastboot flash boot out/dipper/images/boot.img +fastboot reboot +``` + +To go back to stock at any time: + +```sh +fastboot flash boot "$VERIFIED_STOCK_BOOT_IMAGE" +``` + +Set `VERIFIED_STOCK_BOOT_IMAGE` to the checksum-verified stock image in the +private backup before running the recovery command. + +**Never flash** `xbl*`, `abl*`, `tz*`, `hyp*`, `aop*`, `cmnlib*`, `devcfg*`, +`keymaster*`, `qupfw*`, `storsec*`, `modem`, `modemst1`, `modemst2`, `fsg`, `persist`, +`vbmeta` or `devinfo`. Nothing in this port needs them, and several of them are +unrecoverable per-device data. + +`userdata` is not touched by any step above. Installing a full Omarchy root later +**erases it**, which also removes stock Android's data — that is a separate decision, +not part of first light. + +## 4. Known unknowns at first light + +- **Touch** is an ST FTS5 controller (`st,fts` downstream, `fts@49` on `i2c14`). The + DTS uses `st,stmfts5` and the kernel carries upstream's FTS5 driver and controller-ready + wait fix, whose series was tested on Mi 8. On the updated RAM boot, the driver bound and + a physical tap produced `ABS_MT_POSITION_X`, confirming basic touch input. Full + coordinate/gesture coverage is open; firmware loading, low-power touch and wake-on-touch + are not implemented. +- **Display.** The panel is Samsung EA8074 in **command mode** (the stock kernel's + `dsi_ss_ea8074_notch_fhd_cmd_display`, and `qcom,mdss-dsi-panel-type = "dsi_cmd_mode"` + in the stock tree), but the recovered panel driver sets `MIPI_DSI_MODE_VIDEO_BURST`. + That mismatch is left exactly as its author wrote it, because changing untested + timing blind is worse than reporting it. Expect the display to need work. +- **Sound** will not probe: the DTS asks for `ti,tas2559`, whose driver exists only in + the `sdm845-mainline` fork, not upstream. +- **Modem/Wi-Fi, cameras, fingerprint (Goodix), suspend**: not yet tested on mainline. +- The shared initramfs crashes deliberately after 20 s with no USB host, expecting ABL + to fall back to slot A. **On dipper there is no slot A**, so that path just reboots + into the same image. With `fastboot boot` this is harmless; after flashing it is a + bootloop, exited with Volume Down + Power. diff --git a/device/dipper/HANDOFF.md b/device/dipper/HANDOFF.md new file mode 100644 index 000000000..0ce59aa69 --- /dev/null +++ b/device/dipper/HANDOFF.md @@ -0,0 +1,39 @@ + +# Handoff: Omarchy Mobile on Xiaomi Mi 8 + +Read STATE.md, ../../AGENTS.md, NOTES.md, FLASH-RUNBOOK.md and WIFI-PLAN.md. +The repository-root PORTING-PLAN.md is a historical discovery log. + +## Pick up here + +Last checked 2026-11-02: Omarchy is running on the phone, and the owner has +confirmed that the display is visible. A fresh USB SSH connection through +tools/phone-ssh --fresh succeeded and sshd is active. The display is exposed as +DSI-1 (405x843 in the current Wayland session). A VNC protocol handshake +succeeded, but rendering and remote input through a user's client have not +been checked. + +This repository intentionally contains no owner SSID, LAN address, SSH alias, +SSH key path, password, token, or private backup path. No reboot, flash or +partition write was performed during the 2026-11-02 remote-access checks. +Audio playback, sensors and 3D acceleration still need separate verification; +do not infer them from device enumeration alone. + +## Next work + +1. Keep device support changes in this repository and submit kernel drivers, + bindings and DTS changes to the kernel repository as separate subsystem + branches, following CONTRIBUTING.md. +2. Run the repository checks and the read-only phone smoke test before opening + a pull request. Record only results, never captures or device identifiers. +3. Continue audio, sensor and GPU validation only from the corresponding + gated plans, with the verified stock backup available before radio work. + +## Stop conditions + +- Do not erase or format userdata, or use the shared Pixel installer. +- Do not flash the boot image without a separate explicit decision and the + phone physically available for recovery. +- Stop radio work if the off-device stock backup cannot be checksum-verified, + if read-only partition protection is not confirmed, or if live logging and + SSH recovery are lost. diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md new file mode 100644 index 000000000..b197683b6 --- /dev/null +++ b/device/dipper/NOTES.md @@ -0,0 +1,123 @@ + +# dipper (Xiaomi Mi 8) — bring-up notes + +Facts only, each read off the phone. Captures live outside the repo +(`private off-device reference directory (path omitted)/`) because they carry the serial, the cpuid +and Wi-Fi keys; quoted here are the facts, never the files. + +## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root + +- **SoC** SDM845. Live DT root: `model = "Xiaomi Technologies, Inc. Dipper new MP v2.1"`, + `compatible = "qcom,sdm845-mtp", "qcom,sdm845", "qcom,mtp"`, + `qcom,msm-id = <0x141 0x20001>`, `qcom,board-id = <0x37 0x00>`. + 6 GB RAM. `androidboot.cert=M1803E1A` (Mi 8 Global), `hwversion=3.13.0`. +- **Stock on the phone now** is a custom Android 14 (SDK 34) ROM with Magisk 30.7, not MIUI; + its build fingerprint is a spoofed MIUI 8.1 string, and `ro.boot.verifiedbootstate=green` + with `flash.locked=1` contradict the owner's unlocked bootloader. **No boot-state claim + may be made from Android on this phone; read it in fastboot.** Running kernel 4.9.337. +- **Not A/B for the OS.** 92 entries under `/dev/block/by-name/`: a single `boot` (64 MiB), + `recovery` (64 MiB), `dtbo` (8 MiB), `system`, `vendor`, `cache` and `userdata` + (113 GiB). Only the bootloader chain is slotted: `xbl`, `xbl_config`, `abl`, `tz`, `hyp`, + `aop`, `cmnlib`, `cmnlib64`, `devcfg`, `keymaster`, `qupfw`, `storsec`. + **There is therefore no known-good OS slot to fall back to**, which the shared Pixel + safety model assumes. A full stock backup is a precondition, not a nicety. +- **Boot image** is Android header v1, page size 4096, `second_size = 0`, and the kernel + blob ends with **two concatenated FDTs of ~480 KB each** (`d00dfeed`, version 17): the + base DTB is appended to the kernel and ABL selects one by msm-id/board-id. Hence + `BOOT_METHOD=android-v1-appended-dtb`. +- **Display** Samsung **EA8074**, 1080x2248, command mode, 60 Hz, notch; physical + 68 x 142 mm. Confirmed twice: `msm_drm.dsi_display0=dsi_ss_ea8074_notch_fhd_cmd_display` + on the kernel command line, and the live DT node `qcom,mdss_dsi_ss_notch_fhd_ea8074_cmd` + (`qcom,mdss-dsi-panel-width = <0x438>`, `height = <0x8c8>`, `framerate = <0x3c>`). +- **Touch is STMicroelectronics, not FocalTech.** Live DT, on `i2c@a98000` (mainline + `i2c14`): `fts@49 { compatible = "st,fts"; fts,irq-gpio = <&tlmm 31 ...>; + fts,reset-gpio = <&tlmm 32 ...>; fts,default-fw-name = "st_fts_e1.ftb"; }`, with + `fts,tp-vendor = <0x48>`. The running kernel's input device is `N: Name="fts"`. + An `atmel,mxt-ts@4a` node exists as the alternate vendor and is not the active one. + **Open:** mainline's ST driver is `st,stmfts` (`drivers/input/touchscreen/stmfts.c`), + a different driver from Xiaomi's downstream `st_fts`; whether it binds this controller + is untested and is the largest unknown in this port. No sibling board helps — + polaris uses `syna,rmi4-i2c@20`, beryllium a FocalTech/Novatek part. +- **Audio** `sdm845-tavil-snd-card` (WCD9340). **Fingerprint** Goodix, capacitive + (`fingerprint_goodix`, `uinput-goodix`); no mainline driver, out of scope. + **Buttons** `qpnp_pon` plus `gpio-keys`. +- **UFS** host at `1d84000.ufshc`. Stock `system` is dm-verity over the `system` partition. + +## Prior art this port builds on + +`sdm845-mainline/linux` **MR !71** ("Add sdm845-xiaomi-dipper", Jun 2023) is **closed, never +merged**, and its branch is deleted; the dipper DTS is in no live branch of that tree. Of its +97 commits only three are dipper-specific — the board DTS + `dipper-common.dtsi`, a +purpose-written `panel-samsung-ea8074.c`, and the config switch. They are recovered and kept +outside this repo. The other 94 were that tree's whole SDM845 stack rebased in, which is the +likely reason it was closed, and most of it has landed there since. + +Against the live DT the DTS is right about the touch bus (`i2c14`) and both GPIOs (31, 32) +and wrong about the controller: it says `focaltech,ea8074` at `0x38`, i.e. the panel's name +and another vendor's address. That is the evidenced reason postmarketOS lists dipper's +touchscreen as broken. + +## 2026-10-29 — first light, and what the hardware said + +**The phone boots mainline and gives a shell.** `fastboot boot` of our image, kernel +7.3.0-rc6 with our DTB: UFS up (all six LUNs, ext4 mounts), USB NCM gadget, dropbear +on `172.16.42.1`, gpio-keys, 8 CPUs, 5.7 GB RAM. The storage guard works as designed: +`boot`, `recovery` and `persist` read-only, `userdata` and `logdump` writable. + +### What had to be fixed before any of that +Five defects in the recovered MR !71 work, three of them fatal: + +1. **`qcom,board-id = <69 0>` (0x45) is polaris's.** dipper reports `0x37`. ABL matches on + it and silently refuses the whole boot image otherwise — no kernel output, no panic, + just a reboot. Two blind attempts from `recovery` were lost to this. +2. `drm_panel_init()` no longer exists; the panel probe needed the refcounted + `devm_drm_panel_alloc()`. +3. `panel-samsung-ea8074.ko` had no `MODULE_LICENSE()`, so modpost refused to link. +4. The touch node named `focaltech,ea8074` at `0x38`; the chip is ST at `0x49`. +5. Its Kconfig entry was copied from an SPI panel (`depends on SPI`, `select DRM_MIPI_DBI`) + for what is a `mipi_dsi_driver`. +6. `ts_int_default` carried `bias-pull-down` from beryllium; dipper's own stock tree says + `ts_active { pins = "gpio31", "gpio32"; drive-strength = <16>; bias-pull-up; }`. + +### And two kernel-config lessons, both found on the hardware +Devices probe once, early. A driver that only appears later as a module never gets a +second chance — the device is left unbound and is not even on the deferred list. Proven +twice: the Qualcomm PHYs (so no USB and no storage: `dwc3: failed to initialize core`, +`sync_state() pending due to 88e8000.phy`), then i2c (`modprobe i2c-qcom-geni` bound to +nothing, and a hand-written `bind` failed). Everything first light needs is now `=y` in +`device/dipper/kernel.config`, with the reasoning in the file. + +### Touch: first failed probe (historical) + +The original FTS4-only driver bound and timed out. These observations describe that +kernel revision; they are not results from the current FTS5 driver: + +- `i2c-14` and `i2c-5` come up; the touch device **exists as `14-0049`**, so the bus and + address in the DTS are right. +- Both supplies are enabled and in use: `ldo28` at 2.856 V, `vreg_tp_vddio` at 1.8 V, + one user each. +- `stmfts` binds and fails with **`-110`** from `wait_for_completion_timeout` — it sends + its first command and never sees the reply interrupt. +- The interrupt pin bias was corrected to pull-up per the stock tree. **No change.** +- `i2cdetect` output is incoherent: in `-r` mode every even address reads as present and + every register as `0x00`; in quick-write mode `0x49` is not detected at all, while + `stmfts`'s own `i2c_smbus_write_byte` to `0x49` returns success. +- On i2c5 the driver logs **`geni_i2c_gpi_xfer:I2C timeout` / `GPI transfer failed: -110`**, + so the GPI DMA path is not reliable here. +- GPI DMA cannot simply be turned off: this kernel's `geni_i2c` requires the channels and + defers forever without them (`geni_i2c: Failed to get tx DMA ch`). There is no FIFO + fallback to fall back to. + +At the time, it was unknown whether GENI/GPI or the FTS5 protocol caused the timeout. + +### 2026-10-29 — FTS5 driver update (not yet built or hardware-tested) + +The live controller is FTS5, so the DTS now declares `st,stmfts5` and +`linux/drivers/input/touchscreen/stmfts.c` carries the upstream FTS5 support and +controller-ready wait fix. The upstream v8 series states it was tested on Xiaomi Mi 8: +[FTS5 driver patch](https://lists.openwall.net/linux-kernel/2026/09/25/2213), +[controller-ready fix](https://lists.openwall.net/linux-kernel/2026/09/25/2214), +[binding update](https://lists.openwall.net/linux-kernel/2026/09/25/2212). +This is the first protocol-matched driver tried here, but it still needs a kernel build +and attended RAM-boot test. The upstream series provides basic touch only; firmware +loading and wake-on-touch/AP-SLPI handoff are not implemented. diff --git a/device/dipper/STATE.md b/device/dipper/STATE.md new file mode 100644 index 000000000..58644d7eb --- /dev/null +++ b/device/dipper/STATE.md @@ -0,0 +1,392 @@ + +# Xiaomi Mi 8 port state + +Last updated: 2026-11-02. Older discovery notes below are historical where they +conflict with this summary. + +Latest live state (2026-11-02): +- Omarchy is running; the owner confirmed the physical display is visible. +- A fresh USB SSH connection through tools/phone-ssh --fresh succeeded and + sshd is active. +- The current Wayland output is DSI-1 (405x843). A VNC RFB 3.8 handshake + succeeded; the viewer's rendered image and remote input remain unverified. +- SSID, LAN address, SSH aliases and key paths, credentials and private backup + paths are intentionally omitted from this repository. +- No reboot, flash or partition write was performed during the latest + remote-access checks. Audio playback, sensors and 3D acceleration remain + unverified. + +## Device and safety + +- Xiaomi Mi 8 (`dipper`), Snapdragon 845, non-A/B OS layout. There is one `boot` + and one `userdata`; installing Arch to `userdata` erases Android user data. +- Android was reachable over ADB; Tailscale reconnected after its app was + opened once. A fresh backup passed all 15 device/source hash checks at + `private off-device reference directory (path omitted)/`. + A later RAM-rescue modem/Wi-Fi attempt ended with remoteproc `crashed` and + recovery disabled. On 2026-10-31 the owner authorized one RAM-only boot of + `/tmp/mi8-panel-nfs-image/images/boot.img` (SHA-256 + `9185f790896fb77bf5cedcfff745aa90a3bbf4477a4a82c424e5777caf74ac8c`). The + phone mounted the exported scratch root; systemd eventually reached SDDM. + SSH accepted the root key. `pam_systemd` first timed out waiting for the root + user manager; later short commands succeeded, then SSH stopped accepting + connections while USB remained enumerated. No partition was written. +- Mainline kernel/initramfs previously reached first light through RAM boot: + UFS/ext4, USB NCM and rescue SSH worked; storage guard allowed only `userdata`. + No persistent boot/rootfs install has been performed by this work. +- The owner authorized an attended Wi-Fi bring-up attempt and one clean RAM boot + of the revised image. Do not restart the crashed modem in place and do not + flash any partition. Do not use the shared Pixel installer for this non-A/B + device. + +## Current implementation + +- Kernel source is `../../../linux` (workspace `linux/`), branch has existing + user changes; preserve them. Current release string: + `7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty`. +- `CONFIG_TOUCHSCREEN_STMFTS=y`; DTS uses `st,stmfts5`. Upstream FTS5 support, + including the controller-ready wait fix, is present and compiled in `linux/`. + The RAM-booted kernel registered `stmfts` as `/dev/input/event1` on the + handset. A confirmed physical tap produced an `EV_ABS` `ABS_MT_POSITION_X` + event, so basic touch input works. Full coordinate/gesture coverage is not + done. Firmware loading and low-power/wake touch are out of scope for this + driver series. +- Rootfs builder now consumes `ROOTFS_DIST_PACKAGES`, stages + `out/dipper/firmware/{qcom,ath10k}`, and fails for dipper if the proprietary + firmware is absent. The four Qualcomm IPC packages have PKGBUILDs under + `packages/{qrtr,pd-mapper,tqftpserv,rmtfs}` and are listed for the dipper rootfs. +- The current boot-image revision RAM-booted on 2026-10-30 and confirmed USB + rescue SSH, visible console text and FTS5 touch input. It used Zopfli because + the regular gzip kernel exceeds ABL's kernel limit. The current image revision + and its untested status are recorded below. +- Rebuilt `out/dipper/images/boot.img` after adding the read-only-checked `fsc` + link. SHA-256 is `42b51401d98ac587f04f33aebd8ab92201c5069da216c74a42aa4e23748975c4`; + the 25,432,064-byte image fits the 64 MiB partition with 41,676,800 bytes of + headroom. It has been RAM-booted successfully. +- `out/dipper/modules-.tar.zst` is staged for rootfs. All four Qualcomm + aarch64 packages and `omamobile-device-dipper` built and were signed into the + local repo; the device package's 12 native checks passed. The 38 published + Omarchy Mobile packages were fetched with signature/hash verification and + imported. The first full-rootfs attempt failed in pacstrap while checking + three local package checksums. Their archive SHA-256 values matched the repo + database; the retry completed successfully. The rootfs image is + `omarchy-mobile/out/dipper/omamobile-rootfs-2026.10.29-dipper-aarch64.img.zst` + (3.1 GiB compressed; 9,580 MiB used in a 12 GiB ext4 filesystem). Its + checksum verifies, the manifest includes all four Qualcomm daemons, the + dipper package and the Qualcomm/Atheros firmware packages, and all 11 + `tests/rootfs-smoke` checks passed. Firmware was copied from the private + device extraction at build time; it is not tracked. +- No modem/Wi-Fi service is enabled automatically. Several attended modem + starts under mainline have crashed. Use + `device/dipper/WIFI-PLAN.md` before another attended attempt. +- The boot reached rescue SSH over USB NCM. A later NFS-root Omarchy session + also reached Hyprland and Quickshell; see the display attempt below. The + physical panel still did not show the desktop reliably. +- Wi-Fi driver loading was attempted, but no WLAN interface or scan appeared. + The rescue initramfs lacks Qualcomm + daemons, firmware and radio modules. A temporary host NFS export of a + disposable rootfs copy was mounted read-write at `the host-side scratch mount` over USB; only + this scratch copy was writable, not the compressed image or phone storage. + The NFS client is currently disconnected. The host copy remains at + `the disposable host-side NFS root`. + Loading `qcom_q6v5_mss` first failed because the PDC reset provider was absent; + after `reset_qcom_pdc` was loaded, remoteproc registered offline. On + 2026-10-30 `rmtfs -v -r -P -s` started the modem with all five NV links + verified read-only. QRTR WLAN service 69 appeared. On the MCFG retry, both + MCFG files were served and WLAN DSP firmware was fetched, but the modem + crashed with `modem_xpu_int.c:456:XPU violation End`. Recovery was disabled. + Timed from `wifi-20261030-mcfg-ath10k-crash-dmesg.log`, the modem came up at + t=160.5 s and stayed healthy for 137 s; `cfg80211` loaded at t=297.53 s (the + ath10k module insertion pulling in mac80211/cfg80211) and the XPU violation + arrived at t=297.89 s, 0.36 s later. So the trigger is the ath10k_snoc QMI + handshake, not modem boot or MCFG. That log contains no ath10k lines at all: + the capture ended with the phone, so the `CONFIG_ATH10K_DEBUG` output that + was built for this run was never obtained. Next attempt must stream the log + off-device, or read it back from pstore, before the module is inserted. TFTP logs + The `rmtfs` log's rejected `/boot/modem_fsg_oem_1` and `_2` requests are benign: + dipper has no `fsg_oem*` partition and stock `/vendor/bin/rmt_storage` knows only + `/boot/modem_fs1`, `/boot/modem_fs2`, `/boot/modem_fsc` and `/boot/modem_fsg`, so + stock refuses them identically. Do not alias them. TFTP logs + showed two modem MCFG files missing from staged firmware on the earlier run; + the matching files are now in the private firmware and scratch rootfs, and + `tools/dipper/extract-firmware` stages them for future builds. A private + capture is at `private off-device reference directory (path omitted)`. + Older kmsg captures show automatic recovery + loops reaching crash counters 1–6 and 1–5; the kernel defaults recovery to + enabled. Disable and verify recovery while remoteproc is offline before any + future single start. Do not retry in place. `ath10k_snoc` was + loaded on the latest attempt but no WLAN interface, scan or association + occurred. NV partitions remained + read-only. The `rmtfs` log showed the rescue initramfs lacks + `/dev/disk/by-partlabel` links; the first attempt missed `modemst1`, and the + second missed `fsc`. Every temporary target is verified read-only. A fresh + 15-partition snapshot matching the phone before RAM boot is at + `private off-device reference directory (path omitted)/`; it does + not include `userdata`, Android system/vendor, or the separately extracted + firmware. A private live kernel log runs outside the repository. + Host NFS service is disabled at boot and serves only the USB client. The + scratch rootfs WCN3990 `board-2.bin` matches the staged corrected file + (SHA-256 `81b0f78adcf995e93d789daf8691254ff745d53f843a4c5c7d2549cfc15f8a36`); + the compressed rootfs image has not yet been rebuilt with it. +- Owner Wi-Fi credentials stay in ignored local provisioning settings; do not include their values in this public handoff. Use it without echoing values; never copy credentials into + tracked files or logs. No Tailscale auth token was found in that file or the + searched Claude/provision history. + +## Session of 2026-10-30 (late): Tailscale fixed, Wi-Fi diagnosed + +- **Tailscale now starts by itself** and is confirmed three times (two warm + reboots and one cold power-cycle): `settings put secure always_on_vpn_app + com.tailscale.ipn`, `always_on_vpn_lockdown 0` (deliberately off, so a + Tailscale failure cannot cut the phone off), plus the package added to the + doze whitelist. After the cold power-cycle the peer came up **with no USB + attached at all**, direct to its LAN address, so it no longer needs the app + opened by hand. +- `tools/dipper/backup-stock` gained an adb transport (`TRANSPORT=auto|adb|ssh`, + `adb exec-out` so the `dd` pipe stays binary). It needs no SimpleSSHD or + Tailscale now, and `adb root` already gives uid 0. +- A verified snapshot of all 15 partitions was taken before the radio runs. After + them, everything we could have damaged -- `boot`, `recovery`, `dtbo`, `vbmeta`, + `fsc`, `devinfo`, `misc`, `logo`, `splash`, `persistbak`, `modemst2`, `fsg` -- + was byte-identical. Only `persist`, `modemst1` and `frp` changed, which stock + Android rewrites on every boot; our runs held all five NV partitions at `ro=1` + before and after, so a write from our side was not possible. +- Four attended RAM boots diagnosed the Wi-Fi failure down to the SDM845 XPU + erratum that ath10k already works around with a fixed `msleep(20)` tuned to one + MPSS build. dipper runs a different build. `qmi.c` now takes that delay from a + module parameter (`ath10k_snoc msa_perm_delay_ms`, default 20). Our board data + and the WCN3990 supply map are both cleared by evidence. Full write-up, the + cleared-suspect table and the gated next run are in `WIFI-PLAN.md`. +- The `msa_perm_delay_ms=300` run is **prepared but not yet performed**. + +### Current blocker + +The phone is in Android and reachable over Wi-Fi and Tailscale, but it is **not +on USB data**: `lsusb` shows no phone and `adb` lists none. SimpleSSHD answers on +port 2222 with the project key, but only as an unprivileged app +(`untrusted_app_29`), and `fastboot` cannot be driven over the network. The next +run needs the USB data connection restored -- a data-capable cable and port, not +a charge-only one. + +Note the last run ended with the phone failing to return from `reboot -f` on its +own; it needed a physical power-cycle. Prefer `adb reboot` from Android, and +expect a RAM boot with a crashed modem to need the button. + +## Wi-Fi works (2026-10-30) + +On a RAM boot, nothing flashed, NV read-only throughout: `wlan0` associated to the +owner's AP on 2.4 GHz (`wpa_state=COMPLETED`, -59 dBm), took a DHCP lease, got a +default route and reached the internet (`ping 1.1.1.1` 3/3, 16 ms). The modem +stayed `running`. Three things were needed, all recorded in `WIFI-PLAN.md`: + +1. `ath10k_snoc msa_perm_delay_ms=300` -- the upstream 20 ms XPU-settling sleep is + tuned to a different MPSS build than dipper's. +2. Gate the ath10k load on QRTR service 69. Loading before the modem publishes it + is what looked like flakiness; it cost the modem every time. +3. `ath user_regd=1` + `iw reg set SK` -- the calibration reports CN and ath + applied it as a strict custom per-phy domain, so the global domain was ignored. + +**DFS channels do not work.** The owner's 5 GHz AP is on channel 104, a DFS +channel. Scanning it works and the firmware returns valid noise floors, but +`vdev start` crashes the closed WLAN firmware after 52 ms, every time, with +`CONFIG_ATH10K_DFS_CERTIFIED=y` included. The same crash is reported on a +OnePlus 6T (same SoC and radio) with no upstream fix. Non-DFS and permitted here: +2.4 GHz, UNII-1 (36-48) and UNII-3 (149-165). Moving the AP's 5 GHz radio to +36-48 is the practical route to 5 GHz and is **untested**. + +## Omarchy boots on the phone, from NFS (2026-10-30) + +`initramfs/init` gained `boot_nfs()`, gated on `/etc/omamobile-nfsroot` existing +(the same file-presence idiom the init already uses for `omamobile-compatible` +and `omamobile-ufs-rw`), so no device changes behaviour without that file. +`tools/dipper/build` takes `DIPPER_NFSROOT=:` and writes it. +`CONFIG_ROOT_NFS` and `NFS_FS` are `=y`, so no module is needed. **Nothing is +written to the phone and `userdata` is untouched** -- the root filesystem is +served from the host over the USB link. + +Confirmed working: `switch_root` into the Arch root, systemd as PID 1, journald, +udev, sysctl and vconsole all starting, the NFS root in active use (an +established connection from the phone to the host's port 2049), and +systemd-networkd giving `usb0` its address (the host resolves 172.16.42.1 by ARP +and pings it). + +### Omarchy display attempts (2026-10-30 and 31) + +Captured over USB SSH: Hyprland first failed EGL initialization because this +Mesa build had no `msm_dri.so`. The rootfs does contain Zink and Turnip, so +`MESA_LOADER_DRIVER_OVERRIDE=zink` and +`__GLX_VENDOR_LIBRARY_NAME=mesa` were added to +`/etc/environment.d/90-zink-turnip.conf` and the Zink override to +`/home//.config/uwsm/env`; SDDM was restarted. Hyprland then reported +`zink Vulkan 1.3 (Turnip Adreno 630)`, stayed up, and launched Quickshell. + +The panel still failed on a later modeset: `Failed to exit sleep mode: -22`, +followed by `fb=0` on the CRTC. The EA8074 panel bridge did not request its DSI +host to pre-enable first. The kernel source now sets +`ctx->panel.prepare_prev_first = true` for this command-mode panel. The panel +object and `.ko` compile with the saved dipper config. The rebuilt `.ko` is +staged in `the disposable host-side NFS root/usr/lib/modules//.../panel-samsung-ea8074.ko`; +its vermagic matches the current +`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` kernel. Its module was included +in the 2026-10-31 RAM boot, but the run did not reach a panel modeset, so this +change is not hardware-validated. + +The scratch root's previous SDDM logs (19:34-19:37) show its Wayland greeter +found a socket but Mesa/Zink failed `vkEnumeratePhysicalDevices` with +`VK_ERROR_INITIALIZATION_FAILED`, then failed to choose a Vulkan device and +create a DRI2 screen. The expected Zink/Turnip overrides from the earlier +successful session were absent from this scratch root's `/etc/environment.d` +and the desktop user's UWSM environment. This is a likely userspace cause of +the black desktop in this root; the earlier panel `-22` is a separate display +issue. + +This scratch root is an unprovisioned build image: `/home` is empty, there is +no non-system account in `/etc/passwd`, and `/etc/omamobile/firstboot.conf` is +absent. The firstboot unit therefore did not create the desktop account. In +the 2026-10-31 run, SDDM started at about 307 s and Hyprland created the +greeter's Wayland socket by 366 s, but no desktop-user session or Quickshell +started. This run cannot confirm a usable Omarchy login until the normal +firstboot account setup is supplied. + +In the 2026-10-31 RAM boot, kernel journal recorded simpledrm `fb0`, then a +`qcom_wled` warning at about 187 s: `wled_ovp_work` called `enable_irq()` and +hit `__enable_irq`'s warning path. It was non-fatal: systemd continued and SDDM +started later; no later EA8074 modeset error is recorded. Runtime DRM exposed +only `card0` from simpledrm (`Unknown-1`), with no MSM/DPU/DSI KMS card; the +kernel also logged `aux_bridge ... failed to acquire drm_bridge`. The source +DTS enables `&mdss` and `&mdss_dsi0`, so the mismatch between the booted tree and +the absent runtime DRM device remains open. + +At about 742 s SDDM's Wayland greeter logged Zink's +`vkEnumeratePhysicalDevices` failure and `failed to create dri2 screen`, then +still added a view for `Unknown-1`. This reproduces the missing Vulkan path in +the scratch root; the Zink/Turnip environment overrides are absent. Systemd +eventually reported `running`, with SDDM and sshd active. SSH root-key auth +worked once the root user manager started, but an earlier connection timed out +in `pam_systemd` while `user@0.service` was still starting. Systemd also timed +out waiting for `/dev/ttyGS0`, so the serial getty escape hatch did not start. +USB ping remains intermittent. The host log is in +`the disposable host-side NFS root/var/log/journal`. + +At ~1,090 s, a root SSH command loaded the existing `msm.ko` successfully. +Sysfs then showed the MDSS, DPU and DSI platform devices bound to `msm-mdss`, +`msm_dpu` and `msm_dsi`, but `/sys/class/drm` still exposed only simpledrm. +The live device tree reports the SDM845 display nodes and EA8074 panel enabled; +the failure is therefore later in DSI component/bridge registration, not a +missing DT status or an unloaded module. Extracting the exact `Image.gz-dtb` +from the boot image independently confirmed `status = "okay"` on the MDSS, +DSI and EA8074 nodes, and the DPU-to-DSI and DSI-to-panel graph endpoints are +connected. ALSA still reported no soundcards. ADSP had booted and WCD934x +returned its chip ID; the DTS has a TAS2559 DAI link, while this kernel tree +has no TAS2559 driver or staged TAS2559 firmware. + +A root-only `pam_systemd` bypass was staged in the scratch NFS root after +repeated root user-manager teardown timeouts. Later NFS-root SSH logs confirmed +root sessions opened with the bypass. Its original PAM file is backed up at +`the disposable host-side NFS root/root/system-login.pre-root-ssh-test`. The read-only NFS +control channel subsequently ran several diagnostics and a runtime SSH start; +no request marker remains. The five-second `/dev/ttyACM0` capture produced no +serial output. The stable system has since returned to its existing ext4 boot, +with USB SSH and the DSI Hyprland monitor verified. + +#### Gated RAM-boot test + +1. The image `/tmp/mi8-panel-nfs-image/images/boot.img` was RAM-booted on + 2026-10-31 after fastboot reported `product: dipper`, `unlocked: yes`. + NFS mounted; no partition was written. +2. This run reached SDDM and Hyprland's Wayland socket, but had no provisioned + desktop account. Runtime DRM exposed only simpledrm; SDDM also logged the + Zink Vulkan failure. Manually loading `msm` bound MDSS/DPU/DSI but still did + not register an MSM DRM card. ALSA exposed no soundcard. The `qcom_wled` + warning at ~187 s was non-fatal; the panel change remains unverified and no + user session was available. +3. On a separately authorized next boot, capture serial and USB logs before + boot, confirm the exact image/hash and restricted NFS export, then check + `dmesg` for DSI component/bridge registration, DRM state, and ALSA cards over + SSH. Pass only when the error is absent, the panel is visible, and sound is + audible from a working route. + +Stop on a repeated `-22`, a black panel, or loss of the USB console. The test is +RAM-only; do not flash. Risk: moderate; this latest test temporarily left the +phone unresponsive and required physical recovery, but did not change its +partitions. + +### What it took, and the traps + +1. **The hardware watchdog must be handed over to systemd.** SDM845 leaves its + watchdogs *running* -- `watchdog0: watchdog did not stop!` -- and the + initramfs daemon that pets it dies with everything else at `switch_root`. The + first boot reached "Started Journal Service" and died at + `watchdog0: pretimeout event`, 34 s in. Fixed by a new + `vendor/systemd/system.conf.d/10-omamobile-watchdog.conf` in the dipper + package. `RuntimeWatchdogSec=10s` was **not enough**: systemd programs that + as the *hardware* timeout and pings at half of it, and a first boot spends + about 8 s inside "Applying preset policy", so the pretimeout fired again at + 17 s. 30 s was still not enough on a cold NFS boot (died at 37 s). **60 s + works.** +2. `/etc/machine-id` shipped as `uninitialized`, which makes systemd run + `preset-all` on first boot -- slow on NFS and the cause of trap 1's second + failure. Writing a real id removes that stall. +3. **The image has no SSH host keys**, so `sshd` cannot start and the phone boots + with no way in. Generated with `ssh-keygen -A -f `. This is why the + first good boot was unreachable despite being healthy. +4. `systemd-pstore` consumes `/sys/fs/pstore` on boot, which eats the ramoops + console log before it can be read. Mask it while bringing up. +5. The journal is useless for a boot that dies: systemd preallocates 8 MiB and + flushes almost nothing, so `ramoops` remains the only record. + +### Escape hatches added, because there was none + +A healthy phone with no `sshd` has no channel at all -- no adb (that is Android's +daemon and goes with it), no fastboot (that is the bootloader), no console. Both +of these are now staged in the scratch rootfs: + +- `serial-getty@ttyGS0` with an autologin drop-in. The initramfs already creates + `acm.GS0` and the host sees `/dev/ttyACM0`; there was simply no getty on it, + and root's password hash is `!*` so a plain getty would refuse anyway. +- `omamobile-nfs-trigger.timer`, polling the NFS-served root for a `/reboot-now` + file. The root is writable from the host, so it doubles as a control channel. + +Withdrawing the NFS export does **not** force a reset: systemd keeps petting the +watchdog from memory, so the phone hangs rather than rebooting. + +### Still to verify on the next boot + +A shell in Omarchy (host keys are now in place), then whether +`omamobile-wlan.service` brings Wi-Fi up by itself. The radio pieces are staged: +`modprobe.d` with `msa_perm_delay_ms=300`, `user_regd=1` and `ath10k_snoc` +blacklisted; the gated bring-up unit; `wireless-regdom` SK; the IPC chain +enabled; and a NetworkManager profile for the 2.4 GHz band. + +Only the watchdog file has been moved into the dipper package so far. The rest +lives in the disposable scratch rootfs and still needs a proper home. + +## Next steps + +1. Restore a physical USB data connection and identify the phone's current + mode before sending device commands. If Android has booted since the saved + snapshot, capture and verify a fresh off-device read-only backup before + radio work. Continue with RAM boot only; do not flash. +2. Verify completion and exit status of the diagnostic kernel/image build. + Verified 2026-10-30: the build completed and debug ath10k modules exist under + `out/dipper/modules/lib/modules//.../ath10k/`. There is **no** saved + original `linux/.config` — `.config.old` is an unrelated kconfig artefact + (6017 differing lines), not a pre-debug backup. The only recorded diagnostic + change is `CONFIG_ATH10K_DEBUG=y`, so "restoring" means unsetting that one + symbol; leave it on until the XPU violation is diagnosed. Still to do: copy + the debug ath10k modules into the disposable NFS scratch rootfs. +3. Review private logs under + `private off-device reference directory (path omitted)*` before deciding + whether another attended radio attempt is justified. Do not restart a + crashed modem in place. Keep NV links read-only, recovery disabled, and a + private live log active. +4. The earlier NFS scratch boot exposed only simpledrm and deferred DSI on the + IBB regulator, but the current stable boot exposes a connected 1080x2248 + DSI monitor with Hyprland and Quickshell active. Physical panel visibility + was not directly observed. Audio is still incomplete: the current sound + card probe defers on the missing TAS2559 DAI; do not remove the speaker link + without a working replacement route. No flash or install to `userdata`. +5. No radio service is enabled by default. Keep `rmtfs` read-only on any later + attempt and load one subsystem at a time. + +Build script references: `device/dipper/FLASH-RUNBOOK.md`, `WIFI-PLAN.md`, +`tools/dipper/build`, `tools/build-packages`, `tools/build-rootfs`. diff --git a/device/dipper/WIFI-PLAN.md b/device/dipper/WIFI-PLAN.md new file mode 100644 index 000000000..1e404e455 --- /dev/null +++ b/device/dipper/WIFI-PLAN.md @@ -0,0 +1,545 @@ + +# dipper — Wi-Fi plan + +Wi-Fi matters more on this phone than on a Pixel: dipper is not A/B, so a boot +without working networking leaves no remote access at all. It is also not a +self-contained driver, which is the main thing to understand before debugging it. + +## What actually has to be true + +WCN3990 has no firmware of its own. **The WLAN firmware runs on the modem's DSP**, so +`ath10k_snoc` only gets a chip once the whole Qualcomm IPC chain is up: + +| Piece | Where it comes from | State | +| --- | --- | --- | +| `ath10k_snoc` + `qcom,wcn3990-wifi` node | mainline; node enabled in our DTS with beryllium's supply set | **in the DTS** | +| `ath10k/WCN3990/hw1.0/firmware-5.bin` | linux-firmware — a 60-byte metadata stub, no code | fetched | +| `ath10k/WCN3990/hw1.0/board-2.bin` | **built from this phone's own calibration** (below) | **built** | +| `wlanmdsp.mbn` (3.6 MiB) | the phone's `/vendor/firmware_mnt/image` | extracted | +| `mba.mbn` + `modem.mbn` (60 MiB) | the phone; `modem` squashed from `.mdt` + 27 `.bNN` | extracted | +| `*.jsn` protection-domain maps | the phone; `pd-mapper` reads them | extracted | +| `qrtr`, `pd-mapper`, `rmtfs`, `tqftpserv` | **AUR PKGBUILDs**, not repository packages: `qrtr` 1.2, `rmtfs` 1.2, `tqftpserv` 1.2, `pd-mapper` 1.1 | exist; **must be built for aarch64** | +| `rmtfs_mem` reserved region | in our DTS at `0xf6301000 + 0x200000` | in the DTS | + +So the realistic order is: register the modem remoteproc → start `rmtfs`/`tqftpserv` → +explicitly start the modem firmware → `pd-mapper` answers protection-domain lookups → +`ath10k_snoc` finds a chip. **Wi-Fi cannot be brought up before the modem subsystem runs.** That is why first light +targets USB networking instead, and why the cable is not optional. + +## Attended first-radio run + +The newest private off-device snapshot of all 15 saved partitions is +`private off-device reference directory (path omitted)/`; all +device/source hashes matched before the RAM boot. Keep +the live kernel log private under `private off-device reference directory (path omitted)/`. + +The phone was in rescue initramfs. Its NFS client is built into this kernel, so a +disposable copy at host `the disposable host-side NFS root` was served over USB NCM and mounted +read-write at `the host-side scratch mount`; only that scratch copy was writable. At the latest +host check (2026-10-30), ADB and fastboot listed no device, the Mi 8 Tailscale +peer was offline, and `lsusb` showed no identifiable phone. Host `usb0` remained +up but does not establish phone connectivity. The phone's current screen/mode is +unknown; no further device commands were sent. The host NFS service is disabled +at boot and its export is restricted to the USB client. The original compressed +image and `userdata` are untouched. + +The 2026-10-30 RAM boot confirmed the revised image and all five NV links +read-only. The modem exposed QRTR WLAN service 69. On the MCFG retry, both MCFG +files were served successfully and the WLAN DSP firmware was fetched; the modem +still crashed with `modem_xpu_int.c:456:XPU violation End`. Re-timed from +`wifi-20261030-mcfg-ath10k-crash-dmesg.log`: the modem came up at t=160.5 s and +ran healthy for 137 s; `cfg80211` loaded at t=297.53 s (the ath10k insert +pulling in mac80211/cfg80211) and the violation arrived at t=297.89 s, 0.36 s +later. The trigger is therefore ath10k's QMI handshake, not modem boot or MCFG. +That capture holds no ath10k lines at all, so the `CONFIG_ATH10K_DEBUG` output +built for the run was never obtained; stream the log off-device, or read it back +from pstore, before the module is inserted. No WLAN interface, scan or association occurred. +The MCFG files are now in the private firmware tree and scratch rootfs, and +`tools/dipper/extract-firmware` stages them for future builds. Resolved 2026-10-30: the rejected +`/boot/modem_fsg_oem_1` and `/boot/modem_fsg_oem_2` requests are benign. Dipper +has no `fsg_oem*` partition (only a single `fsg`), and stock `/vendor/bin/rmt_storage` +knows exactly four paths -- `/boot/modem_fs1`, `/boot/modem_fs2`, `/boot/modem_fsc`, +`/boot/modem_fsg` -- so stock refuses those two requests too and Android works +regardless. The modem probes them opportunistically. Do not alias them to any +partition; the rejection is not a fault and is not the XPU violation's cause. A whole-phone reboot separated the earlier and +latest RAM attempts. On a prior Android boot, Tailscale reconnected after its +app was opened. The latest radio attempt left remoteproc `crashed` with +recovery disabled; do not retry in place. NV partitions remained read-only. + +The saved kmsg logs show automatic remoteproc recovery during the failed +sessions: one boot reached crash counters 1–6 and another reached 1–5, +restarting MBA/MPSS after each fatal error. The kernel defaults recovery to +enabled. Before the next single start, while `remoteproc0` is offline, set +`/sys/class/remoteproc/remoteproc0/recovery` to `disabled` and read it back. +If that attempt crashes, leave it crashed and stop; do not invoke `recover` or +enable recovery. + +For the next attempt, first restore physical USB data and identify the phone's +mode. If stock Android has run since the saved snapshot, capture and verify a +fresh off-device backup before radio work. Verify the pending diagnostic build +and image-pack status; `CONFIG_ATH10K_DEBUG=y` was enabled to expose QMI/SNOC +messages. Restore the saved original kernel config after securing outputs, and +ensure matching debug modules are installed in the disposable scratch rootfs. +Then RAM-boot the image (do not flash it), confirm its initramfs created the links above +and recheck their `ro` values. Start a private live log, mount the NFS scratch root +read-write, bind live `/dev`, `/proc`, `/sys` and +`/run`, set +`/sys/module/firmware_class/parameters/path` to `the host-side scratch mount/usr/lib/firmware`, then load +`rmtfs_mem`, `qrtr-smd`, `reset_qcom_pdc` and `qcom_q6v5_mss` from its module tree. The +rebuilt Dipper initramfs creates read-only-checked `by-partlabel` links for `persist`, `fsg`, +`fsc`, `modemst1` and `modemst2`; verify their targets have `ro=1` before continuing. This +image is now RAM-booted. If a link is missing, stop before starting rmtfs. Confirm +`remoteproc0` is `offline`, disable and verify remoteproc recovery, start `pd-mapper` and +`tqftpserv` first, then start `rmtfs -r -P -s` once. Its `-s` option starts the MSS +remoteproc itself; do not also write `start` to the remoteproc state file. `rmtfs` must stay +read-only. Stop if the modem does not stay online, +reports storage/NV errors, or UFS reports an error-handler pass. Do not retry a failed +modem in place. Only after a stable modem and QRTR services are confirmed should a later +session apply the WLAN MAC from read-only `persist`, load `ath10k_snoc`, verify WCN3990 +board data, and attempt a scan. Use the owner's Wi-Fi credentials from ignored local provisioning settings +without echoing them or putting them in logs. +The success test is association to the owner's requested network, then DHCP and connectivity. + +Stop if any backed-up partition is not read-only, USB rescue SSH or live logging is lost, +or any daemon/firmware/board-data step fails. No partition should be written. After a +successful test, a power-cycle of this RAM boot returns to Android. Do not retry a modem +that crashed in the same boot; diagnose it first. +This test runs the untrusted modem firmware, so keep the phone attended and on USB power, +and leave the live log private. + +## Attended run 2026-10-30 (second): where it actually dies + +The diagnostic image RAM-booted, rescue SSH came up, all five `by-partlabel` +targets read `ro=1`, and the live kmsg was streamed **off-device over SSH before +any module was inserted** -- the gap that lost the previous run's evidence. The +modem started once from `rmtfs -v -r -P -s`, reached `running`, and registered 46 +QRTR services including 69 `ATH10k WLAN firmware service`. `recovery` was +`disabled` before the start and the run ended with exactly **one** crash, no +recovery loop. Nothing was written; all five NV partitions stayed `ro=1`. + +`ath10k_core` was loaded with `debug_mask=0x300822` (BOOT|SNOC|QMI|WMI|REGULATORY), +then `ath10k_snoc`. The captured sequence is private at +`private off-device reference directory (path omitted)`: + +``` +snoc xo-cal-data return -22 +qmi msa.paddr: 0x000000008e300000 +snoc probe / wifi fw qmi service found / connected +qmi indication register request completed +qmi msa mem region 0 addr 0x8e300000 size 0x4000 flag 0x1 +qmi msa mem region 1 addr 0x8e304000 size 0xfc000 flag 0x0 +qmi msa mem info request completed <- last successful step +... 57 ms ... +fatal error received: SFR Init: wdog or kernel error suspected +``` + +No `msa ready` line and no `failed to assign msa map permissions` error, so the +modem dies inside `ath10k_qmi_setup_msa_permissions()`'s `qcom_scm_assign_mem()` +window or at `msa_ready` immediately after. The two regions sum to 0x100000, +matching our reserved region. + +### Ruled out, with evidence -- do not re-test these + +| Suspect | Why it is not the cause | +| --- | --- | +| MSA address/size wrong | stock DT reserves `wlan_fw_region@0x8e300000` size `0x100000`, identical to our `wlan_msa_mem` | +| `xo-cal-data return -22` | **no** DTS in the tree sets `qcom,xo-cal-data`, beryllium included; the driver leaves `xo_cal_supported` false and continues | +| rejected `/boot/modem_fsg_oem_1`/`_2` | stock `/vendor/bin/rmt_storage` knows only four paths and refuses them too | +| `qcom,snoc-host-cap-skip-quirk` wrong | beryllium (SDM845 + WCN3990, working) sets the same quirk | +| missing `qrtr-ns` | the name service has been in-kernel (`net/qrtr/ns.c`) since 5.7; upstream dropped the binary. 46 services resolved without it | +| board-2.bin malformed | never reached -- board data is fetched after `msa_ready` | + +### Next step, gated + +`qcom,msa-fixed-perm` has been added to our `&wifi` node as the one hypothesis +the evidence supports: dipper reserves MSA at a *fixed* address, so ABL/TZ has +likely already granted the modem access, and reassigning it from HLOS strips +permissions the modem already holds. Note that no sdm845 DTS upstream sets this +property, so if it fixes dipper that difference needs explaining before the +change goes anywhere near upstream. + +| | | +| --- | --- | +| Do | rebuild DTB + boot image, RAM boot (**never flash**), repeat the sequence above | +| Expect | a `msa ready request completed` line, then board-data fetch, then a `wlan0` interface | +| Pass | modem stays `running` through `ath10k_snoc` load | +| Stop | any fatal error -- leave it crashed, do not `recover`, do not retry in place | +| Rollback | drop the property; power-cycle returns the phone to Android | +| Risk | low: RAM boot only, nothing written, NV read-only | + +Two host-side gotchas worth keeping: busybox `mount` needs an explicit +`addr=`, so the NFS mount is `-o nolock,vers=3,addr=172.16.42.2` (v4 and a bare +v3 both fail with "mount program didn't pass remote address"); and the rootfs +daemons are glibc while the rescue initramfs is musl, so `pd-mapper`, +`tqftpserv` and `rmtfs` must be run via `chroot the host-side scratch mount`, not directly. + +## 2026-10-30, runs 2-4: the failure is the SDM845 XPU erratum, not our config + +Three more attended RAM boots (never flashed; NV read-only throughout; one crash +each, recovery disabled first). Each one moved the failure, and together they +close out most of the suspect list. + +### Run 3: `qcom,msa-fixed-perm` -- got much further, then died anyway + +Setting it skips `qcom_scm_assign_mem()`. The QMI handshake then sailed past the +point that had killed runs 1-2 and reached, in order: `msa mem ready request +completed`, `chip_id 0x30214 chip_family 0x4001 board_id 0xff`, `fw_build_id +WLAN.HL.2.0.c3-00534-QCAHLSWMTPLZ-1`, board-data match, `bdf download request +completed`, `cal report request completed` -- then `SFR Init: wdog or kernel +error suspected` 24 ms later, with no host log line in between. + +So the property is **not** the fix and is deliberately not set: skipping the +assignment leaves the modem without MSA permissions, and it dies at the first +real *use* of that region (the BDF is written into it). The assignment is +required. + +### Run 4: upstream board-2.bin -- identical crash, so our board data is cleared + +Swapping linux-firmware's generic `board-2.bin` for ours changed nothing: same +`cal report` then same watchdog, 23 ms later. Since that generic data is exactly +what beryllium loads and beryllium works, **board data is not the cause**. Ours +is restored (it carries the phone's factory calibration, so TX power is right). + +### What the evidence actually points at + +`ath10k_qmi_event_server_arrive()` carries an upstream workaround: + +```c +/* + * HACK: sleep for a while between receiving the msa info response + * and the XPU update to prevent SDM845 from crashing due to a security + * violation, when running MPSS.AT.4.0.c2-01184-SDM845_GEN_PACK-1. + */ +msleep(20); +``` + +Upstream already knows SDM845 trips an XPU security violation here, and the 20 ms +was measured against **one** MPSS build. dipper runs a different one -- taken from +the phone's own modem image, `MPSS.AT.4.0.c2.6-00335-SDM845_GEN_PACK-1.309997.1` +against upstream's `MPSS.AT.4.0.c2-01184`. Same family, different build. + +That makes both observed failures one bug seen from two sides: with the +assignment, the XPU update itself faults (runs 1-2); without it, the modem has no +permissions and faults on first use (runs 3-4). + +`drivers/net/wireless/ath/ath10k/qmi.c` now takes the settling time from a module +parameter instead of the constant, default 20 so upstream behaviour is unchanged: + +``` +modprobe ath10k_snoc msa_perm_delay_ms= # 0 disables the sleep +``` + +It lives in `ath10k_snoc.ko`, not `ath10k_core.ko` (`qmi.o` is in `snoc-y`). + +### Also cleared, with evidence -- do not re-test + +| Suspect | Why not | +| --- | --- | +| WCN3990 supplies | stock `qcom,icnss@18800000` uses pm8998 l5/l7/l17/l25, which is exactly our l5a/l7a/l17a/l25a; voltages are in stock's own configured ranges | +| a missing WLAN enable GPIO | stock's node has none -- only `gpio-force-fatal-error`/`gpio-early-crash-ind` crash lines | +| `iommus` SID | stock `<0x29 0x40 0x01>` matches mainline `<&apps_smmu 0x0040 0x1>` | +| `pd-mapper` not finding its `.jsn` maps | it falls back to `/lib/firmware/` silently, which resolves correctly inside the chroot; an empty log means success | +| our custom `board-2.bin` | run 4, above | +| the `modem.mbn` squash | MBA authenticates every segment and the modem reaches `running` with 46 QMI services, so the image is intact | + +### Still unexplained, worth noting + +- dipper's `&wifi` is byte-for-byte beryllium's apart from beryllium's + `qcom,calibration-variant = "xiaomi_beryllium"`. Ours has no variant, so + ath10k loads the plain `qmi-board-id=ff` entry. Adding a variant with no + matching board-2.bin entry only falls back to the same data, so it was not + tried; revisit only if the delay theory fails. +- stock also sets `vdd-3.3-ch1` **nowhere**, while mainline's regulator list has + five entries and `regulator_bulk_get()` wants them all. Ours points ch1 at + `vreg_l23a_3p3`, as beryllium does. +- tqftpserv's served-file set differs run to run (`wlanmdsp.mbn` in run 1; + `miui_customized_region` and `ota_firewall/ruleset`, both rejected, in run 4). + Those two rejects are unexplained but stock has real files behind them. + +### Next step, gated -- NOT yet run + +The `delay300` run was prepared and aborted before touching the radio: the phone +did not come back from the previous run's reboot (see STATE.md). + +| | | +| --- | --- | +| Do | RAM boot, full sequence, then `modprobe ath10k_snoc msa_perm_delay_ms=300` | +| Expect | `msa ready`, `bdf download`, `cal report`, then a `wlan0` interface | +| Pass | modem stays `running` after the ath10k load | +| If it still crashes | sweep the delay (100/500/1000) before abandoning the theory; one value per boot, the modem cannot be retried in place | +| Stop | any fatal error -- leave it crashed, never `recover` | +| Rollback | `msa_perm_delay_ms=20` restores upstream behaviour; nothing is flashed | + +The driver change is local and uncommitted. If a longer delay does fix dipper, it +is evidence the 20 ms is an MPSS-version-dependent guess, which is worth taking +upstream -- but it needs a second device to confirm before it is more than a +local workaround. + +## 2026-10-30, run 5: Wi-Fi comes up. The erratum delay was the fix. + +`modprobe ath10k_snoc msa_perm_delay_ms=300` and the modem did **not** crash. +The whole chain completed for the first time: + +``` +qmi msa mem ready request completed +qmi chip_id 0x30214 chip_family 0x4001 board_id 0xff +qmi bdf download request completed / qmi cal report request completed +wifi fw ready event received <- never reached before +soc power on +qmi wlan mode req completed: 0 +boot init ce src/dest ring id 0..11 +Hardware name wcn3990 hw1.0 version 0x8 +``` + +Result on the phone: `remoteproc0` stayed `running`, `phy0` exists, `wlan0` +exists, no ath10k error or warning, and `iw dev wlan0 scan` returned **23 BSSes** +across 2.4 GHz and 5 GHz. The radio transmits and receives. + +So the 20 ms in `ath10k_qmi_event_server_arrive()` is too short for +`MPSS.AT.4.0.c2.6-00335`; 300 ms works. The value is now +`ath10k_snoc`'s `msa_perm_delay_ms` (default 20, upstream behaviour unchanged). +**The minimum working value has not been bisected** -- 300 was the first tried. +Worth narrowing before this is proposed anywhere, and worth confirming on a +second SDM845 device. + +### Why it still does not associate to the owner's AP + +Not a driver fault. `iw phy phy0 info` shows: + +| Band | State | +| --- | --- | +| 36-48 (UNII-1) | enabled, 23 dBm | +| 52-64 (UNII-2A) | enabled, no-IR, radar detection | +| **100-144 (5470-5725)** | **disabled** | +| 149-165 (UNII-3) | enabled, 13 dBm | + +That is exactly the **CN** regulatory domain (CN permits 5150-5350 and +5725-5850, but not 5470-5725) -- this is a Chinese-market handset and the +regdomain comes from its calibration data. The owner's 5 GHz AP sits on +**channel 104 / 5520 MHz**, inside the forbidden gap, so the radio will not even +scan it: none of the three configured SSIDs appears among the 23 networks found, +while 22 neighbours on 2.4 GHz and two on UNII-1 do. + +`iw reg set SK` was tried and changes nothing, because `ath10k_regd_update()` +drives the firmware from `ar->ath_common.regulatory.regpair` (ath/regd.c, +`REGULATORY_CUSTOM_REG`): the calibration regdomain wins over the host hint. + +Note stock Android **does** connect on 5520 MHz, so the hardware is capable; stock +derives its country from the modem/NV rather than from the ath10k default. Making +mainline do the same means changing where `current_rd` comes from, which is +regulatory-limit territory and is deliberately left as a separate decision rather +than patched quietly. + +### To finish: one of these + +| Option | Cost | +| --- | --- | +| Put the AP on a permitted channel (36-48, 149-165) or use its 2.4 GHz SSID | router-side, one setting, proves the stack immediately | +| Make ath10k take the country from the modem/NV as stock does | real work, touches regulatory limits, needs a deliberate decision | + +Nothing else is in the way: association was not reached only because no network +the phone has credentials for is reachable on a channel this calibration permits. + +### Still open from this run + +- `wlan0`'s MAC was the random `c2:fa:...`: `omamobile-dipper-identity` does not + run in the rescue initramfs, so the real address was not applied from `persist`. + Harmless for association, but apply it for a real boot. +- `DT bdf variant name not set.` remains; beryllium sets + `qcom,calibration-variant`. Untried, since our board-2.bin has no variant + entries and ath10k would fall back to the same data. +- wpa_supplicant ran fine (`wpa_state=SCANNING`) and is not implicated. + +## 2026-10-30: Wi-Fi WORKS. Associated, DHCP, internet. + +On a RAM boot (nothing flashed, NV read-only throughout) the Mi 8 associated to +the owner's AP on 2.4 GHz and carried real traffic: + +``` +wpa_state=COMPLETED freq=2447 signal -59 dBm +udhcpc: lease obtained from the local gateway (addresses omitted) +default route via the local gateway on wlan0 +ping -I wlan0 1.1.1.1 -> 3/3 packets, 11.0/16.1/20.2 ms +remoteproc0: running +``` + +### What it took, in the order it mattered + +1. **`ath10k_snoc msa_perm_delay_ms=300`.** The upstream `msleep(20)` before the + XPU update in `ath10k_qmi_event_server_arrive()` is tuned to + `MPSS.AT.4.0.c2-01184`; dipper runs `MPSS.AT.4.0.c2.6-00335` and needs longer. + Now a module parameter, default 20, so upstream behaviour is unchanged. + **The minimum working value has not been bisected.** +2. **Wait for QRTR service 69 before loading ath10k.** This was the whole + "flakiness": loading `ath10k_snoc` before the modem publishes the ATH10k WLAN + firmware service makes the driver wait, time out after ~17 s, and take the + modem down with it (`fatal error without message`). Gating on service 69 -- + it shows up about 4 s after the modem start -- turned a roughly 50% success + rate into every attempt. **Any boot script must gate on this, not sleep.** +3. **`ath user_regd=1` plus `iw reg set SK`.** The calibration reports **CN**, + which omits 5470-5725 entirely, and `ath_regd_init_wiphy()` applies it as a + `REGULATORY_STRICT_REG | REGULATORY_CUSTOM_REG` domain, so the phy ignored the + global domain -- `iw phy phy0 reg get` kept saying `country CN` while the + global said SK. The new `user_regd` parameter (ath.ko, default off) leaves the + phy on cfg80211's domain instead. With it, channels 100-144 went from + `(disabled)` to `(26.0 dBm) (no IR, radar detection)` and the firmware really + did scan 5500-5720 with valid noise floors. + +### The one thing that does NOT work: DFS channels + +The owner's 5 GHz AP is on **channel 104 / 5520 MHz**, a DFS channel. Scanning it +works; associating does not. Every attempt ends the same way, 52 ms after the +driver tunes to it: + +``` +wmi tlv vdev start +firmware crashed! (guid ...) kconfig ... dfs 1 ... +wifi fw qmi service disconnected +qcom-q6v5-mss: watchdog received: SFR Init: wdog or kernel error suspected +``` + +`CONFIG_ATH10K_DFS_CERTIFIED=y` was enabled and makes no difference -- the banner +shows `dfs 1` and it still crashes. The 2.4 GHz run above proves association, +DHCP and traffic are all fine, so this is specific to starting a vdev on a DFS +channel, not to association. + +This matches the only close prior art found: a OnePlus 6T (same SDM845, same +WCN3990) report of `mpss` asserting in `wlan_vdev.c:_wlan_vdev_down` and +escalating to a watchdog, where the reporter ruled out ADSP load, module load +timing, rmtfs read-write and firmware packaging, and concluded "I have not found +a configuration that keeps Wi-Fi and is free of this crash." There is no upstream +fix. The firmware is closed (`WLAN.HL.2.0.c3-00534`), so this is a firmware-side +limit, not something the DT or the driver reaches. + +**Practical answer: keep the phone off DFS channels.** Non-DFS and permitted +here: 2.4 GHz, UNII-1 (36-48) and UNII-3 (149-165). Moving the AP's 5 GHz radio +to 36-48 is one router setting and should give 5 GHz without the DFS path; that +is untested but uses the same `vdev start` that works on 2.4 GHz. + +### Cleared earlier, with evidence -- do not re-test + +| Suspect | Why not | +| --- | --- | +| MSA address/size | stock reserves `wlan_fw_region@0x8e300000/0x100000`, identical to ours | +| `qcom,msa-fixed-perm` | gets past the XPU violation but then dies at first MSA *use*; the assignment is required | +| our `board-2.bin` | upstream's generic file crashes identically | +| `xo-cal-data return -22` | no DTS in tree sets `qcom,xo-cal-data`, beryllium included | +| rejected OEM FSG paths | stock `rmt_storage` knows only four paths and refuses them too | +| WCN3990 supplies | stock icnss uses pm8998 l5/l7/l17/l25, exactly our l5a/l7a/l17a/l25a | +| missing `qrtr-ns` | in-kernel since 5.7; 46 services resolve without it | +| stale initramfs modules | rebuilt with the kernel; made no difference | + +### For a real boot (not yet done) + +- `msa_perm_delay_ms=300` and `user_regd=1` belong in `/etc/modprobe.d`. +- The regulatory domain must be set at boot, or the phy falls back to CN. +- Something must gate ath10k on QRTR service 69; the modem chain + (`rmtfs`/`pd-mapper`/`tqftpserv`) still starts nothing automatically. +- `wlan0` had a random MAC; `omamobile-dipper-identity` does not run in rescue. + +## board-2.bin: why ours and not upstream's + +Upstream linux-firmware's WCN3990 `board-2.bin` holds **36 entries, every one keyed +`qmi-board-id=ff`** (plus a few other SoCs). dipper's own WLAN firmware reports +**board id 0** — the stock kernel logs it verbatim: + +``` +wlan: [443:I:WMA] wma_rx_service_ready_event: Board id: 0, Board version: 0 0 0 0 0 +``` + +With no matching entry ath10k loads no board data, and Wi-Fi stays down. So +`tools/dipper/build-board-2.py` builds one from the phone's own 34 board-data files: + +- **23 entries**, `bus=snoc,qmi-board-id=,qmi-chip-id=30214` (both ids are `%x` in + `ath10k_core_create_board_name()`; `30214` is hex, as in upstream's own names), +- board ids **0** and **ff** both carry the phone's default `bdwlan.bin`, covering what it + reports and ath10k's fallback, +- the 21 `bdwlan.bNN` variants go in under their own ids, so a different unit of the same + phone still finds its own calibration. + +This uses **the phone's factory calibration** rather than generic data, which is what keeps +transmit power correct rather than merely legal-looking. The tool cross-checks itself by +parsing upstream's file first (36 entries, all `snoc`) and refuses to write anything if that +parse fails; `tools/dipper/test-board-2.py` covers round-tripping, a bad magic, IE alignment, +the file-name-to-board-id mapping, and the empty-input refusal. + +## The MAC address: generic, read at boot + +Generic board data carries no per-unit MAC, so without help the interface comes up with +whatever ath10k invents — different on each boot, which breaks anything keyed to the address. + +**The image stays device-agnostic.** `tools/dipper/identity/omamobile-dipper-identity` runs +once at boot, mounts `persist` **read-only**, reads `/wlan_bt/wlan.mac` and +`/wlan_bt/bt.mac` — where every Mi 8 keeps its own factory addresses — and applies them: + +- writes `/etc/systemd/network/10-dipper-wlan.link`, which `systemd-udevd` applies whoever + manages the interface afterwards, NetworkManager included, and sets `wlan0` immediately if + it already exists; +- sets the Bluetooth public address with `btmgmt` when `hci0` and `btmgmt` are both there. + +It refuses an all-zero, broadcast, multicast or short-read value rather than configuring +nonsense, is a quiet no-op when `persist` is absent, and does not rewrite an unchanged link +file. `tools/dipper/identity/test-identity.sh` drives **the script itself** (not a copy of its +logic) through all of those cases. + +So **the same image works on any Xiaomi Mi 8**: nothing device-specific is compiled in. + +### The single-device alternative, off by default +`tools/dipper/apply-identity` can write a Bluetooth address into the built DTB's +`local-bd-address` instead, which has the advantage of being set before userspace runs. It is +opt-in (`DIPPER_BAKE_IDENTITY=1`) because it makes the image specific to one handset. The DTS +itself carries an all-zero placeholder, so no identifier is ever committed, and the tool finds +the `qcom,wcn3990-bt` node by compatible rather than by path and reads the value back to +confirm it took. `tools/dipper/extract-identity` recovers the addresses offline from the +`persist` backup with `debugfs`, for when the phone is not reachable. + +## Is any of this specific to one phone? + +Worth being precise, because it decides whether this port serves every Mi 8 or just one: + +| Piece | Scope | +| --- | --- | +| board data (`bdwlan.*`) | **per model, not per unit** — it comes from the `modem` partition, so every Mi 8 on the same firmware has the identical set. Our `board-2.bin` carries **all 23 board ids**, not just the one this handset reports, so a unit that reports a different id still finds its own calibration. | +| `wlanmdsp.mbn`, `modem.mbn`, `mba.mbn`, DSP and GPU images | per model | +| WLAN and Bluetooth MAC | **per unit** — and therefore never in the image; read from `persist` at boot | +| the device tree, the panel driver, the descriptor | per model | + +The one thing that cannot be shared is distribution: the firmware and board data are Xiaomi's +proprietary blobs, so each owner runs `tools/dipper/extract-firmware` against their own phone. +The tooling is general; the blobs are not ours to ship. That is the same line the project draws +for cheetah's camera data. + +## Open + +- The four IPC daemons are now vendored as source PKGBUILDs under + `packages/{qrtr,pd-mapper,tqftpserv,rmtfs}` and included in dipper's local package set. + All four aarch64 packages and `omamobile-device-dipper` built and were signed into + `out/dipper/repo`; the full rootfs is built at + `out/dipper/omamobile-rootfs-2026.10.29-dipper-aarch64.img.zst`. Its manifest + lists the daemons and Qualcomm/Atheros distro firmware packages, and the 11 + rootfs smoke checks pass. The builder copies private firmware from + `out/dipper/firmware`. This confirms packaging only: Wi-Fi has not been tested + on mainline and no radio service is enabled automatically. +- All four IPC daemons exist in the AUR (checked against the AUR API: `qrtr` 1.2-1, + `rmtfs` 1.2-1, `tqftpserv` 1.2-1, `pd-mapper` 1.1-1, plus `-git` variants for qrtr and + pd-mapper). These source builds use the project package builder for aarch64. +- Two modem starts have been attempted on this phone under mainline, both crashed. No + modem/Wi-Fi service is enabled automatically. The older backup's `persist` and `modemst2` + hashes did not match the live partitions. A fresh read-only snapshot was captured after + stock Android boot at + `private off-device reference directory (path omitted)/`; all 15 saved + partitions match the handset and report read-only. The original snapshots remain + preserved. `userdata`, Android system/vendor and separately extracted firmware are not + part of this 15-partition snapshot. +- A private live `/dev/kmsg` stream is being captured outside the repository. The rescue + initramfs has no Qualcomm user-space daemons, firmware or radio modules. To avoid writing + to `userdata`, a disposable host-side copy of the built rootfs is exported over the USB + NCM link and mounted read-write at `the host-side scratch mount` on the phone. Writes affect only the + scratch copy. The NFS server is disabled at host boot and its export is USB-client-only. +- The current crash followed an `rmtfs` failure to open `/dev/disk/by-partlabel/fsc` for + `/boot/modem_fsc`. A temporary read-only-checked link stopped new errors, but the crashed + modem was not restarted. `initramfs/init` now includes `fsc`; rebuild the boot image before + another RAM boot. Recovery is disabled in the current rescue session, and `ath10k_snoc` + has not been loaded. +- `qcom,calibration-variant` is deliberately **not** set: we key on board id instead, which + needs no variant string and no guess about which one this unit is. diff --git a/device/dipper/device.conf b/device/dipper/device.conf new file mode 100644 index 000000000..a07e342bc --- /dev/null +++ b/device/dipper/device.conf @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: MIT +# Device descriptor: Xiaomi Mi 8 (dipper). Every value below is read off the +# phone itself (live device tree, boot image header, /proc/partitions) or from +# the running stock kernel; nothing is copied from another board. +CODENAME=dipper +NAME="Xiaomi Mi 8" +SOC=sdm845 +# Matches the board DTS this port carries (sdm845-xiaomi-dipper.dts). +COMPATIBLE="xiaomi,dipper" +# Android boot image header v1, page size 4096, second_size 0, and two ~480 KB +# FDTs concatenated at the end of the kernel blob: the DTB is appended to the +# kernel and ABL picks one by qcom,msm-id / qcom,board-id. +BOOT_METHOD=android-v1-appended-dtb +BOOT_PAGESIZE=0x1000 +PACKAGE=omamobile-device-dipper +ROOTFS_PROFILE=dipper +ROOTFS_PACKAGES="qrtr pd-mapper tqftpserv rmtfs" +# Arch repository packages only. Wi-Fi also needs the Qualcomm IPC daemons +# (qrtr, rmtfs, tqftpserv, pd-mapper), which exist as AUR PKGBUILDs rather than +# repository packages, so they have to be built for aarch64 like our own +# packages -- they cannot be listed here. See WIFI-PLAN.md. +ROOTFS_DIST_PACKAGES="vulkan-freedreno linux-firmware-qcom linux-firmware-atheros" +# Set once the kernel is built; the port has no kernel release yet. +KERNEL_RELEASE= +# dipper is NOT A/B for the OS: one `boot`, one `system`, one `userdata`, plus a +# `recovery` partition. Only the bootloader chain is slotted (xbl/abl/tz/hyp/...), +# and this port never writes any of it. So there is no `_b` suffix anywhere here +# and no fallback slot: see NOTES.md. +BOOT_IMAGES="boot" +UFS_RW="userdata" +# 0x438 x 0x8c8 from the active panel node (Samsung EA8074, notch, cmd mode, 60 Hz). +PANEL_SIZE=1080x2248 +MONITOR_SCALE=2.25 diff --git a/device/dipper/kernel.config b/device/dipper/kernel.config new file mode 100644 index 000000000..b7c5a5bd3 --- /dev/null +++ b/device/dipper/kernel.config @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: MIT +# dipper's kernel fragment, merged after kernel/configs/omamobile.config. +# +# Everything the phone needs to reach a shell is built in, not a module. The +# first boot proved why: arm64 defconfig makes the Qualcomm PHY drivers and the +# UFS glue modules, while dwc3 and ufshcd are built in. So they probed, found no +# PHY, and gave up -- the kernel logged +# platform a600000.usb: deferred probe pending: dwc3: failed to initialize core +# gcc-sdm845 100000.clock-controller: sync_state() pending due to 88e8000.phy +# and the initramfs never got USB or storage. Modules in the initramfs do not +# help when nothing loads them before the devices probe. + +# USB and UFS PHYs. Without these, both the USB gadget and storage are dead. +CONFIG_PHY_QCOM_QMP=y +CONFIG_PHY_QCOM_QMP_COMBO=y +CONFIG_PHY_QCOM_QMP_UFS=y +CONFIG_PHY_QCOM_QUSB2=y + +# Storage: the core is already built in, the Qualcomm glue was not. +CONFIG_SCSI_UFS_QCOM=y + +# The Type-C port manager on the PMIC, for the role switch and VBUS detection. +CONFIG_TYPEC_QCOM_PMIC=y + +# Display: built in, so a console exists before any module is loaded. +CONFIG_DRM_MSM=y +CONFIG_DRM_PANEL_SAMSUNG_EA8074=y + +# Touch, so a working panel is usable without waiting for userspace. +CONFIG_TOUCHSCREEN_STMFTS=y + +# Console log into the stock ramoops region: the only way to read an early hang +# on a phone with no serial header. +CONFIG_PSTORE=y +CONFIG_PSTORE_RAM=y +CONFIG_PSTORE_CONSOLE=y + +# Tailscale needs a tun device; arm64 defconfig has it, pin it so a later +# fragment cannot quietly drop it. +CONFIG_TUN=y + +# --- the same lesson, applied to everything first light touches --------------- +# Devices probe once, early. A driver that only turns up later as a module never +# gets a second chance: the device is left unbound and not even on the deferred +# list. The first boot proved it for the PHYs; the second proved it again for +# i2c (geni_i2c loaded by hand bound to nothing, and `bind` by hand failed). +# So everything needed to reach a usable system is built in. + +# i2c: the touchscreen lives on i2c14, and nothing on that bus exists without it. +CONFIG_I2C_QCOM_GENI=y +CONFIG_QCOM_GPI_DMA=y +# Nothing of ours is on SPI, so it stays a module: every built-in byte counts +# against the ABL kernel limit below. +CONFIG_SPI_QCOM_GENI=m + +# Display comes from the bootloader's framebuffer through simpledrm, not from +# the MSM display driver, so DRM_MSM stays a module. Built in it pushed the +# kernel past about 16 MiB, which this ABL refuses outright: +# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') +# Nothing loads it; the panel path is open work (see NOTES.md). +CONFIG_DRM_MSM=m +CONFIG_DRM_SIMPLEDRM=y +CONFIG_SYSFB_SIMPLEFB=y + +# The remoteprocs Wi-Fi depends on (the modem hosts the WLAN firmware) stay +# modules. Built in they pushed the kernel past what this ABL will load: a +# kernel+dtb of 16,247,767 bytes boots and 16,376,528 does not, with only +# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') +# to go on. In the root filesystem udev loads them; the bring-up initramfs does +# not need the modem. +CONFIG_QCOM_RPROC_COMMON=m +CONFIG_QCOM_Q6V5_PAS=m +CONFIG_QCOM_Q6V5_MSS=m +CONFIG_QCOM_SYSMON=m +CONFIG_RPMSG_QCOM_GLINK_SMEM=m + +# Left as modules with DRM_MSM: pinning them only mattered to allow DRM_MSM=y, +# which the ABL size limit ruled out. +CONFIG_QCOM_OCMEM=m +CONFIG_QCOM_LLCC=m + +# This phone's ABL refuses a boot image whose kernel is too large, saying only +# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') +# Measured: kernel+dtb of 16,247,767 bytes boots, 16,343,459 does not. The +# boundary sits at 0xF80000 = 16,252,928, which tools/dipper/build-boot.py now +# refuses to cross so the failure is ours and explained, not the bootloader's +# and silent. + +# The DSI core can be a module: the panel driver that needs it is one too, and +# the display comes from simpledrm over the bootloader's framebuffer. +CONFIG_DRM_MIPI_DSI=m diff --git a/initramfs/init b/initramfs/init index 36cd2d946..353ce2036 100755 --- a/initramfs/init +++ b/initramfs/init @@ -92,6 +92,32 @@ ufs_rw_load() { ufs_rw_load mkdir -p /run/ufs-ro ufs_partname() { sed -n 's/^PARTNAME=//p' "$1/uevent" 2>/dev/null; } +ufs_dipper_partlabel_links() { + local s name part link target old + tr '\0' '\n' < /proc/device-tree/compatible 2>/dev/null | grep -qx 'xiaomi,dipper' || return 0 + mkdir -p /dev/disk/by-partlabel + for s in /sys/block/sd* /sys/block/sd*/sd*; do + [ -r "$s/ro" ] || continue + name=${s##*/} + [ -b "/dev/$name" ] || continue + part=$(ufs_partname "$s") + case "$part" in persist|fsg|fsc|modemst1|modemst2) ;; *) continue ;; esac + [ "$(cat "$s/ro")" = 1 ] || continue + link=/dev/disk/by-partlabel/$part + target=/dev/$name + [ -e "/run/ufs-ro/ambiguous-$part" ] && continue + if [ -L "$link" ]; then + old=$(readlink "$link") + [ "$old" = "$target" ] && continue + rm -f "$link" + : > "/run/ufs-ro/ambiguous-$part" + ufs_ro_log "duplicate PARTNAME $part; refusing by-partlabel link" + continue + fi + [ ! -e "$link" ] || continue + ln -s "$target" "$link" && ufs_ro_log "$link -> $target" + done +} ufs_ro_pass() { local s ro name part disk for s in /sys/block/sd* /sys/block/sd*/sd*; do @@ -123,6 +149,7 @@ ufs_ro_pass() { echo "omamobile: WARNING: /dev/$name is NOT read-only" > /dev/tty0 2>/dev/null fi done + ufs_dipper_partlabel_links } # Prints every disk or partition that is writable but not on the allowlist # (sda itself excepted: its node is removed). Empty means the guard holds. @@ -408,6 +435,41 @@ grow_root() { # Hand over to Arch on userdata, unless omamobile.initramfs is on the command # line. Everything is checked before the irreversible exec; if anything is # missing we stay here in the initramfs shell. +# Boot the Arch root from NFS instead of the UFS, for bring-up: nothing on the +# phone is written and the stock OS is left alone, so a root filesystem can be +# tried before anyone decides to install it. Enabled only by the presence of +# /etc/omamobile-nfsroot, holding one line, ":" -- no file, no change. +# The USB gadget and its address are already up by the time this runs, and the +# kernel keeps them across the switch, so the mount survives switch_root. +boot_nfs() { + local spec + [ -r /etc/omamobile-nfsroot ] || return 1 + spec=$(cat /etc/omamobile-nfsroot) + [ -n "$spec" ] || return 1 + say "nfsroot: trying $spec" + mkdir -p /newroot + # busybox mount cannot work out the server address on its own here, so pass it. + # Retry: the phone boots faster than the host brings its usb0 end up, so the + # first mount can race the link coming up. ~30s covers a late host. + local i=0 + until mount -t nfs -o "nolock,vers=3,addr=${spec%%:*}" "$spec" /newroot 2>/dev/null; do + i=$((i + 1)) + [ "$i" -ge 15 ] && { + say "nfsroot: cannot mount $spec (staying in the initramfs)"; return 1; } + sleep 2 + done + if [ ! -x /newroot/usr/lib/systemd/systemd ]; then + say "nfsroot: no systemd on $spec"; umount /newroot; return 1 + fi + say "nfsroot: switching to Arch Linux on $spec" + kill -9 -1 2>/dev/null + sleep 1 + for m in /dev /proc /sys /run; do + mkdir -p "/newroot$m" && mount --move "$m" "/newroot$m" + done + exec switch_root /newroot /usr/lib/systemd/systemd +} + boot_arch() { grep -q omamobile.initramfs /proc/cmdline && return 1 local dev="" s @@ -445,6 +507,7 @@ boot_arch() { done exec switch_root /newroot /usr/lib/systemd/systemd } +boot_nfs boot_arch # PID 1 must never exit: if it does the kernel panics and freezes (silently, diff --git a/packages/mesa/.SRCINFO b/packages/mesa/.SRCINFO index 7e1c025d2..d7008bd48 100644 --- a/packages/mesa/.SRCINFO +++ b/packages/mesa/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = mesa - pkgdesc = Open-source OpenGL drivers (Omarchy Mobile: Mali-G710, Mali-G78, Mali-G715) + pkgdesc = Open-source OpenGL drivers (Omarchy Mobile: Adreno and Mali) pkgver = 26.2.4 - pkgrel = 1.4 + pkgrel = 1.5 epoch = 1 url = https://www.mesa3d.org/ arch = aarch64 diff --git a/packages/mesa/PKGBUILD b/packages/mesa/PKGBUILD index fb6c6a7eb..3c0c01dab 100644 --- a/packages/mesa/PKGBUILD +++ b/packages/mesa/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: 0BSD # -# Omarchy Mobile build of Mesa for the Pixel 7 Pro (Mali-G710 on Panthor) -# and the Pixel 6 and 6 Pro (Mali-G78 on Panfrost), plus Pixel 9a +# Omarchy Mobile build of Mesa for Qualcomm Adreno and the Pixel 7 Pro +# (Mali-G710 on Panthor), Pixel 6/6 Pro (Mali-G78 on Panfrost), and Pixel 9a # (Mali-G715 on Panthor). # # Derived from Arch Linux's mesa PKGBUILD, tag 1-26.2.4-1 @@ -17,7 +17,7 @@ # backported (drop it once Mesa ships it in a release). # - 0004-panfrost-add-Mali-G78-to-the-model-table.patch: the Pixel 6's # Mali-G78, next to the G68 (drop it once Mesa ships the G78 entry). -# - aarch64 only, and only the drivers this phone can use: Gallium +# - aarch64 only, and only the drivers our phones can use: Gallium freedreno, # panfrost (with kmsro), llvmpipe, softpipe and zink; Vulkan panfrost # (PanVK). Splits: mesa, vulkan-panfrost, vulkan-mesa-implicit-layers # (vulkan-panfrost depends on it). No rusticl, NVK, docs or valgrind, @@ -39,10 +39,10 @@ pkgname=( ) pkgver=26.2.4 _pkgver=${pkgver/[a-z]/-&} -pkgrel=1.4 +pkgrel=1.5 _omamobile=omamobile4 epoch=1 -pkgdesc="Open-source OpenGL drivers (Omarchy Mobile: Mali-G710, Mali-G78, Mali-G715)" +pkgdesc="Open-source OpenGL drivers (Omarchy Mobile: Adreno and Mali)" url="https://www.mesa3d.org/" arch=(aarch64) license=("MIT AND BSD-3-Clause AND SGI-B-2.0") @@ -165,7 +165,7 @@ build() { --optimization 2 -D android-libbacktrace=disabled -D b_ndebug=true - -D gallium-drivers=panfrost,llvmpipe,softpipe,zink + -D gallium-drivers=freedreno,panfrost,llvmpipe,softpipe,zink -D gallium-extra-hud=true -D gallium-mediafoundation=disabled -D gallium-rusticl=false diff --git a/packages/mesa/README.md b/packages/mesa/README.md index 13cc1eeb5..247a3a7f5 100644 --- a/packages/mesa/README.md +++ b/packages/mesa/README.md @@ -1,8 +1,8 @@ # mesa (Omarchy Mobile build) -Arch Linux's Mesa 26.2.4 package, rebuilt for the Pixel 7 Pro and the -Pixel 6 and 6 Pro, with additional Pixel 9a Mali-G715 support. Mali-G710 +Arch Linux's Mesa 26.2.4 package, rebuilt for the Xiaomi Mi 8 (Adreno 630), +Pixel 7 Pro, Pixel 6/6 Pro, and Pixel 9a. Mali-G710 (gs201) and Mali-G78 (gs101, with upstream's G68 next to it) are added to Panfrost's model table. Without an entry, Mesa rejects the GPU (for the G710 even when Panthor is loaded): the Gallium @@ -27,15 +27,19 @@ driver bails out on an unknown model, and PanVK returns - The patches above. - `arch=(aarch64)`. - Only drivers this phone can use: - - Gallium `panfrost` (which brings `kmsro`), `llvmpipe`, `softpipe` and `zink`. + - Gallium `freedreno`, `panfrost` (which brings `kmsro`), `llvmpipe`, `softpipe` and `zink`. - Vulkan `panfrost` (PanVK). - The `device-select` and `anti-lag` layers. - Only three split packages: `mesa`, `vulkan-panfrost` and `vulkan-mesa-implicit-layers` (which `vulkan-panfrost` depends on). -- `pkgrel=1.4`. makepkg only accepts `integer[.integer]`, so the Omarchy Mobile - marker is in Mesa's version string instead: `26.2.4-arch1.1.4.omamobile4`. +- `pkgrel=1.5`. makepkg only accepts `integer[.integer]`, so the Omarchy Mobile + marker is in Mesa's version string instead: `26.2.4-arch1.1.5.omamobile4`. That string shows up in `GL_VERSION` and in the `libgallium-*.so` file name. +Freedreno supplies the Adreno DRI driver (`msm_dri.so`) needed by the Mi 8's +Wayland compositor. The separate Vulkan Freedreno package remains supplied by +Arch Linux ARM. + The other ALARM split packages (`vulkan-swrast`, `opencl-mesa` and so on) don't depend on `mesa`'s exact version. They can stay installed at `1:26.2.4-1`. diff --git a/packages/omamobile-device-dipper/LICENSE b/packages/omamobile-device-dipper/LICENSE new file mode 100644 index 000000000..aecd59624 --- /dev/null +++ b/packages/omamobile-device-dipper/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Derek Ross + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/omamobile-device-dipper/PKGBUILD b/packages/omamobile-device-dipper/PKGBUILD new file mode 100644 index 000000000..fc08e422f --- /dev/null +++ b/packages/omamobile-device-dipper/PKGBUILD @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: MIT +# Maintainer: Derek Ross +pkgname=omamobile-device-dipper +pkgver=$(cat "${startdir:-.}/version") +pkgrel=1 +pkgdesc="Omarchy Mobile support for the Xiaomi Mi 8 (dipper)" +arch=(aarch64) +url="https://github.com/derekross/omarchy-mobile" +license=(MIT) +depends=(bash systemd omamobile-keyring qrtr pd-mapper tqftpserv rmtfs) +provides=(omamobile-device) +conflicts=(omamobile-device) +backup=(etc/pacman.d/omamobile-mirrorlist) +install=omamobile-device-dipper.install +makedepends=(gcc) + +build() { + "$startdir/build" "$srcdir/build" +} + +check() { + "$startdir/test/all" +} + +package() { + "$startdir/install" "$pkgdir" "$srcdir/build" +} diff --git a/packages/omamobile-device-dipper/README.md b/packages/omamobile-device-dipper/README.md new file mode 100644 index 000000000..8567ad87a --- /dev/null +++ b/packages/omamobile-device-dipper/README.md @@ -0,0 +1,19 @@ +# omamobile-device-dipper + +Omarchy Mobile support for the Xiaomi Mi 8 (dipper, Snapdragon 845). It hides Android partitions from desktop tools and configures USB networking, device identity and optional Tailscale startup. Qualcomm Wi-Fi userspace and firmware are included in the image; radio startup remains a gated hardware bring-up step. + +| Path | Installs to | What it does | +| --- | --- | --- | +| `vendor/udev/rules.d/10-omamobile-storage.rules` | `/usr/lib/udev/rules.d` | Hides `sda` and every Android partition except `userdata` from desktop tools. Same rule as the Pixel 7 Pro. The initramfs stops its guard loop before `switch_root`; the kernel's read-only flags are what remain | +| `vendor/systemd/network/20-usb-gadget.network` | `/usr/lib/systemd/network` | Sets usb0 to 172.16.42.1/24 after handover. A replug may need a reboot: this package does not close the USB2 switch again (as on the Pixel Fold; dipper's replug is untested) | +| `vendor/systemd/logind.conf.d/10-omamobile-power-key.conf` | `/usr/lib/systemd/logind.conf.d` | A short power press does not power the phone off. Same drop-in as the Pixel 7 Pro. On dipper the forced reset is Power + Volume Up held 15-30 s ([BRINGUP-M1](../../device/dipper/BRINGUP-M1.md) test 23) | +| `vendor/NetworkManager/conf.d/10-omamobile-usb.conf` | `/usr/lib/NetworkManager/conf.d` | Keeps NetworkManager off that link | +| `etc/omamobile-mirrorlist` | `/etc/pacman.d/omamobile-mirrorlist` | Where pacman finds the `[omamobile]` repository. Same file as the Pixel 7 Pro package | +| `omamobile-device-dipper.install` | pacman hook | Adds `[omamobile]` to `pacman.conf` before `[omarchy]`, once. Same script as the Pixel 7 Pro package | +| `src/reboot-to.c` | `/usr/bin/reboot-to` | Reboot with a reason the bootloader understands. Same bytes as the Pixel 7 Pro package; the test checks | +| `device.conf` | `/usr/share/omamobile/device.conf` | The descriptor, the same bytes as `device/dipper/device.conf` | +| `src/reboot-to.c` | build input | Compiles `reboot-to`, which requests a reboot to the bootloader | + +`./build [DIR]` compiles `reboot-to` from this directory, `./install DESTDIR [DIR]` stages the files, and `test/all` checks the copies when it is run from the repository. + +Not in this package: the boot-success marker, automatic modem/Wi-Fi startup, the charger, cameras, and the slot-B image hook. Automatic radio startup stays disabled until its hardware runbook passes. There is no lid drop-in: dipper has no hinge. diff --git a/packages/omamobile-device-dipper/bin/omamobile-dipper-identity b/packages/omamobile-device-dipper/bin/omamobile-dipper-identity new file mode 100755 index 000000000..8e3654dd8 --- /dev/null +++ b/packages/omamobile-device-dipper/bin/omamobile-dipper-identity @@ -0,0 +1,84 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Apply this phone's own WLAN and Bluetooth addresses, read at boot from its +# `persist` partition. Nothing device-specific is baked into the image, so the +# same image works on any Xiaomi Mi 8. +# +# Generic WCN3990 board data carries no per-unit MAC, so without this the +# interface comes up with an address ath10k invents, different on every boot. +set -eu + +PERSIST=${PERSIST:-/dev/disk/by-partlabel/persist} +MNT=${MNT:-/run/omamobile-persist} +LINK=${LINK:-/etc/systemd/network/10-dipper-wlan.link} +log() { echo "omamobile-identity: $*"; } + +mac_from() { # 6 raw bytes -> aa:bb:cc:dd:ee:ff, or nothing if not a station MAC + [ -s "$1" ] || return 1 + # POSIX awk only: and() and strtonum() are gawk extensions that neither the + # phone's awk nor busybox awk has. Running this on the phone is how that + # was found, so do not "simplify" it back. + od -An -tx1 -N6 "$1" | tr -d ' \n' | awk ' + length($0) != 12 { exit 1 } + { + for (i = 1; i <= 11; i += 2) b[++n] = substr($0, i, 2) + all = b[1] b[2] b[3] b[4] b[5] b[6] + if (all == "000000000000") exit 1 # unset + if (all == "ffffffffffff") exit 1 # broadcast + # The multicast bit is the low bit of the first byte, i.e. its + # second hex digit is odd. + if (index("13579bdfBDF", substr(b[1], 2, 1)) > 0) exit 1 + printf "%s:%s:%s:%s:%s:%s", b[1], b[2], b[3], b[4], b[5], b[6] + }' +} + +[ -e "$PERSIST" ] || { log "no persist partition at $PERSIST"; exit 0; } +mkdir -p "$MNT" +mounted=0 +# NOMOUNT lets the test drive this script against a plain directory of files. +if [ "${NOMOUNT:-0}" != 1 ] && ! mountpoint -q "$MNT"; then + mount -o ro,nosuid,nodev,noexec "$PERSIST" "$MNT" || { log "cannot mount persist read-only"; exit 0; } + mounted=1 +fi +cleanup() { [ "$mounted" = 1 ] && umount "$MNT" 2>/dev/null || true; } +trap cleanup EXIT + +wlan=$(mac_from "$MNT/wlan_bt/wlan.mac" || true) +bt=$(mac_from "$MNT/wlan_bt/bt.mac" || true) + +if [ -n "${wlan:-}" ]; then + # A udev .link file is applied whoever manages the interface later, + # NetworkManager included. Rewrite it only when it would change. + want="[Match] +OriginalName=wlan0 + +[Link] +MACAddress=$wlan" + if [ ! -f "$LINK" ] || [ "$(cat "$LINK")" != "$want" ]; then + mkdir -p "$(dirname "$LINK")" + printf '%s\n' "$want" > "$LINK" + log "wrote $LINK" + fi + # Apply now as well, in case wlan0 already exists this boot. + if [ -d /sys/class/net/wlan0 ]; then + ip link set dev wlan0 down 2>/dev/null || true + ip link set dev wlan0 address "$wlan" 2>/dev/null \ + && log "wlan0 address set from persist" \ + || log "could not set wlan0 address now; the link file covers the next boot" + ip link set dev wlan0 up 2>/dev/null || true + fi +else + log "no usable WLAN address in persist; leaving the interface alone" +fi + +if [ -n "${bt:-}" ]; then + if [ -d /sys/class/bluetooth/hci0 ] && command -v btmgmt >/dev/null; then + btmgmt --index 0 public-addr "$bt" >/dev/null 2>&1 \ + && log "bluetooth public address set from persist" \ + || log "btmgmt refused the public address (controller may not support it)" + else + log "no hci0 or no btmgmt yet; bluetooth keeps the firmware default address" + fi +else + log "no usable Bluetooth address in persist" +fi diff --git a/packages/omamobile-device-dipper/bin/omamobile-tailscale-join b/packages/omamobile-device-dipper/bin/omamobile-tailscale-join new file mode 100755 index 000000000..321bfabed --- /dev/null +++ b/packages/omamobile-device-dipper/bin/omamobile-tailscale-join @@ -0,0 +1,46 @@ +#!/bin/sh +# Join the tailnet unattended, then destroy the key. Idempotent: a no-op once +# logged in, so every later boot just rejoins from tailscaled's own state. +# +# Nothing here is hardcoded. Everything comes from the config file, and every +# value has a default, so an empty or missing config is a quiet no-op. +set -eu + +# Overridable only so this script can be tested as-is; production leaves these. +CONF=${OMAMOBILE_TS_CONF:-/etc/omamobile/tailscale.conf} + +# Defaults. The config file may override any of them. +TS_AUTHKEY_FILE=/etc/omamobile/tailscale.authkey +TS_HOSTNAME=$(hostname 2>/dev/null || echo omamobile) +TS_UP_ARGS=--accept-dns=false +TS_KEEP_KEY=0 + +# The config is data: KEY=value lines only, no shell, so a typo cannot run code. +if [ -r "$CONF" ]; then + while IFS= read -r line || [ -n "$line" ]; do + case $line in + ''|\#*) continue ;; + TS_AUTHKEY_FILE=*|TS_HOSTNAME=*|TS_UP_ARGS=*|TS_KEEP_KEY=*) ;; + *) echo "omamobile-tailscale: ignoring unknown setting: ${line%%=*}" >&2; continue ;; + esac + key=${line%%=*} + value=${line#*=} + # strip one layer of surrounding quotes, if present + case $value in \"*\") value=${value#\"}; value=${value%\"} ;; esac + eval "$key=\$value" + done < "$CONF" +fi +KEY=${OMAMOBILE_TS_KEY:-$TS_AUTHKEY_FILE} + +# Already joined? tailscaled persists its node state, so every later boot lands here. +if tailscale status --json 2>/dev/null | grep -q '"BackendState"[[:space:]]*:[[:space:]]*"Running"'; then + exit 0 +fi +[ -s "$KEY" ] || exit 0 + +# file: keeps the key out of the command line and the journal (tailscale >= 1.38). +# shellcheck disable=SC2086 +tailscale up --auth-key="file:$KEY" --hostname="$TS_HOSTNAME" $TS_UP_ARGS + +# A single-use key must not survive on disk. TS_KEEP_KEY=1 is for a reusable key. +[ "$TS_KEEP_KEY" = 1 ] || rm -f "$KEY" diff --git a/packages/omamobile-device-dipper/build b/packages/omamobile-device-dipper/build new file mode 100755 index 000000000..966b2ff2a --- /dev/null +++ b/packages/omamobile-device-dipper/build @@ -0,0 +1,8 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Compile reboot-to into BUILDDIR (default: build). +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" +out=${1:-build-output} +mkdir -p "$out" +${CC:-cc} ${CFLAGS:--O2} -Wall -Wextra -o "$out/reboot-to" src/reboot-to.c ${LDFLAGS:-} diff --git a/packages/omamobile-device-dipper/device.conf b/packages/omamobile-device-dipper/device.conf new file mode 100644 index 000000000..a07e342bc --- /dev/null +++ b/packages/omamobile-device-dipper/device.conf @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: MIT +# Device descriptor: Xiaomi Mi 8 (dipper). Every value below is read off the +# phone itself (live device tree, boot image header, /proc/partitions) or from +# the running stock kernel; nothing is copied from another board. +CODENAME=dipper +NAME="Xiaomi Mi 8" +SOC=sdm845 +# Matches the board DTS this port carries (sdm845-xiaomi-dipper.dts). +COMPATIBLE="xiaomi,dipper" +# Android boot image header v1, page size 4096, second_size 0, and two ~480 KB +# FDTs concatenated at the end of the kernel blob: the DTB is appended to the +# kernel and ABL picks one by qcom,msm-id / qcom,board-id. +BOOT_METHOD=android-v1-appended-dtb +BOOT_PAGESIZE=0x1000 +PACKAGE=omamobile-device-dipper +ROOTFS_PROFILE=dipper +ROOTFS_PACKAGES="qrtr pd-mapper tqftpserv rmtfs" +# Arch repository packages only. Wi-Fi also needs the Qualcomm IPC daemons +# (qrtr, rmtfs, tqftpserv, pd-mapper), which exist as AUR PKGBUILDs rather than +# repository packages, so they have to be built for aarch64 like our own +# packages -- they cannot be listed here. See WIFI-PLAN.md. +ROOTFS_DIST_PACKAGES="vulkan-freedreno linux-firmware-qcom linux-firmware-atheros" +# Set once the kernel is built; the port has no kernel release yet. +KERNEL_RELEASE= +# dipper is NOT A/B for the OS: one `boot`, one `system`, one `userdata`, plus a +# `recovery` partition. Only the bootloader chain is slotted (xbl/abl/tz/hyp/...), +# and this port never writes any of it. So there is no `_b` suffix anywhere here +# and no fallback slot: see NOTES.md. +BOOT_IMAGES="boot" +UFS_RW="userdata" +# 0x438 x 0x8c8 from the active panel node (Samsung EA8074, notch, cmd mode, 60 Hz). +PANEL_SIZE=1080x2248 +MONITOR_SCALE=2.25 diff --git a/packages/omamobile-device-dipper/etc/omamobile-mirrorlist b/packages/omamobile-device-dipper/etc/omamobile-mirrorlist new file mode 100644 index 000000000..f9be3d0e9 --- /dev/null +++ b/packages/omamobile-device-dipper/etc/omamobile-mirrorlist @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: MIT +# Where pacman gets Omarchy Mobile's packages ([omamobile] in /etc/pacman.conf). +# +# The one active Server line is the channel this phone follows: +# stable what has run on the Pixel 7 Pro; phones installed from a +# release follow it +# development every day's build, first; for builders and testers +# local the repository on the phone itself, /var/lib/omamobile/repo, +# filled from a build machine by tools/repo-push +# +# Switch with: sudo omamobile-update channel development (or stable, local) +# See which: omamobile-update check +# +# pacman keeps a changed copy of this file across upgrades (backup= in the +# device package); a new default then arrives as omamobile-mirrorlist.pacnew. +Server = https://pkgs.omamobile.org/stable/$arch +#Server = https://pkgs.omamobile.org/development/$arch +#Server = file:///var/lib/omamobile/repo/$arch diff --git a/packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example b/packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example new file mode 100644 index 000000000..6d43c8f3e --- /dev/null +++ b/packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example @@ -0,0 +1,18 @@ +# /etc/omamobile/tailscale.conf -- how the phone joins the tailnet. +# KEY=value lines only; anything else is ignored with a warning. Every setting +# has a default, so you can delete this file entirely and nothing breaks. + +# Where the auth key is read from. Delete the key file (or leave it empty) and +# the join is skipped: do `tailscale up` by hand instead. +#TS_AUTHKEY_FILE=/etc/omamobile/tailscale.authkey + +# The name the node takes in the tailnet. Defaults to the phone's hostname. +#TS_HOSTNAME=mi8 + +# Extra flags for `tailscale up`. Defaults to --accept-dns=false. +# Examples: "--accept-routes --advertise-tags=tag:phone" +#TS_UP_ARGS=--accept-dns=false + +# Single-use keys are deleted after a successful join. Set to 1 for a reusable +# key you want to keep on the phone. +#TS_KEEP_KEY=0 diff --git a/packages/omamobile-device-dipper/install b/packages/omamobile-device-dipper/install new file mode 100755 index 000000000..5042c0246 --- /dev/null +++ b/packages/omamobile-device-dipper/install @@ -0,0 +1,38 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Stage omamobile-device-dipper into DESTDIR. Nothing is enabled that would +# mark a slot successful or start the radio, the charger, or a camera. +# ./install DESTDIR [BUILDDIR] +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" +destination=${1:?Usage: ./install DESTDIR [BUILDDIR]} +build=${2:-build-output} +[[ $destination == /* && $destination != "/" ]] || { echo "Use an absolute staging directory" >&2; exit 1; } +install -Dm755 "$build/reboot-to" "$destination/usr/bin/reboot-to" +install -Dm644 vendor/udev/rules.d/10-omamobile-storage.rules \ + "$destination/usr/lib/udev/rules.d/10-omamobile-storage.rules" +install -Dm644 vendor/systemd/network/20-usb-gadget.network \ + "$destination/usr/lib/systemd/network/20-usb-gadget.network" +install -Dm644 vendor/systemd/system.conf.d/10-omamobile-watchdog.conf \ + "$destination/usr/lib/systemd/system.conf.d/10-omamobile-watchdog.conf" +install -Dm644 vendor/systemd/logind.conf.d/10-omamobile-power-key.conf \ + "$destination/usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf" +install -Dm644 vendor/NetworkManager/conf.d/10-omamobile-usb.conf \ + "$destination/usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf" +# This phone's own WLAN and Bluetooth addresses are read from `persist` at boot, +# so the image stays identical for every Mi 8. +install -Dm755 bin/omamobile-dipper-identity "$destination/usr/local/bin/omamobile-dipper-identity" +install -Dm644 vendor/systemd/system/omamobile-dipper-identity.service \ + "$destination/usr/lib/systemd/system/omamobile-dipper-identity.service" +# Unattended tailnet join, driven entirely by /etc/omamobile/tailscale.conf. +install -Dm755 bin/omamobile-tailscale-join "$destination/usr/local/bin/omamobile-tailscale-join" +install -Dm644 vendor/systemd/system/omamobile-tailscale-join.service \ + "$destination/usr/lib/systemd/system/omamobile-tailscale-join.service" +install -Dm644 etc/omamobile/tailscale.conf.example \ + "$destination/usr/share/omamobile/tailscale.conf.example" +install -Dm644 device.conf \ + "$destination/usr/share/omamobile/device.conf" +install -Dm644 etc/omamobile-mirrorlist \ + "$destination/etc/pacman.d/omamobile-mirrorlist" +install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-dipper/LICENSE" +install -Dm644 version "$destination/usr/share/omamobile/device-dipper/version" diff --git a/packages/omamobile-device-dipper/omamobile-device-dipper.install b/packages/omamobile-device-dipper/omamobile-device-dipper.install new file mode 100644 index 000000000..908195f92 --- /dev/null +++ b/packages/omamobile-device-dipper/omamobile-device-dipper.install @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: MIT +# Add the [omamobile] repository to pacman.conf, before [omarchy] so its +# builds (e.g. Mesa with Mali-G710 support) win. Added once; never removed +# automatically, so a user's edits stay. +add_repository() { + local conf=/etc/pacman.conf + grep -q '^\[omamobile\]' "$conf" && return + local entry='[omamobile]\nInclude = /etc/pacman.d/omamobile-mirrorlist\n' + if grep -q '^\[omarchy\]' "$conf"; then + sed -i "0,/^\[omarchy\]/s//${entry//\//\\/}\n[omarchy]/" "$conf" + elif grep -q '^\[core\]' "$conf"; then + sed -i "0,/^\[core\]/s//${entry//\//\\/}\n[core]/" "$conf" + else + printf '\n[omamobile]\nInclude = /etc/pacman.d/omamobile-mirrorlist\n' >>"$conf" + fi +} + +# The identity service makes the image device-agnostic (it reads this phone's +# own addresses from `persist`); the tailnet join is a no-op without a key. +enable_units() { + systemctl enable omamobile-dipper-identity.service >/dev/null 2>&1 || true + systemctl enable omamobile-tailscale-join.service >/dev/null 2>&1 || true +} + +post_install() { + add_repository + enable_units +} + +post_upgrade() { + add_repository + enable_units +} diff --git a/packages/omamobile-device-dipper/test/all b/packages/omamobile-device-dipper/test/all new file mode 100755 index 000000000..183508786 --- /dev/null +++ b/packages/omamobile-device-dipper/test/all @@ -0,0 +1,106 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Tests for omamobile-device-dipper. reboot-to is compiled from +# src/reboot-to.c in this directory, so a copied package still builds. +# Do not execute reboot-to. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +pass() { printf 'ok - %s\n' "$1"; } +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT + +bash -n build || fail "build parses" +bash -n install || fail "install parses" +pass "scripts parse" + +grep -q '\.\./\.\.' build install && fail "build or install reaches outside the package directory" +pass "build and install stay inside the package directory" + +if [[ -f ../omamobile-device-cheetah/src/reboot-to.c ]]; then + cmp -s src/reboot-to.c ../omamobile-device-cheetah/src/reboot-to.c \ + || fail "reboot-to.c drifted from the cheetah package" + pass "reboot-to.c matches the cheetah source" + # Deliberately NOT cheetah's rule: dipper is not A/B, so userdata is the only + # writable partition, and its Android partitions span six LUNs (sda..sdf) + # rather than cheetah's four. Assert dipper's own intent instead of equality. + rules=vendor/udev/rules.d/10-omamobile-storage.rules + grep -q 'KERNEL=="sd\[a-f\]", MODE="0000"' "$rules" \ + || fail "the whole-disk nodes of all six LUNs must be inaccessible" + grep -q 'ID_PART_ENTRY_NAME}!="userdata"' "$rules" \ + || fail "every partition but userdata must be ignored by desktop tools" + grep -q 'sd\[a-f\]\[0-9\]' "$rules" \ + || fail "the partition rule must cover all six LUNs" + grep -qE '_b"|slot B' "$rules" \ + && fail "dipper has no slot B; the rule must not mention one" + pass "the storage rule matches dipper's layout (six LUNs, userdata only)" + cmp -s etc/omamobile-mirrorlist ../omamobile-device-cheetah/etc/omamobile-mirrorlist \ + || fail "the mirrorlist drifted from the cheetah package" + pass "the mirrorlist matches the cheetah package" + cmp -s vendor/systemd/logind.conf.d/10-omamobile-power-key.conf \ + ../omamobile-device-cheetah/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf \ + || fail "the power-key drop-in drifted from the cheetah package" + pass "the power-key drop-in matches the cheetah package" + # dipper's install script adds its own units on top of cheetah's repository + # setup, so it is not identical; check both halves are there. + grep -q 'add_repository' omamobile-device-dipper.install \ + || fail "the install script must still add the [omamobile] repository" + grep -q 'omamobile-dipper-identity.service' omamobile-device-dipper.install \ + || fail "the identity service must be enabled on install" + grep -q 'omamobile-tailscale-join.service' omamobile-device-dipper.install \ + || fail "the tailnet join must be enabled on install" + pass "the install script adds the repository and dipper's own units" +fi +grep -q 'omamobile-keyring' PKGBUILD || fail "pacman needs omamobile-keyring" +grep -q '^install=omamobile-device-dipper.install$' PKGBUILD \ + || fail "the pacman install script is not named" +[[ -f etc/omamobile-mirrorlist && -f omamobile-device-dipper.install ]] \ + || fail "the pacman mirrorlist or install script is missing" +pass "pacman gets the keyring, the mirrorlist, and the install script" +if [[ -f ../../device/dipper/device.conf ]]; then + cmp -s device.conf ../../device/dipper/device.conf \ + || fail "device.conf drifted from the descriptor" + pass "device.conf matches the descriptor" +fi + +./build "$tmp/build" || fail "reboot-to compiles" +[[ -x $tmp/build/reboot-to ]] || fail "reboot-to is not executable" +pass "reboot-to compiles" + +./install "$tmp/root" "$tmp/build" +for f in usr/bin/reboot-to \ + usr/lib/udev/rules.d/10-omamobile-storage.rules \ + usr/lib/systemd/network/20-usb-gadget.network \ + usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf \ + usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf \ + usr/share/omamobile/device.conf \ + usr/share/omamobile/device-dipper/version \ + usr/share/licenses/omamobile-device-dipper/LICENSE \ + etc/pacman.d/omamobile-mirrorlist; do + [[ -f $tmp/root/$f ]] || fail "install stages $f" +done +# dipper has six UFS LUNs, so the rule covers sda..sdf rather than sda alone. +grep -q 'KERNEL=="sd\[a-f\]", MODE="0000"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \ + || fail "the whole-disk nodes of all six LUNs are made inaccessible" +grep -q 'ID_PART_ENTRY_NAME}!="userdata"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \ + || fail "userdata is the only partition desktop tools may see" +grep -q 'Address=172.16.42.1/24' "$tmp/root/usr/lib/systemd/network/20-usb-gadget.network" \ + || fail "usb0 keeps the initramfs address" +power="$tmp/root/usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf" +grep -qx '\[Login\]' "$power" \ + || fail "the power-key drop-in needs a [Login] header" +grep -q '^HandlePowerKey=ignore$' "$power" \ + || fail "a short press must not power the phone off" +grep -q '^HandlePowerKeyLongPress=ignore$' "$power" \ + || fail "the long press stays the PMIC reset" +grep -q '^PACKAGE=omamobile-device-dipper$' "$tmp/root/usr/share/omamobile/device.conf" \ + || fail "the installed descriptor is dipper" +for absent in usr/bin/omamobile-boot-success usr/bin/omamobile-bootctl \ + usr/lib/systemd/system/omamobile-boot-success.service \ + usr/bin/omamobile-wifi-start usr/bin/omamobile-charge-guard \ + usr/bin/omamobile-camera-start; do + [[ ! -e $tmp/root/$absent ]] || fail "install includes $absent" +done +pass "install stages the udev rule, the USB link, and the mirrorlist, and nothing that marks a slot or starts hardware" +[[ ! -e $tmp/root/usr/lib/systemd/logind.conf.d/10-omamobile-lid.conf ]] \ + || fail "dipper has no lid: no lid drop-in" +pass "no lid drop-in" diff --git a/packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf b/packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf new file mode 100644 index 000000000..252de6e15 --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile: the USB gadget link to the host (usb0) is configured by +# systemd-networkd; NetworkManager manages everything else (Wi-Fi later). +[keyfile] +unmanaged-devices=interface-name:usb0 diff --git a/packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf b/packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf new file mode 100644 index 000000000..a1e2cb0eb --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile: a short press of the power button opens Omarchy's system menu +# (bound in Hyprland by omamobile-setup-user), as Super + Escape does, instead +# of powering off. A long press still forces a reset in the PMIC hardware. +[Login] +HandlePowerKey=ignore +HandlePowerKeyLongPress=ignore diff --git a/packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network b/packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network new file mode 100644 index 000000000..fe5ce66e9 --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile: USB networking to the host. The initramfs sets up the USB +# gadget (CDC NCM) before handing over to Arch; this gives it an address. +# The host shares its internet over this link (NetworkManager "shared" +# mode on 172.16.42.2), so it is also the gateway. DNS goes to public resolvers. +[Match] +Name=usb0 + +[Network] +Address=172.16.42.1/24 +DNS=1.1.1.1 +DNS=9.9.9.9 +ConfigureWithoutCarrier=yes + +# Default route via the host, but a high metric so Wi-Fi/ethernet (metric ~600) +# win when present; USB stays the fallback internet path. +[Route] +Gateway=172.16.42.2 +Metric=1000 diff --git a/packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf b/packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf new file mode 100644 index 000000000..7c01e4d1b --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile, Xiaomi Mi 8: unlike the Pixels, SDM845 leaves its cluster +# watchdogs *running*, and the initramfs claims /dev/watchdog0 and pets it +# (`watchdog -t 5 -T 30`). That daemon dies with everything else just before +# switch_root, so unless systemd picks the watchdog up, nothing holds it and the +# hardware resets the phone about 30 s into the boot. Measured: an otherwise +# healthy first boot reached "Started Journal Service" and then died at +# `watchdog0: pretimeout event`, 34 s in. +# +# RuntimeWatchdogSec programs the *hardware* timeout and systemd pings at half +# of it, so it must leave room for the longest stretch systemd spends not +# servicing its main loop. 10 s was not enough: on a first boot systemd spends +# about 8 s in "Applying preset policy" (preset-all, because /etc/machine-id is +# still `uninitialized`) and the pretimeout fired at 17 s, mid-boot. 30 s is +# what the initramfs daemon already proved this watchdog accepts. +# RebootWatchdogSec is the Pixel rationale: if shutdown hangs, let the watchdog +# reset the phone after a minute rather than leaving it on the splash. +[Manager] +RuntimeWatchdogSec=30s +RebootWatchdogSec=1min diff --git a/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service b/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service new file mode 100644 index 000000000..d307135b9 --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service @@ -0,0 +1,15 @@ +[Unit] +Description=Apply the Mi 8's own WLAN and Bluetooth addresses from persist +# persist is read-only to us; the storage guard keeps it that way. +ConditionPathExists=/dev/disk/by-partlabel/persist +Before=NetworkManager.service bluetooth.service +Wants=local-fs.target +After=local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/bin/omamobile-dipper-identity + +[Install] +WantedBy=multi-user.target diff --git a/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service b/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service new file mode 100644 index 000000000..c725ba9e0 --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service @@ -0,0 +1,17 @@ +[Unit] +Description=Join the tailnet once from a pre-seeded auth key +# NetworkManager-wait-online is masked by omamobile-firstboot, so don't wait on it: +# tailscaled retries by itself until Wi-Fi or usb0 is up. +Wants=tailscaled.service +After=tailscaled.service +ConditionPathExists=/etc/omamobile/tailscale.authkey + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/usr/local/bin/omamobile-tailscale-join +# A single-use key is a credential: don't let a failure loop retry it forever. +Restart=no + +[Install] +WantedBy=multi-user.target diff --git a/packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules b/packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules new file mode 100644 index 000000000..b0d6ed47e --- /dev/null +++ b/packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile storage guard, continued in Arch. The initramfs marks every UFS +# partition read-only except userdata (dipper is not A/B: there is one `boot`, +# one `system` and one `userdata`, so nothing else is ever written). udev would +# recreate the whole-disk nodes, so make them inaccessible and keep desktop +# tools away from every Android partition. +# +# dipper spreads its partitions over six LUNs, sda to sdf, with userdata on sda. +SUBSYSTEM=="block", KERNEL=="sd[a-f]", MODE="0000", ENV{UDISKS_IGNORE}="1" +SUBSYSTEM=="block", KERNEL=="sd[a-f][0-9]*", ENV{ID_PART_ENTRY_NAME}!="userdata", ENV{UDISKS_IGNORE}="1" diff --git a/packages/omamobile-device-dipper/version b/packages/omamobile-device-dipper/version new file mode 100644 index 000000000..6e8bf73aa --- /dev/null +++ b/packages/omamobile-device-dipper/version @@ -0,0 +1 @@ +0.1.0 diff --git a/packages/pd-mapper/PKGBUILD b/packages/pd-mapper/PKGBUILD new file mode 100644 index 000000000..be579edc3 --- /dev/null +++ b/packages/pd-mapper/PKGBUILD @@ -0,0 +1,31 @@ +# Maintainer: Super Tecno Gym + +pkgname="pd-mapper" +pkgdesc="Qualcomm IPC Router protocol" +pkgver=1.1 +pkgrel=1 +arch=(aarch64 x86_64) +url="https://github.com/linux-msm/pd-mapper" +license=("BSD-3-Clause") +conflicts=("${pkgname%-git}") +depends=(qrtr) +groups=(qcom-icnss-wlan) +makedepends=(qrtr) +_srcname="${pkgname}-${pkgver}" +source=( + "${_srcname}.tar.gz::https://github.com/linux-msm/pd-mapper/archive/refs/tags/v${pkgver}.tar.gz" +) +sha256sums=('7654a7fb8b70b0c7670f98ad9313649abc48eabcef84dad086ed01408fd538a2') + +build() { + cd "$_srcname" + + make prefix=/usr +} + +package() { + cd "$_srcname" + + make prefix=/usr DESTDIR="$pkgdir/" install + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING +} diff --git a/packages/qrtr/PKGBUILD b/packages/qrtr/PKGBUILD new file mode 100644 index 000000000..725b2aa7f --- /dev/null +++ b/packages/qrtr/PKGBUILD @@ -0,0 +1,31 @@ +# Maintainer: Super Tecno Gym +# Contributor: Sam Day + +pkgname="qrtr" +pkgdesc="Userspace reference for net/qrtr in the Linux kernel" +pkgver=1.2 +pkgrel=1 +arch=(aarch64 x86_64) +url="https://github.com/linux-msm/qrtr" +license=("BSD-3-Clause") +conflicts=("${pkgname%-git}") +groups=(qcom-icnss-wlan) +_srcname="${pkgname}-${pkgver}" +source=("${_srcname}.tar.gz::https://github.com/linux-msm/qrtr/archive/refs/tags/v${pkgver}.tar.gz") +sha256sums=('7a82bf80246fe71287b13c66c0466208822e8337fcd4aaf302eee6c5fcb48a52') +makedepends=(meson) + +build() { + cd "$_srcname" + + mkdir -p build + meson setup build --prefix=/usr + meson compile -C build +} + +package() { + cd "$_srcname" + + meson install -C build --destdir "$pkgdir" + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING +} diff --git a/packages/rmtfs/PKGBUILD b/packages/rmtfs/PKGBUILD new file mode 100644 index 000000000..401c92de0 --- /dev/null +++ b/packages/rmtfs/PKGBUILD @@ -0,0 +1,38 @@ +# Maintainer: Super Tecno Gym +# Contributor: Sam Day + +pkgname="rmtfs" +pkgdesc="Qualcomm Remote Filesystem Service Implementation" +pkgver=1.2 +pkgrel=1 +arch=(aarch64 x86_64) +url="https://github.com/linux-msm/rmtfs" +license=("BSD-3-Clause") +depends=(qrtr libudev.so) +conflicts=("${pkgname%-git}") +groups=(qcom-icnss-wlan) +makedepends=() +_srcname="${pkgname}-${pkgver}" +source=( + "${_srcname}.tar.gz::https://github.com/linux-msm/rmtfs/archive/refs/tags/v${pkgver}.tar.gz" + "udev.rules" + ) + +sha256sums=( + '5be459af54b5ff0f1447fc265246e526d27e8250212f5f380458f9ee551bd3a3' + '0c2f26d40d9d18e3089c6d836b64231c4f7e0c1ca41686fe7c9d1eb495dc6bbe' +) + +build() { + cd "$_srcname" + + make prefix=/usr +} + +package() { + cd "$_srcname" + + make prefix=/usr DESTDIR="$pkgdir/" install + install -Dm644 "$srcdir"/udev.rules "$pkgdir/usr/lib/udev/rules.d/65-$pkgname.rules" + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING +} diff --git a/packages/rmtfs/udev.rules b/packages/rmtfs/udev.rules new file mode 100644 index 000000000..72886cb57 --- /dev/null +++ b/packages/rmtfs/udev.rules @@ -0,0 +1 @@ +SUBSYSTEM=="uio", ATTR{name}=="rmtfs", SYMLINK+="qcom_rmtfs_uio1" diff --git a/packages/tqftpserv/PKGBUILD b/packages/tqftpserv/PKGBUILD new file mode 100644 index 000000000..3c764cba5 --- /dev/null +++ b/packages/tqftpserv/PKGBUILD @@ -0,0 +1,33 @@ +# Maintainer: Super Tecno Gym + +pkgname="tqftpserv" +pkgdesc="Trivial File Transfer Protocol server over AF_QIPCRTR" +pkgver=1.2 +pkgrel=1 +arch=(aarch64 x86_64) +url="https://github.com/linux-msm/tqftpserv" +license=("BSD-3-Clause") +conflicts=("${pkgname%-git}") +depends=(qrtr) +groups=(qcom-icnss-wlan) +makedepends=(qrtr) +_srcname="${pkgname}-${pkgver}" +source=("${_srcname}.tar.gz::https://github.com/linux-msm/tqftpserv/archive/refs/tags/v${pkgver}.tar.gz") +sha256sums=('a3850c34e48f23b7bc360d70f1e91700de2f8c60af003eda93e14182f8cf6af1') +makedepends=(meson) + +build() { + cd "$_srcname" + + mkdir -p build + meson setup build --prefix=/usr + meson compile -C build + +} + +package() { + cd "$_srcname" + + meson install -C build --destdir "$pkgdir" + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING +} diff --git a/rootfs/build-inside b/rootfs/build-inside index 14ba41b88..7ce78abcc 100755 --- a/rootfs/build-inside +++ b/rootfs/build-inside @@ -7,7 +7,8 @@ # /modules the kernel modules tarball (read-only) # /target an empty volume: the root file system is assembled here # /out where the raw image and the MANIFEST go -# Environment: VERSION, DEVICE, DEVICE_PACKAGE, ROOTFS_PACKAGES and +# Environment: VERSION, DEVICE, DEVICE_PACKAGE, ROOTFS_PACKAGES, +# ROOTFS_DIST_PACKAGES and # ALLOW_MISSING (both space-separated), KERNEL_RELEASE, MODULES_SHA256, # GIT_COMMIT, ALARM_SHA256, OMARCHY_CHANNEL, CHANNEL ([omamobile]: stable, # development or local). @@ -29,12 +30,13 @@ pacman -Sy >/dev/null available() { pacman -Sp --print-format %n "$1" >/dev/null 2>&1; } mapfile -t base < <(list /src/rootfs/packages.base) +read -ra distro <<<"${ROOTFS_DIST_PACKAGES:-}" mapfile -t ours < <(list /src/rootfs/packages.omamobile) ours+=("$DEVICE_PACKAGE") read -ra board <<<"${ROOTFS_PACKAGES:-}" ours+=("${board[@]}") missing=() skipped_ours=() -for p in "${base[@]}"; do available "$p" || missing+=("$p"); done +for p in "${base[@]}" "${distro[@]}"; do available "$p" || missing+=("$p"); done ((${#missing[@]} == 0)) || die "not in any repository: ${missing[*]}" # Every package of ours must come from [omamobile], not a same-named one # elsewhere (Mesa, Hyprland, libcamera are in Arch Linux ARM and [omarchy] @@ -53,7 +55,7 @@ done ((${#missing[@]} == 0)) || die "not in out/repo: ${missing[*]} (build them: tools/build-packages; or allow: --allow-missing)" say "Base system and Omarchy (${#base[@]} packages)" -pacstrap -C /etc/pacman.conf -c -M "$T" "${base[@]}" >/var/log/pacstrap-base.log 2>&1 || { tail -40 /var/log/pacstrap-base.log; die "pacstrap failed"; } +pacstrap -C /etc/pacman.conf -c -M "$T" "${base[@]}" "${distro[@]}" >/var/log/pacstrap-base.log 2>&1 || { tail -40 /var/log/pacstrap-base.log; die "pacstrap failed"; } omarchy_list=$T/usr/share/omarchy/install/omarchy-base.packages [[ -f $omarchy_list ]] || die "no $omarchy_list in the omarchy package" @@ -114,6 +116,19 @@ depmod -b "$T" -a "$KERNEL_RELEASE" # bin/omamobile push compares this with its tarball, so it won't push them again echo "$MODULES_SHA256" > "$T/usr/lib/modules/$KERNEL_RELEASE/.omamobile-tarball" +if [[ -d /device-firmware ]]; then + say "Device firmware" + for d in qcom ath10k; do + if [[ -d /device-firmware/$d ]]; then + cp -a "/device-firmware/$d" "$T/usr/lib/firmware/" + elif [[ $DEVICE == dipper ]]; then + die "missing dipper firmware /device-firmware/$d (run tools/dipper/extract-firmware)" + fi + done +elif [[ $DEVICE == dipper ]]; then + die "missing dipper firmware staging directory (run tools/dipper/build)" +fi + say "Omarchy patches (omamobile-omarchy)" # The same code path as every Omarchy upgrade on a phone: the package's pacman # hook already applied the series when pacstrap installed it; this runs it @@ -175,6 +190,7 @@ say "MANIFEST" echo "# Omarchy Mobile root image" echo "version: $VERSION" echo "device: $DEVICE ($DEVICE_PACKAGE${ROOTFS_PACKAGES:+ $ROOTFS_PACKAGES})" + echo "distribution packages: ${ROOTFS_DIST_PACKAGES:-none}" echo "built: $(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "repository commit: $GIT_COMMIT" echo "arch linux arm tarball sha256: $ALARM_SHA256" diff --git a/tools/build-packages b/tools/build-packages index f8af48c8e..a75d810ec 100755 --- a/tools/build-packages +++ b/tools/build-packages @@ -62,7 +62,7 @@ done # Default order: dependencies of our own packages first (check() of a later # package can then install an earlier one from the repository being built). -ORDER=(omamobile-keyring libfprint neard omacam omamobile-apps omamobile-device-cheetah omamobile-device-felix omamobile-device-lynx omamobile-device-raven omamobile-device-panther omamobile-audio +ORDER=(qrtr pd-mapper tqftpserv rmtfs omamobile-keyring libfprint neard omacam omamobile-apps omamobile-device-cheetah omamobile-device-felix omamobile-device-lynx omamobile-device-raven omamobile-device-panther omamobile-device-dipper omamobile-audio omamobile-sensors omamobile-gnss omamobile-fingerprint omamobile-mirror omamobile-omarchy omamobile-owl-widgets omamobile-shell omamobile-modem omamobile-modem-sit omamobile-mmd omamobile-speaker-tuning omamobile-waydroid omamobile-firstboot mesa hyprland libcamera) diff --git a/tools/build-rootfs b/tools/build-rootfs index 4499d538b..3d68572f6 100755 --- a/tools/build-rootfs +++ b/tools/build-rootfs @@ -103,6 +103,8 @@ DEVICE_PACKAGE=$(sed -n 's/^PACKAGE=\([a-z0-9-]*\)$/\1/p' "$conf") [[ -n $DEVICE_PACKAGE ]] || alarm_die "$conf has no PACKAGE" ROOTFS_PACKAGES=$(sed -n 's/^ROOTFS_PACKAGES="\(.*\)"$/\1/p' "$conf") [[ $ROOTFS_PACKAGES =~ ^[a-z0-9\ -]*$ ]] || alarm_die "$conf: ROOTFS_PACKAGES may hold only package names" +ROOTFS_DIST_PACKAGES=$(sed -n 's/^ROOTFS_DIST_PACKAGES="\(.*\)"$/\1/p' "$conf") +[[ $ROOTFS_DIST_PACKAGES =~ ^[a-z0-9\ -]*$ ]] || alarm_die "$conf: ROOTFS_DIST_PACKAGES may hold only package names" repo=$outrel/repo/aarch64 [[ -f $repo/omamobile.db ]] || @@ -112,6 +114,10 @@ release=$(cat "$KERNEL_OUT/include/config/kernel.release") modules=$KERNEL_OUT/modules-$release.tar.zst [[ -f $modules ]] || alarm_die "no $modules: run KERNEL_OUT=$KERNEL_OUT bin/omamobile modules" +device_firmware=$ROOT/../out/$DEVICE/firmware +docker_args=(-v "$ROOT:/src:ro" -v "$ROOT/$outrel/repo:/repo:ro" -v "$modules:/modules:ro") +[[ ! -d $device_firmware ]] || docker_args+=(-v "$device_firmware:/device-firmware:ro") + name=omamobile-rootfs-$DEVICE-$VERSION-aarch64 out=$ROOT/$outrel mkdir -p "$out" @@ -136,10 +142,11 @@ start=$(date +%s) alarm_say "Building $name for $DEVICE (kernel $release, [omamobile] channel $CHANNEL)" commit=$(git rev-parse --short=12 HEAD)$(git diff --quiet HEAD -- rootfs packages tools device 2>/dev/null || echo "-dirty") docker run --rm --privileged --platform linux/arm64 \ - -v "$ROOT:/src:ro" -v "$ROOT/$outrel/repo:/repo:ro" -v "$modules:/modules:ro" \ + "${docker_args[@]}" \ -v "$volume:/target" -v "$work:/out" -v "$ALARM_CACHE/pkg:/var/cache/pacman/pkg" \ -e VERSION="$VERSION" -e DEVICE="$DEVICE" -e DEVICE_PACKAGE="$DEVICE_PACKAGE" \ -e ROOTFS_PACKAGES="$ROOTFS_PACKAGES" \ + -e ROOTFS_DIST_PACKAGES="$ROOTFS_DIST_PACKAGES" \ -e KERNEL_RELEASE="$release" -e MODULES_SHA256="$(sha256sum < "$modules" | cut -d' ' -f1)" \ -e GIT_COMMIT="$commit" -e ALARM_SHA256="$(sha256sum < "$ALARM_TARBALL" | cut -d' ' -f1)" \ -e OMARCHY_CHANNEL="$OMARCHY_CHANNEL" -e CHANNEL="$CHANNEL" -e ALLOW_MISSING="$ALLOW_MISSING" \ diff --git a/tools/dipper/apply-identity b/tools/dipper/apply-identity new file mode 100755 index 000000000..6186a13a9 --- /dev/null +++ b/tools/dipper/apply-identity @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Write this phone's Bluetooth address into a built DTB, so the identifier lives +# in the flashed image and never in the repository. +# +# apply-identity (edits the file in place) +# +# Without an identity file it leaves the placeholder alone and says so: the DTB +# stays valid, Bluetooth just keeps the firmware's shared default address. +set -euo pipefail + +dtb=${1:?usage: apply-identity } +ID=${ID:-$HOME/android/reference/dipper-stock/identity.env} +NODE=${NODE:-} + +[[ -f $dtb ]] || { echo "no such DTB: $dtb" >&2; exit 1; } +command -v fdtput >/dev/null || { echo "need fdtput (device-tree-compiler)" >&2; exit 1; } + +if [[ ! -r $ID ]]; then + echo "no identity file at $ID: leaving local-bd-address at the placeholder" + echo "(run tools/dipper/extract-identity after tools/dipper/backup-stock)" + exit 0 +fi +# shellcheck disable=SC1090 +. "$ID" +[[ -n ${DIPPER_BT_BD_LE:-} ]] || { echo "$ID has no DIPPER_BT_BD_LE" >&2; exit 1; } + +# Find the bluetooth node rather than hardcoding a path, so a DTS reshuffle +# cannot silently write the address nowhere. +if [[ -z $NODE ]]; then + NODE=$(fdtget -l / "$dtb" >/dev/null 2>&1 && true; python3 - "$dtb" <<'PY' +import subprocess, sys +dtb = sys.argv[1] +dts = subprocess.check_output(["dtc", "-I", "dtb", "-O", "dts", dtb], + stderr=subprocess.DEVNULL).decode() +path, found = [], [] +for line in dts.splitlines(): + t = line.strip() + if t.endswith("{"): + path.append(t[:-1].strip().split(":")[-1].strip()) + elif t.startswith("}"): + if path: path.pop() + elif t.startswith('compatible = "qcom,wcn3990-bt"'): + found.append("/" + "/".join(p for p in path[1:] if p)) +if len(found) != 1: + print("", end=""); sys.exit(1) +print(found[0], end="") +PY +) +fi +[[ -n $NODE ]] || { echo "could not find exactly one qcom,wcn3990-bt node in $dtb" >&2; exit 1; } + +# shellcheck disable=SC2086 +fdtput -t bx "$dtb" "$NODE" local-bd-address $DIPPER_BT_BD_LE + +got=$(fdtget -t bx "$dtb" "$NODE" local-bd-address | tr -s ' ') +want=$(printf '%s' "$DIPPER_BT_BD_LE" | tr -s ' ') +# fdtget prints 0x-prefixed bytes; normalise both sides before comparing. +norm() { python3 -c " +import sys +print(' '.join(f'{int(x,16):02x}' for x in sys.stdin.read().split()))"; } +[[ $(norm <<<"$got") == $(norm <<<"$want") ]] || { + echo "the address did not take: wrote '$want', read back '$got'" >&2; exit 1; } + +echo "local-bd-address written into $NODE and verified" diff --git a/tools/dipper/backup-stock b/tools/dipper/backup-stock new file mode 100755 index 000000000..3e58bd092 --- /dev/null +++ b/tools/dipper/backup-stock @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Read-only backup of dipper's stock partitions, with checksums verified on both +# ends. Nothing is written to the phone. +# +# This is not optional on dipper: the OS partitions are single-copy (one `boot`, +# no slot B), so a bad image has no known-good slot to fall back to. The only +# way back is fastboot over USB with these files. +# +# Needs: SSH to the phone with root available (SimpleSSHD + Magisk, or adb). +set -euo pipefail + +HOST=${HOST:-mi8} +SU=${SU:-/debug_ramdisk/su} +OUT=${OUT:-$HOME/android/reference/dipper-stock/backup} + +# Everything we could overwrite, plus the per-device data that cannot be +# regenerated from any download. `modem` and `dsp` are firmware and the largest +# items; pass --with-firmware to include them. +PARTS=(boot recovery dtbo vbmeta persist persistbak modemst1 modemst2 fsg fsc devinfo misc frp logo splash) +FIRMWARE=(modem dsp) + +[[ ${1:-} == --with-firmware ]] && PARTS+=("${FIRMWARE[@]}") + +umask 077 +mkdir -p "$OUT"; chmod 700 "$OUT" +sums=$OUT/sha256sums.txt +: > "$sums" + +# adb needs no SimpleSSHD or Tailscale and `adb root` already gives uid=0, so it +# is the default when a device is attached. exec-out keeps the dd pipe binary. +if [[ ${TRANSPORT:-auto} == adb ]] || { [[ ${TRANSPORT:-auto} == auto ]] && adb get-state &>/dev/null; }; then + remote() { adb exec-out "$1"; } + via="adb" +else + remote() { ssh "$HOST" "$SU -c '$1'"; } + via="ssh $HOST" +fi + +[[ $(remote 'id -u' | tr -d '\r\n') == 0 ]] || { echo "no root over $via" >&2; exit 1; } + +total=0 failed=0 +for p in "${PARTS[@]}"; do + dev=$(remote "readlink -f /dev/block/by-name/$p" | tr -d '\r\n') + [[ -n $dev ]] || { echo "SKIP $p (no such partition)"; continue; } + size=$(remote "blockdev --getsize64 $dev" | tr -d '\r\n') + want=$(remote "sha256sum $dev" | awk '{print $1}') + printf '%-12s %10s bytes ... ' "$p" "$size" + # dd straight down the ssh pipe: no temp file on the phone, nothing written. + remote "dd if=$dev bs=1M 2>/dev/null" > "$OUT/$p.img" + got=$(sha256sum "$OUT/$p.img" | awk '{print $1}') + local_size=$(stat -c%s "$OUT/$p.img") + if [[ $got == "$want" && $local_size == "$size" ]]; then + echo "ok" + printf '%s %s.img\n' "$got" "$p" >> "$sums" + total=$((total + local_size)) + else + echo "MISMATCH (phone $want/$size, here $got/$local_size)" + rm -f "$OUT/$p.img" + failed=$((failed + 1)) + fi +done + +printf '\n%s bytes backed up into %s\n' "$total" "$OUT" +if (( failed )); then + echo "$failed partition(s) FAILED to verify -- do not treat this backup as usable" >&2 + exit 1 +fi +echo "every partition verified by sha256 on the phone and here." +echo "Restore (phone in fastboot, USB): fastboot flash .img" diff --git a/tools/dipper/bringup-patch-init.py b/tools/dipper/bringup-patch-init.py new file mode 100755 index 000000000..1ae1301ea --- /dev/null +++ b/tools/dipper/bringup-patch-init.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Patch the shared initramfs init for a bring-up image. + +dipper has no serial header, and ABL leaves no framebuffer that mainline can +claim, so a boot with no cable attached is completely blind. This makes the +image mirror the kernel log into the `logdump` partition (33 MiB, all zero on +this phone, used by nothing), which Android can read back afterwards with root. + +That needs logdump writable, so the storage guard's allowlist is widened -- for +this image only. It deliberately weakens a safety property: the result is a +diagnostic image, never an install image, and must not be written to `boot`. +""" +import sys +from pathlib import Path + +MIRROR = r'''# BRING-UP: mirror the kernel log to the logdump partition every 2 s, so a +# cable-free boot can still be read back from Android afterwards. +omamobile_logdump_dev() { + for u in /sys/block/sd*/sd*/uevent; do + [ -r "$u" ] || continue + if [ "$(sed -n 's/^PARTNAME=//p' "$u")" = logdump ]; then + echo "/dev/$(sed -n 's/^DEVNAME=//p' "$u")" + return 0 + fi + done + return 1 +} +omamobile_logdump_loop() { + dev=$(omamobile_logdump_dev) || { echo "omamobile: no logdump partition" >/dev/kmsg; return; } + [ -w "$dev" ] || { echo "omamobile: $dev is read-only; the guard kept it closed" >/dev/kmsg; return; } + n=0 + while :; do + n=$((n + 1)) + { echo "=== omamobile bring-up log, pass $n, uptime $(cut -d" " -f1 /proc/uptime) ===" + dmesg + echo "=== probe results, pass $n ===" + # One blind boot has to answer everything worth knowing, because there is + # no shell without a cable. Keep this read-only and cheap. + echo "-- loaded modules --"; cat /proc/modules 2>/dev/null + echo "-- input devices --"; cat /proc/bus/input/devices 2>/dev/null + echo "-- drm cards --"; ls -l /sys/class/drm 2>/dev/null + echo "-- framebuffers --"; ls -l /sys/class/graphics 2>/dev/null + echo "-- block devices --"; ls -l /sys/block 2>/dev/null + echo "-- net interfaces --"; ls -l /sys/class/net 2>/dev/null + echo "-- i2c buses --"; ls -l /sys/bus/i2c/devices 2>/dev/null + echo "-- spmi / platform probe failures --" + for d in /sys/bus/platform/devices/*/driver; do :; done + ls -l /sys/bus/platform/devices 2>/dev/null | head -80 + echo "-- regulators --"; ls /sys/class/regulator 2>/dev/null | head -40 + echo "-- thermal --"; ls /sys/class/thermal 2>/dev/null + echo "-- remoteproc --"; for r in /sys/class/remoteproc/*; do [ -e "$r/state" ] && echo "$r: $(cat "$r/state")"; done + echo "-- cmdline --"; cat /proc/cmdline 2>/dev/null + echo "-- device tree model --"; cat /proc/device-tree/model 2>/dev/null; echo + echo "-- uptime / mem --"; cat /proc/uptime /proc/meminfo 2>/dev/null | head -5 + echo "=== end of pass $n ===" + } | dd of="$dev" bs=4096 conv=notrunc 2>/dev/null + sleep 2 + done +} +omamobile_logdump_loop & +echo "omamobile: bring-up log mirror started" >/dev/kmsg +''' + +ALLOW = " boot_b|init_boot_b|vendor_boot_b|vendor_kernel_boot_b|dtbo_b|userdata) ;;" +ANCHOR = "hostname omamobile\n" + + +def main() -> int: + p = Path(sys.argv[1]) + s = p.read_text() + if s.count(ALLOW) != 1: + raise SystemExit("shared init changed: storage-guard allowlist not found") + if s.count(ANCHOR) != 1: + raise SystemExit("shared init changed: hostname anchor not found") + if "omamobile_logdump_loop" in s: + print("already patched for bring-up") + return 0 + s = s.replace(ALLOW, ALLOW.replace("|userdata)", "|userdata|logdump)"), 1) + s = s.replace(ANCHOR, MIRROR + ANCHOR, 1) + p.write_text(s) + print("init patched: logdump allowed, log mirror started before handover") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/dipper/build b/tools/dipper/build new file mode 100755 index 000000000..309e9290b --- /dev/null +++ b/tools/dipper/build @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Build dipper's deployable artefacts: initramfs (in an aarch64 container), +# then the Android v1 boot image with the DTB appended to the kernel. +# +# Needs: the kernel already built in $KERNEL_SRC (Image.gz, the dipper DTB and +# modules), docker with arm64 emulation registered, zopfli, and SSH_PUBKEY. +set -euo pipefail + +here=$(cd "$(dirname "$0")" && pwd) +repo=$(cd "$here/../.." && pwd) + +KERNEL_SRC=${KERNEL_SRC:-$repo/../linux} +# BRINGUP=1 builds the diagnostic image instead: it mirrors the kernel log into +# the unused `logdump` partition, so a first boot with no cable attached can be +# read back from Android. It goes into its own output directory so the two can +# never be confused, and it must never be written to `boot`. +if [[ ${BRINGUP:-0} == 1 ]]; then + OUT=${OUT:-$repo/../out/dipper-bringup} + export DIPPER_BRINGUP=1 +else + OUT=${OUT:-$repo/../out/dipper} +fi +: "${SSH_PUBKEY:?set SSH_PUBKEY to your authorized public key}" +ALPINE=${ALPINE:-alpine:3.22} + +die() { echo "error: $*" >&2; exit 1; } + +[[ -d $KERNEL_SRC ]] || die "no kernel tree at $KERNEL_SRC (set KERNEL_SRC)" +image=$KERNEL_SRC/arch/arm64/boot/Image.gz +dtb=$KERNEL_SRC/arch/arm64/boot/dts/qcom/sdm845-xiaomi-dipper.dtb +[[ -f $image ]] || die "no $image -- build the kernel first" +[[ -f $dtb ]] || die "no $dtb -- build qcom/sdm845-xiaomi-dipper.dtb first" +[[ -r $SSH_PUBKEY ]] || die "no SSH public key at $SSH_PUBKEY (set SSH_PUBKEY)" +grep -q '^ssh-' "$SSH_PUBKEY" || die "$SSH_PUBKEY is not an OpenSSH public key" +command -v docker >/dev/null || die "docker is needed for the aarch64 initramfs" + +release=$(cat "$KERNEL_SRC/include/config/kernel.release") +echo "kernel release: $release" + +umask 077 +mkdir -p "$OUT"; chmod 700 "$OUT" +mods=$OUT/modules +echo "installing modules into $mods" +rm -rf "$mods/lib/modules/$release" +make -C "$KERNEL_SRC" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \ + INSTALL_MOD_PATH="$mods" INSTALL_MOD_STRIP=1 modules_install >/dev/null +mkdir -p "$OUT/include/config" +cp "$KERNEL_SRC/include/config/kernel.release" "$OUT/include/config/kernel.release" +tar -C "$mods/lib/modules" --owner=0 --group=0 --numeric-owner -cf - "$release" \ + | zstd -q -19 -T0 -f -o "$OUT/modules-$release.tar.zst" + +echo "building the initramfs in $ALPINE (linux/arm64)" +docker run --rm --platform linux/arm64 \ + -v "$repo:/src:ro" -v "$mods:/modules:ro" -v "$SSH_PUBKEY:/input/key.pub:ro" \ + -v "$OUT:/out" \ + -e "KERNEL_RELEASE=$release" -e "OUT_UID=$(id -u)" -e "OUT_GID=$(id -g)" \ + -e "DIPPER_BRINGUP=${DIPPER_BRINGUP:-0}" \ + -e "DIPPER_NFSROOT=${DIPPER_NFSROOT:-}" \ + "$ALPINE" sh /src/tools/dipper/initramfs-inside.sh + +# Pack a copy of the DTB so nothing we do can dirty the kernel tree. +packdtb=$OUT/sdm845-xiaomi-dipper.dtb +cp "$dtb" "$packdtb" +# By default the image stays generic: it carries no device identifier and works +# on any Mi 8, because omamobile-dipper-identity reads this phone's own WLAN and +# Bluetooth addresses out of `persist` at boot. Baking the Bluetooth address into +# the DTB is opt-in, for someone who wants a single-device image and a BD address +# set before userspace runs. +if [[ ${DIPPER_BAKE_IDENTITY:-0} == 1 ]]; then + "$here/apply-identity" "$packdtb" +else + echo "generic image: Bluetooth address left at the placeholder, applied at boot from persist" +fi + +kernel_image=$image +if command -v zopfli >/dev/null; then + echo "compressing the kernel with zopfli for dipper's ABL size limit" + zopfli -c --i1 "$KERNEL_SRC/arch/arm64/boot/Image" > "$OUT/Image.gz" + kernel_image=$OUT/Image.gz +fi +# A failed size check must not leave an older boot.img under the current name. +rm -f "$OUT/images/boot.img" "$OUT/images/BOOT-MANIFEST.json" +"$here/build-boot.py" --kernel "$kernel_image" --dtb "$packdtb" \ + --ramdisk "$OUT/initramfs.cpio.gz" --out "$OUT/images" + +# Firmware and the Wi-Fi fix-ups are not part of the boot image; they go into the +# root filesystem. Collect them beside it so one directory holds everything. +fw=${FIRMWARE_DIR:-$HOME/android/reference/dipper-stock/firmware} +if [[ -d $fw ]]; then + mkdir -p "$OUT/firmware" + # The blobs come off the phone mode 400, so a plain cp cannot overwrite them + # on a rebuild. Copy without preserving the mode and make them readable. + for d in qcom ath10k; do + [[ -d $fw/$d ]] || continue + rm -rf "$OUT/firmware/$d" + cp -r --no-preserve=mode "$fw/$d" "$OUT/firmware/" + done + chmod -R u+rwX "$OUT/firmware" + # The boot-time identity service, which makes the image device-agnostic. + mkdir -p "$OUT/identity" + cp "$here/identity/omamobile-dipper-identity" "$here/identity/omamobile-dipper-identity.service" \ + "$OUT/identity/" + echo "firmware and Wi-Fi files staged in $OUT/firmware" +else + echo "note: no firmware at $fw (run tools/dipper/extract-firmware); GPU and Wi-Fi will not come up" +fi + +echo +echo "artefacts in $OUT/images:" +ls -l "$OUT/images" +cat <<'NOTE' + +To try it WITHOUT writing anything to the phone (nothing persists, a reboot +returns to stock): + + fastboot boot boot.img + +Only flash it once that has booted, and only with a verified stock backup in +hand: dipper has no second slot to fall back to. +NOTE +if [[ ${DIPPER_BRINGUP:-0} == 1 ]]; then + cat <<'NOTE2' +THIS IS THE DIAGNOSTIC IMAGE. It mirrors the kernel log into `logdump` and runs +with a widened storage guard. Write it to `recovery` only -- never to `boot` -- +so stock Android stays bootable, and enter it with Volume Up + Power. +NOTE2 +fi diff --git a/tools/dipper/build-board-2.py b/tools/dipper/build-board-2.py new file mode 100755 index 000000000..612831157 --- /dev/null +++ b/tools/dipper/build-board-2.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Build an ath10k board-2.bin for dipper from the phone's own board data. + +Why this exists: upstream linux-firmware's WCN3990 board-2.bin has entries only +for qmi-board-id=ff, and this phone's WLAN firmware reports board id 0 (the +stock kernel logs "wma_rx_service_ready_event: Board id: 0"). If ath10k finds no +matching entry it does not load board data at all and Wi-Fi stays down. So we +build a file keyed by the ids this phone can actually report, carrying its own +factory calibration instead of generic data. + +Name format comes from ath10k_core_create_board_name(): + bus=snoc,qmi-board-id=%x,qmi-chip-id=%x[,variant=%s] +Both ids are hex. WCN3990 on SDM845 reports chip id 0x30214. + +File format: the 16-byte magic, then length-prefixed IEs. Each ATH10K_BD_IE_BOARD +holds a NAME sub-IE and a DATA sub-IE. +""" +import argparse, re, struct, sys +from pathlib import Path + +MAGIC = b"QCA-ATH10K-BOARD" +BD_IE_BOARD = 0 +BD_IE_BOARD_NAME = 0 +BD_IE_BOARD_DATA = 1 +CHIP_ID = 0x30214 # WCN3990 as it appears in upstream's own names + + +def ie(id_: int, payload: bytes) -> bytes: + """One IE: id, length, payload padded to a 4-byte boundary.""" + pad = (-len(payload)) % 4 + return struct.pack(" 0xNN. bdwlan.bin is the default used when no id matches.""" + m = re.fullmatch(r"bdwlan\.b([0-9a-fA-F]{1,4})", path.name) + return int(m.group(1), 16) if m else None + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--src", type=Path, required=True, help="directory of bdwlan.* files") + ap.add_argument("--out", type=Path, required=True, help="board-2.bin to write") + ap.add_argument("--verify", type=Path, help="also parse this reference file first") + a = ap.parse_args() + + if a.verify: + ref = parse(a.verify.read_bytes()) + snoc = [n for n, _ in ref if n and n.startswith("bus=snoc")] + if not snoc: + raise SystemExit(f"{a.verify}: parsed {len(ref)} entries but none look like snoc " + "boards -- the parser is wrong, refusing to build") + print(f"parser check: read {len(ref)} entries from {a.verify.name}, " + f"{len(snoc)} of them snoc") + + default = a.src / "bdwlan.bin" + if not default.is_file(): + raise SystemExit(f"no {default}: that is the phone's default board data") + data_default = default.read_bytes() + + entries = [] + # The ids this phone can report. 0 is what its stock firmware logs; ff is + # ath10k's fallback and what upstream's own file uses. Both get the default + # calibration blob, which is the one the phone itself ships. + for bid in (0x0, 0xff): + entries.append((f"bus=snoc,qmi-board-id={bid:x},qmi-chip-id={CHIP_ID:x}", data_default)) + # Every per-board-id blob the phone carries, under its own id, so a unit that + # reports something else still finds its own calibration. + for f in sorted(a.src.glob("bdwlan.b*")): + bid = board_id_of(f) + if bid is None or bid in (0x0, 0xff): + continue + entries.append((f"bus=snoc,qmi-board-id={bid:x},qmi-chip-id={CHIP_ID:x}", f.read_bytes())) + + blob = bytearray(MAGIC + b"\0") + blob += b"\0" * ((-len(blob)) % 4) + for name, data in entries: + body = ie(BD_IE_BOARD_NAME, name.encode()) + ie(BD_IE_BOARD_DATA, data) + blob += ie(BD_IE_BOARD, body) + + got = parse(bytes(blob)) + if len(got) != len(entries): + raise SystemExit(f"wrote {len(entries)} entries but read back {len(got)}") + for (wn, wd), (gn, gl) in zip(entries, got): + if gn != wn or gl != len(wd): + raise SystemExit(f"entry did not round-trip: wrote {wn!r}/{len(wd)}, read {gn!r}/{gl}") + + a.out.parent.mkdir(parents=True, exist_ok=True) + a.out.write_bytes(bytes(blob)) + print(f"wrote {a.out} ({len(blob)} bytes, {len(entries)} entries), verified by re-parsing:") + for n, l in got: + print(f" {n} ({l} bytes)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/dipper/build-boot.py b/tools/dipper/build-boot.py new file mode 100755 index 000000000..d1210b2e8 --- /dev/null +++ b/tools/dipper/build-boot.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Pack dipper's kernel + appended DTB and the initramfs into an Android v1 boot image. + +Every offset here was read off the phone's own stock boot image (header v1, +page 4096, kernel 0x8000, ramdisk 0x1000000, tags 0x100, base 0), so the image +we hand ABL has the same geometry as the one it already boots. The DTB is +appended to the kernel because dipper's stock image carries its FDTs that way +(two concatenated FDTs at the end of the kernel blob, selected by msm-id). + +No mkbootimg dependency: the v1 header is 1648 bytes of fixed layout and we +verify what we wrote before returning. +""" +import argparse, hashlib, json, struct, sys +from pathlib import Path + +PAGE = 4096 +BASE = 0x00000000 +KERNEL_OFF = 0x00008000 +# Stock's own value, and the only one seen to boot on this phone. It leaves +# 16 MiB - 32 KiB for the kernel; check_layout() refuses anything larger rather +# than letting ABL answer with +# Failed to load/authenticate boot image: 00000050 +# which it does with no kernel output and no clue. +RAMDISK_OFF = 0x01000000 +SECOND_OFF = 0x00f00000 +TAGS_OFF = 0x00000100 +HDR_VERSION = 1 +HDR_SIZE = 1648 +# From the phone: console on the framebuffer, early console on the SoC's UART +# (stock passes earlycon=msm_geni_serial,0xA84000), then the shared init. +CMDLINE = ("console=tty0 earlycon=msm_geni_serial,0xa84000 rdinit=/init " + "panic=10 printk.devkmsg=on rootwait") +# dipper's boot partition, measured: 65536 blocks of 1 KiB. +BOOT_PARTITION_BYTES = 64 * 1024 * 1024 +# This ABL refuses a larger kernel with only +# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') +# Measured on the phone: 16,247,767 bytes boots, 16,343,459 does not. +KERNEL_MAX = 0xF80000 + + +def pad(b: bytes) -> bytes: + r = len(b) % PAGE + return b + (b"\0" * (PAGE - r) if r else b"") + + +def check_layout(kernel: bytes, ramdisk: bytes) -> None: + """The kernel must end before the ramdisk begins, or ABL rejects the image.""" + if len(kernel) > KERNEL_MAX: + raise SystemExit( + f"kernel+dtb is {len(kernel)} bytes; this phone's ABL refuses more " + f"than {KERNEL_MAX} ({KERNEL_MAX / 1048576:.2f} MiB) and says only " + "'Failed to load/authenticate boot image: 00000050'. Move drivers " + "to modules.") + room = RAMDISK_OFF - KERNEL_OFF + if len(kernel) > room: + raise SystemExit( + f"kernel+dtb is {len(kernel)} bytes but only {room} fit between " + f"kernel_offset {KERNEL_OFF:#x} and ramdisk_offset {RAMDISK_OFF:#x}; " + "raise RAMDISK_OFF or shrink the kernel") + end = RAMDISK_OFF + len(ramdisk) + if end > BOOT_PARTITION_BYTES * 4: + raise SystemExit(f"the loaded image would reach {end:#x}, which is implausible") + + +def build_header(kernel: bytes, ramdisk: bytes, cmdline: str) -> bytes: + cmd = cmdline.encode() + if len(cmd) > 511: + raise SystemExit(f"cmdline is {len(cmd)} bytes; the v1 header holds 512 with its NUL") + h = bytearray(PAGE) + h[0:8] = b"ANDROID!" + struct.pack_into("<10I", h, 8, + len(kernel), BASE + KERNEL_OFF, + len(ramdisk), BASE + RAMDISK_OFF, + 0, BASE + SECOND_OFF, # no second stage: the DTB is appended + BASE + TAGS_OFF, PAGE, HDR_VERSION, 0) + h[48:64] = b"\0" * 16 # product name: stock leaves it empty too + h[64:64 + len(cmd)] = cmd + # id[32] at 576 and extra_cmdline[1024] at 608 stay zero. + struct.pack_into(" None: + """Re-read what we wrote: a wrong header silently bricks a boot attempt.""" + if img[:8] != b"ANDROID!": + raise SystemExit("bad magic in the image we just built") + ks, ka, rs, ra, ss, sa, tags, ps, hv, _ = struct.unpack_from("<10I", img, 8) + if (ks, rs, ss) != (len(kernel), len(ramdisk), 0): + raise SystemExit(f"sizes disagree: {(ks, rs, ss)}") + if (ka, ra, tags, ps, hv) != (BASE + KERNEL_OFF, BASE + RAMDISK_OFF, BASE + TAGS_OFF, PAGE, HDR_VERSION): + raise SystemExit(f"geometry disagrees with the stock image: {(ka, ra, tags, ps, hv)}") + if struct.unpack_from(" int: + ap = argparse.ArgumentParser() + ap.add_argument("--kernel", type=Path, required=True, help="Image.gz") + ap.add_argument("--dtb", type=Path, required=True, help="sdm845-xiaomi-dipper.dtb") + ap.add_argument("--ramdisk", type=Path, required=True, help="initramfs.cpio.gz") + ap.add_argument("--out", type=Path, required=True, help="output directory") + ap.add_argument("--cmdline", default=CMDLINE) + a = ap.parse_args() + + a.out.mkdir(parents=True, exist_ok=True) + kernel = a.kernel.read_bytes() + a.dtb.read_bytes() # Image.gz-dtb + ramdisk = a.ramdisk.read_bytes() + (a.out / "Image.gz-dtb").write_bytes(kernel) + + check_layout(kernel, ramdisk) + img = build_header(kernel, ramdisk, a.cmdline) + pad(kernel) + pad(ramdisk) + verify(img, kernel, ramdisk, a.cmdline) + if len(img) > BOOT_PARTITION_BYTES: + raise SystemExit(f"image is {len(img)} bytes; dipper's boot partition holds " + f"{BOOT_PARTITION_BYTES}") + + out = a.out / "boot.img" + out.write_bytes(img) + manifest = { + "device": "dipper", + "header_version": HDR_VERSION, + "pagesize": PAGE, + "cmdline": a.cmdline, + "kernel_bytes": len(kernel), + "dtb_bytes": a.dtb.stat().st_size, + "ramdisk_bytes": len(ramdisk), + "boot_bytes": len(img), + "boot_partition_bytes": BOOT_PARTITION_BYTES, + "headroom_bytes": BOOT_PARTITION_BYTES - len(img), + "kernel_sha256": hashlib.sha256(kernel).hexdigest(), + "ramdisk_sha256": hashlib.sha256(ramdisk).hexdigest(), + "boot_sha256": hashlib.sha256(img).hexdigest(), + "hardware_boot_tested": False, + } + (a.out / "BOOT-MANIFEST.json").write_text(json.dumps(manifest, indent=2) + "\n") + print(f"packed {out} ({len(img)} bytes, {manifest['headroom_bytes']} spare in the partition)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/dipper/extract-firmware b/tools/dipper/extract-firmware new file mode 100755 index 000000000..7854ab7b7 --- /dev/null +++ b/tools/dipper/extract-firmware @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Pull dipper's own vendor firmware off the phone and merge the split Qualcomm +# .mdt/.bNN sets into the single .mbn files mainline's remoteproc asks for. +# +# Nothing here is redistributable: it is the owner's device firmware, extracted +# from their own phone, and it stays outside the repository. +set -euo pipefail + +HOST=${HOST:-mi8} +SU=${SU:-/debug_ramdisk/su} +OUT=${OUT:-$HOME/android/reference/dipper-stock/firmware} + +remote() { ssh "$HOST" "$SU -c '$1'"; } + +umask 077 +raw=$OUT/raw; mkdir -p "$raw" "$OUT/qcom/sdm845/dipper"; chmod -R 700 "$OUT" + +# Where each blob lives on this phone, measured: /vendor/firmware for the GPU and +# IPA, /vendor/firmware_mnt/image for the DSPs and the modem. + +# One tar stream per source directory: a regex through `su -c` is a quoting +# minefield, and per-file ssh over a relayed link is needlessly slow. +fetch() { # fetch + local dir=$1; shift + ssh "$HOST" "$SU -c \"cd $dir && tar cf - $* 2>/dev/null\"" | tar xf - -C "$raw" +} +fetch_base64() { # fetch one small binary file through Android's text-only SSH bridge + ssh "$HOST" "$SU -c \"base64 $1\"" | base64 -d > "$2" +} +echo "== GPU zap shader and IPA from /vendor/firmware" +fetch /vendor/firmware 'a630_zap.mdt a630_zap.b* ipa_fws.mdt ipa_fws.b*' +echo "== DSP and modem images from /vendor/firmware_mnt/image" +fetch /vendor/firmware_mnt/image 'adsp.mdt adsp.b* cdsp.mdt cdsp.b* mba.mbn' +echo "== modem configuration files requested by MPSS" +mkdir -p "$raw/modem_pr/mcfg/configs/mcfg_hw" "$raw/modem_pr/mcfg/configs/mcfg_sw" +fetch_base64 /vendor/firmware_mnt/image/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig "$raw/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig" +fetch_base64 /vendor/firmware_mnt/image/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig "$raw/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig" +echo "== ath10k board data and firmware" +mkdir -p "$OUT/wlan" +ssh "$HOST" "$SU -c \"cd /vendor/firmware && tar cf - wlan 2>/dev/null\"" | tar xf - -C "$OUT" +# mba is already a single signed image; the rest get squashed below. +[ -f "$raw/mba.mbn" ] && mv "$raw/mba.mbn" "$OUT/qcom/sdm845/dipper/mba.mbn" +echo "raw files pulled: $(find "$raw" -type f | wc -l)" + +python3 "$(dirname "$0")/pil-squash.py" "$raw" "$OUT/qcom/sdm845/dipper" + +# MPSS requests these over TFTP; stage them beside modem.mbn for tqftpserv. +install -D -m 600 "$raw/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig" "$OUT/qcom/sdm845/dipper/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig" +install -D -m 600 "$raw/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig" "$OUT/qcom/sdm845/dipper/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig" + +echo +echo "firmware tree for the phone's /lib/firmware:" +find "$OUT/qcom" "$OUT/wlan" -type f 2>/dev/null | sed "s#$OUT/# #" | sort +echo +echo "Device firmware from this phone only. Do not commit or redistribute it." diff --git a/tools/dipper/extract-identity b/tools/dipper/extract-identity new file mode 100755 index 000000000..47b427cf5 --- /dev/null +++ b/tools/dipper/extract-identity @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Recover this phone's factory WLAN and Bluetooth addresses from its own +# `persist` backup. Offline: the phone is not touched and need not be reachable. +# +# These are device identifiers. They are written outside the repository, mode +# 600, and must never be committed. +set -euo pipefail + +REF=${REF:-$HOME/android/reference/dipper-stock} +PERSIST=${PERSIST:-$REF/backup/persist.img} +OUT=${OUT:-$REF/identity.env} +DEBUGFS=${DEBUGFS:-/sbin/debugfs} + +[[ -f $PERSIST ]] || { echo "no $PERSIST -- run tools/dipper/backup-stock first" >&2; exit 1; } +[[ -x $DEBUGFS ]] || { echo "need debugfs (e2fsprogs) at $DEBUGFS" >&2; exit 1; } + +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +umask 077 + +# persist is ext4; read it with debugfs so nothing has to be mounted or elevated. +"$DEBUGFS" -R "dump /wlan_bt/wlan.mac $tmp/wlan.mac" "$PERSIST" 2>/dev/null || true +"$DEBUGFS" -R "dump /wlan_bt/bt.mac $tmp/bt.mac" "$PERSIST" 2>/dev/null || true + +fmt() { # 6 raw bytes -> aa:bb:cc:dd:ee:ff, rejecting anything that is not a MAC + local f=$1 + [[ -s $f ]] || return 1 + python3 - "$f" <<'PY' +import sys +d = open(sys.argv[1], 'rb').read() +if len(d) != 6 or d == b'\0' * 6 or d == b'\xff' * 6: + sys.exit(1) +if d[0] & 1: # a multicast bit means this is not a station address + sys.exit(1) +print(":".join(f"{b:02x}" for b in d)) +PY +} + +wlan=$(fmt "$tmp/wlan.mac") || { echo "no usable WLAN address in persist" >&2; exit 1; } +bt=$(fmt "$tmp/bt.mac") || { echo "no usable Bluetooth address in persist" >&2; exit 1; } + +# little-endian byte list for the device tree's local-bd-address +bd_le=$(python3 -c "print(' '.join(reversed('$bt'.split(':'))))") + +mkdir -p "$(dirname "$OUT")" +cat > "$OUT" < "$link" < aa:bb:cc:dd:ee:ff, or nothing if not a station MAC + [ -s "$1" ] || return 1 + # POSIX awk only: and() and strtonum() are gawk extensions that neither the + # phone's awk nor busybox awk has. Running this on the phone is how that + # was found, so do not "simplify" it back. + od -An -tx1 -N6 "$1" | tr -d ' \n' | awk ' + length($0) != 12 { exit 1 } + { + for (i = 1; i <= 11; i += 2) b[++n] = substr($0, i, 2) + all = b[1] b[2] b[3] b[4] b[5] b[6] + if (all == "000000000000") exit 1 # unset + if (all == "ffffffffffff") exit 1 # broadcast + # The multicast bit is the low bit of the first byte, i.e. its + # second hex digit is odd. + if (index("13579bdfBDF", substr(b[1], 2, 1)) > 0) exit 1 + printf "%s:%s:%s:%s:%s:%s", b[1], b[2], b[3], b[4], b[5], b[6] + }' +} + +[ -e "$PERSIST" ] || { log "no persist partition at $PERSIST"; exit 0; } +mkdir -p "$MNT" +mounted=0 +# NOMOUNT lets the test drive this script against a plain directory of files. +if [ "${NOMOUNT:-0}" != 1 ] && ! mountpoint -q "$MNT"; then + mount -o ro,nosuid,nodev,noexec "$PERSIST" "$MNT" || { log "cannot mount persist read-only"; exit 0; } + mounted=1 +fi +cleanup() { [ "$mounted" = 1 ] && umount "$MNT" 2>/dev/null || true; } +trap cleanup EXIT + +wlan=$(mac_from "$MNT/wlan_bt/wlan.mac" || true) +bt=$(mac_from "$MNT/wlan_bt/bt.mac" || true) + +if [ -n "${wlan:-}" ]; then + # A udev .link file is applied whoever manages the interface later, + # NetworkManager included. Rewrite it only when it would change. + want="[Match] +OriginalName=wlan0 + +[Link] +MACAddress=$wlan" + if [ ! -f "$LINK" ] || [ "$(cat "$LINK")" != "$want" ]; then + mkdir -p "$(dirname "$LINK")" + printf '%s\n' "$want" > "$LINK" + log "wrote $LINK" + fi + # Apply now as well, in case wlan0 already exists this boot. + if [ -d /sys/class/net/wlan0 ]; then + ip link set dev wlan0 down 2>/dev/null || true + ip link set dev wlan0 address "$wlan" 2>/dev/null \ + && log "wlan0 address set from persist" \ + || log "could not set wlan0 address now; the link file covers the next boot" + ip link set dev wlan0 up 2>/dev/null || true + fi +else + log "no usable WLAN address in persist; leaving the interface alone" +fi + +if [ -n "${bt:-}" ]; then + if [ -d /sys/class/bluetooth/hci0 ] && command -v btmgmt >/dev/null; then + btmgmt --index 0 public-addr "$bt" >/dev/null 2>&1 \ + && log "bluetooth public address set from persist" \ + || log "btmgmt refused the public address (controller may not support it)" + else + log "no hci0 or no btmgmt yet; bluetooth keeps the firmware default address" + fi +else + log "no usable Bluetooth address in persist" +fi diff --git a/tools/dipper/identity/omamobile-dipper-identity.service b/tools/dipper/identity/omamobile-dipper-identity.service new file mode 100644 index 000000000..d307135b9 --- /dev/null +++ b/tools/dipper/identity/omamobile-dipper-identity.service @@ -0,0 +1,15 @@ +[Unit] +Description=Apply the Mi 8's own WLAN and Bluetooth addresses from persist +# persist is read-only to us; the storage guard keeps it that way. +ConditionPathExists=/dev/disk/by-partlabel/persist +Before=NetworkManager.service bluetooth.service +Wants=local-fs.target +After=local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/bin/omamobile-dipper-identity + +[Install] +WantedBy=multi-user.target diff --git a/tools/dipper/identity/test-identity.sh b/tools/dipper/identity/test-identity.sh new file mode 100755 index 000000000..fc74ac8d2 --- /dev/null +++ b/tools/dipper/identity/test-identity.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Drive the real boot-time identity script against fake persist trees. No phone, +# no mounting, no root. Asserts it accepts a genuine address and refuses junk. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +script=$here/omamobile-dipper-identity +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +fails=() + +# Run the script with a persist tree holding the given raw wlan/bt bytes. +run_with() { # run_with + local root=$tmp/p$RANDOM + mkdir -p "$root/wlan_bt" + python3 -c "import sys,pathlib; pathlib.Path(sys.argv[1]).write_bytes(bytes.fromhex(sys.argv[2]))" \ + "$root/wlan_bt/wlan.mac" "$1" + python3 -c "import sys,pathlib; pathlib.Path(sys.argv[1]).write_bytes(bytes.fromhex(sys.argv[2]))" \ + "$root/wlan_bt/bt.mac" "$2" + NOMOUNT=1 PERSIST="$root" MNT="$root" LINK="$3" sh "$script" 2>&1 +} + +# 1. a valid locally administered address must land in the link file, formatted +out=$(run_with 021042000001 021042000002 "$tmp/link1") +grep -q "MACAddress=02:10:42:00:00:01" "$tmp/link1" 2>/dev/null || fails+=("valid address not written to the link file") +grep -q "OriginalName=wlan0" "$tmp/link1" 2>/dev/null || fails+=("link file has no Match section") + +# 2. junk must be refused, and no link file written +for name_hex in "000000000000:all-zero" "ffffffffffff:broadcast" "01005e000001:multicast"; do + hex=${name_hex%%:*}; what=${name_hex##*:} + out=$(run_with "$hex" "$hex" "$tmp/link-$what") + grep -q "no usable WLAN address" <<<"$out" || fails+=("$what: not reported as unusable") + [[ ! -f $tmp/link-$what ]] || fails+=("$what: wrote a link file anyway") +done + +# 3. a short read must be refused too +out=$(run_with a45046 a45046 "$tmp/link-short") +grep -q "no usable WLAN address" <<<"$out" || fails+=("short read: not reported as unusable") +[[ ! -f $tmp/link-short ]] || fails+=("short read: wrote a link file anyway") + +# 4. no persist at all: a quiet no-op, exit 0, nothing written +out=$(PERSIST=$tmp/none MNT=$tmp/m LINK=$tmp/link-none sh "$script" 2>&1) \ + || fails+=("exited non-zero with no persist") +grep -q "no persist partition" <<<"$out" || fails+=("missing persist not reported") +[[ ! -f $tmp/link-none ]] || fails+=("wrote a link file with no persist") + +# 5. rewriting must be idempotent: the same input must not rewrite the file +run_with a45046ec5154 a45046ac5155 "$tmp/link1" >/dev/null +before=$(stat -c%Y "$tmp/link1"); sleep 1 +out=$(run_with a45046ec5154 a45046ac5155 "$tmp/link1") +[[ $(stat -c%Y "$tmp/link1") == "$before" ]] || fails+=("rewrote an unchanged link file") +grep -q "wrote .*link1" <<<"$out" && fails+=("claimed a write when nothing changed") + +if ((${#fails[@]})); then printf 'FAIL:\n'; printf ' %s\n' "${fails[@]}"; exit 1; fi +echo "test-identity OK: real script accepts a genuine MAC, refuses zero/broadcast/multicast/short, no-op without persist, idempotent" diff --git a/tools/dipper/initramfs-inside.sh b/tools/dipper/initramfs-inside.sh new file mode 100755 index 000000000..9da0893f7 --- /dev/null +++ b/tools/dipper/initramfs-inside.sh @@ -0,0 +1,131 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Runs inside an aarch64 Alpine container. Only files under /out change. +# Adapted from tools/alioth/build-initramfs.sh: same class of device (non-A/B +# Qualcomm, appended DTB), different panel, watchdog name and descriptor values. +set -eu + +: "${KERNEL_RELEASE:?KERNEL_RELEASE must be passed in}" + +apk add --no-cache cpio gcc musl-dev gzip kmod python3 dropbear + +stage=/tmp/dipper-initramfs +mkdir -p "$stage" +apk --root "$stage" --initdb --no-cache \ + --repositories-file /etc/apk/repositories --keys-dir /etc/apk/keys add \ + alpine-baselayout busybox busybox-extras dropbear iproute2 util-linux \ + e2fsprogs e2fsprogs-extra kmod \ + ${DIPPER_BRINGUP:+i2c-tools evtest strace pciutils usbutils} + +mkdir -p "$stage/proc" "$stage/sys" "$stage/dev" "$stage/run" "$stage/root/.ssh" \ + "$stage/usr/lib/modules" "$stage/usr/lib/firmware" "$stage/etc/dropbear" "$stage/usr/local/bin" +# Alpine is not usr-merged; kmod and the kernel look below /lib. +ln -s ../usr/lib/modules "$stage/lib/modules" +ln -s ../usr/lib/firmware "$stage/lib/firmware" + +cp /input/key.pub "$stage/root/.ssh/authorized_keys" +chmod 700 "$stage/root/.ssh" +chmod 600 "$stage/root/.ssh/authorized_keys" + +# Keep the rescue server's host key stable across rebuilds, so the laptop's +# known_hosts does not change under us. Private key stays in local output. +hostkey=/out/dropbear_ed25519_host_key +if [ ! -s "$hostkey" ]; then + umask 077 + dropbearkey -t ed25519 -f "$hostkey" >/dev/null 2>&1 +fi +cp "$hostkey" "$stage/etc/dropbear/dropbear_ed25519_host_key" +chmod 600 "$stage/etc/dropbear/dropbear_ed25519_host_key" +chown "${OUT_UID:-0}:${OUT_GID:-0}" "$hostkey" + +cp -a "/modules/lib/modules/$KERNEL_RELEASE" "$stage/usr/lib/modules/" +# The build tree symlinks point at the builder's paths; they are useless here. +rm -f "$stage/usr/lib/modules/$KERNEL_RELEASE/build" \ + "$stage/usr/lib/modules/$KERNEL_RELEASE/source" +depmod -b "$stage" "$KERNEL_RELEASE" + +# Keep only the modules this initramfs actually loads, with their dependencies. +# The full tree is ~1764 modules and dominates the image: with the PHYs, UFS, +# i2c and simpledrm built in, almost none of it is reachable here, and ABL +# refuses a boot image that grows too large. Everything else belongs in the +# root filesystem, not here. The pruner reads modules.dep and fails loudly +# rather than silently emptying the tree. +python3 /src/tools/dipper/prune-modules.py \ + "$stage/usr/lib/modules/$KERNEL_RELEASE" qcom_wdt panel-samsung-ea8074 +depmod -b "$stage" "$KERNEL_RELEASE" + +# The modules the init loads must exist AND match this kernel exactly, or the +# phone boots to a black screen with no watchdog taken over. +for module in qcom_wdt panel-samsung-ea8074; do + path=$(modinfo -b "$stage" -k "$KERNEL_RELEASE" -n "$module") + [ "$(modinfo -F vermagic "$path" | cut -d ' ' -f1)" = "$KERNEL_RELEASE" ] || { + echo "module $module does not match $KERNEL_RELEASE" >&2; exit 1; } +done + +cp /src/initramfs/init "$stage/init" +python3 - "$stage/init" <<'PY' +from pathlib import Path +import sys +p = Path(sys.argv[1]); s = p.read_text() + +# SDM845 leaves the cluster watchdogs running; take them over early. +needle = 'hostname omamobile\n' +assert s.count(needle) == 1, "shared init changed: hostname anchor" +s = s.replace(needle, '''# SDM845's watchdogs keep running until a driver claims them. +modprobe qcom_wdt || echo "omamobile: qcom watchdog module failed" >/dev/kmsg +if [ -c /dev/watchdog0 ]; then + watchdog -t 5 -T 30 /dev/watchdog0 +fi +modprobe panel-samsung-ea8074 || echo "omamobile: panel module failed" >/dev/kmsg +hostname omamobile +''') + +# Bind the rescue sshd to the USB link only, never to every interface. +needle = 'dropbear -R -E -p 22' +assert s.count(needle) == 1, "shared init changed: dropbear anchor" +s = s.replace(needle, 'dropbear -R -E -s -p 172.16.42.1:22') +p.write_text(s) +PY +chmod 755 "$stage/init" + +echo xiaomi,dipper > "$stage/etc/omamobile-compatible" +echo userdata > "$stage/etc/omamobile-ufs-rw" + +# A diagnostic image, for a first boot with no cable attached: it mirrors the +# kernel log into the unused `logdump` partition so Android can read it back. +# See tools/dipper/bringup-patch-init.py. Never write this one to `boot`. +if [ "${DIPPER_BRINGUP:-0}" = 1 ]; then + echo "userdata logdump" > "$stage/etc/omamobile-ufs-rw" + python3 /src/tools/dipper/bringup-patch-init.py "$stage/init" + echo 'BRING-UP IMAGE: logdump mirror on, storage guard widened' > "$stage/etc/omamobile-bringup" +fi +# Bring-up only: boot the Arch root from NFS over the USB link instead of the +# UFS, so a root filesystem can be tried without writing to the phone at all. +if [ -n "${DIPPER_NFSROOT:-}" ]; then + echo "$DIPPER_NFSROOT" > "$stage/etc/omamobile-nfsroot" + echo "NFS ROOT IMAGE: the Arch root comes from $DIPPER_NFSROOT, not the UFS" \ + > "$stage/etc/omamobile-nfsroot-note" +fi +echo 'Xiaomi Mi 8 Omarchy' > "$stage/etc/omamobile-usb-product" + +gcc -Os -static -o "$stage/usr/local/bin/reboot-to" \ + /src/packages/omamobile-device-cheetah/src/reboot-to.c + +# Prove the packaged userspace actually runs on ARM before shipping it. +chroot "$stage" /bin/busybox true +chroot "$stage" /usr/sbin/dropbear -h >/tmp/dropbear-help 2>&1 || [ "$?" = 1 ] +grep -q 'Dropbear' /tmp/dropbear-help + +# Reproducible archive: fixed mtimes, sorted, no owners. +python3 - "$stage" <<'PY' +import os, sys +from pathlib import Path +root = Path(sys.argv[1]) +for path in list(root.rglob('*')) + [root]: + os.utime(path, (1790636353, 1790636353), follow_symlinks=False) +PY +(cd "$stage" && find . -print0 | sort -z | cpio --null --quiet -o -H newc --owner=0:0 --reproducible) \ + | gzip -n -9 > /out/initramfs.cpio.gz +cp /tmp/dropbear-help /out/dropbear-help.txt +chown "${OUT_UID:-0}:${OUT_GID:-0}" /out/initramfs.cpio.gz /out/dropbear-help.txt +echo "dipper initramfs built for $KERNEL_RELEASE; storage guard permits userdata only" diff --git a/tools/dipper/pil-squash.py b/tools/dipper/pil-squash.py new file mode 100755 index 000000000..9ce19fc01 --- /dev/null +++ b/tools/dipper/pil-squash.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Merge a split Qualcomm firmware (.mdt + .bNN) into the single .mbn image +mainline remoteproc loads. + +The .mdt holds the ELF header and program headers; each loadable segment sits in +.bNN at the offset its program header names. Writing the segments back at those +offsets, under the .mdt's own header, reconstructs the image. + + pil-squash.py [name ...] +""" +# pil-squasher: an .mdt is the ELF header plus program headers; each loadable +# segment lives in .bNN at the offset its program header names. Writing them +# back at those offsets reconstructs the single .mbn image. +import struct, sys +from pathlib import Path + +raw, out = Path(sys.argv[1]), Path(sys.argv[2]) +out.mkdir(parents=True, exist_ok=True) +only = set(sys.argv[3:]) +for mdt in sorted(raw.glob('*.mdt')): + if only and mdt.stem not in only: + continue + d = mdt.read_bytes() + if d[:4] != b'\x7fELF': + print(f"{mdt.name}: not an ELF, skipped"); continue + is64 = d[4] == 2 + if is64: + e_phoff, = struct.unpack_from(' [name ...] +""" +import sys +from pathlib import Path + + +def basename(path: str) -> str: + n = Path(path).name + for suffix in (".ko.zst", ".ko.xz", ".ko.gz", ".ko"): + if n.endswith(suffix): + return n[: -len(suffix)] + return n + + +def main() -> int: + moddir = Path(sys.argv[1]) + wanted = {n.replace("-", "_") for n in sys.argv[2:]} + dep = moddir / "modules.dep" + if not dep.is_file(): + raise SystemExit(f"no {dep}") + + deps, by_name = {}, {} + for line in dep.read_text().splitlines(): + if ":" not in line: + continue + target, rest = line.split(":", 1) + target = target.strip() + deps[target] = rest.split() + by_name[basename(target).replace("-", "_")] = target + + missing = wanted - set(by_name) + if missing: + raise SystemExit(f"not in modules.dep: {', '.join(sorted(missing))}") + + keep, queue = set(), [by_name[n] for n in wanted] + while queue: + cur = queue.pop() + if cur in keep: + continue + keep.add(cur) + queue.extend(deps.get(cur, [])) + + kept_paths = {(moddir / k).resolve() for k in keep} + before = removed = 0 + for f in moddir.rglob("*"): + if not f.is_file() or ".ko" not in f.name: + continue + before += 1 + if f.resolve() not in kept_paths: + f.unlink() + removed += 1 + for d in sorted(moddir.rglob("*"), key=lambda p: -len(p.parts)): + if d.is_dir() and not any(d.iterdir()): + d.rmdir() + + print(f"kept {len(keep)} of {before} modules: " + f"{', '.join(sorted(basename(k) for k in keep))}") + if len(keep) < len(wanted): + raise SystemExit("fewer modules kept than asked for") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/dipper/push-verified b/tools/dipper/push-verified new file mode 100755 index 000000000..34762d632 --- /dev/null +++ b/tools/dipper/push-verified @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# Copy a file to the phone in verified chunks, then optionally write it to a +# partition -- refusing at every step unless the checksum matches. +# +# Why chunks: a single 47 MB stream over the relayed link has silently truncated +# at 32 MiB, and an unverified truncated image written to a partition is exactly +# the mistake this tool exists to make impossible. +set -euo pipefail + +HOST=${HOST:-mi8} +SU=${SU:-/debug_ramdisk/su} +REMOTE_DIR=${REMOTE_DIR:-/data/user/0/org.galexander.sshd/files} +CHUNK_MB=${CHUNK_MB:-4} +RETRIES=${RETRIES:-3} + +src=${1:?usage: push-verified [--to-partition ]} +part="" +if [[ ${2:-} == --to-partition ]]; then part=${3:?partition name}; fi + +[[ -f $src ]] || { echo "no such file: $src" >&2; exit 1; } +size=$(stat -c%s "$src") +want=$(sha256sum "$src" | cut -d' ' -f1) +chunk=$((CHUNK_MB * 1024 * 1024)) +n=$(( (size + chunk - 1) / chunk )) +base=$(basename "$src") +remote=$REMOTE_DIR/$base + +echo "$src: $size bytes, $n chunk(s) of ${CHUNK_MB} MiB, sha256 ${want:0:16}…" +ssh "$HOST" "rm -f '$remote' '$remote'.part" >/dev/null 2>&1 || true + +for ((i = 0; i < n; i++)); do + off=$((i * chunk)) + len=$chunk + (( off + len > size )) && len=$((size - off)) + csum=$(dd if="$src" bs=1M skip=$((i * CHUNK_MB)) count=$CHUNK_MB 2>/dev/null | sha256sum | cut -d' ' -f1) + ok=0 + for ((try = 1; try <= RETRIES; try++)); do + dd if="$src" bs=1M skip=$((i * CHUNK_MB)) count=$CHUNK_MB 2>/dev/null | + ssh "$HOST" "dd of='$remote'.part bs=1M 2>/dev/null" || true + got=$(ssh "$HOST" "sha256sum '$remote'.part 2>/dev/null | cut -d' ' -f1" | tr -d '\r\n') + if [[ $got == "$csum" ]]; then ok=1; break; fi + echo " chunk $((i + 1))/$n attempt $try mismatched; retrying" >&2 + done + (( ok )) || { echo "chunk $((i + 1))/$n failed after $RETRIES attempts" >&2; exit 1; } + ssh "$HOST" "cat '$remote'.part >> '$remote' && rm -f '$remote'.part" + printf '\r %d/%d chunks verified' "$((i + 1))" "$n" +done +echo + +got_size=$(ssh "$HOST" "stat -c%s '$remote'" | tr -d '\r\n') +got_sum=$(ssh "$HOST" "sha256sum '$remote' | cut -d' ' -f1" | tr -d '\r\n') +[[ $got_size == "$size" && $got_sum == "$want" ]] || { + echo "whole-file check failed on the phone: $got_size bytes, ${got_sum:0:16}…" >&2; exit 1; } +echo "uploaded and verified: $remote" + +[[ -n $part ]] || exit 0 + +echo "writing to the $part partition" +blocks=$(( (size + 4095) / 4096 )) +(( size % 4096 == 0 )) || { echo "image is not a multiple of 4096; refusing" >&2; exit 1; } +ssh "$HOST" "$SU -c \" +dev=\\\$(readlink -f /dev/block/by-name/$part) +[ -n \\\"\\\$dev\\\" ] || { echo 'no such partition: $part' >&2; exit 1; } +psize=\\\$(blockdev --getsize64 \\\$dev) +[ \\\"\\\$psize\\\" -ge $size ] || { echo \\\"image $size exceeds \\\$dev (\\\$psize)\\\" >&2; exit 1; } +dd if='$remote' of=\\\$dev bs=1M conv=fsync 2>/dev/null +dd if=\\\$dev bs=4096 count=$blocks 2>/dev/null | sha256sum | cut -d' ' -f1 +\"" | tr -d '\r\n' | { + read -r back + if [[ $back == "$want" ]]; then + echo "$part written and read back byte-exact" + else + echo "READ-BACK MISMATCH: partition holds ${back:0:16}…, expected ${want:0:16}…" >&2 + exit 1 + fi +} +ssh "$HOST" "rm -f '$remote'" diff --git a/tools/dipper/test-board-2.py b/tools/dipper/test-board-2.py new file mode 100755 index 000000000..c1f11e760 --- /dev/null +++ b/tools/dipper/test-board-2.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Check build-board-2.py: it must read upstream's own file and refuse bad input.""" +import importlib.util, os, struct, subprocess, sys, tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent +spec = importlib.util.spec_from_file_location("bb2", HERE / "build-board-2.py") +bb2 = importlib.util.module_from_spec(spec); spec.loader.exec_module(bb2) + +fails = [] +def check(c, m): + if not c: fails.append(m) + +# 1. a hand-built file must round-trip through our own parser +name = "bus=snoc,qmi-board-id=0,qmi-chip-id=30214" +data = bytes(range(256)) * 4 +body = bb2.ie(bb2.BD_IE_BOARD_NAME, name.encode()) + bb2.ie(bb2.BD_IE_BOARD_DATA, data) +blob = bb2.MAGIC + b"\0" + b"\0" * ((-(len(bb2.MAGIC) + 1)) % 4) + bb2.ie(bb2.BD_IE_BOARD, body) +got = bb2.parse(blob) +check(got == [(name, len(data))], f"round-trip failed: {got}") + +# 2. the magic must be rejected when wrong, so a truncated download cannot pass +try: + bb2.parse(b"NOT-A-BOARD-FILE" + b"\0" * 8); fails.append("accepted a bad magic") +except ValueError: + pass + +# 3. odd-length payloads must still align, or every later IE is misread +odd = bb2.ie(7, b"abc") +check(len(odd) % 4 == 0, "IE not padded to a 4-byte boundary") +check(struct.unpack_from("= 30, f"only {len(entries)} entries parsed from upstream's file") + check(len(snoc) == len(entries), "some upstream entries did not parse as snoc boards") + check(any("xiaomi_beryllium" in n for n in snoc), "beryllium missing: parse is suspect") + print(f"upstream cross-check: {len(entries)} entries, all snoc") +else: + print("upstream cross-check: SKIPPED (no reference board-2.bin)") + +if fails: + print("FAIL:"); [print(" ", f) for f in fails]; sys.exit(1) +print("test-board-2 OK: round-trips, rejects bad magic, aligns IEs, parses upstream's file") diff --git a/tools/dipper/test-build-boot.py b/tools/dipper/test-build-boot.py new file mode 100755 index 000000000..688e644f4 --- /dev/null +++ b/tools/dipper/test-build-boot.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Check build-boot.py against the phone's own stock boot header, not invented numbers. + +An optional stock header may be supplied with BOOT_HEADER_REFERENCE. Keep the +capture outside the repository; the comparison is skipped when it is unset. +""" +import gzip, importlib.util, os, struct, subprocess, sys, tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent +STOCK = Path(os.environ["BOOT_HEADER_REFERENCE"]) if os.environ.get("BOOT_HEADER_REFERENCE") else None + +spec = importlib.util.spec_from_file_location("bb", HERE / "build-boot.py") +bb = importlib.util.module_from_spec(spec); spec.loader.exec_module(bb) + +fails = [] +def check(cond, msg): + if not cond: fails.append(msg) + +# 1. geometry must equal the stock image's, field by field +if STOCK is not None and STOCK.is_file(): + d = STOCK.read_bytes() + ks, ka, rs, ra, ss, sa, tags, ps, hv, _ = struct.unpack_from("<10I", d, 8) + hdr_size = struct.unpack_from("= ra, + f"our ramdisk_addr {bb.BASE+bb.RAMDISK_OFF:#x} is below stock's {ra:#x}") + # Stock's layout leaves 16 MiB minus the 32 KiB kernel offset, so assert the + # room we actually have rather than a round number. + check(bb.RAMDISK_OFF - bb.KERNEL_OFF >= 16 * 1024 * 1024 - bb.KERNEL_OFF, + f"only {bb.RAMDISK_OFF - bb.KERNEL_OFF} bytes before the ramdisk") + check(tags == bb.BASE + bb.TAGS_OFF, f"tags_addr {tags:#x} != ours {bb.BASE+bb.TAGS_OFF:#x}") + check(ps == bb.PAGE, f"page size {ps} != ours {bb.PAGE}") + check(hv == bb.HDR_VERSION, f"header_version {hv} != ours {bb.HDR_VERSION}") + check(ss == 0, "stock uses a second stage; our packer assumes none") + check(hdr_size == bb.HDR_SIZE, f"header_size {hdr_size} != ours {bb.HDR_SIZE}") + print("stock geometry: matched field by field") +else: + print("stock geometry: SKIPPED (set BOOT_HEADER_REFERENCE to a private stock header)") + +# 2. pack a dummy image and read it back +with tempfile.TemporaryDirectory() as t: + t = Path(t) + kern = t / "Image.gz"; kern.write_bytes(gzip.compress(b"not really a kernel" * 500)) + # a minimal but valid FDT, so the appended-DTB check has something to find + dtb = t / "d.dtb" + body = b"\x00" * 56 + dtb.write_bytes(b"\xd0\x0d\xfe\xed" + struct.pack(">I", 64) + body) + rd = t / "initramfs.cpio.gz"; rd.write_bytes(gzip.compress(b"ramdisk" * 300)) + out = t / "images" + r = subprocess.run([sys.executable, str(HERE / "build-boot.py"), "--kernel", str(kern), + "--dtb", str(dtb), "--ramdisk", str(rd), "--out", str(out)], + capture_output=True, text=True) + check(r.returncode == 0, f"packer failed: {r.stderr.strip()}") + img = (out / "boot.img").read_bytes() + check(img[:8] == b"ANDROID!", "no magic") + check(len(img) % bb.PAGE == 0, "image is not page aligned") + kb = kern.read_bytes() + dtb.read_bytes() + check(struct.unpack_from(" Date: Mon, 2 Nov 2026 12:51:35 +0100 Subject: [PATCH 02/21] dipper: depend on bluez-utils for btmgmt --- packages/omamobile-device-dipper/PKGBUILD | 2 +- packages/omamobile-device-dipper/test/all | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-device-dipper/PKGBUILD b/packages/omamobile-device-dipper/PKGBUILD index fc08e422f..37e55a769 100644 --- a/packages/omamobile-device-dipper/PKGBUILD +++ b/packages/omamobile-device-dipper/PKGBUILD @@ -7,7 +7,7 @@ pkgdesc="Omarchy Mobile support for the Xiaomi Mi 8 (dipper)" arch=(aarch64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) -depends=(bash systemd omamobile-keyring qrtr pd-mapper tqftpserv rmtfs) +depends=(bash systemd bluez-utils omamobile-keyring qrtr pd-mapper tqftpserv rmtfs) provides=(omamobile-device) conflicts=(omamobile-device) backup=(etc/pacman.d/omamobile-mirrorlist) diff --git a/packages/omamobile-device-dipper/test/all b/packages/omamobile-device-dipper/test/all index 183508786..8f91f1b26 100755 --- a/packages/omamobile-device-dipper/test/all +++ b/packages/omamobile-device-dipper/test/all @@ -13,6 +13,10 @@ bash -n build || fail "build parses" bash -n install || fail "install parses" pass "scripts parse" +grep -q '^depends=.*bluez-utils' PKGBUILD \ + || fail "the identity service needs bluez-utils for btmgmt" +pass "the Bluetooth identity helper has btmgmt installed" + grep -q '\.\./\.\.' build install && fail "build or install reaches outside the package directory" pass "build and install stay inside the package directory" From c751e7184c7d3162bc93d3f7c2ac1e69053529bb Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 2 Nov 2026 14:16:58 +0100 Subject: [PATCH 03/21] dipper: build panel in and skip stale initramfs module --- device/dipper/kernel.config | 3 +++ tools/dipper/initramfs-inside.sh | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/device/dipper/kernel.config b/device/dipper/kernel.config index b7c5a5bd3..d31632625 100644 --- a/device/dipper/kernel.config +++ b/device/dipper/kernel.config @@ -24,6 +24,9 @@ CONFIG_TYPEC_QCOM_PMIC=y # Display: built in, so a console exists before any module is loaded. CONFIG_DRM_MSM=y +# The panel must be built in; the installed rootfs module is stale. +CONFIG_DRM=y +CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_DRM_PANEL_SAMSUNG_EA8074=y # Touch, so a working panel is usable without waiting for userspace. diff --git a/tools/dipper/initramfs-inside.sh b/tools/dipper/initramfs-inside.sh index 9da0893f7..464b0d6c4 100755 --- a/tools/dipper/initramfs-inside.sh +++ b/tools/dipper/initramfs-inside.sh @@ -50,13 +50,20 @@ depmod -b "$stage" "$KERNEL_RELEASE" # refuses a boot image that grows too large. Everything else belongs in the # root filesystem, not here. The pruner reads modules.dep and fails loudly # rather than silently emptying the tree. +modules=qcom_wdt +if grep -qF 'drivers/gpu/drm/panel/panel-samsung-ea8074.ko' \ + "$stage/usr/lib/modules/$KERNEL_RELEASE/modules.builtin"; then + : > "$stage/etc/omamobile-panel-built-in" +else + modules="$modules panel-samsung-ea8074" +fi python3 /src/tools/dipper/prune-modules.py \ - "$stage/usr/lib/modules/$KERNEL_RELEASE" qcom_wdt panel-samsung-ea8074 + "$stage/usr/lib/modules/$KERNEL_RELEASE" $modules depmod -b "$stage" "$KERNEL_RELEASE" # The modules the init loads must exist AND match this kernel exactly, or the # phone boots to a black screen with no watchdog taken over. -for module in qcom_wdt panel-samsung-ea8074; do +for module in $modules; do path=$(modinfo -b "$stage" -k "$KERNEL_RELEASE" -n "$module") [ "$(modinfo -F vermagic "$path" | cut -d ' ' -f1)" = "$KERNEL_RELEASE" ] || { echo "module $module does not match $KERNEL_RELEASE" >&2; exit 1; } @@ -76,7 +83,9 @@ modprobe qcom_wdt || echo "omamobile: qcom watchdog module failed" >/dev/kmsg if [ -c /dev/watchdog0 ]; then watchdog -t 5 -T 30 /dev/watchdog0 fi -modprobe panel-samsung-ea8074 || echo "omamobile: panel module failed" >/dev/kmsg +if [ ! -e /etc/omamobile-panel-built-in ]; then + modprobe panel-samsung-ea8074 || echo "omamobile: panel module failed" >/dev/kmsg +fi hostname omamobile ''') From 0b4a17e6ecd22f1724c182d7e0c218f89e54bdb0 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Sat, 7 Nov 2026 22:58:47 +0100 Subject: [PATCH 04/21] NOTES: keep Dipper stage-0 and first-light record --- AGENTS.md | 25 +- device/dipper/FLASH-RUNBOOK.md | 135 ----- device/dipper/HANDOFF.md | 39 -- device/dipper/NOTES.md | 14 - device/dipper/STATE.md | 392 ------------- device/dipper/WIFI-PLAN.md | 545 ------------------ device/dipper/device.conf | 33 -- device/dipper/kernel.config | 94 --- initramfs/init | 63 -- packages/mesa/.SRCINFO | 4 +- packages/mesa/PKGBUILD | 12 +- packages/mesa/README.md | 14 +- packages/omamobile-device-dipper/LICENSE | 21 - packages/omamobile-device-dipper/PKGBUILD | 27 - packages/omamobile-device-dipper/README.md | 19 - .../bin/omamobile-dipper-identity | 84 --- .../bin/omamobile-tailscale-join | 46 -- packages/omamobile-device-dipper/build | 8 - packages/omamobile-device-dipper/device.conf | 33 -- .../etc/omamobile-mirrorlist | 18 - .../etc/omamobile/tailscale.conf.example | 18 - packages/omamobile-device-dipper/install | 38 -- .../omamobile-device-dipper.install | 33 -- packages/omamobile-device-dipper/test/all | 110 ---- .../conf.d/10-omamobile-usb.conf | 5 - .../logind.conf.d/10-omamobile-power-key.conf | 7 - .../systemd/network/20-usb-gadget.network | 19 - .../system.conf.d/10-omamobile-watchdog.conf | 20 - .../system/omamobile-dipper-identity.service | 15 - .../system/omamobile-tailscale-join.service | 17 - .../udev/rules.d/10-omamobile-storage.rules | 10 - packages/omamobile-device-dipper/version | 1 - packages/pd-mapper/PKGBUILD | 31 - packages/qrtr/PKGBUILD | 31 - packages/rmtfs/PKGBUILD | 38 -- packages/rmtfs/udev.rules | 1 - packages/tqftpserv/PKGBUILD | 33 -- rootfs/build-inside | 22 +- tools/build-packages | 2 +- tools/build-rootfs | 9 +- tools/dipper/apply-identity | 65 --- tools/dipper/backup-stock | 70 --- tools/dipper/bringup-patch-init.py | 87 --- tools/dipper/build | 128 ---- tools/dipper/build-board-2.py | 124 ---- tools/dipper/build-boot.py | 153 ----- tools/dipper/extract-firmware | 56 -- tools/dipper/extract-identity | 71 --- .../dipper/identity/omamobile-dipper-identity | 84 --- .../omamobile-dipper-identity.service | 15 - tools/dipper/identity/test-identity.sh | 53 -- tools/dipper/initramfs-inside.sh | 140 ----- tools/dipper/pil-squash.py | 64 -- tools/dipper/prune-modules.py | 72 --- tools/dipper/push-verified | 78 --- tools/dipper/test-board-2.py | 63 -- tools/dipper/test-build-boot.py | 93 --- tools/phone-ssh | 3 +- 58 files changed, 20 insertions(+), 3485 deletions(-) delete mode 100644 device/dipper/FLASH-RUNBOOK.md delete mode 100644 device/dipper/HANDOFF.md delete mode 100644 device/dipper/STATE.md delete mode 100644 device/dipper/WIFI-PLAN.md delete mode 100644 device/dipper/device.conf delete mode 100644 device/dipper/kernel.config delete mode 100644 packages/omamobile-device-dipper/LICENSE delete mode 100644 packages/omamobile-device-dipper/PKGBUILD delete mode 100644 packages/omamobile-device-dipper/README.md delete mode 100755 packages/omamobile-device-dipper/bin/omamobile-dipper-identity delete mode 100755 packages/omamobile-device-dipper/bin/omamobile-tailscale-join delete mode 100755 packages/omamobile-device-dipper/build delete mode 100644 packages/omamobile-device-dipper/device.conf delete mode 100644 packages/omamobile-device-dipper/etc/omamobile-mirrorlist delete mode 100644 packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example delete mode 100755 packages/omamobile-device-dipper/install delete mode 100644 packages/omamobile-device-dipper/omamobile-device-dipper.install delete mode 100755 packages/omamobile-device-dipper/test/all delete mode 100644 packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf delete mode 100644 packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf delete mode 100644 packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network delete mode 100644 packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf delete mode 100644 packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service delete mode 100644 packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service delete mode 100644 packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules delete mode 100644 packages/omamobile-device-dipper/version delete mode 100644 packages/pd-mapper/PKGBUILD delete mode 100644 packages/qrtr/PKGBUILD delete mode 100644 packages/rmtfs/PKGBUILD delete mode 100644 packages/rmtfs/udev.rules delete mode 100644 packages/tqftpserv/PKGBUILD delete mode 100755 tools/dipper/apply-identity delete mode 100755 tools/dipper/backup-stock delete mode 100755 tools/dipper/bringup-patch-init.py delete mode 100755 tools/dipper/build delete mode 100755 tools/dipper/build-board-2.py delete mode 100755 tools/dipper/build-boot.py delete mode 100755 tools/dipper/extract-firmware delete mode 100755 tools/dipper/extract-identity delete mode 100755 tools/dipper/identity/omamobile-dipper-identity delete mode 100644 tools/dipper/identity/omamobile-dipper-identity.service delete mode 100755 tools/dipper/identity/test-identity.sh delete mode 100755 tools/dipper/initramfs-inside.sh delete mode 100755 tools/dipper/pil-squash.py delete mode 100755 tools/dipper/prune-modules.py delete mode 100755 tools/dipper/push-verified delete mode 100755 tools/dipper/test-board-2.py delete mode 100755 tools/dipper/test-build-boot.py diff --git a/AGENTS.md b/AGENTS.md index 23c8689bb..0d80253c1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,32 +7,9 @@ Omarchy Mobile runs native Omarchy (Arch Linux ARM, Hyprland, Omarchy's packages ## 1. Safety rules (non-negotiable) -### Xiaomi Mi 8 (`dipper`) exception - -`dipper` is non-A/B and has no stock slot to fall back to. This device-specific -rule overrides the A/B Pixel rules below. Do not use the shared -Pixel installer or unsuffixed flash flow. Follow [dipper STATE](device/dipper/STATE.md) -and [FLASH-RUNBOOK](device/dipper/FLASH-RUNBOOK.md). Never erase or format `userdata` -without a separate explicit decision: it contains Android's user data. Before modem, -Wi-Fi or other radio bring-up, verify the off-device stock backup and keep a live log; -do not enable a radio service or reboot the phone as part of a build task. - -For an unfinished Dipper session, read `device/dipper/HANDOFF.md`, -`device/dipper/STATE.md` and `device/dipper/WIFI-PLAN.md` before touching the -phone; they record the current hardware state and next safe step. Owner Wi-Fi -credentials stay in ignored local provisioning settings; never print, log, commit -or copy their values into an image. - -#### Dipper diagnostics over USB - -- Prefix host shell commands with `rtk`. Use `tools/phone-ssh --fresh -- ''` to test a new SSH session and collect phone state; check `systemctl`, `findmnt`, `/sys/class/drm/*/status`, `/proc/asound/cards`, and narrowly filtered `dmesg` output. Do not dump the full kernel command line, device identifiers or private partition contents. -- When SSH is down during an authorized RAM/NFS boot, inspect the host side first: `ip -brief link`, USB interface byte counters, `fastboot devices | wc -l` (never print device serials), and the disposable NFS root's journal with `sudo journalctl --directory=/var/log/journal -b`. If that boot's NFS trigger service is confirmed active, `/run-cmd` on the scratch root runs a host-staged script and writes `/run-cmd.out`; limit it to read-only status checks and verify the marker was consumed before relying on output. `/reboot-now` triggers an immediate forced reboot; use it only when a reboot is intended. -- Use `fastboot boot ` only for a RAM test after checking its hash. Never use `fastboot flash` or write to phone block devices during diagnostics. Keep the NFS export limited to the phone's USB network address and put all experimental rootfs changes under a host-side disposable scratch root. -- If a driver operation could interrupt USB or display, capture logs on the host and arm an automatic rollback/watchdog first. Prefer a clean RAM reboot over reloading display drivers after a failed attach. Confirm screen and sound physically; DRM connector state and ALSA card enumeration alone do not prove visible output or audible playback. - - **Ask the human before every reboot, flash, `push`, overlay boot or irreversible write.** That includes RPMB writes, a first `storageproxyd` run, `devinfo` and anything under `/dev/sd*`. The phone is real hardware with calibration data that can't be replaced, and a human has to be ready to recover it. - **The phone is shared with a human. Announce anything that affects the screen or the feel of the phone before you run it**: DPMS, display modes and refresh rate, brightness, `bl_power`, haptics, the torch, the shell restarting, rotation. Otherwise they think the phone is broken, or it buzzes in their hand. -- **On A/B Pixel devices, only slot B and `userdata` are ours.** Write only `boot_b`, `init_boot_b`, `vendor_boot_b`, `vendor_kernel_boot_b` and `dtbo_b`, and only through `bin/omamobile flash|push`. Never touch bootloader, radio, `devinfo`, `persist`, `efs*`, `modem*` or `vbmeta`, and never run an unsuffixed `fastboot flash`, with one exception: `userdata`, and only through `tools/install-phone` (serial pinned, codename typed, allowlist, dry run first). Slot A's stock Android is the way back. +- **Only slot B and `userdata` are ours.** Write only `boot_b`, `init_boot_b`, `vendor_boot_b`, `vendor_kernel_boot_b` and `dtbo_b`, and only through `bin/omamobile flash|push`. Never touch bootloader, radio, `devinfo`, `persist`, `efs*`, `modem*` or `vbmeta`, and never run an unsuffixed `fastboot flash`, with one exception: `userdata`, and only through `tools/install-phone` (serial pinned, codename typed, allowlist, dry run first). Slot A's stock Android is the way back. - **Qualcomm A/B phones (Pixel 4 family) keep the slot flags in GPT attributes,** so slot B can only be marked bootable by writing the partition table. That write is a narrow, named exception, never automatic: by hand, once per install of slot B's boot image, and only for a device whose entry in [CONTRIBUTING](CONTRIBUTING.md) §3.1 names the LUN, the four sectors (LBAs 1, 2, last-1 and last), the attribute bit and the CRCs it rewrites. That device's plan must also record the slot flags before and after, the rollback for a corrupted GPT, and the way back: stock restored on slot A first, or the owner's explicit acceptance of buttons-only recovery. The storage guard can't block this write, so it never runs from a service or at boot. - **Never weaken the storage guard.** Don't `blockdev --setrw` a partition or recreate `/dev/sda`. Don't mount Android partitions read-write, and don't add names to the `UFS_RW` allowlist without the human's say-so. The guard is what keeps a bad command from erasing the IMEI. - **Check backups before radio, PMIC, AoC or Trusty work.** Run the checksum check of `efs`, `efs_backup`, `modem_userdata`, `persist` and `modem_a/b` against the off-repo backup first ([MODEM-PLAN.md](device/cheetah/MODEM-PLAN.md) M0.1). If there's no backup, stop. Find each partition by `PARTNAME` in `/sys/class/block/*/uevent`: the Arch root has no `/dev/disk/by-partlabel`. **Take a fresh read-only backup after any stock Android boot** (a slot A fallback counts): stock's modem stack writes `efs`, `persist` and `modem_userdata`, so the old checksums stop matching and the next check can't tell a change of ours from stock's. diff --git a/device/dipper/FLASH-RUNBOOK.md b/device/dipper/FLASH-RUNBOOK.md deleted file mode 100644 index 9db7b8209..000000000 --- a/device/dipper/FLASH-RUNBOOK.md +++ /dev/null @@ -1,135 +0,0 @@ - -# dipper (Xiaomi Mi 8) — first-light runbook - -**Read §0 first. dipper is not a Pixel and the shared safety model does not apply to it.** - -## 0. Why this device needs its own runbook - -The project's safety model is "stock Android stays on slot A, we only ever write slot B". -**dipper has no second OS slot.** Measured on the phone: one `boot` (64 MiB), one -`recovery` (64 MiB), one `system`, one `vendor`, one `userdata` (113 GiB). Only the -bootloader chain is slotted (`xbl`, `abl`, `tz`, `hyp`, `aop`, `cmnlib`, `devcfg`, -`keymaster`, `qupfw`, `storsec`), and this port never writes any of it. - -Consequences, stated plainly: - -- **A bad `boot` image means a bootloop with nothing to fall back to.** The way out is - physical: power off, hold **Volume Down + Power** until "FASTBOOT" appears, then - `fastboot flash boot boot.img` with the stock image from the backup. -- **`fastboot` is USB-only.** There is no fastboot over a network. Tailscale and SSH - reach the *running* phone; they are not a recovery path. **Do not attempt any of - this without the phone in hand and a cable.** -- So: **step 2 below boots from RAM and writes nothing.** Do not flash until that has - worked. - -## 1. Before anything: a verified stock backup - -```sh -tools/dipper/backup-stock # boot, recovery, dtbo, vbmeta, persist, - # modemst1/2, fsg, fsc, devinfo, misc, frp, - # logo, splash (~460 MiB) -tools/dipper/backup-stock --with-firmware # adds modem (192 MiB) and dsp (32 MiB) -``` - -It reads each partition over SSH and compares a `sha256sum` taken **on the phone** -against one taken locally; a mismatch deletes the file and fails the run. Keep the -output and checksums in an operator-controlled backup location outside the repository. - -`persist` and `modemst1`/`modemst2` hold per-device calibration and the modem's NV. -They cannot be downloaded from anywhere. Keep this backup even if you never flash. - -## 2. Build, then boot from RAM — nothing is written - -```sh -# kernel (once): mainline 7.3-rc6 tree + our fragment -make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j"$(nproc)" Image.gz dtbs modules -make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- qcom/sdm845-xiaomi-dipper.dtb - -# initramfs (aarch64 container) + the Android v1 boot image -tools/dipper/build - -# full Arch/Omarchy root image (keep the signed source packages and local key private) -tools/fetch-published out/dipper/published -tools/build-packages --local dipper --import out/dipper/published \ - packages/qrtr packages/pd-mapper packages/tqftpserv packages/rmtfs \ - packages/omamobile-device-dipper -KERNEL_OUT=../out/dipper DEVICE=dipper tools/build-rootfs --local dipper -``` - -The host needs `zopfli` for the smaller kernel gzip stream that fits dipper's ABL -limit; `tools/dipper/build` uses it when available and `build-boot.py` refuses an -oversized kernel. The build also stages the private modem/WLAN firmware and the -module archive under `out/dipper/` for the root image. - -Then, phone powered off, **Volume Down + Power** until "FASTBOOT" shows: - -```sh -fastboot getvar unlocked # must say yes. Android's props on this phone are - # spoofed and cannot be trusted for this. -fastboot boot out/dipper/images/boot.img -``` - -`fastboot boot` runs the image from RAM. **It does not touch `boot`.** A power cycle -returns the phone to stock, whatever happens. This is the only step that is safe to -repeat freely, so iterate here. - -What success looks like: a USB network device appears on the laptop -(`Xiaomi Mi 8 Omarchy`, CDC NCM plus an ACM console), and - -```sh -tools/phone-ssh --fresh -- 'id' -``` - -gets a shell from the initramfs. The rescue sshd is bound to `172.16.42.1` only — -never to Wi-Fi. There is no display yet at this stage: the console is the USB link. - -If nothing appears: the ACM console (`/dev/ttyACM0`, 115200) carries the kernel log. -If not even that, the kernel did not reach the initramfs; power-cycle and read §4. - -## 3. Only then: flash - -Do not do this until §2 has booted and you have §1's backup verified. - -```sh -fastboot flash boot out/dipper/images/boot.img -fastboot reboot -``` - -To go back to stock at any time: - -```sh -fastboot flash boot "$VERIFIED_STOCK_BOOT_IMAGE" -``` - -Set `VERIFIED_STOCK_BOOT_IMAGE` to the checksum-verified stock image in the -private backup before running the recovery command. - -**Never flash** `xbl*`, `abl*`, `tz*`, `hyp*`, `aop*`, `cmnlib*`, `devcfg*`, -`keymaster*`, `qupfw*`, `storsec*`, `modem`, `modemst1`, `modemst2`, `fsg`, `persist`, -`vbmeta` or `devinfo`. Nothing in this port needs them, and several of them are -unrecoverable per-device data. - -`userdata` is not touched by any step above. Installing a full Omarchy root later -**erases it**, which also removes stock Android's data — that is a separate decision, -not part of first light. - -## 4. Known unknowns at first light - -- **Touch** is an ST FTS5 controller (`st,fts` downstream, `fts@49` on `i2c14`). The - DTS uses `st,stmfts5` and the kernel carries upstream's FTS5 driver and controller-ready - wait fix, whose series was tested on Mi 8. On the updated RAM boot, the driver bound and - a physical tap produced `ABS_MT_POSITION_X`, confirming basic touch input. Full - coordinate/gesture coverage is open; firmware loading, low-power touch and wake-on-touch - are not implemented. -- **Display.** The panel is Samsung EA8074 in **command mode** (the stock kernel's - `dsi_ss_ea8074_notch_fhd_cmd_display`, and `qcom,mdss-dsi-panel-type = "dsi_cmd_mode"` - in the stock tree), but the recovered panel driver sets `MIPI_DSI_MODE_VIDEO_BURST`. - That mismatch is left exactly as its author wrote it, because changing untested - timing blind is worse than reporting it. Expect the display to need work. -- **Sound** will not probe: the DTS asks for `ti,tas2559`, whose driver exists only in - the `sdm845-mainline` fork, not upstream. -- **Modem/Wi-Fi, cameras, fingerprint (Goodix), suspend**: not yet tested on mainline. -- The shared initramfs crashes deliberately after 20 s with no USB host, expecting ABL - to fall back to slot A. **On dipper there is no slot A**, so that path just reboots - into the same image. With `fastboot boot` this is harmless; after flashing it is a - bootloop, exited with Volume Down + Power. diff --git a/device/dipper/HANDOFF.md b/device/dipper/HANDOFF.md deleted file mode 100644 index 0ce59aa69..000000000 --- a/device/dipper/HANDOFF.md +++ /dev/null @@ -1,39 +0,0 @@ - -# Handoff: Omarchy Mobile on Xiaomi Mi 8 - -Read STATE.md, ../../AGENTS.md, NOTES.md, FLASH-RUNBOOK.md and WIFI-PLAN.md. -The repository-root PORTING-PLAN.md is a historical discovery log. - -## Pick up here - -Last checked 2026-11-02: Omarchy is running on the phone, and the owner has -confirmed that the display is visible. A fresh USB SSH connection through -tools/phone-ssh --fresh succeeded and sshd is active. The display is exposed as -DSI-1 (405x843 in the current Wayland session). A VNC protocol handshake -succeeded, but rendering and remote input through a user's client have not -been checked. - -This repository intentionally contains no owner SSID, LAN address, SSH alias, -SSH key path, password, token, or private backup path. No reboot, flash or -partition write was performed during the 2026-11-02 remote-access checks. -Audio playback, sensors and 3D acceleration still need separate verification; -do not infer them from device enumeration alone. - -## Next work - -1. Keep device support changes in this repository and submit kernel drivers, - bindings and DTS changes to the kernel repository as separate subsystem - branches, following CONTRIBUTING.md. -2. Run the repository checks and the read-only phone smoke test before opening - a pull request. Record only results, never captures or device identifiers. -3. Continue audio, sensor and GPU validation only from the corresponding - gated plans, with the verified stock backup available before radio work. - -## Stop conditions - -- Do not erase or format userdata, or use the shared Pixel installer. -- Do not flash the boot image without a separate explicit decision and the - phone physically available for recovery. -- Stop radio work if the off-device stock backup cannot be checksum-verified, - if read-only partition protection is not confirmed, or if live logging and - SSH recovery are lost. diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index b197683b6..25de7b33c 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -43,20 +43,6 @@ and Wi-Fi keys; quoted here are the facts, never the files. **Buttons** `qpnp_pon` plus `gpio-keys`. - **UFS** host at `1d84000.ufshc`. Stock `system` is dm-verity over the `system` partition. -## Prior art this port builds on - -`sdm845-mainline/linux` **MR !71** ("Add sdm845-xiaomi-dipper", Jun 2023) is **closed, never -merged**, and its branch is deleted; the dipper DTS is in no live branch of that tree. Of its -97 commits only three are dipper-specific — the board DTS + `dipper-common.dtsi`, a -purpose-written `panel-samsung-ea8074.c`, and the config switch. They are recovered and kept -outside this repo. The other 94 were that tree's whole SDM845 stack rebased in, which is the -likely reason it was closed, and most of it has landed there since. - -Against the live DT the DTS is right about the touch bus (`i2c14`) and both GPIOs (31, 32) -and wrong about the controller: it says `focaltech,ea8074` at `0x38`, i.e. the panel's name -and another vendor's address. That is the evidenced reason postmarketOS lists dipper's -touchscreen as broken. - ## 2026-10-29 — first light, and what the hardware said **The phone boots mainline and gives a shell.** `fastboot boot` of our image, kernel diff --git a/device/dipper/STATE.md b/device/dipper/STATE.md deleted file mode 100644 index 58644d7eb..000000000 --- a/device/dipper/STATE.md +++ /dev/null @@ -1,392 +0,0 @@ - -# Xiaomi Mi 8 port state - -Last updated: 2026-11-02. Older discovery notes below are historical where they -conflict with this summary. - -Latest live state (2026-11-02): -- Omarchy is running; the owner confirmed the physical display is visible. -- A fresh USB SSH connection through tools/phone-ssh --fresh succeeded and - sshd is active. -- The current Wayland output is DSI-1 (405x843). A VNC RFB 3.8 handshake - succeeded; the viewer's rendered image and remote input remain unverified. -- SSID, LAN address, SSH aliases and key paths, credentials and private backup - paths are intentionally omitted from this repository. -- No reboot, flash or partition write was performed during the latest - remote-access checks. Audio playback, sensors and 3D acceleration remain - unverified. - -## Device and safety - -- Xiaomi Mi 8 (`dipper`), Snapdragon 845, non-A/B OS layout. There is one `boot` - and one `userdata`; installing Arch to `userdata` erases Android user data. -- Android was reachable over ADB; Tailscale reconnected after its app was - opened once. A fresh backup passed all 15 device/source hash checks at - `private off-device reference directory (path omitted)/`. - A later RAM-rescue modem/Wi-Fi attempt ended with remoteproc `crashed` and - recovery disabled. On 2026-10-31 the owner authorized one RAM-only boot of - `/tmp/mi8-panel-nfs-image/images/boot.img` (SHA-256 - `9185f790896fb77bf5cedcfff745aa90a3bbf4477a4a82c424e5777caf74ac8c`). The - phone mounted the exported scratch root; systemd eventually reached SDDM. - SSH accepted the root key. `pam_systemd` first timed out waiting for the root - user manager; later short commands succeeded, then SSH stopped accepting - connections while USB remained enumerated. No partition was written. -- Mainline kernel/initramfs previously reached first light through RAM boot: - UFS/ext4, USB NCM and rescue SSH worked; storage guard allowed only `userdata`. - No persistent boot/rootfs install has been performed by this work. -- The owner authorized an attended Wi-Fi bring-up attempt and one clean RAM boot - of the revised image. Do not restart the crashed modem in place and do not - flash any partition. Do not use the shared Pixel installer for this non-A/B - device. - -## Current implementation - -- Kernel source is `../../../linux` (workspace `linux/`), branch has existing - user changes; preserve them. Current release string: - `7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty`. -- `CONFIG_TOUCHSCREEN_STMFTS=y`; DTS uses `st,stmfts5`. Upstream FTS5 support, - including the controller-ready wait fix, is present and compiled in `linux/`. - The RAM-booted kernel registered `stmfts` as `/dev/input/event1` on the - handset. A confirmed physical tap produced an `EV_ABS` `ABS_MT_POSITION_X` - event, so basic touch input works. Full coordinate/gesture coverage is not - done. Firmware loading and low-power/wake touch are out of scope for this - driver series. -- Rootfs builder now consumes `ROOTFS_DIST_PACKAGES`, stages - `out/dipper/firmware/{qcom,ath10k}`, and fails for dipper if the proprietary - firmware is absent. The four Qualcomm IPC packages have PKGBUILDs under - `packages/{qrtr,pd-mapper,tqftpserv,rmtfs}` and are listed for the dipper rootfs. -- The current boot-image revision RAM-booted on 2026-10-30 and confirmed USB - rescue SSH, visible console text and FTS5 touch input. It used Zopfli because - the regular gzip kernel exceeds ABL's kernel limit. The current image revision - and its untested status are recorded below. -- Rebuilt `out/dipper/images/boot.img` after adding the read-only-checked `fsc` - link. SHA-256 is `42b51401d98ac587f04f33aebd8ab92201c5069da216c74a42aa4e23748975c4`; - the 25,432,064-byte image fits the 64 MiB partition with 41,676,800 bytes of - headroom. It has been RAM-booted successfully. -- `out/dipper/modules-.tar.zst` is staged for rootfs. All four Qualcomm - aarch64 packages and `omamobile-device-dipper` built and were signed into the - local repo; the device package's 12 native checks passed. The 38 published - Omarchy Mobile packages were fetched with signature/hash verification and - imported. The first full-rootfs attempt failed in pacstrap while checking - three local package checksums. Their archive SHA-256 values matched the repo - database; the retry completed successfully. The rootfs image is - `omarchy-mobile/out/dipper/omamobile-rootfs-2026.10.29-dipper-aarch64.img.zst` - (3.1 GiB compressed; 9,580 MiB used in a 12 GiB ext4 filesystem). Its - checksum verifies, the manifest includes all four Qualcomm daemons, the - dipper package and the Qualcomm/Atheros firmware packages, and all 11 - `tests/rootfs-smoke` checks passed. Firmware was copied from the private - device extraction at build time; it is not tracked. -- No modem/Wi-Fi service is enabled automatically. Several attended modem - starts under mainline have crashed. Use - `device/dipper/WIFI-PLAN.md` before another attended attempt. -- The boot reached rescue SSH over USB NCM. A later NFS-root Omarchy session - also reached Hyprland and Quickshell; see the display attempt below. The - physical panel still did not show the desktop reliably. -- Wi-Fi driver loading was attempted, but no WLAN interface or scan appeared. - The rescue initramfs lacks Qualcomm - daemons, firmware and radio modules. A temporary host NFS export of a - disposable rootfs copy was mounted read-write at `the host-side scratch mount` over USB; only - this scratch copy was writable, not the compressed image or phone storage. - The NFS client is currently disconnected. The host copy remains at - `the disposable host-side NFS root`. - Loading `qcom_q6v5_mss` first failed because the PDC reset provider was absent; - after `reset_qcom_pdc` was loaded, remoteproc registered offline. On - 2026-10-30 `rmtfs -v -r -P -s` started the modem with all five NV links - verified read-only. QRTR WLAN service 69 appeared. On the MCFG retry, both - MCFG files were served and WLAN DSP firmware was fetched, but the modem - crashed with `modem_xpu_int.c:456:XPU violation End`. Recovery was disabled. - Timed from `wifi-20261030-mcfg-ath10k-crash-dmesg.log`, the modem came up at - t=160.5 s and stayed healthy for 137 s; `cfg80211` loaded at t=297.53 s (the - ath10k module insertion pulling in mac80211/cfg80211) and the XPU violation - arrived at t=297.89 s, 0.36 s later. So the trigger is the ath10k_snoc QMI - handshake, not modem boot or MCFG. That log contains no ath10k lines at all: - the capture ended with the phone, so the `CONFIG_ATH10K_DEBUG` output that - was built for this run was never obtained. Next attempt must stream the log - off-device, or read it back from pstore, before the module is inserted. TFTP logs - The `rmtfs` log's rejected `/boot/modem_fsg_oem_1` and `_2` requests are benign: - dipper has no `fsg_oem*` partition and stock `/vendor/bin/rmt_storage` knows only - `/boot/modem_fs1`, `/boot/modem_fs2`, `/boot/modem_fsc` and `/boot/modem_fsg`, so - stock refuses them identically. Do not alias them. TFTP logs - showed two modem MCFG files missing from staged firmware on the earlier run; - the matching files are now in the private firmware and scratch rootfs, and - `tools/dipper/extract-firmware` stages them for future builds. A private - capture is at `private off-device reference directory (path omitted)`. - Older kmsg captures show automatic recovery - loops reaching crash counters 1–6 and 1–5; the kernel defaults recovery to - enabled. Disable and verify recovery while remoteproc is offline before any - future single start. Do not retry in place. `ath10k_snoc` was - loaded on the latest attempt but no WLAN interface, scan or association - occurred. NV partitions remained - read-only. The `rmtfs` log showed the rescue initramfs lacks - `/dev/disk/by-partlabel` links; the first attempt missed `modemst1`, and the - second missed `fsc`. Every temporary target is verified read-only. A fresh - 15-partition snapshot matching the phone before RAM boot is at - `private off-device reference directory (path omitted)/`; it does - not include `userdata`, Android system/vendor, or the separately extracted - firmware. A private live kernel log runs outside the repository. - Host NFS service is disabled at boot and serves only the USB client. The - scratch rootfs WCN3990 `board-2.bin` matches the staged corrected file - (SHA-256 `81b0f78adcf995e93d789daf8691254ff745d53f843a4c5c7d2549cfc15f8a36`); - the compressed rootfs image has not yet been rebuilt with it. -- Owner Wi-Fi credentials stay in ignored local provisioning settings; do not include their values in this public handoff. Use it without echoing values; never copy credentials into - tracked files or logs. No Tailscale auth token was found in that file or the - searched Claude/provision history. - -## Session of 2026-10-30 (late): Tailscale fixed, Wi-Fi diagnosed - -- **Tailscale now starts by itself** and is confirmed three times (two warm - reboots and one cold power-cycle): `settings put secure always_on_vpn_app - com.tailscale.ipn`, `always_on_vpn_lockdown 0` (deliberately off, so a - Tailscale failure cannot cut the phone off), plus the package added to the - doze whitelist. After the cold power-cycle the peer came up **with no USB - attached at all**, direct to its LAN address, so it no longer needs the app - opened by hand. -- `tools/dipper/backup-stock` gained an adb transport (`TRANSPORT=auto|adb|ssh`, - `adb exec-out` so the `dd` pipe stays binary). It needs no SimpleSSHD or - Tailscale now, and `adb root` already gives uid 0. -- A verified snapshot of all 15 partitions was taken before the radio runs. After - them, everything we could have damaged -- `boot`, `recovery`, `dtbo`, `vbmeta`, - `fsc`, `devinfo`, `misc`, `logo`, `splash`, `persistbak`, `modemst2`, `fsg` -- - was byte-identical. Only `persist`, `modemst1` and `frp` changed, which stock - Android rewrites on every boot; our runs held all five NV partitions at `ro=1` - before and after, so a write from our side was not possible. -- Four attended RAM boots diagnosed the Wi-Fi failure down to the SDM845 XPU - erratum that ath10k already works around with a fixed `msleep(20)` tuned to one - MPSS build. dipper runs a different build. `qmi.c` now takes that delay from a - module parameter (`ath10k_snoc msa_perm_delay_ms`, default 20). Our board data - and the WCN3990 supply map are both cleared by evidence. Full write-up, the - cleared-suspect table and the gated next run are in `WIFI-PLAN.md`. -- The `msa_perm_delay_ms=300` run is **prepared but not yet performed**. - -### Current blocker - -The phone is in Android and reachable over Wi-Fi and Tailscale, but it is **not -on USB data**: `lsusb` shows no phone and `adb` lists none. SimpleSSHD answers on -port 2222 with the project key, but only as an unprivileged app -(`untrusted_app_29`), and `fastboot` cannot be driven over the network. The next -run needs the USB data connection restored -- a data-capable cable and port, not -a charge-only one. - -Note the last run ended with the phone failing to return from `reboot -f` on its -own; it needed a physical power-cycle. Prefer `adb reboot` from Android, and -expect a RAM boot with a crashed modem to need the button. - -## Wi-Fi works (2026-10-30) - -On a RAM boot, nothing flashed, NV read-only throughout: `wlan0` associated to the -owner's AP on 2.4 GHz (`wpa_state=COMPLETED`, -59 dBm), took a DHCP lease, got a -default route and reached the internet (`ping 1.1.1.1` 3/3, 16 ms). The modem -stayed `running`. Three things were needed, all recorded in `WIFI-PLAN.md`: - -1. `ath10k_snoc msa_perm_delay_ms=300` -- the upstream 20 ms XPU-settling sleep is - tuned to a different MPSS build than dipper's. -2. Gate the ath10k load on QRTR service 69. Loading before the modem publishes it - is what looked like flakiness; it cost the modem every time. -3. `ath user_regd=1` + `iw reg set SK` -- the calibration reports CN and ath - applied it as a strict custom per-phy domain, so the global domain was ignored. - -**DFS channels do not work.** The owner's 5 GHz AP is on channel 104, a DFS -channel. Scanning it works and the firmware returns valid noise floors, but -`vdev start` crashes the closed WLAN firmware after 52 ms, every time, with -`CONFIG_ATH10K_DFS_CERTIFIED=y` included. The same crash is reported on a -OnePlus 6T (same SoC and radio) with no upstream fix. Non-DFS and permitted here: -2.4 GHz, UNII-1 (36-48) and UNII-3 (149-165). Moving the AP's 5 GHz radio to -36-48 is the practical route to 5 GHz and is **untested**. - -## Omarchy boots on the phone, from NFS (2026-10-30) - -`initramfs/init` gained `boot_nfs()`, gated on `/etc/omamobile-nfsroot` existing -(the same file-presence idiom the init already uses for `omamobile-compatible` -and `omamobile-ufs-rw`), so no device changes behaviour without that file. -`tools/dipper/build` takes `DIPPER_NFSROOT=:` and writes it. -`CONFIG_ROOT_NFS` and `NFS_FS` are `=y`, so no module is needed. **Nothing is -written to the phone and `userdata` is untouched** -- the root filesystem is -served from the host over the USB link. - -Confirmed working: `switch_root` into the Arch root, systemd as PID 1, journald, -udev, sysctl and vconsole all starting, the NFS root in active use (an -established connection from the phone to the host's port 2049), and -systemd-networkd giving `usb0` its address (the host resolves 172.16.42.1 by ARP -and pings it). - -### Omarchy display attempts (2026-10-30 and 31) - -Captured over USB SSH: Hyprland first failed EGL initialization because this -Mesa build had no `msm_dri.so`. The rootfs does contain Zink and Turnip, so -`MESA_LOADER_DRIVER_OVERRIDE=zink` and -`__GLX_VENDOR_LIBRARY_NAME=mesa` were added to -`/etc/environment.d/90-zink-turnip.conf` and the Zink override to -`/home//.config/uwsm/env`; SDDM was restarted. Hyprland then reported -`zink Vulkan 1.3 (Turnip Adreno 630)`, stayed up, and launched Quickshell. - -The panel still failed on a later modeset: `Failed to exit sleep mode: -22`, -followed by `fb=0` on the CRTC. The EA8074 panel bridge did not request its DSI -host to pre-enable first. The kernel source now sets -`ctx->panel.prepare_prev_first = true` for this command-mode panel. The panel -object and `.ko` compile with the saved dipper config. The rebuilt `.ko` is -staged in `the disposable host-side NFS root/usr/lib/modules//.../panel-samsung-ea8074.ko`; -its vermagic matches the current -`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` kernel. Its module was included -in the 2026-10-31 RAM boot, but the run did not reach a panel modeset, so this -change is not hardware-validated. - -The scratch root's previous SDDM logs (19:34-19:37) show its Wayland greeter -found a socket but Mesa/Zink failed `vkEnumeratePhysicalDevices` with -`VK_ERROR_INITIALIZATION_FAILED`, then failed to choose a Vulkan device and -create a DRI2 screen. The expected Zink/Turnip overrides from the earlier -successful session were absent from this scratch root's `/etc/environment.d` -and the desktop user's UWSM environment. This is a likely userspace cause of -the black desktop in this root; the earlier panel `-22` is a separate display -issue. - -This scratch root is an unprovisioned build image: `/home` is empty, there is -no non-system account in `/etc/passwd`, and `/etc/omamobile/firstboot.conf` is -absent. The firstboot unit therefore did not create the desktop account. In -the 2026-10-31 run, SDDM started at about 307 s and Hyprland created the -greeter's Wayland socket by 366 s, but no desktop-user session or Quickshell -started. This run cannot confirm a usable Omarchy login until the normal -firstboot account setup is supplied. - -In the 2026-10-31 RAM boot, kernel journal recorded simpledrm `fb0`, then a -`qcom_wled` warning at about 187 s: `wled_ovp_work` called `enable_irq()` and -hit `__enable_irq`'s warning path. It was non-fatal: systemd continued and SDDM -started later; no later EA8074 modeset error is recorded. Runtime DRM exposed -only `card0` from simpledrm (`Unknown-1`), with no MSM/DPU/DSI KMS card; the -kernel also logged `aux_bridge ... failed to acquire drm_bridge`. The source -DTS enables `&mdss` and `&mdss_dsi0`, so the mismatch between the booted tree and -the absent runtime DRM device remains open. - -At about 742 s SDDM's Wayland greeter logged Zink's -`vkEnumeratePhysicalDevices` failure and `failed to create dri2 screen`, then -still added a view for `Unknown-1`. This reproduces the missing Vulkan path in -the scratch root; the Zink/Turnip environment overrides are absent. Systemd -eventually reported `running`, with SDDM and sshd active. SSH root-key auth -worked once the root user manager started, but an earlier connection timed out -in `pam_systemd` while `user@0.service` was still starting. Systemd also timed -out waiting for `/dev/ttyGS0`, so the serial getty escape hatch did not start. -USB ping remains intermittent. The host log is in -`the disposable host-side NFS root/var/log/journal`. - -At ~1,090 s, a root SSH command loaded the existing `msm.ko` successfully. -Sysfs then showed the MDSS, DPU and DSI platform devices bound to `msm-mdss`, -`msm_dpu` and `msm_dsi`, but `/sys/class/drm` still exposed only simpledrm. -The live device tree reports the SDM845 display nodes and EA8074 panel enabled; -the failure is therefore later in DSI component/bridge registration, not a -missing DT status or an unloaded module. Extracting the exact `Image.gz-dtb` -from the boot image independently confirmed `status = "okay"` on the MDSS, -DSI and EA8074 nodes, and the DPU-to-DSI and DSI-to-panel graph endpoints are -connected. ALSA still reported no soundcards. ADSP had booted and WCD934x -returned its chip ID; the DTS has a TAS2559 DAI link, while this kernel tree -has no TAS2559 driver or staged TAS2559 firmware. - -A root-only `pam_systemd` bypass was staged in the scratch NFS root after -repeated root user-manager teardown timeouts. Later NFS-root SSH logs confirmed -root sessions opened with the bypass. Its original PAM file is backed up at -`the disposable host-side NFS root/root/system-login.pre-root-ssh-test`. The read-only NFS -control channel subsequently ran several diagnostics and a runtime SSH start; -no request marker remains. The five-second `/dev/ttyACM0` capture produced no -serial output. The stable system has since returned to its existing ext4 boot, -with USB SSH and the DSI Hyprland monitor verified. - -#### Gated RAM-boot test - -1. The image `/tmp/mi8-panel-nfs-image/images/boot.img` was RAM-booted on - 2026-10-31 after fastboot reported `product: dipper`, `unlocked: yes`. - NFS mounted; no partition was written. -2. This run reached SDDM and Hyprland's Wayland socket, but had no provisioned - desktop account. Runtime DRM exposed only simpledrm; SDDM also logged the - Zink Vulkan failure. Manually loading `msm` bound MDSS/DPU/DSI but still did - not register an MSM DRM card. ALSA exposed no soundcard. The `qcom_wled` - warning at ~187 s was non-fatal; the panel change remains unverified and no - user session was available. -3. On a separately authorized next boot, capture serial and USB logs before - boot, confirm the exact image/hash and restricted NFS export, then check - `dmesg` for DSI component/bridge registration, DRM state, and ALSA cards over - SSH. Pass only when the error is absent, the panel is visible, and sound is - audible from a working route. - -Stop on a repeated `-22`, a black panel, or loss of the USB console. The test is -RAM-only; do not flash. Risk: moderate; this latest test temporarily left the -phone unresponsive and required physical recovery, but did not change its -partitions. - -### What it took, and the traps - -1. **The hardware watchdog must be handed over to systemd.** SDM845 leaves its - watchdogs *running* -- `watchdog0: watchdog did not stop!` -- and the - initramfs daemon that pets it dies with everything else at `switch_root`. The - first boot reached "Started Journal Service" and died at - `watchdog0: pretimeout event`, 34 s in. Fixed by a new - `vendor/systemd/system.conf.d/10-omamobile-watchdog.conf` in the dipper - package. `RuntimeWatchdogSec=10s` was **not enough**: systemd programs that - as the *hardware* timeout and pings at half of it, and a first boot spends - about 8 s inside "Applying preset policy", so the pretimeout fired again at - 17 s. 30 s was still not enough on a cold NFS boot (died at 37 s). **60 s - works.** -2. `/etc/machine-id` shipped as `uninitialized`, which makes systemd run - `preset-all` on first boot -- slow on NFS and the cause of trap 1's second - failure. Writing a real id removes that stall. -3. **The image has no SSH host keys**, so `sshd` cannot start and the phone boots - with no way in. Generated with `ssh-keygen -A -f `. This is why the - first good boot was unreachable despite being healthy. -4. `systemd-pstore` consumes `/sys/fs/pstore` on boot, which eats the ramoops - console log before it can be read. Mask it while bringing up. -5. The journal is useless for a boot that dies: systemd preallocates 8 MiB and - flushes almost nothing, so `ramoops` remains the only record. - -### Escape hatches added, because there was none - -A healthy phone with no `sshd` has no channel at all -- no adb (that is Android's -daemon and goes with it), no fastboot (that is the bootloader), no console. Both -of these are now staged in the scratch rootfs: - -- `serial-getty@ttyGS0` with an autologin drop-in. The initramfs already creates - `acm.GS0` and the host sees `/dev/ttyACM0`; there was simply no getty on it, - and root's password hash is `!*` so a plain getty would refuse anyway. -- `omamobile-nfs-trigger.timer`, polling the NFS-served root for a `/reboot-now` - file. The root is writable from the host, so it doubles as a control channel. - -Withdrawing the NFS export does **not** force a reset: systemd keeps petting the -watchdog from memory, so the phone hangs rather than rebooting. - -### Still to verify on the next boot - -A shell in Omarchy (host keys are now in place), then whether -`omamobile-wlan.service` brings Wi-Fi up by itself. The radio pieces are staged: -`modprobe.d` with `msa_perm_delay_ms=300`, `user_regd=1` and `ath10k_snoc` -blacklisted; the gated bring-up unit; `wireless-regdom` SK; the IPC chain -enabled; and a NetworkManager profile for the 2.4 GHz band. - -Only the watchdog file has been moved into the dipper package so far. The rest -lives in the disposable scratch rootfs and still needs a proper home. - -## Next steps - -1. Restore a physical USB data connection and identify the phone's current - mode before sending device commands. If Android has booted since the saved - snapshot, capture and verify a fresh off-device read-only backup before - radio work. Continue with RAM boot only; do not flash. -2. Verify completion and exit status of the diagnostic kernel/image build. - Verified 2026-10-30: the build completed and debug ath10k modules exist under - `out/dipper/modules/lib/modules//.../ath10k/`. There is **no** saved - original `linux/.config` — `.config.old` is an unrelated kconfig artefact - (6017 differing lines), not a pre-debug backup. The only recorded diagnostic - change is `CONFIG_ATH10K_DEBUG=y`, so "restoring" means unsetting that one - symbol; leave it on until the XPU violation is diagnosed. Still to do: copy - the debug ath10k modules into the disposable NFS scratch rootfs. -3. Review private logs under - `private off-device reference directory (path omitted)*` before deciding - whether another attended radio attempt is justified. Do not restart a - crashed modem in place. Keep NV links read-only, recovery disabled, and a - private live log active. -4. The earlier NFS scratch boot exposed only simpledrm and deferred DSI on the - IBB regulator, but the current stable boot exposes a connected 1080x2248 - DSI monitor with Hyprland and Quickshell active. Physical panel visibility - was not directly observed. Audio is still incomplete: the current sound - card probe defers on the missing TAS2559 DAI; do not remove the speaker link - without a working replacement route. No flash or install to `userdata`. -5. No radio service is enabled by default. Keep `rmtfs` read-only on any later - attempt and load one subsystem at a time. - -Build script references: `device/dipper/FLASH-RUNBOOK.md`, `WIFI-PLAN.md`, -`tools/dipper/build`, `tools/build-packages`, `tools/build-rootfs`. diff --git a/device/dipper/WIFI-PLAN.md b/device/dipper/WIFI-PLAN.md deleted file mode 100644 index 1e404e455..000000000 --- a/device/dipper/WIFI-PLAN.md +++ /dev/null @@ -1,545 +0,0 @@ - -# dipper — Wi-Fi plan - -Wi-Fi matters more on this phone than on a Pixel: dipper is not A/B, so a boot -without working networking leaves no remote access at all. It is also not a -self-contained driver, which is the main thing to understand before debugging it. - -## What actually has to be true - -WCN3990 has no firmware of its own. **The WLAN firmware runs on the modem's DSP**, so -`ath10k_snoc` only gets a chip once the whole Qualcomm IPC chain is up: - -| Piece | Where it comes from | State | -| --- | --- | --- | -| `ath10k_snoc` + `qcom,wcn3990-wifi` node | mainline; node enabled in our DTS with beryllium's supply set | **in the DTS** | -| `ath10k/WCN3990/hw1.0/firmware-5.bin` | linux-firmware — a 60-byte metadata stub, no code | fetched | -| `ath10k/WCN3990/hw1.0/board-2.bin` | **built from this phone's own calibration** (below) | **built** | -| `wlanmdsp.mbn` (3.6 MiB) | the phone's `/vendor/firmware_mnt/image` | extracted | -| `mba.mbn` + `modem.mbn` (60 MiB) | the phone; `modem` squashed from `.mdt` + 27 `.bNN` | extracted | -| `*.jsn` protection-domain maps | the phone; `pd-mapper` reads them | extracted | -| `qrtr`, `pd-mapper`, `rmtfs`, `tqftpserv` | **AUR PKGBUILDs**, not repository packages: `qrtr` 1.2, `rmtfs` 1.2, `tqftpserv` 1.2, `pd-mapper` 1.1 | exist; **must be built for aarch64** | -| `rmtfs_mem` reserved region | in our DTS at `0xf6301000 + 0x200000` | in the DTS | - -So the realistic order is: register the modem remoteproc → start `rmtfs`/`tqftpserv` → -explicitly start the modem firmware → `pd-mapper` answers protection-domain lookups → -`ath10k_snoc` finds a chip. **Wi-Fi cannot be brought up before the modem subsystem runs.** That is why first light -targets USB networking instead, and why the cable is not optional. - -## Attended first-radio run - -The newest private off-device snapshot of all 15 saved partitions is -`private off-device reference directory (path omitted)/`; all -device/source hashes matched before the RAM boot. Keep -the live kernel log private under `private off-device reference directory (path omitted)/`. - -The phone was in rescue initramfs. Its NFS client is built into this kernel, so a -disposable copy at host `the disposable host-side NFS root` was served over USB NCM and mounted -read-write at `the host-side scratch mount`; only that scratch copy was writable. At the latest -host check (2026-10-30), ADB and fastboot listed no device, the Mi 8 Tailscale -peer was offline, and `lsusb` showed no identifiable phone. Host `usb0` remained -up but does not establish phone connectivity. The phone's current screen/mode is -unknown; no further device commands were sent. The host NFS service is disabled -at boot and its export is restricted to the USB client. The original compressed -image and `userdata` are untouched. - -The 2026-10-30 RAM boot confirmed the revised image and all five NV links -read-only. The modem exposed QRTR WLAN service 69. On the MCFG retry, both MCFG -files were served successfully and the WLAN DSP firmware was fetched; the modem -still crashed with `modem_xpu_int.c:456:XPU violation End`. Re-timed from -`wifi-20261030-mcfg-ath10k-crash-dmesg.log`: the modem came up at t=160.5 s and -ran healthy for 137 s; `cfg80211` loaded at t=297.53 s (the ath10k insert -pulling in mac80211/cfg80211) and the violation arrived at t=297.89 s, 0.36 s -later. The trigger is therefore ath10k's QMI handshake, not modem boot or MCFG. -That capture holds no ath10k lines at all, so the `CONFIG_ATH10K_DEBUG` output -built for the run was never obtained; stream the log off-device, or read it back -from pstore, before the module is inserted. No WLAN interface, scan or association occurred. -The MCFG files are now in the private firmware tree and scratch rootfs, and -`tools/dipper/extract-firmware` stages them for future builds. Resolved 2026-10-30: the rejected -`/boot/modem_fsg_oem_1` and `/boot/modem_fsg_oem_2` requests are benign. Dipper -has no `fsg_oem*` partition (only a single `fsg`), and stock `/vendor/bin/rmt_storage` -knows exactly four paths -- `/boot/modem_fs1`, `/boot/modem_fs2`, `/boot/modem_fsc`, -`/boot/modem_fsg` -- so stock refuses those two requests too and Android works -regardless. The modem probes them opportunistically. Do not alias them to any -partition; the rejection is not a fault and is not the XPU violation's cause. A whole-phone reboot separated the earlier and -latest RAM attempts. On a prior Android boot, Tailscale reconnected after its -app was opened. The latest radio attempt left remoteproc `crashed` with -recovery disabled; do not retry in place. NV partitions remained read-only. - -The saved kmsg logs show automatic remoteproc recovery during the failed -sessions: one boot reached crash counters 1–6 and another reached 1–5, -restarting MBA/MPSS after each fatal error. The kernel defaults recovery to -enabled. Before the next single start, while `remoteproc0` is offline, set -`/sys/class/remoteproc/remoteproc0/recovery` to `disabled` and read it back. -If that attempt crashes, leave it crashed and stop; do not invoke `recover` or -enable recovery. - -For the next attempt, first restore physical USB data and identify the phone's -mode. If stock Android has run since the saved snapshot, capture and verify a -fresh off-device backup before radio work. Verify the pending diagnostic build -and image-pack status; `CONFIG_ATH10K_DEBUG=y` was enabled to expose QMI/SNOC -messages. Restore the saved original kernel config after securing outputs, and -ensure matching debug modules are installed in the disposable scratch rootfs. -Then RAM-boot the image (do not flash it), confirm its initramfs created the links above -and recheck their `ro` values. Start a private live log, mount the NFS scratch root -read-write, bind live `/dev`, `/proc`, `/sys` and -`/run`, set -`/sys/module/firmware_class/parameters/path` to `the host-side scratch mount/usr/lib/firmware`, then load -`rmtfs_mem`, `qrtr-smd`, `reset_qcom_pdc` and `qcom_q6v5_mss` from its module tree. The -rebuilt Dipper initramfs creates read-only-checked `by-partlabel` links for `persist`, `fsg`, -`fsc`, `modemst1` and `modemst2`; verify their targets have `ro=1` before continuing. This -image is now RAM-booted. If a link is missing, stop before starting rmtfs. Confirm -`remoteproc0` is `offline`, disable and verify remoteproc recovery, start `pd-mapper` and -`tqftpserv` first, then start `rmtfs -r -P -s` once. Its `-s` option starts the MSS -remoteproc itself; do not also write `start` to the remoteproc state file. `rmtfs` must stay -read-only. Stop if the modem does not stay online, -reports storage/NV errors, or UFS reports an error-handler pass. Do not retry a failed -modem in place. Only after a stable modem and QRTR services are confirmed should a later -session apply the WLAN MAC from read-only `persist`, load `ath10k_snoc`, verify WCN3990 -board data, and attempt a scan. Use the owner's Wi-Fi credentials from ignored local provisioning settings -without echoing them or putting them in logs. -The success test is association to the owner's requested network, then DHCP and connectivity. - -Stop if any backed-up partition is not read-only, USB rescue SSH or live logging is lost, -or any daemon/firmware/board-data step fails. No partition should be written. After a -successful test, a power-cycle of this RAM boot returns to Android. Do not retry a modem -that crashed in the same boot; diagnose it first. -This test runs the untrusted modem firmware, so keep the phone attended and on USB power, -and leave the live log private. - -## Attended run 2026-10-30 (second): where it actually dies - -The diagnostic image RAM-booted, rescue SSH came up, all five `by-partlabel` -targets read `ro=1`, and the live kmsg was streamed **off-device over SSH before -any module was inserted** -- the gap that lost the previous run's evidence. The -modem started once from `rmtfs -v -r -P -s`, reached `running`, and registered 46 -QRTR services including 69 `ATH10k WLAN firmware service`. `recovery` was -`disabled` before the start and the run ended with exactly **one** crash, no -recovery loop. Nothing was written; all five NV partitions stayed `ro=1`. - -`ath10k_core` was loaded with `debug_mask=0x300822` (BOOT|SNOC|QMI|WMI|REGULATORY), -then `ath10k_snoc`. The captured sequence is private at -`private off-device reference directory (path omitted)`: - -``` -snoc xo-cal-data return -22 -qmi msa.paddr: 0x000000008e300000 -snoc probe / wifi fw qmi service found / connected -qmi indication register request completed -qmi msa mem region 0 addr 0x8e300000 size 0x4000 flag 0x1 -qmi msa mem region 1 addr 0x8e304000 size 0xfc000 flag 0x0 -qmi msa mem info request completed <- last successful step -... 57 ms ... -fatal error received: SFR Init: wdog or kernel error suspected -``` - -No `msa ready` line and no `failed to assign msa map permissions` error, so the -modem dies inside `ath10k_qmi_setup_msa_permissions()`'s `qcom_scm_assign_mem()` -window or at `msa_ready` immediately after. The two regions sum to 0x100000, -matching our reserved region. - -### Ruled out, with evidence -- do not re-test these - -| Suspect | Why it is not the cause | -| --- | --- | -| MSA address/size wrong | stock DT reserves `wlan_fw_region@0x8e300000` size `0x100000`, identical to our `wlan_msa_mem` | -| `xo-cal-data return -22` | **no** DTS in the tree sets `qcom,xo-cal-data`, beryllium included; the driver leaves `xo_cal_supported` false and continues | -| rejected `/boot/modem_fsg_oem_1`/`_2` | stock `/vendor/bin/rmt_storage` knows only four paths and refuses them too | -| `qcom,snoc-host-cap-skip-quirk` wrong | beryllium (SDM845 + WCN3990, working) sets the same quirk | -| missing `qrtr-ns` | the name service has been in-kernel (`net/qrtr/ns.c`) since 5.7; upstream dropped the binary. 46 services resolved without it | -| board-2.bin malformed | never reached -- board data is fetched after `msa_ready` | - -### Next step, gated - -`qcom,msa-fixed-perm` has been added to our `&wifi` node as the one hypothesis -the evidence supports: dipper reserves MSA at a *fixed* address, so ABL/TZ has -likely already granted the modem access, and reassigning it from HLOS strips -permissions the modem already holds. Note that no sdm845 DTS upstream sets this -property, so if it fixes dipper that difference needs explaining before the -change goes anywhere near upstream. - -| | | -| --- | --- | -| Do | rebuild DTB + boot image, RAM boot (**never flash**), repeat the sequence above | -| Expect | a `msa ready request completed` line, then board-data fetch, then a `wlan0` interface | -| Pass | modem stays `running` through `ath10k_snoc` load | -| Stop | any fatal error -- leave it crashed, do not `recover`, do not retry in place | -| Rollback | drop the property; power-cycle returns the phone to Android | -| Risk | low: RAM boot only, nothing written, NV read-only | - -Two host-side gotchas worth keeping: busybox `mount` needs an explicit -`addr=`, so the NFS mount is `-o nolock,vers=3,addr=172.16.42.2` (v4 and a bare -v3 both fail with "mount program didn't pass remote address"); and the rootfs -daemons are glibc while the rescue initramfs is musl, so `pd-mapper`, -`tqftpserv` and `rmtfs` must be run via `chroot the host-side scratch mount`, not directly. - -## 2026-10-30, runs 2-4: the failure is the SDM845 XPU erratum, not our config - -Three more attended RAM boots (never flashed; NV read-only throughout; one crash -each, recovery disabled first). Each one moved the failure, and together they -close out most of the suspect list. - -### Run 3: `qcom,msa-fixed-perm` -- got much further, then died anyway - -Setting it skips `qcom_scm_assign_mem()`. The QMI handshake then sailed past the -point that had killed runs 1-2 and reached, in order: `msa mem ready request -completed`, `chip_id 0x30214 chip_family 0x4001 board_id 0xff`, `fw_build_id -WLAN.HL.2.0.c3-00534-QCAHLSWMTPLZ-1`, board-data match, `bdf download request -completed`, `cal report request completed` -- then `SFR Init: wdog or kernel -error suspected` 24 ms later, with no host log line in between. - -So the property is **not** the fix and is deliberately not set: skipping the -assignment leaves the modem without MSA permissions, and it dies at the first -real *use* of that region (the BDF is written into it). The assignment is -required. - -### Run 4: upstream board-2.bin -- identical crash, so our board data is cleared - -Swapping linux-firmware's generic `board-2.bin` for ours changed nothing: same -`cal report` then same watchdog, 23 ms later. Since that generic data is exactly -what beryllium loads and beryllium works, **board data is not the cause**. Ours -is restored (it carries the phone's factory calibration, so TX power is right). - -### What the evidence actually points at - -`ath10k_qmi_event_server_arrive()` carries an upstream workaround: - -```c -/* - * HACK: sleep for a while between receiving the msa info response - * and the XPU update to prevent SDM845 from crashing due to a security - * violation, when running MPSS.AT.4.0.c2-01184-SDM845_GEN_PACK-1. - */ -msleep(20); -``` - -Upstream already knows SDM845 trips an XPU security violation here, and the 20 ms -was measured against **one** MPSS build. dipper runs a different one -- taken from -the phone's own modem image, `MPSS.AT.4.0.c2.6-00335-SDM845_GEN_PACK-1.309997.1` -against upstream's `MPSS.AT.4.0.c2-01184`. Same family, different build. - -That makes both observed failures one bug seen from two sides: with the -assignment, the XPU update itself faults (runs 1-2); without it, the modem has no -permissions and faults on first use (runs 3-4). - -`drivers/net/wireless/ath/ath10k/qmi.c` now takes the settling time from a module -parameter instead of the constant, default 20 so upstream behaviour is unchanged: - -``` -modprobe ath10k_snoc msa_perm_delay_ms= # 0 disables the sleep -``` - -It lives in `ath10k_snoc.ko`, not `ath10k_core.ko` (`qmi.o` is in `snoc-y`). - -### Also cleared, with evidence -- do not re-test - -| Suspect | Why not | -| --- | --- | -| WCN3990 supplies | stock `qcom,icnss@18800000` uses pm8998 l5/l7/l17/l25, which is exactly our l5a/l7a/l17a/l25a; voltages are in stock's own configured ranges | -| a missing WLAN enable GPIO | stock's node has none -- only `gpio-force-fatal-error`/`gpio-early-crash-ind` crash lines | -| `iommus` SID | stock `<0x29 0x40 0x01>` matches mainline `<&apps_smmu 0x0040 0x1>` | -| `pd-mapper` not finding its `.jsn` maps | it falls back to `/lib/firmware/` silently, which resolves correctly inside the chroot; an empty log means success | -| our custom `board-2.bin` | run 4, above | -| the `modem.mbn` squash | MBA authenticates every segment and the modem reaches `running` with 46 QMI services, so the image is intact | - -### Still unexplained, worth noting - -- dipper's `&wifi` is byte-for-byte beryllium's apart from beryllium's - `qcom,calibration-variant = "xiaomi_beryllium"`. Ours has no variant, so - ath10k loads the plain `qmi-board-id=ff` entry. Adding a variant with no - matching board-2.bin entry only falls back to the same data, so it was not - tried; revisit only if the delay theory fails. -- stock also sets `vdd-3.3-ch1` **nowhere**, while mainline's regulator list has - five entries and `regulator_bulk_get()` wants them all. Ours points ch1 at - `vreg_l23a_3p3`, as beryllium does. -- tqftpserv's served-file set differs run to run (`wlanmdsp.mbn` in run 1; - `miui_customized_region` and `ota_firewall/ruleset`, both rejected, in run 4). - Those two rejects are unexplained but stock has real files behind them. - -### Next step, gated -- NOT yet run - -The `delay300` run was prepared and aborted before touching the radio: the phone -did not come back from the previous run's reboot (see STATE.md). - -| | | -| --- | --- | -| Do | RAM boot, full sequence, then `modprobe ath10k_snoc msa_perm_delay_ms=300` | -| Expect | `msa ready`, `bdf download`, `cal report`, then a `wlan0` interface | -| Pass | modem stays `running` after the ath10k load | -| If it still crashes | sweep the delay (100/500/1000) before abandoning the theory; one value per boot, the modem cannot be retried in place | -| Stop | any fatal error -- leave it crashed, never `recover` | -| Rollback | `msa_perm_delay_ms=20` restores upstream behaviour; nothing is flashed | - -The driver change is local and uncommitted. If a longer delay does fix dipper, it -is evidence the 20 ms is an MPSS-version-dependent guess, which is worth taking -upstream -- but it needs a second device to confirm before it is more than a -local workaround. - -## 2026-10-30, run 5: Wi-Fi comes up. The erratum delay was the fix. - -`modprobe ath10k_snoc msa_perm_delay_ms=300` and the modem did **not** crash. -The whole chain completed for the first time: - -``` -qmi msa mem ready request completed -qmi chip_id 0x30214 chip_family 0x4001 board_id 0xff -qmi bdf download request completed / qmi cal report request completed -wifi fw ready event received <- never reached before -soc power on -qmi wlan mode req completed: 0 -boot init ce src/dest ring id 0..11 -Hardware name wcn3990 hw1.0 version 0x8 -``` - -Result on the phone: `remoteproc0` stayed `running`, `phy0` exists, `wlan0` -exists, no ath10k error or warning, and `iw dev wlan0 scan` returned **23 BSSes** -across 2.4 GHz and 5 GHz. The radio transmits and receives. - -So the 20 ms in `ath10k_qmi_event_server_arrive()` is too short for -`MPSS.AT.4.0.c2.6-00335`; 300 ms works. The value is now -`ath10k_snoc`'s `msa_perm_delay_ms` (default 20, upstream behaviour unchanged). -**The minimum working value has not been bisected** -- 300 was the first tried. -Worth narrowing before this is proposed anywhere, and worth confirming on a -second SDM845 device. - -### Why it still does not associate to the owner's AP - -Not a driver fault. `iw phy phy0 info` shows: - -| Band | State | -| --- | --- | -| 36-48 (UNII-1) | enabled, 23 dBm | -| 52-64 (UNII-2A) | enabled, no-IR, radar detection | -| **100-144 (5470-5725)** | **disabled** | -| 149-165 (UNII-3) | enabled, 13 dBm | - -That is exactly the **CN** regulatory domain (CN permits 5150-5350 and -5725-5850, but not 5470-5725) -- this is a Chinese-market handset and the -regdomain comes from its calibration data. The owner's 5 GHz AP sits on -**channel 104 / 5520 MHz**, inside the forbidden gap, so the radio will not even -scan it: none of the three configured SSIDs appears among the 23 networks found, -while 22 neighbours on 2.4 GHz and two on UNII-1 do. - -`iw reg set SK` was tried and changes nothing, because `ath10k_regd_update()` -drives the firmware from `ar->ath_common.regulatory.regpair` (ath/regd.c, -`REGULATORY_CUSTOM_REG`): the calibration regdomain wins over the host hint. - -Note stock Android **does** connect on 5520 MHz, so the hardware is capable; stock -derives its country from the modem/NV rather than from the ath10k default. Making -mainline do the same means changing where `current_rd` comes from, which is -regulatory-limit territory and is deliberately left as a separate decision rather -than patched quietly. - -### To finish: one of these - -| Option | Cost | -| --- | --- | -| Put the AP on a permitted channel (36-48, 149-165) or use its 2.4 GHz SSID | router-side, one setting, proves the stack immediately | -| Make ath10k take the country from the modem/NV as stock does | real work, touches regulatory limits, needs a deliberate decision | - -Nothing else is in the way: association was not reached only because no network -the phone has credentials for is reachable on a channel this calibration permits. - -### Still open from this run - -- `wlan0`'s MAC was the random `c2:fa:...`: `omamobile-dipper-identity` does not - run in the rescue initramfs, so the real address was not applied from `persist`. - Harmless for association, but apply it for a real boot. -- `DT bdf variant name not set.` remains; beryllium sets - `qcom,calibration-variant`. Untried, since our board-2.bin has no variant - entries and ath10k would fall back to the same data. -- wpa_supplicant ran fine (`wpa_state=SCANNING`) and is not implicated. - -## 2026-10-30: Wi-Fi WORKS. Associated, DHCP, internet. - -On a RAM boot (nothing flashed, NV read-only throughout) the Mi 8 associated to -the owner's AP on 2.4 GHz and carried real traffic: - -``` -wpa_state=COMPLETED freq=2447 signal -59 dBm -udhcpc: lease obtained from the local gateway (addresses omitted) -default route via the local gateway on wlan0 -ping -I wlan0 1.1.1.1 -> 3/3 packets, 11.0/16.1/20.2 ms -remoteproc0: running -``` - -### What it took, in the order it mattered - -1. **`ath10k_snoc msa_perm_delay_ms=300`.** The upstream `msleep(20)` before the - XPU update in `ath10k_qmi_event_server_arrive()` is tuned to - `MPSS.AT.4.0.c2-01184`; dipper runs `MPSS.AT.4.0.c2.6-00335` and needs longer. - Now a module parameter, default 20, so upstream behaviour is unchanged. - **The minimum working value has not been bisected.** -2. **Wait for QRTR service 69 before loading ath10k.** This was the whole - "flakiness": loading `ath10k_snoc` before the modem publishes the ATH10k WLAN - firmware service makes the driver wait, time out after ~17 s, and take the - modem down with it (`fatal error without message`). Gating on service 69 -- - it shows up about 4 s after the modem start -- turned a roughly 50% success - rate into every attempt. **Any boot script must gate on this, not sleep.** -3. **`ath user_regd=1` plus `iw reg set SK`.** The calibration reports **CN**, - which omits 5470-5725 entirely, and `ath_regd_init_wiphy()` applies it as a - `REGULATORY_STRICT_REG | REGULATORY_CUSTOM_REG` domain, so the phy ignored the - global domain -- `iw phy phy0 reg get` kept saying `country CN` while the - global said SK. The new `user_regd` parameter (ath.ko, default off) leaves the - phy on cfg80211's domain instead. With it, channels 100-144 went from - `(disabled)` to `(26.0 dBm) (no IR, radar detection)` and the firmware really - did scan 5500-5720 with valid noise floors. - -### The one thing that does NOT work: DFS channels - -The owner's 5 GHz AP is on **channel 104 / 5520 MHz**, a DFS channel. Scanning it -works; associating does not. Every attempt ends the same way, 52 ms after the -driver tunes to it: - -``` -wmi tlv vdev start -firmware crashed! (guid ...) kconfig ... dfs 1 ... -wifi fw qmi service disconnected -qcom-q6v5-mss: watchdog received: SFR Init: wdog or kernel error suspected -``` - -`CONFIG_ATH10K_DFS_CERTIFIED=y` was enabled and makes no difference -- the banner -shows `dfs 1` and it still crashes. The 2.4 GHz run above proves association, -DHCP and traffic are all fine, so this is specific to starting a vdev on a DFS -channel, not to association. - -This matches the only close prior art found: a OnePlus 6T (same SDM845, same -WCN3990) report of `mpss` asserting in `wlan_vdev.c:_wlan_vdev_down` and -escalating to a watchdog, where the reporter ruled out ADSP load, module load -timing, rmtfs read-write and firmware packaging, and concluded "I have not found -a configuration that keeps Wi-Fi and is free of this crash." There is no upstream -fix. The firmware is closed (`WLAN.HL.2.0.c3-00534`), so this is a firmware-side -limit, not something the DT or the driver reaches. - -**Practical answer: keep the phone off DFS channels.** Non-DFS and permitted -here: 2.4 GHz, UNII-1 (36-48) and UNII-3 (149-165). Moving the AP's 5 GHz radio -to 36-48 is one router setting and should give 5 GHz without the DFS path; that -is untested but uses the same `vdev start` that works on 2.4 GHz. - -### Cleared earlier, with evidence -- do not re-test - -| Suspect | Why not | -| --- | --- | -| MSA address/size | stock reserves `wlan_fw_region@0x8e300000/0x100000`, identical to ours | -| `qcom,msa-fixed-perm` | gets past the XPU violation but then dies at first MSA *use*; the assignment is required | -| our `board-2.bin` | upstream's generic file crashes identically | -| `xo-cal-data return -22` | no DTS in tree sets `qcom,xo-cal-data`, beryllium included | -| rejected OEM FSG paths | stock `rmt_storage` knows only four paths and refuses them too | -| WCN3990 supplies | stock icnss uses pm8998 l5/l7/l17/l25, exactly our l5a/l7a/l17a/l25a | -| missing `qrtr-ns` | in-kernel since 5.7; 46 services resolve without it | -| stale initramfs modules | rebuilt with the kernel; made no difference | - -### For a real boot (not yet done) - -- `msa_perm_delay_ms=300` and `user_regd=1` belong in `/etc/modprobe.d`. -- The regulatory domain must be set at boot, or the phy falls back to CN. -- Something must gate ath10k on QRTR service 69; the modem chain - (`rmtfs`/`pd-mapper`/`tqftpserv`) still starts nothing automatically. -- `wlan0` had a random MAC; `omamobile-dipper-identity` does not run in rescue. - -## board-2.bin: why ours and not upstream's - -Upstream linux-firmware's WCN3990 `board-2.bin` holds **36 entries, every one keyed -`qmi-board-id=ff`** (plus a few other SoCs). dipper's own WLAN firmware reports -**board id 0** — the stock kernel logs it verbatim: - -``` -wlan: [443:I:WMA] wma_rx_service_ready_event: Board id: 0, Board version: 0 0 0 0 0 -``` - -With no matching entry ath10k loads no board data, and Wi-Fi stays down. So -`tools/dipper/build-board-2.py` builds one from the phone's own 34 board-data files: - -- **23 entries**, `bus=snoc,qmi-board-id=,qmi-chip-id=30214` (both ids are `%x` in - `ath10k_core_create_board_name()`; `30214` is hex, as in upstream's own names), -- board ids **0** and **ff** both carry the phone's default `bdwlan.bin`, covering what it - reports and ath10k's fallback, -- the 21 `bdwlan.bNN` variants go in under their own ids, so a different unit of the same - phone still finds its own calibration. - -This uses **the phone's factory calibration** rather than generic data, which is what keeps -transmit power correct rather than merely legal-looking. The tool cross-checks itself by -parsing upstream's file first (36 entries, all `snoc`) and refuses to write anything if that -parse fails; `tools/dipper/test-board-2.py` covers round-tripping, a bad magic, IE alignment, -the file-name-to-board-id mapping, and the empty-input refusal. - -## The MAC address: generic, read at boot - -Generic board data carries no per-unit MAC, so without help the interface comes up with -whatever ath10k invents — different on each boot, which breaks anything keyed to the address. - -**The image stays device-agnostic.** `tools/dipper/identity/omamobile-dipper-identity` runs -once at boot, mounts `persist` **read-only**, reads `/wlan_bt/wlan.mac` and -`/wlan_bt/bt.mac` — where every Mi 8 keeps its own factory addresses — and applies them: - -- writes `/etc/systemd/network/10-dipper-wlan.link`, which `systemd-udevd` applies whoever - manages the interface afterwards, NetworkManager included, and sets `wlan0` immediately if - it already exists; -- sets the Bluetooth public address with `btmgmt` when `hci0` and `btmgmt` are both there. - -It refuses an all-zero, broadcast, multicast or short-read value rather than configuring -nonsense, is a quiet no-op when `persist` is absent, and does not rewrite an unchanged link -file. `tools/dipper/identity/test-identity.sh` drives **the script itself** (not a copy of its -logic) through all of those cases. - -So **the same image works on any Xiaomi Mi 8**: nothing device-specific is compiled in. - -### The single-device alternative, off by default -`tools/dipper/apply-identity` can write a Bluetooth address into the built DTB's -`local-bd-address` instead, which has the advantage of being set before userspace runs. It is -opt-in (`DIPPER_BAKE_IDENTITY=1`) because it makes the image specific to one handset. The DTS -itself carries an all-zero placeholder, so no identifier is ever committed, and the tool finds -the `qcom,wcn3990-bt` node by compatible rather than by path and reads the value back to -confirm it took. `tools/dipper/extract-identity` recovers the addresses offline from the -`persist` backup with `debugfs`, for when the phone is not reachable. - -## Is any of this specific to one phone? - -Worth being precise, because it decides whether this port serves every Mi 8 or just one: - -| Piece | Scope | -| --- | --- | -| board data (`bdwlan.*`) | **per model, not per unit** — it comes from the `modem` partition, so every Mi 8 on the same firmware has the identical set. Our `board-2.bin` carries **all 23 board ids**, not just the one this handset reports, so a unit that reports a different id still finds its own calibration. | -| `wlanmdsp.mbn`, `modem.mbn`, `mba.mbn`, DSP and GPU images | per model | -| WLAN and Bluetooth MAC | **per unit** — and therefore never in the image; read from `persist` at boot | -| the device tree, the panel driver, the descriptor | per model | - -The one thing that cannot be shared is distribution: the firmware and board data are Xiaomi's -proprietary blobs, so each owner runs `tools/dipper/extract-firmware` against their own phone. -The tooling is general; the blobs are not ours to ship. That is the same line the project draws -for cheetah's camera data. - -## Open - -- The four IPC daemons are now vendored as source PKGBUILDs under - `packages/{qrtr,pd-mapper,tqftpserv,rmtfs}` and included in dipper's local package set. - All four aarch64 packages and `omamobile-device-dipper` built and were signed into - `out/dipper/repo`; the full rootfs is built at - `out/dipper/omamobile-rootfs-2026.10.29-dipper-aarch64.img.zst`. Its manifest - lists the daemons and Qualcomm/Atheros distro firmware packages, and the 11 - rootfs smoke checks pass. The builder copies private firmware from - `out/dipper/firmware`. This confirms packaging only: Wi-Fi has not been tested - on mainline and no radio service is enabled automatically. -- All four IPC daemons exist in the AUR (checked against the AUR API: `qrtr` 1.2-1, - `rmtfs` 1.2-1, `tqftpserv` 1.2-1, `pd-mapper` 1.1-1, plus `-git` variants for qrtr and - pd-mapper). These source builds use the project package builder for aarch64. -- Two modem starts have been attempted on this phone under mainline, both crashed. No - modem/Wi-Fi service is enabled automatically. The older backup's `persist` and `modemst2` - hashes did not match the live partitions. A fresh read-only snapshot was captured after - stock Android boot at - `private off-device reference directory (path omitted)/`; all 15 saved - partitions match the handset and report read-only. The original snapshots remain - preserved. `userdata`, Android system/vendor and separately extracted firmware are not - part of this 15-partition snapshot. -- A private live `/dev/kmsg` stream is being captured outside the repository. The rescue - initramfs has no Qualcomm user-space daemons, firmware or radio modules. To avoid writing - to `userdata`, a disposable host-side copy of the built rootfs is exported over the USB - NCM link and mounted read-write at `the host-side scratch mount` on the phone. Writes affect only the - scratch copy. The NFS server is disabled at host boot and its export is USB-client-only. -- The current crash followed an `rmtfs` failure to open `/dev/disk/by-partlabel/fsc` for - `/boot/modem_fsc`. A temporary read-only-checked link stopped new errors, but the crashed - modem was not restarted. `initramfs/init` now includes `fsc`; rebuild the boot image before - another RAM boot. Recovery is disabled in the current rescue session, and `ath10k_snoc` - has not been loaded. -- `qcom,calibration-variant` is deliberately **not** set: we key on board id instead, which - needs no variant string and no guess about which one this unit is. diff --git a/device/dipper/device.conf b/device/dipper/device.conf deleted file mode 100644 index a07e342bc..000000000 --- a/device/dipper/device.conf +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: MIT -# Device descriptor: Xiaomi Mi 8 (dipper). Every value below is read off the -# phone itself (live device tree, boot image header, /proc/partitions) or from -# the running stock kernel; nothing is copied from another board. -CODENAME=dipper -NAME="Xiaomi Mi 8" -SOC=sdm845 -# Matches the board DTS this port carries (sdm845-xiaomi-dipper.dts). -COMPATIBLE="xiaomi,dipper" -# Android boot image header v1, page size 4096, second_size 0, and two ~480 KB -# FDTs concatenated at the end of the kernel blob: the DTB is appended to the -# kernel and ABL picks one by qcom,msm-id / qcom,board-id. -BOOT_METHOD=android-v1-appended-dtb -BOOT_PAGESIZE=0x1000 -PACKAGE=omamobile-device-dipper -ROOTFS_PROFILE=dipper -ROOTFS_PACKAGES="qrtr pd-mapper tqftpserv rmtfs" -# Arch repository packages only. Wi-Fi also needs the Qualcomm IPC daemons -# (qrtr, rmtfs, tqftpserv, pd-mapper), which exist as AUR PKGBUILDs rather than -# repository packages, so they have to be built for aarch64 like our own -# packages -- they cannot be listed here. See WIFI-PLAN.md. -ROOTFS_DIST_PACKAGES="vulkan-freedreno linux-firmware-qcom linux-firmware-atheros" -# Set once the kernel is built; the port has no kernel release yet. -KERNEL_RELEASE= -# dipper is NOT A/B for the OS: one `boot`, one `system`, one `userdata`, plus a -# `recovery` partition. Only the bootloader chain is slotted (xbl/abl/tz/hyp/...), -# and this port never writes any of it. So there is no `_b` suffix anywhere here -# and no fallback slot: see NOTES.md. -BOOT_IMAGES="boot" -UFS_RW="userdata" -# 0x438 x 0x8c8 from the active panel node (Samsung EA8074, notch, cmd mode, 60 Hz). -PANEL_SIZE=1080x2248 -MONITOR_SCALE=2.25 diff --git a/device/dipper/kernel.config b/device/dipper/kernel.config deleted file mode 100644 index d31632625..000000000 --- a/device/dipper/kernel.config +++ /dev/null @@ -1,94 +0,0 @@ -# SPDX-License-Identifier: MIT -# dipper's kernel fragment, merged after kernel/configs/omamobile.config. -# -# Everything the phone needs to reach a shell is built in, not a module. The -# first boot proved why: arm64 defconfig makes the Qualcomm PHY drivers and the -# UFS glue modules, while dwc3 and ufshcd are built in. So they probed, found no -# PHY, and gave up -- the kernel logged -# platform a600000.usb: deferred probe pending: dwc3: failed to initialize core -# gcc-sdm845 100000.clock-controller: sync_state() pending due to 88e8000.phy -# and the initramfs never got USB or storage. Modules in the initramfs do not -# help when nothing loads them before the devices probe. - -# USB and UFS PHYs. Without these, both the USB gadget and storage are dead. -CONFIG_PHY_QCOM_QMP=y -CONFIG_PHY_QCOM_QMP_COMBO=y -CONFIG_PHY_QCOM_QMP_UFS=y -CONFIG_PHY_QCOM_QUSB2=y - -# Storage: the core is already built in, the Qualcomm glue was not. -CONFIG_SCSI_UFS_QCOM=y - -# The Type-C port manager on the PMIC, for the role switch and VBUS detection. -CONFIG_TYPEC_QCOM_PMIC=y - -# Display: built in, so a console exists before any module is loaded. -CONFIG_DRM_MSM=y -# The panel must be built in; the installed rootfs module is stale. -CONFIG_DRM=y -CONFIG_BACKLIGHT_CLASS_DEVICE=y -CONFIG_DRM_PANEL_SAMSUNG_EA8074=y - -# Touch, so a working panel is usable without waiting for userspace. -CONFIG_TOUCHSCREEN_STMFTS=y - -# Console log into the stock ramoops region: the only way to read an early hang -# on a phone with no serial header. -CONFIG_PSTORE=y -CONFIG_PSTORE_RAM=y -CONFIG_PSTORE_CONSOLE=y - -# Tailscale needs a tun device; arm64 defconfig has it, pin it so a later -# fragment cannot quietly drop it. -CONFIG_TUN=y - -# --- the same lesson, applied to everything first light touches --------------- -# Devices probe once, early. A driver that only turns up later as a module never -# gets a second chance: the device is left unbound and not even on the deferred -# list. The first boot proved it for the PHYs; the second proved it again for -# i2c (geni_i2c loaded by hand bound to nothing, and `bind` by hand failed). -# So everything needed to reach a usable system is built in. - -# i2c: the touchscreen lives on i2c14, and nothing on that bus exists without it. -CONFIG_I2C_QCOM_GENI=y -CONFIG_QCOM_GPI_DMA=y -# Nothing of ours is on SPI, so it stays a module: every built-in byte counts -# against the ABL kernel limit below. -CONFIG_SPI_QCOM_GENI=m - -# Display comes from the bootloader's framebuffer through simpledrm, not from -# the MSM display driver, so DRM_MSM stays a module. Built in it pushed the -# kernel past about 16 MiB, which this ABL refuses outright: -# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') -# Nothing loads it; the panel path is open work (see NOTES.md). -CONFIG_DRM_MSM=m -CONFIG_DRM_SIMPLEDRM=y -CONFIG_SYSFB_SIMPLEFB=y - -# The remoteprocs Wi-Fi depends on (the modem hosts the WLAN firmware) stay -# modules. Built in they pushed the kernel past what this ABL will load: a -# kernel+dtb of 16,247,767 bytes boots and 16,376,528 does not, with only -# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') -# to go on. In the root filesystem udev loads them; the bring-up initramfs does -# not need the modem. -CONFIG_QCOM_RPROC_COMMON=m -CONFIG_QCOM_Q6V5_PAS=m -CONFIG_QCOM_Q6V5_MSS=m -CONFIG_QCOM_SYSMON=m -CONFIG_RPMSG_QCOM_GLINK_SMEM=m - -# Left as modules with DRM_MSM: pinning them only mattered to allow DRM_MSM=y, -# which the ABL size limit ruled out. -CONFIG_QCOM_OCMEM=m -CONFIG_QCOM_LLCC=m - -# This phone's ABL refuses a boot image whose kernel is too large, saying only -# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') -# Measured: kernel+dtb of 16,247,767 bytes boots, 16,343,459 does not. The -# boundary sits at 0xF80000 = 16,252,928, which tools/dipper/build-boot.py now -# refuses to cross so the failure is ours and explained, not the bootloader's -# and silent. - -# The DSI core can be a module: the panel driver that needs it is one too, and -# the display comes from simpledrm over the bootloader's framebuffer. -CONFIG_DRM_MIPI_DSI=m diff --git a/initramfs/init b/initramfs/init index 353ce2036..36cd2d946 100755 --- a/initramfs/init +++ b/initramfs/init @@ -92,32 +92,6 @@ ufs_rw_load() { ufs_rw_load mkdir -p /run/ufs-ro ufs_partname() { sed -n 's/^PARTNAME=//p' "$1/uevent" 2>/dev/null; } -ufs_dipper_partlabel_links() { - local s name part link target old - tr '\0' '\n' < /proc/device-tree/compatible 2>/dev/null | grep -qx 'xiaomi,dipper' || return 0 - mkdir -p /dev/disk/by-partlabel - for s in /sys/block/sd* /sys/block/sd*/sd*; do - [ -r "$s/ro" ] || continue - name=${s##*/} - [ -b "/dev/$name" ] || continue - part=$(ufs_partname "$s") - case "$part" in persist|fsg|fsc|modemst1|modemst2) ;; *) continue ;; esac - [ "$(cat "$s/ro")" = 1 ] || continue - link=/dev/disk/by-partlabel/$part - target=/dev/$name - [ -e "/run/ufs-ro/ambiguous-$part" ] && continue - if [ -L "$link" ]; then - old=$(readlink "$link") - [ "$old" = "$target" ] && continue - rm -f "$link" - : > "/run/ufs-ro/ambiguous-$part" - ufs_ro_log "duplicate PARTNAME $part; refusing by-partlabel link" - continue - fi - [ ! -e "$link" ] || continue - ln -s "$target" "$link" && ufs_ro_log "$link -> $target" - done -} ufs_ro_pass() { local s ro name part disk for s in /sys/block/sd* /sys/block/sd*/sd*; do @@ -149,7 +123,6 @@ ufs_ro_pass() { echo "omamobile: WARNING: /dev/$name is NOT read-only" > /dev/tty0 2>/dev/null fi done - ufs_dipper_partlabel_links } # Prints every disk or partition that is writable but not on the allowlist # (sda itself excepted: its node is removed). Empty means the guard holds. @@ -435,41 +408,6 @@ grow_root() { # Hand over to Arch on userdata, unless omamobile.initramfs is on the command # line. Everything is checked before the irreversible exec; if anything is # missing we stay here in the initramfs shell. -# Boot the Arch root from NFS instead of the UFS, for bring-up: nothing on the -# phone is written and the stock OS is left alone, so a root filesystem can be -# tried before anyone decides to install it. Enabled only by the presence of -# /etc/omamobile-nfsroot, holding one line, ":" -- no file, no change. -# The USB gadget and its address are already up by the time this runs, and the -# kernel keeps them across the switch, so the mount survives switch_root. -boot_nfs() { - local spec - [ -r /etc/omamobile-nfsroot ] || return 1 - spec=$(cat /etc/omamobile-nfsroot) - [ -n "$spec" ] || return 1 - say "nfsroot: trying $spec" - mkdir -p /newroot - # busybox mount cannot work out the server address on its own here, so pass it. - # Retry: the phone boots faster than the host brings its usb0 end up, so the - # first mount can race the link coming up. ~30s covers a late host. - local i=0 - until mount -t nfs -o "nolock,vers=3,addr=${spec%%:*}" "$spec" /newroot 2>/dev/null; do - i=$((i + 1)) - [ "$i" -ge 15 ] && { - say "nfsroot: cannot mount $spec (staying in the initramfs)"; return 1; } - sleep 2 - done - if [ ! -x /newroot/usr/lib/systemd/systemd ]; then - say "nfsroot: no systemd on $spec"; umount /newroot; return 1 - fi - say "nfsroot: switching to Arch Linux on $spec" - kill -9 -1 2>/dev/null - sleep 1 - for m in /dev /proc /sys /run; do - mkdir -p "/newroot$m" && mount --move "$m" "/newroot$m" - done - exec switch_root /newroot /usr/lib/systemd/systemd -} - boot_arch() { grep -q omamobile.initramfs /proc/cmdline && return 1 local dev="" s @@ -507,7 +445,6 @@ boot_arch() { done exec switch_root /newroot /usr/lib/systemd/systemd } -boot_nfs boot_arch # PID 1 must never exit: if it does the kernel panics and freezes (silently, diff --git a/packages/mesa/.SRCINFO b/packages/mesa/.SRCINFO index d7008bd48..7e1c025d2 100644 --- a/packages/mesa/.SRCINFO +++ b/packages/mesa/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = mesa - pkgdesc = Open-source OpenGL drivers (Omarchy Mobile: Adreno and Mali) + pkgdesc = Open-source OpenGL drivers (Omarchy Mobile: Mali-G710, Mali-G78, Mali-G715) pkgver = 26.2.4 - pkgrel = 1.5 + pkgrel = 1.4 epoch = 1 url = https://www.mesa3d.org/ arch = aarch64 diff --git a/packages/mesa/PKGBUILD b/packages/mesa/PKGBUILD index 3c0c01dab..fb6c6a7eb 100644 --- a/packages/mesa/PKGBUILD +++ b/packages/mesa/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: 0BSD # -# Omarchy Mobile build of Mesa for Qualcomm Adreno and the Pixel 7 Pro -# (Mali-G710 on Panthor), Pixel 6/6 Pro (Mali-G78 on Panfrost), and Pixel 9a +# Omarchy Mobile build of Mesa for the Pixel 7 Pro (Mali-G710 on Panthor) +# and the Pixel 6 and 6 Pro (Mali-G78 on Panfrost), plus Pixel 9a # (Mali-G715 on Panthor). # # Derived from Arch Linux's mesa PKGBUILD, tag 1-26.2.4-1 @@ -17,7 +17,7 @@ # backported (drop it once Mesa ships it in a release). # - 0004-panfrost-add-Mali-G78-to-the-model-table.patch: the Pixel 6's # Mali-G78, next to the G68 (drop it once Mesa ships the G78 entry). -# - aarch64 only, and only the drivers our phones can use: Gallium freedreno, +# - aarch64 only, and only the drivers this phone can use: Gallium # panfrost (with kmsro), llvmpipe, softpipe and zink; Vulkan panfrost # (PanVK). Splits: mesa, vulkan-panfrost, vulkan-mesa-implicit-layers # (vulkan-panfrost depends on it). No rusticl, NVK, docs or valgrind, @@ -39,10 +39,10 @@ pkgname=( ) pkgver=26.2.4 _pkgver=${pkgver/[a-z]/-&} -pkgrel=1.5 +pkgrel=1.4 _omamobile=omamobile4 epoch=1 -pkgdesc="Open-source OpenGL drivers (Omarchy Mobile: Adreno and Mali)" +pkgdesc="Open-source OpenGL drivers (Omarchy Mobile: Mali-G710, Mali-G78, Mali-G715)" url="https://www.mesa3d.org/" arch=(aarch64) license=("MIT AND BSD-3-Clause AND SGI-B-2.0") @@ -165,7 +165,7 @@ build() { --optimization 2 -D android-libbacktrace=disabled -D b_ndebug=true - -D gallium-drivers=freedreno,panfrost,llvmpipe,softpipe,zink + -D gallium-drivers=panfrost,llvmpipe,softpipe,zink -D gallium-extra-hud=true -D gallium-mediafoundation=disabled -D gallium-rusticl=false diff --git a/packages/mesa/README.md b/packages/mesa/README.md index 247a3a7f5..13cc1eeb5 100644 --- a/packages/mesa/README.md +++ b/packages/mesa/README.md @@ -1,8 +1,8 @@ # mesa (Omarchy Mobile build) -Arch Linux's Mesa 26.2.4 package, rebuilt for the Xiaomi Mi 8 (Adreno 630), -Pixel 7 Pro, Pixel 6/6 Pro, and Pixel 9a. Mali-G710 +Arch Linux's Mesa 26.2.4 package, rebuilt for the Pixel 7 Pro and the +Pixel 6 and 6 Pro, with additional Pixel 9a Mali-G715 support. Mali-G710 (gs201) and Mali-G78 (gs101, with upstream's G68 next to it) are added to Panfrost's model table. Without an entry, Mesa rejects the GPU (for the G710 even when Panthor is loaded): the Gallium @@ -27,19 +27,15 @@ driver bails out on an unknown model, and PanVK returns - The patches above. - `arch=(aarch64)`. - Only drivers this phone can use: - - Gallium `freedreno`, `panfrost` (which brings `kmsro`), `llvmpipe`, `softpipe` and `zink`. + - Gallium `panfrost` (which brings `kmsro`), `llvmpipe`, `softpipe` and `zink`. - Vulkan `panfrost` (PanVK). - The `device-select` and `anti-lag` layers. - Only three split packages: `mesa`, `vulkan-panfrost` and `vulkan-mesa-implicit-layers` (which `vulkan-panfrost` depends on). -- `pkgrel=1.5`. makepkg only accepts `integer[.integer]`, so the Omarchy Mobile - marker is in Mesa's version string instead: `26.2.4-arch1.1.5.omamobile4`. +- `pkgrel=1.4`. makepkg only accepts `integer[.integer]`, so the Omarchy Mobile + marker is in Mesa's version string instead: `26.2.4-arch1.1.4.omamobile4`. That string shows up in `GL_VERSION` and in the `libgallium-*.so` file name. -Freedreno supplies the Adreno DRI driver (`msm_dri.so`) needed by the Mi 8's -Wayland compositor. The separate Vulkan Freedreno package remains supplied by -Arch Linux ARM. - The other ALARM split packages (`vulkan-swrast`, `opencl-mesa` and so on) don't depend on `mesa`'s exact version. They can stay installed at `1:26.2.4-1`. diff --git a/packages/omamobile-device-dipper/LICENSE b/packages/omamobile-device-dipper/LICENSE deleted file mode 100644 index aecd59624..000000000 --- a/packages/omamobile-device-dipper/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2026 Derek Ross - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/omamobile-device-dipper/PKGBUILD b/packages/omamobile-device-dipper/PKGBUILD deleted file mode 100644 index 37e55a769..000000000 --- a/packages/omamobile-device-dipper/PKGBUILD +++ /dev/null @@ -1,27 +0,0 @@ -# SPDX-License-Identifier: MIT -# Maintainer: Derek Ross -pkgname=omamobile-device-dipper -pkgver=$(cat "${startdir:-.}/version") -pkgrel=1 -pkgdesc="Omarchy Mobile support for the Xiaomi Mi 8 (dipper)" -arch=(aarch64) -url="https://github.com/derekross/omarchy-mobile" -license=(MIT) -depends=(bash systemd bluez-utils omamobile-keyring qrtr pd-mapper tqftpserv rmtfs) -provides=(omamobile-device) -conflicts=(omamobile-device) -backup=(etc/pacman.d/omamobile-mirrorlist) -install=omamobile-device-dipper.install -makedepends=(gcc) - -build() { - "$startdir/build" "$srcdir/build" -} - -check() { - "$startdir/test/all" -} - -package() { - "$startdir/install" "$pkgdir" "$srcdir/build" -} diff --git a/packages/omamobile-device-dipper/README.md b/packages/omamobile-device-dipper/README.md deleted file mode 100644 index 8567ad87a..000000000 --- a/packages/omamobile-device-dipper/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# omamobile-device-dipper - -Omarchy Mobile support for the Xiaomi Mi 8 (dipper, Snapdragon 845). It hides Android partitions from desktop tools and configures USB networking, device identity and optional Tailscale startup. Qualcomm Wi-Fi userspace and firmware are included in the image; radio startup remains a gated hardware bring-up step. - -| Path | Installs to | What it does | -| --- | --- | --- | -| `vendor/udev/rules.d/10-omamobile-storage.rules` | `/usr/lib/udev/rules.d` | Hides `sda` and every Android partition except `userdata` from desktop tools. Same rule as the Pixel 7 Pro. The initramfs stops its guard loop before `switch_root`; the kernel's read-only flags are what remain | -| `vendor/systemd/network/20-usb-gadget.network` | `/usr/lib/systemd/network` | Sets usb0 to 172.16.42.1/24 after handover. A replug may need a reboot: this package does not close the USB2 switch again (as on the Pixel Fold; dipper's replug is untested) | -| `vendor/systemd/logind.conf.d/10-omamobile-power-key.conf` | `/usr/lib/systemd/logind.conf.d` | A short power press does not power the phone off. Same drop-in as the Pixel 7 Pro. On dipper the forced reset is Power + Volume Up held 15-30 s ([BRINGUP-M1](../../device/dipper/BRINGUP-M1.md) test 23) | -| `vendor/NetworkManager/conf.d/10-omamobile-usb.conf` | `/usr/lib/NetworkManager/conf.d` | Keeps NetworkManager off that link | -| `etc/omamobile-mirrorlist` | `/etc/pacman.d/omamobile-mirrorlist` | Where pacman finds the `[omamobile]` repository. Same file as the Pixel 7 Pro package | -| `omamobile-device-dipper.install` | pacman hook | Adds `[omamobile]` to `pacman.conf` before `[omarchy]`, once. Same script as the Pixel 7 Pro package | -| `src/reboot-to.c` | `/usr/bin/reboot-to` | Reboot with a reason the bootloader understands. Same bytes as the Pixel 7 Pro package; the test checks | -| `device.conf` | `/usr/share/omamobile/device.conf` | The descriptor, the same bytes as `device/dipper/device.conf` | -| `src/reboot-to.c` | build input | Compiles `reboot-to`, which requests a reboot to the bootloader | - -`./build [DIR]` compiles `reboot-to` from this directory, `./install DESTDIR [DIR]` stages the files, and `test/all` checks the copies when it is run from the repository. - -Not in this package: the boot-success marker, automatic modem/Wi-Fi startup, the charger, cameras, and the slot-B image hook. Automatic radio startup stays disabled until its hardware runbook passes. There is no lid drop-in: dipper has no hinge. diff --git a/packages/omamobile-device-dipper/bin/omamobile-dipper-identity b/packages/omamobile-device-dipper/bin/omamobile-dipper-identity deleted file mode 100755 index 8e3654dd8..000000000 --- a/packages/omamobile-device-dipper/bin/omamobile-dipper-identity +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: MIT -# Apply this phone's own WLAN and Bluetooth addresses, read at boot from its -# `persist` partition. Nothing device-specific is baked into the image, so the -# same image works on any Xiaomi Mi 8. -# -# Generic WCN3990 board data carries no per-unit MAC, so without this the -# interface comes up with an address ath10k invents, different on every boot. -set -eu - -PERSIST=${PERSIST:-/dev/disk/by-partlabel/persist} -MNT=${MNT:-/run/omamobile-persist} -LINK=${LINK:-/etc/systemd/network/10-dipper-wlan.link} -log() { echo "omamobile-identity: $*"; } - -mac_from() { # 6 raw bytes -> aa:bb:cc:dd:ee:ff, or nothing if not a station MAC - [ -s "$1" ] || return 1 - # POSIX awk only: and() and strtonum() are gawk extensions that neither the - # phone's awk nor busybox awk has. Running this on the phone is how that - # was found, so do not "simplify" it back. - od -An -tx1 -N6 "$1" | tr -d ' \n' | awk ' - length($0) != 12 { exit 1 } - { - for (i = 1; i <= 11; i += 2) b[++n] = substr($0, i, 2) - all = b[1] b[2] b[3] b[4] b[5] b[6] - if (all == "000000000000") exit 1 # unset - if (all == "ffffffffffff") exit 1 # broadcast - # The multicast bit is the low bit of the first byte, i.e. its - # second hex digit is odd. - if (index("13579bdfBDF", substr(b[1], 2, 1)) > 0) exit 1 - printf "%s:%s:%s:%s:%s:%s", b[1], b[2], b[3], b[4], b[5], b[6] - }' -} - -[ -e "$PERSIST" ] || { log "no persist partition at $PERSIST"; exit 0; } -mkdir -p "$MNT" -mounted=0 -# NOMOUNT lets the test drive this script against a plain directory of files. -if [ "${NOMOUNT:-0}" != 1 ] && ! mountpoint -q "$MNT"; then - mount -o ro,nosuid,nodev,noexec "$PERSIST" "$MNT" || { log "cannot mount persist read-only"; exit 0; } - mounted=1 -fi -cleanup() { [ "$mounted" = 1 ] && umount "$MNT" 2>/dev/null || true; } -trap cleanup EXIT - -wlan=$(mac_from "$MNT/wlan_bt/wlan.mac" || true) -bt=$(mac_from "$MNT/wlan_bt/bt.mac" || true) - -if [ -n "${wlan:-}" ]; then - # A udev .link file is applied whoever manages the interface later, - # NetworkManager included. Rewrite it only when it would change. - want="[Match] -OriginalName=wlan0 - -[Link] -MACAddress=$wlan" - if [ ! -f "$LINK" ] || [ "$(cat "$LINK")" != "$want" ]; then - mkdir -p "$(dirname "$LINK")" - printf '%s\n' "$want" > "$LINK" - log "wrote $LINK" - fi - # Apply now as well, in case wlan0 already exists this boot. - if [ -d /sys/class/net/wlan0 ]; then - ip link set dev wlan0 down 2>/dev/null || true - ip link set dev wlan0 address "$wlan" 2>/dev/null \ - && log "wlan0 address set from persist" \ - || log "could not set wlan0 address now; the link file covers the next boot" - ip link set dev wlan0 up 2>/dev/null || true - fi -else - log "no usable WLAN address in persist; leaving the interface alone" -fi - -if [ -n "${bt:-}" ]; then - if [ -d /sys/class/bluetooth/hci0 ] && command -v btmgmt >/dev/null; then - btmgmt --index 0 public-addr "$bt" >/dev/null 2>&1 \ - && log "bluetooth public address set from persist" \ - || log "btmgmt refused the public address (controller may not support it)" - else - log "no hci0 or no btmgmt yet; bluetooth keeps the firmware default address" - fi -else - log "no usable Bluetooth address in persist" -fi diff --git a/packages/omamobile-device-dipper/bin/omamobile-tailscale-join b/packages/omamobile-device-dipper/bin/omamobile-tailscale-join deleted file mode 100755 index 321bfabed..000000000 --- a/packages/omamobile-device-dipper/bin/omamobile-tailscale-join +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Join the tailnet unattended, then destroy the key. Idempotent: a no-op once -# logged in, so every later boot just rejoins from tailscaled's own state. -# -# Nothing here is hardcoded. Everything comes from the config file, and every -# value has a default, so an empty or missing config is a quiet no-op. -set -eu - -# Overridable only so this script can be tested as-is; production leaves these. -CONF=${OMAMOBILE_TS_CONF:-/etc/omamobile/tailscale.conf} - -# Defaults. The config file may override any of them. -TS_AUTHKEY_FILE=/etc/omamobile/tailscale.authkey -TS_HOSTNAME=$(hostname 2>/dev/null || echo omamobile) -TS_UP_ARGS=--accept-dns=false -TS_KEEP_KEY=0 - -# The config is data: KEY=value lines only, no shell, so a typo cannot run code. -if [ -r "$CONF" ]; then - while IFS= read -r line || [ -n "$line" ]; do - case $line in - ''|\#*) continue ;; - TS_AUTHKEY_FILE=*|TS_HOSTNAME=*|TS_UP_ARGS=*|TS_KEEP_KEY=*) ;; - *) echo "omamobile-tailscale: ignoring unknown setting: ${line%%=*}" >&2; continue ;; - esac - key=${line%%=*} - value=${line#*=} - # strip one layer of surrounding quotes, if present - case $value in \"*\") value=${value#\"}; value=${value%\"} ;; esac - eval "$key=\$value" - done < "$CONF" -fi -KEY=${OMAMOBILE_TS_KEY:-$TS_AUTHKEY_FILE} - -# Already joined? tailscaled persists its node state, so every later boot lands here. -if tailscale status --json 2>/dev/null | grep -q '"BackendState"[[:space:]]*:[[:space:]]*"Running"'; then - exit 0 -fi -[ -s "$KEY" ] || exit 0 - -# file: keeps the key out of the command line and the journal (tailscale >= 1.38). -# shellcheck disable=SC2086 -tailscale up --auth-key="file:$KEY" --hostname="$TS_HOSTNAME" $TS_UP_ARGS - -# A single-use key must not survive on disk. TS_KEEP_KEY=1 is for a reusable key. -[ "$TS_KEEP_KEY" = 1 ] || rm -f "$KEY" diff --git a/packages/omamobile-device-dipper/build b/packages/omamobile-device-dipper/build deleted file mode 100755 index 966b2ff2a..000000000 --- a/packages/omamobile-device-dipper/build +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: MIT -# Compile reboot-to into BUILDDIR (default: build). -set -euo pipefail -cd -- "$(dirname -- "${BASH_SOURCE[0]}")" -out=${1:-build-output} -mkdir -p "$out" -${CC:-cc} ${CFLAGS:--O2} -Wall -Wextra -o "$out/reboot-to" src/reboot-to.c ${LDFLAGS:-} diff --git a/packages/omamobile-device-dipper/device.conf b/packages/omamobile-device-dipper/device.conf deleted file mode 100644 index a07e342bc..000000000 --- a/packages/omamobile-device-dipper/device.conf +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: MIT -# Device descriptor: Xiaomi Mi 8 (dipper). Every value below is read off the -# phone itself (live device tree, boot image header, /proc/partitions) or from -# the running stock kernel; nothing is copied from another board. -CODENAME=dipper -NAME="Xiaomi Mi 8" -SOC=sdm845 -# Matches the board DTS this port carries (sdm845-xiaomi-dipper.dts). -COMPATIBLE="xiaomi,dipper" -# Android boot image header v1, page size 4096, second_size 0, and two ~480 KB -# FDTs concatenated at the end of the kernel blob: the DTB is appended to the -# kernel and ABL picks one by qcom,msm-id / qcom,board-id. -BOOT_METHOD=android-v1-appended-dtb -BOOT_PAGESIZE=0x1000 -PACKAGE=omamobile-device-dipper -ROOTFS_PROFILE=dipper -ROOTFS_PACKAGES="qrtr pd-mapper tqftpserv rmtfs" -# Arch repository packages only. Wi-Fi also needs the Qualcomm IPC daemons -# (qrtr, rmtfs, tqftpserv, pd-mapper), which exist as AUR PKGBUILDs rather than -# repository packages, so they have to be built for aarch64 like our own -# packages -- they cannot be listed here. See WIFI-PLAN.md. -ROOTFS_DIST_PACKAGES="vulkan-freedreno linux-firmware-qcom linux-firmware-atheros" -# Set once the kernel is built; the port has no kernel release yet. -KERNEL_RELEASE= -# dipper is NOT A/B for the OS: one `boot`, one `system`, one `userdata`, plus a -# `recovery` partition. Only the bootloader chain is slotted (xbl/abl/tz/hyp/...), -# and this port never writes any of it. So there is no `_b` suffix anywhere here -# and no fallback slot: see NOTES.md. -BOOT_IMAGES="boot" -UFS_RW="userdata" -# 0x438 x 0x8c8 from the active panel node (Samsung EA8074, notch, cmd mode, 60 Hz). -PANEL_SIZE=1080x2248 -MONITOR_SCALE=2.25 diff --git a/packages/omamobile-device-dipper/etc/omamobile-mirrorlist b/packages/omamobile-device-dipper/etc/omamobile-mirrorlist deleted file mode 100644 index f9be3d0e9..000000000 --- a/packages/omamobile-device-dipper/etc/omamobile-mirrorlist +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: MIT -# Where pacman gets Omarchy Mobile's packages ([omamobile] in /etc/pacman.conf). -# -# The one active Server line is the channel this phone follows: -# stable what has run on the Pixel 7 Pro; phones installed from a -# release follow it -# development every day's build, first; for builders and testers -# local the repository on the phone itself, /var/lib/omamobile/repo, -# filled from a build machine by tools/repo-push -# -# Switch with: sudo omamobile-update channel development (or stable, local) -# See which: omamobile-update check -# -# pacman keeps a changed copy of this file across upgrades (backup= in the -# device package); a new default then arrives as omamobile-mirrorlist.pacnew. -Server = https://pkgs.omamobile.org/stable/$arch -#Server = https://pkgs.omamobile.org/development/$arch -#Server = file:///var/lib/omamobile/repo/$arch diff --git a/packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example b/packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example deleted file mode 100644 index 6d43c8f3e..000000000 --- a/packages/omamobile-device-dipper/etc/omamobile/tailscale.conf.example +++ /dev/null @@ -1,18 +0,0 @@ -# /etc/omamobile/tailscale.conf -- how the phone joins the tailnet. -# KEY=value lines only; anything else is ignored with a warning. Every setting -# has a default, so you can delete this file entirely and nothing breaks. - -# Where the auth key is read from. Delete the key file (or leave it empty) and -# the join is skipped: do `tailscale up` by hand instead. -#TS_AUTHKEY_FILE=/etc/omamobile/tailscale.authkey - -# The name the node takes in the tailnet. Defaults to the phone's hostname. -#TS_HOSTNAME=mi8 - -# Extra flags for `tailscale up`. Defaults to --accept-dns=false. -# Examples: "--accept-routes --advertise-tags=tag:phone" -#TS_UP_ARGS=--accept-dns=false - -# Single-use keys are deleted after a successful join. Set to 1 for a reusable -# key you want to keep on the phone. -#TS_KEEP_KEY=0 diff --git a/packages/omamobile-device-dipper/install b/packages/omamobile-device-dipper/install deleted file mode 100755 index 5042c0246..000000000 --- a/packages/omamobile-device-dipper/install +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: MIT -# Stage omamobile-device-dipper into DESTDIR. Nothing is enabled that would -# mark a slot successful or start the radio, the charger, or a camera. -# ./install DESTDIR [BUILDDIR] -set -euo pipefail -cd -- "$(dirname -- "${BASH_SOURCE[0]}")" -destination=${1:?Usage: ./install DESTDIR [BUILDDIR]} -build=${2:-build-output} -[[ $destination == /* && $destination != "/" ]] || { echo "Use an absolute staging directory" >&2; exit 1; } -install -Dm755 "$build/reboot-to" "$destination/usr/bin/reboot-to" -install -Dm644 vendor/udev/rules.d/10-omamobile-storage.rules \ - "$destination/usr/lib/udev/rules.d/10-omamobile-storage.rules" -install -Dm644 vendor/systemd/network/20-usb-gadget.network \ - "$destination/usr/lib/systemd/network/20-usb-gadget.network" -install -Dm644 vendor/systemd/system.conf.d/10-omamobile-watchdog.conf \ - "$destination/usr/lib/systemd/system.conf.d/10-omamobile-watchdog.conf" -install -Dm644 vendor/systemd/logind.conf.d/10-omamobile-power-key.conf \ - "$destination/usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf" -install -Dm644 vendor/NetworkManager/conf.d/10-omamobile-usb.conf \ - "$destination/usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf" -# This phone's own WLAN and Bluetooth addresses are read from `persist` at boot, -# so the image stays identical for every Mi 8. -install -Dm755 bin/omamobile-dipper-identity "$destination/usr/local/bin/omamobile-dipper-identity" -install -Dm644 vendor/systemd/system/omamobile-dipper-identity.service \ - "$destination/usr/lib/systemd/system/omamobile-dipper-identity.service" -# Unattended tailnet join, driven entirely by /etc/omamobile/tailscale.conf. -install -Dm755 bin/omamobile-tailscale-join "$destination/usr/local/bin/omamobile-tailscale-join" -install -Dm644 vendor/systemd/system/omamobile-tailscale-join.service \ - "$destination/usr/lib/systemd/system/omamobile-tailscale-join.service" -install -Dm644 etc/omamobile/tailscale.conf.example \ - "$destination/usr/share/omamobile/tailscale.conf.example" -install -Dm644 device.conf \ - "$destination/usr/share/omamobile/device.conf" -install -Dm644 etc/omamobile-mirrorlist \ - "$destination/etc/pacman.d/omamobile-mirrorlist" -install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-dipper/LICENSE" -install -Dm644 version "$destination/usr/share/omamobile/device-dipper/version" diff --git a/packages/omamobile-device-dipper/omamobile-device-dipper.install b/packages/omamobile-device-dipper/omamobile-device-dipper.install deleted file mode 100644 index 908195f92..000000000 --- a/packages/omamobile-device-dipper/omamobile-device-dipper.install +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: MIT -# Add the [omamobile] repository to pacman.conf, before [omarchy] so its -# builds (e.g. Mesa with Mali-G710 support) win. Added once; never removed -# automatically, so a user's edits stay. -add_repository() { - local conf=/etc/pacman.conf - grep -q '^\[omamobile\]' "$conf" && return - local entry='[omamobile]\nInclude = /etc/pacman.d/omamobile-mirrorlist\n' - if grep -q '^\[omarchy\]' "$conf"; then - sed -i "0,/^\[omarchy\]/s//${entry//\//\\/}\n[omarchy]/" "$conf" - elif grep -q '^\[core\]' "$conf"; then - sed -i "0,/^\[core\]/s//${entry//\//\\/}\n[core]/" "$conf" - else - printf '\n[omamobile]\nInclude = /etc/pacman.d/omamobile-mirrorlist\n' >>"$conf" - fi -} - -# The identity service makes the image device-agnostic (it reads this phone's -# own addresses from `persist`); the tailnet join is a no-op without a key. -enable_units() { - systemctl enable omamobile-dipper-identity.service >/dev/null 2>&1 || true - systemctl enable omamobile-tailscale-join.service >/dev/null 2>&1 || true -} - -post_install() { - add_repository - enable_units -} - -post_upgrade() { - add_repository - enable_units -} diff --git a/packages/omamobile-device-dipper/test/all b/packages/omamobile-device-dipper/test/all deleted file mode 100755 index 8f91f1b26..000000000 --- a/packages/omamobile-device-dipper/test/all +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: MIT -# Tests for omamobile-device-dipper. reboot-to is compiled from -# src/reboot-to.c in this directory, so a copied package still builds. -# Do not execute reboot-to. -set -euo pipefail -cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." -fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } -pass() { printf 'ok - %s\n' "$1"; } -tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT - -bash -n build || fail "build parses" -bash -n install || fail "install parses" -pass "scripts parse" - -grep -q '^depends=.*bluez-utils' PKGBUILD \ - || fail "the identity service needs bluez-utils for btmgmt" -pass "the Bluetooth identity helper has btmgmt installed" - -grep -q '\.\./\.\.' build install && fail "build or install reaches outside the package directory" -pass "build and install stay inside the package directory" - -if [[ -f ../omamobile-device-cheetah/src/reboot-to.c ]]; then - cmp -s src/reboot-to.c ../omamobile-device-cheetah/src/reboot-to.c \ - || fail "reboot-to.c drifted from the cheetah package" - pass "reboot-to.c matches the cheetah source" - # Deliberately NOT cheetah's rule: dipper is not A/B, so userdata is the only - # writable partition, and its Android partitions span six LUNs (sda..sdf) - # rather than cheetah's four. Assert dipper's own intent instead of equality. - rules=vendor/udev/rules.d/10-omamobile-storage.rules - grep -q 'KERNEL=="sd\[a-f\]", MODE="0000"' "$rules" \ - || fail "the whole-disk nodes of all six LUNs must be inaccessible" - grep -q 'ID_PART_ENTRY_NAME}!="userdata"' "$rules" \ - || fail "every partition but userdata must be ignored by desktop tools" - grep -q 'sd\[a-f\]\[0-9\]' "$rules" \ - || fail "the partition rule must cover all six LUNs" - grep -qE '_b"|slot B' "$rules" \ - && fail "dipper has no slot B; the rule must not mention one" - pass "the storage rule matches dipper's layout (six LUNs, userdata only)" - cmp -s etc/omamobile-mirrorlist ../omamobile-device-cheetah/etc/omamobile-mirrorlist \ - || fail "the mirrorlist drifted from the cheetah package" - pass "the mirrorlist matches the cheetah package" - cmp -s vendor/systemd/logind.conf.d/10-omamobile-power-key.conf \ - ../omamobile-device-cheetah/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf \ - || fail "the power-key drop-in drifted from the cheetah package" - pass "the power-key drop-in matches the cheetah package" - # dipper's install script adds its own units on top of cheetah's repository - # setup, so it is not identical; check both halves are there. - grep -q 'add_repository' omamobile-device-dipper.install \ - || fail "the install script must still add the [omamobile] repository" - grep -q 'omamobile-dipper-identity.service' omamobile-device-dipper.install \ - || fail "the identity service must be enabled on install" - grep -q 'omamobile-tailscale-join.service' omamobile-device-dipper.install \ - || fail "the tailnet join must be enabled on install" - pass "the install script adds the repository and dipper's own units" -fi -grep -q 'omamobile-keyring' PKGBUILD || fail "pacman needs omamobile-keyring" -grep -q '^install=omamobile-device-dipper.install$' PKGBUILD \ - || fail "the pacman install script is not named" -[[ -f etc/omamobile-mirrorlist && -f omamobile-device-dipper.install ]] \ - || fail "the pacman mirrorlist or install script is missing" -pass "pacman gets the keyring, the mirrorlist, and the install script" -if [[ -f ../../device/dipper/device.conf ]]; then - cmp -s device.conf ../../device/dipper/device.conf \ - || fail "device.conf drifted from the descriptor" - pass "device.conf matches the descriptor" -fi - -./build "$tmp/build" || fail "reboot-to compiles" -[[ -x $tmp/build/reboot-to ]] || fail "reboot-to is not executable" -pass "reboot-to compiles" - -./install "$tmp/root" "$tmp/build" -for f in usr/bin/reboot-to \ - usr/lib/udev/rules.d/10-omamobile-storage.rules \ - usr/lib/systemd/network/20-usb-gadget.network \ - usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf \ - usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf \ - usr/share/omamobile/device.conf \ - usr/share/omamobile/device-dipper/version \ - usr/share/licenses/omamobile-device-dipper/LICENSE \ - etc/pacman.d/omamobile-mirrorlist; do - [[ -f $tmp/root/$f ]] || fail "install stages $f" -done -# dipper has six UFS LUNs, so the rule covers sda..sdf rather than sda alone. -grep -q 'KERNEL=="sd\[a-f\]", MODE="0000"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \ - || fail "the whole-disk nodes of all six LUNs are made inaccessible" -grep -q 'ID_PART_ENTRY_NAME}!="userdata"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \ - || fail "userdata is the only partition desktop tools may see" -grep -q 'Address=172.16.42.1/24' "$tmp/root/usr/lib/systemd/network/20-usb-gadget.network" \ - || fail "usb0 keeps the initramfs address" -power="$tmp/root/usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf" -grep -qx '\[Login\]' "$power" \ - || fail "the power-key drop-in needs a [Login] header" -grep -q '^HandlePowerKey=ignore$' "$power" \ - || fail "a short press must not power the phone off" -grep -q '^HandlePowerKeyLongPress=ignore$' "$power" \ - || fail "the long press stays the PMIC reset" -grep -q '^PACKAGE=omamobile-device-dipper$' "$tmp/root/usr/share/omamobile/device.conf" \ - || fail "the installed descriptor is dipper" -for absent in usr/bin/omamobile-boot-success usr/bin/omamobile-bootctl \ - usr/lib/systemd/system/omamobile-boot-success.service \ - usr/bin/omamobile-wifi-start usr/bin/omamobile-charge-guard \ - usr/bin/omamobile-camera-start; do - [[ ! -e $tmp/root/$absent ]] || fail "install includes $absent" -done -pass "install stages the udev rule, the USB link, and the mirrorlist, and nothing that marks a slot or starts hardware" -[[ ! -e $tmp/root/usr/lib/systemd/logind.conf.d/10-omamobile-lid.conf ]] \ - || fail "dipper has no lid: no lid drop-in" -pass "no lid drop-in" diff --git a/packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf b/packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf deleted file mode 100644 index 252de6e15..000000000 --- a/packages/omamobile-device-dipper/vendor/NetworkManager/conf.d/10-omamobile-usb.conf +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: MIT -# Omarchy Mobile: the USB gadget link to the host (usb0) is configured by -# systemd-networkd; NetworkManager manages everything else (Wi-Fi later). -[keyfile] -unmanaged-devices=interface-name:usb0 diff --git a/packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf b/packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf deleted file mode 100644 index a1e2cb0eb..000000000 --- a/packages/omamobile-device-dipper/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: MIT -# Omarchy Mobile: a short press of the power button opens Omarchy's system menu -# (bound in Hyprland by omamobile-setup-user), as Super + Escape does, instead -# of powering off. A long press still forces a reset in the PMIC hardware. -[Login] -HandlePowerKey=ignore -HandlePowerKeyLongPress=ignore diff --git a/packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network b/packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network deleted file mode 100644 index fe5ce66e9..000000000 --- a/packages/omamobile-device-dipper/vendor/systemd/network/20-usb-gadget.network +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: MIT -# Omarchy Mobile: USB networking to the host. The initramfs sets up the USB -# gadget (CDC NCM) before handing over to Arch; this gives it an address. -# The host shares its internet over this link (NetworkManager "shared" -# mode on 172.16.42.2), so it is also the gateway. DNS goes to public resolvers. -[Match] -Name=usb0 - -[Network] -Address=172.16.42.1/24 -DNS=1.1.1.1 -DNS=9.9.9.9 -ConfigureWithoutCarrier=yes - -# Default route via the host, but a high metric so Wi-Fi/ethernet (metric ~600) -# win when present; USB stays the fallback internet path. -[Route] -Gateway=172.16.42.2 -Metric=1000 diff --git a/packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf b/packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf deleted file mode 100644 index 7c01e4d1b..000000000 --- a/packages/omamobile-device-dipper/vendor/systemd/system.conf.d/10-omamobile-watchdog.conf +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: MIT -# Omarchy Mobile, Xiaomi Mi 8: unlike the Pixels, SDM845 leaves its cluster -# watchdogs *running*, and the initramfs claims /dev/watchdog0 and pets it -# (`watchdog -t 5 -T 30`). That daemon dies with everything else just before -# switch_root, so unless systemd picks the watchdog up, nothing holds it and the -# hardware resets the phone about 30 s into the boot. Measured: an otherwise -# healthy first boot reached "Started Journal Service" and then died at -# `watchdog0: pretimeout event`, 34 s in. -# -# RuntimeWatchdogSec programs the *hardware* timeout and systemd pings at half -# of it, so it must leave room for the longest stretch systemd spends not -# servicing its main loop. 10 s was not enough: on a first boot systemd spends -# about 8 s in "Applying preset policy" (preset-all, because /etc/machine-id is -# still `uninitialized`) and the pretimeout fired at 17 s, mid-boot. 30 s is -# what the initramfs daemon already proved this watchdog accepts. -# RebootWatchdogSec is the Pixel rationale: if shutdown hangs, let the watchdog -# reset the phone after a minute rather than leaving it on the splash. -[Manager] -RuntimeWatchdogSec=30s -RebootWatchdogSec=1min diff --git a/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service b/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service deleted file mode 100644 index d307135b9..000000000 --- a/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-dipper-identity.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Apply the Mi 8's own WLAN and Bluetooth addresses from persist -# persist is read-only to us; the storage guard keeps it that way. -ConditionPathExists=/dev/disk/by-partlabel/persist -Before=NetworkManager.service bluetooth.service -Wants=local-fs.target -After=local-fs.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/local/bin/omamobile-dipper-identity - -[Install] -WantedBy=multi-user.target diff --git a/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service b/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service deleted file mode 100644 index c725ba9e0..000000000 --- a/packages/omamobile-device-dipper/vendor/systemd/system/omamobile-tailscale-join.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Join the tailnet once from a pre-seeded auth key -# NetworkManager-wait-online is masked by omamobile-firstboot, so don't wait on it: -# tailscaled retries by itself until Wi-Fi or usb0 is up. -Wants=tailscaled.service -After=tailscaled.service -ConditionPathExists=/etc/omamobile/tailscale.authkey - -[Service] -Type=oneshot -RemainAfterExit=no -ExecStart=/usr/local/bin/omamobile-tailscale-join -# A single-use key is a credential: don't let a failure loop retry it forever. -Restart=no - -[Install] -WantedBy=multi-user.target diff --git a/packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules b/packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules deleted file mode 100644 index b0d6ed47e..000000000 --- a/packages/omamobile-device-dipper/vendor/udev/rules.d/10-omamobile-storage.rules +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: MIT -# Omarchy Mobile storage guard, continued in Arch. The initramfs marks every UFS -# partition read-only except userdata (dipper is not A/B: there is one `boot`, -# one `system` and one `userdata`, so nothing else is ever written). udev would -# recreate the whole-disk nodes, so make them inaccessible and keep desktop -# tools away from every Android partition. -# -# dipper spreads its partitions over six LUNs, sda to sdf, with userdata on sda. -SUBSYSTEM=="block", KERNEL=="sd[a-f]", MODE="0000", ENV{UDISKS_IGNORE}="1" -SUBSYSTEM=="block", KERNEL=="sd[a-f][0-9]*", ENV{ID_PART_ENTRY_NAME}!="userdata", ENV{UDISKS_IGNORE}="1" diff --git a/packages/omamobile-device-dipper/version b/packages/omamobile-device-dipper/version deleted file mode 100644 index 6e8bf73aa..000000000 --- a/packages/omamobile-device-dipper/version +++ /dev/null @@ -1 +0,0 @@ -0.1.0 diff --git a/packages/pd-mapper/PKGBUILD b/packages/pd-mapper/PKGBUILD deleted file mode 100644 index be579edc3..000000000 --- a/packages/pd-mapper/PKGBUILD +++ /dev/null @@ -1,31 +0,0 @@ -# Maintainer: Super Tecno Gym - -pkgname="pd-mapper" -pkgdesc="Qualcomm IPC Router protocol" -pkgver=1.1 -pkgrel=1 -arch=(aarch64 x86_64) -url="https://github.com/linux-msm/pd-mapper" -license=("BSD-3-Clause") -conflicts=("${pkgname%-git}") -depends=(qrtr) -groups=(qcom-icnss-wlan) -makedepends=(qrtr) -_srcname="${pkgname}-${pkgver}" -source=( - "${_srcname}.tar.gz::https://github.com/linux-msm/pd-mapper/archive/refs/tags/v${pkgver}.tar.gz" -) -sha256sums=('7654a7fb8b70b0c7670f98ad9313649abc48eabcef84dad086ed01408fd538a2') - -build() { - cd "$_srcname" - - make prefix=/usr -} - -package() { - cd "$_srcname" - - make prefix=/usr DESTDIR="$pkgdir/" install - install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING -} diff --git a/packages/qrtr/PKGBUILD b/packages/qrtr/PKGBUILD deleted file mode 100644 index 725b2aa7f..000000000 --- a/packages/qrtr/PKGBUILD +++ /dev/null @@ -1,31 +0,0 @@ -# Maintainer: Super Tecno Gym -# Contributor: Sam Day - -pkgname="qrtr" -pkgdesc="Userspace reference for net/qrtr in the Linux kernel" -pkgver=1.2 -pkgrel=1 -arch=(aarch64 x86_64) -url="https://github.com/linux-msm/qrtr" -license=("BSD-3-Clause") -conflicts=("${pkgname%-git}") -groups=(qcom-icnss-wlan) -_srcname="${pkgname}-${pkgver}" -source=("${_srcname}.tar.gz::https://github.com/linux-msm/qrtr/archive/refs/tags/v${pkgver}.tar.gz") -sha256sums=('7a82bf80246fe71287b13c66c0466208822e8337fcd4aaf302eee6c5fcb48a52') -makedepends=(meson) - -build() { - cd "$_srcname" - - mkdir -p build - meson setup build --prefix=/usr - meson compile -C build -} - -package() { - cd "$_srcname" - - meson install -C build --destdir "$pkgdir" - install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING -} diff --git a/packages/rmtfs/PKGBUILD b/packages/rmtfs/PKGBUILD deleted file mode 100644 index 401c92de0..000000000 --- a/packages/rmtfs/PKGBUILD +++ /dev/null @@ -1,38 +0,0 @@ -# Maintainer: Super Tecno Gym -# Contributor: Sam Day - -pkgname="rmtfs" -pkgdesc="Qualcomm Remote Filesystem Service Implementation" -pkgver=1.2 -pkgrel=1 -arch=(aarch64 x86_64) -url="https://github.com/linux-msm/rmtfs" -license=("BSD-3-Clause") -depends=(qrtr libudev.so) -conflicts=("${pkgname%-git}") -groups=(qcom-icnss-wlan) -makedepends=() -_srcname="${pkgname}-${pkgver}" -source=( - "${_srcname}.tar.gz::https://github.com/linux-msm/rmtfs/archive/refs/tags/v${pkgver}.tar.gz" - "udev.rules" - ) - -sha256sums=( - '5be459af54b5ff0f1447fc265246e526d27e8250212f5f380458f9ee551bd3a3' - '0c2f26d40d9d18e3089c6d836b64231c4f7e0c1ca41686fe7c9d1eb495dc6bbe' -) - -build() { - cd "$_srcname" - - make prefix=/usr -} - -package() { - cd "$_srcname" - - make prefix=/usr DESTDIR="$pkgdir/" install - install -Dm644 "$srcdir"/udev.rules "$pkgdir/usr/lib/udev/rules.d/65-$pkgname.rules" - install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING -} diff --git a/packages/rmtfs/udev.rules b/packages/rmtfs/udev.rules deleted file mode 100644 index 72886cb57..000000000 --- a/packages/rmtfs/udev.rules +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEM=="uio", ATTR{name}=="rmtfs", SYMLINK+="qcom_rmtfs_uio1" diff --git a/packages/tqftpserv/PKGBUILD b/packages/tqftpserv/PKGBUILD deleted file mode 100644 index 3c764cba5..000000000 --- a/packages/tqftpserv/PKGBUILD +++ /dev/null @@ -1,33 +0,0 @@ -# Maintainer: Super Tecno Gym - -pkgname="tqftpserv" -pkgdesc="Trivial File Transfer Protocol server over AF_QIPCRTR" -pkgver=1.2 -pkgrel=1 -arch=(aarch64 x86_64) -url="https://github.com/linux-msm/tqftpserv" -license=("BSD-3-Clause") -conflicts=("${pkgname%-git}") -depends=(qrtr) -groups=(qcom-icnss-wlan) -makedepends=(qrtr) -_srcname="${pkgname}-${pkgver}" -source=("${_srcname}.tar.gz::https://github.com/linux-msm/tqftpserv/archive/refs/tags/v${pkgver}.tar.gz") -sha256sums=('a3850c34e48f23b7bc360d70f1e91700de2f8c60af003eda93e14182f8cf6af1') -makedepends=(meson) - -build() { - cd "$_srcname" - - mkdir -p build - meson setup build --prefix=/usr - meson compile -C build - -} - -package() { - cd "$_srcname" - - meson install -C build --destdir "$pkgdir" - install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING -} diff --git a/rootfs/build-inside b/rootfs/build-inside index 7ce78abcc..14ba41b88 100755 --- a/rootfs/build-inside +++ b/rootfs/build-inside @@ -7,8 +7,7 @@ # /modules the kernel modules tarball (read-only) # /target an empty volume: the root file system is assembled here # /out where the raw image and the MANIFEST go -# Environment: VERSION, DEVICE, DEVICE_PACKAGE, ROOTFS_PACKAGES, -# ROOTFS_DIST_PACKAGES and +# Environment: VERSION, DEVICE, DEVICE_PACKAGE, ROOTFS_PACKAGES and # ALLOW_MISSING (both space-separated), KERNEL_RELEASE, MODULES_SHA256, # GIT_COMMIT, ALARM_SHA256, OMARCHY_CHANNEL, CHANNEL ([omamobile]: stable, # development or local). @@ -30,13 +29,12 @@ pacman -Sy >/dev/null available() { pacman -Sp --print-format %n "$1" >/dev/null 2>&1; } mapfile -t base < <(list /src/rootfs/packages.base) -read -ra distro <<<"${ROOTFS_DIST_PACKAGES:-}" mapfile -t ours < <(list /src/rootfs/packages.omamobile) ours+=("$DEVICE_PACKAGE") read -ra board <<<"${ROOTFS_PACKAGES:-}" ours+=("${board[@]}") missing=() skipped_ours=() -for p in "${base[@]}" "${distro[@]}"; do available "$p" || missing+=("$p"); done +for p in "${base[@]}"; do available "$p" || missing+=("$p"); done ((${#missing[@]} == 0)) || die "not in any repository: ${missing[*]}" # Every package of ours must come from [omamobile], not a same-named one # elsewhere (Mesa, Hyprland, libcamera are in Arch Linux ARM and [omarchy] @@ -55,7 +53,7 @@ done ((${#missing[@]} == 0)) || die "not in out/repo: ${missing[*]} (build them: tools/build-packages; or allow: --allow-missing)" say "Base system and Omarchy (${#base[@]} packages)" -pacstrap -C /etc/pacman.conf -c -M "$T" "${base[@]}" "${distro[@]}" >/var/log/pacstrap-base.log 2>&1 || { tail -40 /var/log/pacstrap-base.log; die "pacstrap failed"; } +pacstrap -C /etc/pacman.conf -c -M "$T" "${base[@]}" >/var/log/pacstrap-base.log 2>&1 || { tail -40 /var/log/pacstrap-base.log; die "pacstrap failed"; } omarchy_list=$T/usr/share/omarchy/install/omarchy-base.packages [[ -f $omarchy_list ]] || die "no $omarchy_list in the omarchy package" @@ -116,19 +114,6 @@ depmod -b "$T" -a "$KERNEL_RELEASE" # bin/omamobile push compares this with its tarball, so it won't push them again echo "$MODULES_SHA256" > "$T/usr/lib/modules/$KERNEL_RELEASE/.omamobile-tarball" -if [[ -d /device-firmware ]]; then - say "Device firmware" - for d in qcom ath10k; do - if [[ -d /device-firmware/$d ]]; then - cp -a "/device-firmware/$d" "$T/usr/lib/firmware/" - elif [[ $DEVICE == dipper ]]; then - die "missing dipper firmware /device-firmware/$d (run tools/dipper/extract-firmware)" - fi - done -elif [[ $DEVICE == dipper ]]; then - die "missing dipper firmware staging directory (run tools/dipper/build)" -fi - say "Omarchy patches (omamobile-omarchy)" # The same code path as every Omarchy upgrade on a phone: the package's pacman # hook already applied the series when pacstrap installed it; this runs it @@ -190,7 +175,6 @@ say "MANIFEST" echo "# Omarchy Mobile root image" echo "version: $VERSION" echo "device: $DEVICE ($DEVICE_PACKAGE${ROOTFS_PACKAGES:+ $ROOTFS_PACKAGES})" - echo "distribution packages: ${ROOTFS_DIST_PACKAGES:-none}" echo "built: $(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "repository commit: $GIT_COMMIT" echo "arch linux arm tarball sha256: $ALARM_SHA256" diff --git a/tools/build-packages b/tools/build-packages index a75d810ec..f8af48c8e 100755 --- a/tools/build-packages +++ b/tools/build-packages @@ -62,7 +62,7 @@ done # Default order: dependencies of our own packages first (check() of a later # package can then install an earlier one from the repository being built). -ORDER=(qrtr pd-mapper tqftpserv rmtfs omamobile-keyring libfprint neard omacam omamobile-apps omamobile-device-cheetah omamobile-device-felix omamobile-device-lynx omamobile-device-raven omamobile-device-panther omamobile-device-dipper omamobile-audio +ORDER=(omamobile-keyring libfprint neard omacam omamobile-apps omamobile-device-cheetah omamobile-device-felix omamobile-device-lynx omamobile-device-raven omamobile-device-panther omamobile-audio omamobile-sensors omamobile-gnss omamobile-fingerprint omamobile-mirror omamobile-omarchy omamobile-owl-widgets omamobile-shell omamobile-modem omamobile-modem-sit omamobile-mmd omamobile-speaker-tuning omamobile-waydroid omamobile-firstboot mesa hyprland libcamera) diff --git a/tools/build-rootfs b/tools/build-rootfs index 3d68572f6..4499d538b 100755 --- a/tools/build-rootfs +++ b/tools/build-rootfs @@ -103,8 +103,6 @@ DEVICE_PACKAGE=$(sed -n 's/^PACKAGE=\([a-z0-9-]*\)$/\1/p' "$conf") [[ -n $DEVICE_PACKAGE ]] || alarm_die "$conf has no PACKAGE" ROOTFS_PACKAGES=$(sed -n 's/^ROOTFS_PACKAGES="\(.*\)"$/\1/p' "$conf") [[ $ROOTFS_PACKAGES =~ ^[a-z0-9\ -]*$ ]] || alarm_die "$conf: ROOTFS_PACKAGES may hold only package names" -ROOTFS_DIST_PACKAGES=$(sed -n 's/^ROOTFS_DIST_PACKAGES="\(.*\)"$/\1/p' "$conf") -[[ $ROOTFS_DIST_PACKAGES =~ ^[a-z0-9\ -]*$ ]] || alarm_die "$conf: ROOTFS_DIST_PACKAGES may hold only package names" repo=$outrel/repo/aarch64 [[ -f $repo/omamobile.db ]] || @@ -114,10 +112,6 @@ release=$(cat "$KERNEL_OUT/include/config/kernel.release") modules=$KERNEL_OUT/modules-$release.tar.zst [[ -f $modules ]] || alarm_die "no $modules: run KERNEL_OUT=$KERNEL_OUT bin/omamobile modules" -device_firmware=$ROOT/../out/$DEVICE/firmware -docker_args=(-v "$ROOT:/src:ro" -v "$ROOT/$outrel/repo:/repo:ro" -v "$modules:/modules:ro") -[[ ! -d $device_firmware ]] || docker_args+=(-v "$device_firmware:/device-firmware:ro") - name=omamobile-rootfs-$DEVICE-$VERSION-aarch64 out=$ROOT/$outrel mkdir -p "$out" @@ -142,11 +136,10 @@ start=$(date +%s) alarm_say "Building $name for $DEVICE (kernel $release, [omamobile] channel $CHANNEL)" commit=$(git rev-parse --short=12 HEAD)$(git diff --quiet HEAD -- rootfs packages tools device 2>/dev/null || echo "-dirty") docker run --rm --privileged --platform linux/arm64 \ - "${docker_args[@]}" \ + -v "$ROOT:/src:ro" -v "$ROOT/$outrel/repo:/repo:ro" -v "$modules:/modules:ro" \ -v "$volume:/target" -v "$work:/out" -v "$ALARM_CACHE/pkg:/var/cache/pacman/pkg" \ -e VERSION="$VERSION" -e DEVICE="$DEVICE" -e DEVICE_PACKAGE="$DEVICE_PACKAGE" \ -e ROOTFS_PACKAGES="$ROOTFS_PACKAGES" \ - -e ROOTFS_DIST_PACKAGES="$ROOTFS_DIST_PACKAGES" \ -e KERNEL_RELEASE="$release" -e MODULES_SHA256="$(sha256sum < "$modules" | cut -d' ' -f1)" \ -e GIT_COMMIT="$commit" -e ALARM_SHA256="$(sha256sum < "$ALARM_TARBALL" | cut -d' ' -f1)" \ -e OMARCHY_CHANNEL="$OMARCHY_CHANNEL" -e CHANNEL="$CHANNEL" -e ALLOW_MISSING="$ALLOW_MISSING" \ diff --git a/tools/dipper/apply-identity b/tools/dipper/apply-identity deleted file mode 100755 index 6186a13a9..000000000 --- a/tools/dipper/apply-identity +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# Write this phone's Bluetooth address into a built DTB, so the identifier lives -# in the flashed image and never in the repository. -# -# apply-identity (edits the file in place) -# -# Without an identity file it leaves the placeholder alone and says so: the DTB -# stays valid, Bluetooth just keeps the firmware's shared default address. -set -euo pipefail - -dtb=${1:?usage: apply-identity } -ID=${ID:-$HOME/android/reference/dipper-stock/identity.env} -NODE=${NODE:-} - -[[ -f $dtb ]] || { echo "no such DTB: $dtb" >&2; exit 1; } -command -v fdtput >/dev/null || { echo "need fdtput (device-tree-compiler)" >&2; exit 1; } - -if [[ ! -r $ID ]]; then - echo "no identity file at $ID: leaving local-bd-address at the placeholder" - echo "(run tools/dipper/extract-identity after tools/dipper/backup-stock)" - exit 0 -fi -# shellcheck disable=SC1090 -. "$ID" -[[ -n ${DIPPER_BT_BD_LE:-} ]] || { echo "$ID has no DIPPER_BT_BD_LE" >&2; exit 1; } - -# Find the bluetooth node rather than hardcoding a path, so a DTS reshuffle -# cannot silently write the address nowhere. -if [[ -z $NODE ]]; then - NODE=$(fdtget -l / "$dtb" >/dev/null 2>&1 && true; python3 - "$dtb" <<'PY' -import subprocess, sys -dtb = sys.argv[1] -dts = subprocess.check_output(["dtc", "-I", "dtb", "-O", "dts", dtb], - stderr=subprocess.DEVNULL).decode() -path, found = [], [] -for line in dts.splitlines(): - t = line.strip() - if t.endswith("{"): - path.append(t[:-1].strip().split(":")[-1].strip()) - elif t.startswith("}"): - if path: path.pop() - elif t.startswith('compatible = "qcom,wcn3990-bt"'): - found.append("/" + "/".join(p for p in path[1:] if p)) -if len(found) != 1: - print("", end=""); sys.exit(1) -print(found[0], end="") -PY -) -fi -[[ -n $NODE ]] || { echo "could not find exactly one qcom,wcn3990-bt node in $dtb" >&2; exit 1; } - -# shellcheck disable=SC2086 -fdtput -t bx "$dtb" "$NODE" local-bd-address $DIPPER_BT_BD_LE - -got=$(fdtget -t bx "$dtb" "$NODE" local-bd-address | tr -s ' ') -want=$(printf '%s' "$DIPPER_BT_BD_LE" | tr -s ' ') -# fdtget prints 0x-prefixed bytes; normalise both sides before comparing. -norm() { python3 -c " -import sys -print(' '.join(f'{int(x,16):02x}' for x in sys.stdin.read().split()))"; } -[[ $(norm <<<"$got") == $(norm <<<"$want") ]] || { - echo "the address did not take: wrote '$want', read back '$got'" >&2; exit 1; } - -echo "local-bd-address written into $NODE and verified" diff --git a/tools/dipper/backup-stock b/tools/dipper/backup-stock deleted file mode 100755 index 3e58bd092..000000000 --- a/tools/dipper/backup-stock +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# Read-only backup of dipper's stock partitions, with checksums verified on both -# ends. Nothing is written to the phone. -# -# This is not optional on dipper: the OS partitions are single-copy (one `boot`, -# no slot B), so a bad image has no known-good slot to fall back to. The only -# way back is fastboot over USB with these files. -# -# Needs: SSH to the phone with root available (SimpleSSHD + Magisk, or adb). -set -euo pipefail - -HOST=${HOST:-mi8} -SU=${SU:-/debug_ramdisk/su} -OUT=${OUT:-$HOME/android/reference/dipper-stock/backup} - -# Everything we could overwrite, plus the per-device data that cannot be -# regenerated from any download. `modem` and `dsp` are firmware and the largest -# items; pass --with-firmware to include them. -PARTS=(boot recovery dtbo vbmeta persist persistbak modemst1 modemst2 fsg fsc devinfo misc frp logo splash) -FIRMWARE=(modem dsp) - -[[ ${1:-} == --with-firmware ]] && PARTS+=("${FIRMWARE[@]}") - -umask 077 -mkdir -p "$OUT"; chmod 700 "$OUT" -sums=$OUT/sha256sums.txt -: > "$sums" - -# adb needs no SimpleSSHD or Tailscale and `adb root` already gives uid=0, so it -# is the default when a device is attached. exec-out keeps the dd pipe binary. -if [[ ${TRANSPORT:-auto} == adb ]] || { [[ ${TRANSPORT:-auto} == auto ]] && adb get-state &>/dev/null; }; then - remote() { adb exec-out "$1"; } - via="adb" -else - remote() { ssh "$HOST" "$SU -c '$1'"; } - via="ssh $HOST" -fi - -[[ $(remote 'id -u' | tr -d '\r\n') == 0 ]] || { echo "no root over $via" >&2; exit 1; } - -total=0 failed=0 -for p in "${PARTS[@]}"; do - dev=$(remote "readlink -f /dev/block/by-name/$p" | tr -d '\r\n') - [[ -n $dev ]] || { echo "SKIP $p (no such partition)"; continue; } - size=$(remote "blockdev --getsize64 $dev" | tr -d '\r\n') - want=$(remote "sha256sum $dev" | awk '{print $1}') - printf '%-12s %10s bytes ... ' "$p" "$size" - # dd straight down the ssh pipe: no temp file on the phone, nothing written. - remote "dd if=$dev bs=1M 2>/dev/null" > "$OUT/$p.img" - got=$(sha256sum "$OUT/$p.img" | awk '{print $1}') - local_size=$(stat -c%s "$OUT/$p.img") - if [[ $got == "$want" && $local_size == "$size" ]]; then - echo "ok" - printf '%s %s.img\n' "$got" "$p" >> "$sums" - total=$((total + local_size)) - else - echo "MISMATCH (phone $want/$size, here $got/$local_size)" - rm -f "$OUT/$p.img" - failed=$((failed + 1)) - fi -done - -printf '\n%s bytes backed up into %s\n' "$total" "$OUT" -if (( failed )); then - echo "$failed partition(s) FAILED to verify -- do not treat this backup as usable" >&2 - exit 1 -fi -echo "every partition verified by sha256 on the phone and here." -echo "Restore (phone in fastboot, USB): fastboot flash .img" diff --git a/tools/dipper/bringup-patch-init.py b/tools/dipper/bringup-patch-init.py deleted file mode 100755 index 1ae1301ea..000000000 --- a/tools/dipper/bringup-patch-init.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: MIT -"""Patch the shared initramfs init for a bring-up image. - -dipper has no serial header, and ABL leaves no framebuffer that mainline can -claim, so a boot with no cable attached is completely blind. This makes the -image mirror the kernel log into the `logdump` partition (33 MiB, all zero on -this phone, used by nothing), which Android can read back afterwards with root. - -That needs logdump writable, so the storage guard's allowlist is widened -- for -this image only. It deliberately weakens a safety property: the result is a -diagnostic image, never an install image, and must not be written to `boot`. -""" -import sys -from pathlib import Path - -MIRROR = r'''# BRING-UP: mirror the kernel log to the logdump partition every 2 s, so a -# cable-free boot can still be read back from Android afterwards. -omamobile_logdump_dev() { - for u in /sys/block/sd*/sd*/uevent; do - [ -r "$u" ] || continue - if [ "$(sed -n 's/^PARTNAME=//p' "$u")" = logdump ]; then - echo "/dev/$(sed -n 's/^DEVNAME=//p' "$u")" - return 0 - fi - done - return 1 -} -omamobile_logdump_loop() { - dev=$(omamobile_logdump_dev) || { echo "omamobile: no logdump partition" >/dev/kmsg; return; } - [ -w "$dev" ] || { echo "omamobile: $dev is read-only; the guard kept it closed" >/dev/kmsg; return; } - n=0 - while :; do - n=$((n + 1)) - { echo "=== omamobile bring-up log, pass $n, uptime $(cut -d" " -f1 /proc/uptime) ===" - dmesg - echo "=== probe results, pass $n ===" - # One blind boot has to answer everything worth knowing, because there is - # no shell without a cable. Keep this read-only and cheap. - echo "-- loaded modules --"; cat /proc/modules 2>/dev/null - echo "-- input devices --"; cat /proc/bus/input/devices 2>/dev/null - echo "-- drm cards --"; ls -l /sys/class/drm 2>/dev/null - echo "-- framebuffers --"; ls -l /sys/class/graphics 2>/dev/null - echo "-- block devices --"; ls -l /sys/block 2>/dev/null - echo "-- net interfaces --"; ls -l /sys/class/net 2>/dev/null - echo "-- i2c buses --"; ls -l /sys/bus/i2c/devices 2>/dev/null - echo "-- spmi / platform probe failures --" - for d in /sys/bus/platform/devices/*/driver; do :; done - ls -l /sys/bus/platform/devices 2>/dev/null | head -80 - echo "-- regulators --"; ls /sys/class/regulator 2>/dev/null | head -40 - echo "-- thermal --"; ls /sys/class/thermal 2>/dev/null - echo "-- remoteproc --"; for r in /sys/class/remoteproc/*; do [ -e "$r/state" ] && echo "$r: $(cat "$r/state")"; done - echo "-- cmdline --"; cat /proc/cmdline 2>/dev/null - echo "-- device tree model --"; cat /proc/device-tree/model 2>/dev/null; echo - echo "-- uptime / mem --"; cat /proc/uptime /proc/meminfo 2>/dev/null | head -5 - echo "=== end of pass $n ===" - } | dd of="$dev" bs=4096 conv=notrunc 2>/dev/null - sleep 2 - done -} -omamobile_logdump_loop & -echo "omamobile: bring-up log mirror started" >/dev/kmsg -''' - -ALLOW = " boot_b|init_boot_b|vendor_boot_b|vendor_kernel_boot_b|dtbo_b|userdata) ;;" -ANCHOR = "hostname omamobile\n" - - -def main() -> int: - p = Path(sys.argv[1]) - s = p.read_text() - if s.count(ALLOW) != 1: - raise SystemExit("shared init changed: storage-guard allowlist not found") - if s.count(ANCHOR) != 1: - raise SystemExit("shared init changed: hostname anchor not found") - if "omamobile_logdump_loop" in s: - print("already patched for bring-up") - return 0 - s = s.replace(ALLOW, ALLOW.replace("|userdata)", "|userdata|logdump)"), 1) - s = s.replace(ANCHOR, MIRROR + ANCHOR, 1) - p.write_text(s) - print("init patched: logdump allowed, log mirror started before handover") - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/dipper/build b/tools/dipper/build deleted file mode 100755 index 309e9290b..000000000 --- a/tools/dipper/build +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# Build dipper's deployable artefacts: initramfs (in an aarch64 container), -# then the Android v1 boot image with the DTB appended to the kernel. -# -# Needs: the kernel already built in $KERNEL_SRC (Image.gz, the dipper DTB and -# modules), docker with arm64 emulation registered, zopfli, and SSH_PUBKEY. -set -euo pipefail - -here=$(cd "$(dirname "$0")" && pwd) -repo=$(cd "$here/../.." && pwd) - -KERNEL_SRC=${KERNEL_SRC:-$repo/../linux} -# BRINGUP=1 builds the diagnostic image instead: it mirrors the kernel log into -# the unused `logdump` partition, so a first boot with no cable attached can be -# read back from Android. It goes into its own output directory so the two can -# never be confused, and it must never be written to `boot`. -if [[ ${BRINGUP:-0} == 1 ]]; then - OUT=${OUT:-$repo/../out/dipper-bringup} - export DIPPER_BRINGUP=1 -else - OUT=${OUT:-$repo/../out/dipper} -fi -: "${SSH_PUBKEY:?set SSH_PUBKEY to your authorized public key}" -ALPINE=${ALPINE:-alpine:3.22} - -die() { echo "error: $*" >&2; exit 1; } - -[[ -d $KERNEL_SRC ]] || die "no kernel tree at $KERNEL_SRC (set KERNEL_SRC)" -image=$KERNEL_SRC/arch/arm64/boot/Image.gz -dtb=$KERNEL_SRC/arch/arm64/boot/dts/qcom/sdm845-xiaomi-dipper.dtb -[[ -f $image ]] || die "no $image -- build the kernel first" -[[ -f $dtb ]] || die "no $dtb -- build qcom/sdm845-xiaomi-dipper.dtb first" -[[ -r $SSH_PUBKEY ]] || die "no SSH public key at $SSH_PUBKEY (set SSH_PUBKEY)" -grep -q '^ssh-' "$SSH_PUBKEY" || die "$SSH_PUBKEY is not an OpenSSH public key" -command -v docker >/dev/null || die "docker is needed for the aarch64 initramfs" - -release=$(cat "$KERNEL_SRC/include/config/kernel.release") -echo "kernel release: $release" - -umask 077 -mkdir -p "$OUT"; chmod 700 "$OUT" -mods=$OUT/modules -echo "installing modules into $mods" -rm -rf "$mods/lib/modules/$release" -make -C "$KERNEL_SRC" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \ - INSTALL_MOD_PATH="$mods" INSTALL_MOD_STRIP=1 modules_install >/dev/null -mkdir -p "$OUT/include/config" -cp "$KERNEL_SRC/include/config/kernel.release" "$OUT/include/config/kernel.release" -tar -C "$mods/lib/modules" --owner=0 --group=0 --numeric-owner -cf - "$release" \ - | zstd -q -19 -T0 -f -o "$OUT/modules-$release.tar.zst" - -echo "building the initramfs in $ALPINE (linux/arm64)" -docker run --rm --platform linux/arm64 \ - -v "$repo:/src:ro" -v "$mods:/modules:ro" -v "$SSH_PUBKEY:/input/key.pub:ro" \ - -v "$OUT:/out" \ - -e "KERNEL_RELEASE=$release" -e "OUT_UID=$(id -u)" -e "OUT_GID=$(id -g)" \ - -e "DIPPER_BRINGUP=${DIPPER_BRINGUP:-0}" \ - -e "DIPPER_NFSROOT=${DIPPER_NFSROOT:-}" \ - "$ALPINE" sh /src/tools/dipper/initramfs-inside.sh - -# Pack a copy of the DTB so nothing we do can dirty the kernel tree. -packdtb=$OUT/sdm845-xiaomi-dipper.dtb -cp "$dtb" "$packdtb" -# By default the image stays generic: it carries no device identifier and works -# on any Mi 8, because omamobile-dipper-identity reads this phone's own WLAN and -# Bluetooth addresses out of `persist` at boot. Baking the Bluetooth address into -# the DTB is opt-in, for someone who wants a single-device image and a BD address -# set before userspace runs. -if [[ ${DIPPER_BAKE_IDENTITY:-0} == 1 ]]; then - "$here/apply-identity" "$packdtb" -else - echo "generic image: Bluetooth address left at the placeholder, applied at boot from persist" -fi - -kernel_image=$image -if command -v zopfli >/dev/null; then - echo "compressing the kernel with zopfli for dipper's ABL size limit" - zopfli -c --i1 "$KERNEL_SRC/arch/arm64/boot/Image" > "$OUT/Image.gz" - kernel_image=$OUT/Image.gz -fi -# A failed size check must not leave an older boot.img under the current name. -rm -f "$OUT/images/boot.img" "$OUT/images/BOOT-MANIFEST.json" -"$here/build-boot.py" --kernel "$kernel_image" --dtb "$packdtb" \ - --ramdisk "$OUT/initramfs.cpio.gz" --out "$OUT/images" - -# Firmware and the Wi-Fi fix-ups are not part of the boot image; they go into the -# root filesystem. Collect them beside it so one directory holds everything. -fw=${FIRMWARE_DIR:-$HOME/android/reference/dipper-stock/firmware} -if [[ -d $fw ]]; then - mkdir -p "$OUT/firmware" - # The blobs come off the phone mode 400, so a plain cp cannot overwrite them - # on a rebuild. Copy without preserving the mode and make them readable. - for d in qcom ath10k; do - [[ -d $fw/$d ]] || continue - rm -rf "$OUT/firmware/$d" - cp -r --no-preserve=mode "$fw/$d" "$OUT/firmware/" - done - chmod -R u+rwX "$OUT/firmware" - # The boot-time identity service, which makes the image device-agnostic. - mkdir -p "$OUT/identity" - cp "$here/identity/omamobile-dipper-identity" "$here/identity/omamobile-dipper-identity.service" \ - "$OUT/identity/" - echo "firmware and Wi-Fi files staged in $OUT/firmware" -else - echo "note: no firmware at $fw (run tools/dipper/extract-firmware); GPU and Wi-Fi will not come up" -fi - -echo -echo "artefacts in $OUT/images:" -ls -l "$OUT/images" -cat <<'NOTE' - -To try it WITHOUT writing anything to the phone (nothing persists, a reboot -returns to stock): - - fastboot boot boot.img - -Only flash it once that has booted, and only with a verified stock backup in -hand: dipper has no second slot to fall back to. -NOTE -if [[ ${DIPPER_BRINGUP:-0} == 1 ]]; then - cat <<'NOTE2' -THIS IS THE DIAGNOSTIC IMAGE. It mirrors the kernel log into `logdump` and runs -with a widened storage guard. Write it to `recovery` only -- never to `boot` -- -so stock Android stays bootable, and enter it with Volume Up + Power. -NOTE2 -fi diff --git a/tools/dipper/build-board-2.py b/tools/dipper/build-board-2.py deleted file mode 100755 index 612831157..000000000 --- a/tools/dipper/build-board-2.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: MIT -"""Build an ath10k board-2.bin for dipper from the phone's own board data. - -Why this exists: upstream linux-firmware's WCN3990 board-2.bin has entries only -for qmi-board-id=ff, and this phone's WLAN firmware reports board id 0 (the -stock kernel logs "wma_rx_service_ready_event: Board id: 0"). If ath10k finds no -matching entry it does not load board data at all and Wi-Fi stays down. So we -build a file keyed by the ids this phone can actually report, carrying its own -factory calibration instead of generic data. - -Name format comes from ath10k_core_create_board_name(): - bus=snoc,qmi-board-id=%x,qmi-chip-id=%x[,variant=%s] -Both ids are hex. WCN3990 on SDM845 reports chip id 0x30214. - -File format: the 16-byte magic, then length-prefixed IEs. Each ATH10K_BD_IE_BOARD -holds a NAME sub-IE and a DATA sub-IE. -""" -import argparse, re, struct, sys -from pathlib import Path - -MAGIC = b"QCA-ATH10K-BOARD" -BD_IE_BOARD = 0 -BD_IE_BOARD_NAME = 0 -BD_IE_BOARD_DATA = 1 -CHIP_ID = 0x30214 # WCN3990 as it appears in upstream's own names - - -def ie(id_: int, payload: bytes) -> bytes: - """One IE: id, length, payload padded to a 4-byte boundary.""" - pad = (-len(payload)) % 4 - return struct.pack(" 0xNN. bdwlan.bin is the default used when no id matches.""" - m = re.fullmatch(r"bdwlan\.b([0-9a-fA-F]{1,4})", path.name) - return int(m.group(1), 16) if m else None - - -def main() -> int: - ap = argparse.ArgumentParser() - ap.add_argument("--src", type=Path, required=True, help="directory of bdwlan.* files") - ap.add_argument("--out", type=Path, required=True, help="board-2.bin to write") - ap.add_argument("--verify", type=Path, help="also parse this reference file first") - a = ap.parse_args() - - if a.verify: - ref = parse(a.verify.read_bytes()) - snoc = [n for n, _ in ref if n and n.startswith("bus=snoc")] - if not snoc: - raise SystemExit(f"{a.verify}: parsed {len(ref)} entries but none look like snoc " - "boards -- the parser is wrong, refusing to build") - print(f"parser check: read {len(ref)} entries from {a.verify.name}, " - f"{len(snoc)} of them snoc") - - default = a.src / "bdwlan.bin" - if not default.is_file(): - raise SystemExit(f"no {default}: that is the phone's default board data") - data_default = default.read_bytes() - - entries = [] - # The ids this phone can report. 0 is what its stock firmware logs; ff is - # ath10k's fallback and what upstream's own file uses. Both get the default - # calibration blob, which is the one the phone itself ships. - for bid in (0x0, 0xff): - entries.append((f"bus=snoc,qmi-board-id={bid:x},qmi-chip-id={CHIP_ID:x}", data_default)) - # Every per-board-id blob the phone carries, under its own id, so a unit that - # reports something else still finds its own calibration. - for f in sorted(a.src.glob("bdwlan.b*")): - bid = board_id_of(f) - if bid is None or bid in (0x0, 0xff): - continue - entries.append((f"bus=snoc,qmi-board-id={bid:x},qmi-chip-id={CHIP_ID:x}", f.read_bytes())) - - blob = bytearray(MAGIC + b"\0") - blob += b"\0" * ((-len(blob)) % 4) - for name, data in entries: - body = ie(BD_IE_BOARD_NAME, name.encode()) + ie(BD_IE_BOARD_DATA, data) - blob += ie(BD_IE_BOARD, body) - - got = parse(bytes(blob)) - if len(got) != len(entries): - raise SystemExit(f"wrote {len(entries)} entries but read back {len(got)}") - for (wn, wd), (gn, gl) in zip(entries, got): - if gn != wn or gl != len(wd): - raise SystemExit(f"entry did not round-trip: wrote {wn!r}/{len(wd)}, read {gn!r}/{gl}") - - a.out.parent.mkdir(parents=True, exist_ok=True) - a.out.write_bytes(bytes(blob)) - print(f"wrote {a.out} ({len(blob)} bytes, {len(entries)} entries), verified by re-parsing:") - for n, l in got: - print(f" {n} ({l} bytes)") - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/dipper/build-boot.py b/tools/dipper/build-boot.py deleted file mode 100755 index d1210b2e8..000000000 --- a/tools/dipper/build-boot.py +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: MIT -"""Pack dipper's kernel + appended DTB and the initramfs into an Android v1 boot image. - -Every offset here was read off the phone's own stock boot image (header v1, -page 4096, kernel 0x8000, ramdisk 0x1000000, tags 0x100, base 0), so the image -we hand ABL has the same geometry as the one it already boots. The DTB is -appended to the kernel because dipper's stock image carries its FDTs that way -(two concatenated FDTs at the end of the kernel blob, selected by msm-id). - -No mkbootimg dependency: the v1 header is 1648 bytes of fixed layout and we -verify what we wrote before returning. -""" -import argparse, hashlib, json, struct, sys -from pathlib import Path - -PAGE = 4096 -BASE = 0x00000000 -KERNEL_OFF = 0x00008000 -# Stock's own value, and the only one seen to boot on this phone. It leaves -# 16 MiB - 32 KiB for the kernel; check_layout() refuses anything larger rather -# than letting ABL answer with -# Failed to load/authenticate boot image: 00000050 -# which it does with no kernel output and no clue. -RAMDISK_OFF = 0x01000000 -SECOND_OFF = 0x00f00000 -TAGS_OFF = 0x00000100 -HDR_VERSION = 1 -HDR_SIZE = 1648 -# From the phone: console on the framebuffer, early console on the SoC's UART -# (stock passes earlycon=msm_geni_serial,0xA84000), then the shared init. -CMDLINE = ("console=tty0 earlycon=msm_geni_serial,0xa84000 rdinit=/init " - "panic=10 printk.devkmsg=on rootwait") -# dipper's boot partition, measured: 65536 blocks of 1 KiB. -BOOT_PARTITION_BYTES = 64 * 1024 * 1024 -# This ABL refuses a larger kernel with only -# Booting FAILED (remote: 'Failed to load/authenticate boot image: 00000050') -# Measured on the phone: 16,247,767 bytes boots, 16,343,459 does not. -KERNEL_MAX = 0xF80000 - - -def pad(b: bytes) -> bytes: - r = len(b) % PAGE - return b + (b"\0" * (PAGE - r) if r else b"") - - -def check_layout(kernel: bytes, ramdisk: bytes) -> None: - """The kernel must end before the ramdisk begins, or ABL rejects the image.""" - if len(kernel) > KERNEL_MAX: - raise SystemExit( - f"kernel+dtb is {len(kernel)} bytes; this phone's ABL refuses more " - f"than {KERNEL_MAX} ({KERNEL_MAX / 1048576:.2f} MiB) and says only " - "'Failed to load/authenticate boot image: 00000050'. Move drivers " - "to modules.") - room = RAMDISK_OFF - KERNEL_OFF - if len(kernel) > room: - raise SystemExit( - f"kernel+dtb is {len(kernel)} bytes but only {room} fit between " - f"kernel_offset {KERNEL_OFF:#x} and ramdisk_offset {RAMDISK_OFF:#x}; " - "raise RAMDISK_OFF or shrink the kernel") - end = RAMDISK_OFF + len(ramdisk) - if end > BOOT_PARTITION_BYTES * 4: - raise SystemExit(f"the loaded image would reach {end:#x}, which is implausible") - - -def build_header(kernel: bytes, ramdisk: bytes, cmdline: str) -> bytes: - cmd = cmdline.encode() - if len(cmd) > 511: - raise SystemExit(f"cmdline is {len(cmd)} bytes; the v1 header holds 512 with its NUL") - h = bytearray(PAGE) - h[0:8] = b"ANDROID!" - struct.pack_into("<10I", h, 8, - len(kernel), BASE + KERNEL_OFF, - len(ramdisk), BASE + RAMDISK_OFF, - 0, BASE + SECOND_OFF, # no second stage: the DTB is appended - BASE + TAGS_OFF, PAGE, HDR_VERSION, 0) - h[48:64] = b"\0" * 16 # product name: stock leaves it empty too - h[64:64 + len(cmd)] = cmd - # id[32] at 576 and extra_cmdline[1024] at 608 stay zero. - struct.pack_into(" None: - """Re-read what we wrote: a wrong header silently bricks a boot attempt.""" - if img[:8] != b"ANDROID!": - raise SystemExit("bad magic in the image we just built") - ks, ka, rs, ra, ss, sa, tags, ps, hv, _ = struct.unpack_from("<10I", img, 8) - if (ks, rs, ss) != (len(kernel), len(ramdisk), 0): - raise SystemExit(f"sizes disagree: {(ks, rs, ss)}") - if (ka, ra, tags, ps, hv) != (BASE + KERNEL_OFF, BASE + RAMDISK_OFF, BASE + TAGS_OFF, PAGE, HDR_VERSION): - raise SystemExit(f"geometry disagrees with the stock image: {(ka, ra, tags, ps, hv)}") - if struct.unpack_from(" int: - ap = argparse.ArgumentParser() - ap.add_argument("--kernel", type=Path, required=True, help="Image.gz") - ap.add_argument("--dtb", type=Path, required=True, help="sdm845-xiaomi-dipper.dtb") - ap.add_argument("--ramdisk", type=Path, required=True, help="initramfs.cpio.gz") - ap.add_argument("--out", type=Path, required=True, help="output directory") - ap.add_argument("--cmdline", default=CMDLINE) - a = ap.parse_args() - - a.out.mkdir(parents=True, exist_ok=True) - kernel = a.kernel.read_bytes() + a.dtb.read_bytes() # Image.gz-dtb - ramdisk = a.ramdisk.read_bytes() - (a.out / "Image.gz-dtb").write_bytes(kernel) - - check_layout(kernel, ramdisk) - img = build_header(kernel, ramdisk, a.cmdline) + pad(kernel) + pad(ramdisk) - verify(img, kernel, ramdisk, a.cmdline) - if len(img) > BOOT_PARTITION_BYTES: - raise SystemExit(f"image is {len(img)} bytes; dipper's boot partition holds " - f"{BOOT_PARTITION_BYTES}") - - out = a.out / "boot.img" - out.write_bytes(img) - manifest = { - "device": "dipper", - "header_version": HDR_VERSION, - "pagesize": PAGE, - "cmdline": a.cmdline, - "kernel_bytes": len(kernel), - "dtb_bytes": a.dtb.stat().st_size, - "ramdisk_bytes": len(ramdisk), - "boot_bytes": len(img), - "boot_partition_bytes": BOOT_PARTITION_BYTES, - "headroom_bytes": BOOT_PARTITION_BYTES - len(img), - "kernel_sha256": hashlib.sha256(kernel).hexdigest(), - "ramdisk_sha256": hashlib.sha256(ramdisk).hexdigest(), - "boot_sha256": hashlib.sha256(img).hexdigest(), - "hardware_boot_tested": False, - } - (a.out / "BOOT-MANIFEST.json").write_text(json.dumps(manifest, indent=2) + "\n") - print(f"packed {out} ({len(img)} bytes, {manifest['headroom_bytes']} spare in the partition)") - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/dipper/extract-firmware b/tools/dipper/extract-firmware deleted file mode 100755 index 7854ab7b7..000000000 --- a/tools/dipper/extract-firmware +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# Pull dipper's own vendor firmware off the phone and merge the split Qualcomm -# .mdt/.bNN sets into the single .mbn files mainline's remoteproc asks for. -# -# Nothing here is redistributable: it is the owner's device firmware, extracted -# from their own phone, and it stays outside the repository. -set -euo pipefail - -HOST=${HOST:-mi8} -SU=${SU:-/debug_ramdisk/su} -OUT=${OUT:-$HOME/android/reference/dipper-stock/firmware} - -remote() { ssh "$HOST" "$SU -c '$1'"; } - -umask 077 -raw=$OUT/raw; mkdir -p "$raw" "$OUT/qcom/sdm845/dipper"; chmod -R 700 "$OUT" - -# Where each blob lives on this phone, measured: /vendor/firmware for the GPU and -# IPA, /vendor/firmware_mnt/image for the DSPs and the modem. - -# One tar stream per source directory: a regex through `su -c` is a quoting -# minefield, and per-file ssh over a relayed link is needlessly slow. -fetch() { # fetch - local dir=$1; shift - ssh "$HOST" "$SU -c \"cd $dir && tar cf - $* 2>/dev/null\"" | tar xf - -C "$raw" -} -fetch_base64() { # fetch one small binary file through Android's text-only SSH bridge - ssh "$HOST" "$SU -c \"base64 $1\"" | base64 -d > "$2" -} -echo "== GPU zap shader and IPA from /vendor/firmware" -fetch /vendor/firmware 'a630_zap.mdt a630_zap.b* ipa_fws.mdt ipa_fws.b*' -echo "== DSP and modem images from /vendor/firmware_mnt/image" -fetch /vendor/firmware_mnt/image 'adsp.mdt adsp.b* cdsp.mdt cdsp.b* mba.mbn' -echo "== modem configuration files requested by MPSS" -mkdir -p "$raw/modem_pr/mcfg/configs/mcfg_hw" "$raw/modem_pr/mcfg/configs/mcfg_sw" -fetch_base64 /vendor/firmware_mnt/image/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig "$raw/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig" -fetch_base64 /vendor/firmware_mnt/image/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig "$raw/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig" -echo "== ath10k board data and firmware" -mkdir -p "$OUT/wlan" -ssh "$HOST" "$SU -c \"cd /vendor/firmware && tar cf - wlan 2>/dev/null\"" | tar xf - -C "$OUT" -# mba is already a single signed image; the rest get squashed below. -[ -f "$raw/mba.mbn" ] && mv "$raw/mba.mbn" "$OUT/qcom/sdm845/dipper/mba.mbn" -echo "raw files pulled: $(find "$raw" -type f | wc -l)" - -python3 "$(dirname "$0")/pil-squash.py" "$raw" "$OUT/qcom/sdm845/dipper" - -# MPSS requests these over TFTP; stage them beside modem.mbn for tqftpserv. -install -D -m 600 "$raw/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig" "$OUT/qcom/sdm845/dipper/modem_pr/mcfg/configs/mcfg_hw/mbn_hw.dig" -install -D -m 600 "$raw/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig" "$OUT/qcom/sdm845/dipper/modem_pr/mcfg/configs/mcfg_sw/mbn_sw.dig" - -echo -echo "firmware tree for the phone's /lib/firmware:" -find "$OUT/qcom" "$OUT/wlan" -type f 2>/dev/null | sed "s#$OUT/# #" | sort -echo -echo "Device firmware from this phone only. Do not commit or redistribute it." diff --git a/tools/dipper/extract-identity b/tools/dipper/extract-identity deleted file mode 100755 index 47b427cf5..000000000 --- a/tools/dipper/extract-identity +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# Recover this phone's factory WLAN and Bluetooth addresses from its own -# `persist` backup. Offline: the phone is not touched and need not be reachable. -# -# These are device identifiers. They are written outside the repository, mode -# 600, and must never be committed. -set -euo pipefail - -REF=${REF:-$HOME/android/reference/dipper-stock} -PERSIST=${PERSIST:-$REF/backup/persist.img} -OUT=${OUT:-$REF/identity.env} -DEBUGFS=${DEBUGFS:-/sbin/debugfs} - -[[ -f $PERSIST ]] || { echo "no $PERSIST -- run tools/dipper/backup-stock first" >&2; exit 1; } -[[ -x $DEBUGFS ]] || { echo "need debugfs (e2fsprogs) at $DEBUGFS" >&2; exit 1; } - -tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT -umask 077 - -# persist is ext4; read it with debugfs so nothing has to be mounted or elevated. -"$DEBUGFS" -R "dump /wlan_bt/wlan.mac $tmp/wlan.mac" "$PERSIST" 2>/dev/null || true -"$DEBUGFS" -R "dump /wlan_bt/bt.mac $tmp/bt.mac" "$PERSIST" 2>/dev/null || true - -fmt() { # 6 raw bytes -> aa:bb:cc:dd:ee:ff, rejecting anything that is not a MAC - local f=$1 - [[ -s $f ]] || return 1 - python3 - "$f" <<'PY' -import sys -d = open(sys.argv[1], 'rb').read() -if len(d) != 6 or d == b'\0' * 6 or d == b'\xff' * 6: - sys.exit(1) -if d[0] & 1: # a multicast bit means this is not a station address - sys.exit(1) -print(":".join(f"{b:02x}" for b in d)) -PY -} - -wlan=$(fmt "$tmp/wlan.mac") || { echo "no usable WLAN address in persist" >&2; exit 1; } -bt=$(fmt "$tmp/bt.mac") || { echo "no usable Bluetooth address in persist" >&2; exit 1; } - -# little-endian byte list for the device tree's local-bd-address -bd_le=$(python3 -c "print(' '.join(reversed('$bt'.split(':'))))") - -mkdir -p "$(dirname "$OUT")" -cat > "$OUT" < "$link" < aa:bb:cc:dd:ee:ff, or nothing if not a station MAC - [ -s "$1" ] || return 1 - # POSIX awk only: and() and strtonum() are gawk extensions that neither the - # phone's awk nor busybox awk has. Running this on the phone is how that - # was found, so do not "simplify" it back. - od -An -tx1 -N6 "$1" | tr -d ' \n' | awk ' - length($0) != 12 { exit 1 } - { - for (i = 1; i <= 11; i += 2) b[++n] = substr($0, i, 2) - all = b[1] b[2] b[3] b[4] b[5] b[6] - if (all == "000000000000") exit 1 # unset - if (all == "ffffffffffff") exit 1 # broadcast - # The multicast bit is the low bit of the first byte, i.e. its - # second hex digit is odd. - if (index("13579bdfBDF", substr(b[1], 2, 1)) > 0) exit 1 - printf "%s:%s:%s:%s:%s:%s", b[1], b[2], b[3], b[4], b[5], b[6] - }' -} - -[ -e "$PERSIST" ] || { log "no persist partition at $PERSIST"; exit 0; } -mkdir -p "$MNT" -mounted=0 -# NOMOUNT lets the test drive this script against a plain directory of files. -if [ "${NOMOUNT:-0}" != 1 ] && ! mountpoint -q "$MNT"; then - mount -o ro,nosuid,nodev,noexec "$PERSIST" "$MNT" || { log "cannot mount persist read-only"; exit 0; } - mounted=1 -fi -cleanup() { [ "$mounted" = 1 ] && umount "$MNT" 2>/dev/null || true; } -trap cleanup EXIT - -wlan=$(mac_from "$MNT/wlan_bt/wlan.mac" || true) -bt=$(mac_from "$MNT/wlan_bt/bt.mac" || true) - -if [ -n "${wlan:-}" ]; then - # A udev .link file is applied whoever manages the interface later, - # NetworkManager included. Rewrite it only when it would change. - want="[Match] -OriginalName=wlan0 - -[Link] -MACAddress=$wlan" - if [ ! -f "$LINK" ] || [ "$(cat "$LINK")" != "$want" ]; then - mkdir -p "$(dirname "$LINK")" - printf '%s\n' "$want" > "$LINK" - log "wrote $LINK" - fi - # Apply now as well, in case wlan0 already exists this boot. - if [ -d /sys/class/net/wlan0 ]; then - ip link set dev wlan0 down 2>/dev/null || true - ip link set dev wlan0 address "$wlan" 2>/dev/null \ - && log "wlan0 address set from persist" \ - || log "could not set wlan0 address now; the link file covers the next boot" - ip link set dev wlan0 up 2>/dev/null || true - fi -else - log "no usable WLAN address in persist; leaving the interface alone" -fi - -if [ -n "${bt:-}" ]; then - if [ -d /sys/class/bluetooth/hci0 ] && command -v btmgmt >/dev/null; then - btmgmt --index 0 public-addr "$bt" >/dev/null 2>&1 \ - && log "bluetooth public address set from persist" \ - || log "btmgmt refused the public address (controller may not support it)" - else - log "no hci0 or no btmgmt yet; bluetooth keeps the firmware default address" - fi -else - log "no usable Bluetooth address in persist" -fi diff --git a/tools/dipper/identity/omamobile-dipper-identity.service b/tools/dipper/identity/omamobile-dipper-identity.service deleted file mode 100644 index d307135b9..000000000 --- a/tools/dipper/identity/omamobile-dipper-identity.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Apply the Mi 8's own WLAN and Bluetooth addresses from persist -# persist is read-only to us; the storage guard keeps it that way. -ConditionPathExists=/dev/disk/by-partlabel/persist -Before=NetworkManager.service bluetooth.service -Wants=local-fs.target -After=local-fs.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/local/bin/omamobile-dipper-identity - -[Install] -WantedBy=multi-user.target diff --git a/tools/dipper/identity/test-identity.sh b/tools/dipper/identity/test-identity.sh deleted file mode 100755 index fc74ac8d2..000000000 --- a/tools/dipper/identity/test-identity.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -# Drive the real boot-time identity script against fake persist trees. No phone, -# no mounting, no root. Asserts it accepts a genuine address and refuses junk. -set -euo pipefail -here=$(cd "$(dirname "$0")" && pwd) -script=$here/omamobile-dipper-identity -tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT -fails=() - -# Run the script with a persist tree holding the given raw wlan/bt bytes. -run_with() { # run_with - local root=$tmp/p$RANDOM - mkdir -p "$root/wlan_bt" - python3 -c "import sys,pathlib; pathlib.Path(sys.argv[1]).write_bytes(bytes.fromhex(sys.argv[2]))" \ - "$root/wlan_bt/wlan.mac" "$1" - python3 -c "import sys,pathlib; pathlib.Path(sys.argv[1]).write_bytes(bytes.fromhex(sys.argv[2]))" \ - "$root/wlan_bt/bt.mac" "$2" - NOMOUNT=1 PERSIST="$root" MNT="$root" LINK="$3" sh "$script" 2>&1 -} - -# 1. a valid locally administered address must land in the link file, formatted -out=$(run_with 021042000001 021042000002 "$tmp/link1") -grep -q "MACAddress=02:10:42:00:00:01" "$tmp/link1" 2>/dev/null || fails+=("valid address not written to the link file") -grep -q "OriginalName=wlan0" "$tmp/link1" 2>/dev/null || fails+=("link file has no Match section") - -# 2. junk must be refused, and no link file written -for name_hex in "000000000000:all-zero" "ffffffffffff:broadcast" "01005e000001:multicast"; do - hex=${name_hex%%:*}; what=${name_hex##*:} - out=$(run_with "$hex" "$hex" "$tmp/link-$what") - grep -q "no usable WLAN address" <<<"$out" || fails+=("$what: not reported as unusable") - [[ ! -f $tmp/link-$what ]] || fails+=("$what: wrote a link file anyway") -done - -# 3. a short read must be refused too -out=$(run_with a45046 a45046 "$tmp/link-short") -grep -q "no usable WLAN address" <<<"$out" || fails+=("short read: not reported as unusable") -[[ ! -f $tmp/link-short ]] || fails+=("short read: wrote a link file anyway") - -# 4. no persist at all: a quiet no-op, exit 0, nothing written -out=$(PERSIST=$tmp/none MNT=$tmp/m LINK=$tmp/link-none sh "$script" 2>&1) \ - || fails+=("exited non-zero with no persist") -grep -q "no persist partition" <<<"$out" || fails+=("missing persist not reported") -[[ ! -f $tmp/link-none ]] || fails+=("wrote a link file with no persist") - -# 5. rewriting must be idempotent: the same input must not rewrite the file -run_with a45046ec5154 a45046ac5155 "$tmp/link1" >/dev/null -before=$(stat -c%Y "$tmp/link1"); sleep 1 -out=$(run_with a45046ec5154 a45046ac5155 "$tmp/link1") -[[ $(stat -c%Y "$tmp/link1") == "$before" ]] || fails+=("rewrote an unchanged link file") -grep -q "wrote .*link1" <<<"$out" && fails+=("claimed a write when nothing changed") - -if ((${#fails[@]})); then printf 'FAIL:\n'; printf ' %s\n' "${fails[@]}"; exit 1; fi -echo "test-identity OK: real script accepts a genuine MAC, refuses zero/broadcast/multicast/short, no-op without persist, idempotent" diff --git a/tools/dipper/initramfs-inside.sh b/tools/dipper/initramfs-inside.sh deleted file mode 100755 index 464b0d6c4..000000000 --- a/tools/dipper/initramfs-inside.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: MIT -# Runs inside an aarch64 Alpine container. Only files under /out change. -# Adapted from tools/alioth/build-initramfs.sh: same class of device (non-A/B -# Qualcomm, appended DTB), different panel, watchdog name and descriptor values. -set -eu - -: "${KERNEL_RELEASE:?KERNEL_RELEASE must be passed in}" - -apk add --no-cache cpio gcc musl-dev gzip kmod python3 dropbear - -stage=/tmp/dipper-initramfs -mkdir -p "$stage" -apk --root "$stage" --initdb --no-cache \ - --repositories-file /etc/apk/repositories --keys-dir /etc/apk/keys add \ - alpine-baselayout busybox busybox-extras dropbear iproute2 util-linux \ - e2fsprogs e2fsprogs-extra kmod \ - ${DIPPER_BRINGUP:+i2c-tools evtest strace pciutils usbutils} - -mkdir -p "$stage/proc" "$stage/sys" "$stage/dev" "$stage/run" "$stage/root/.ssh" \ - "$stage/usr/lib/modules" "$stage/usr/lib/firmware" "$stage/etc/dropbear" "$stage/usr/local/bin" -# Alpine is not usr-merged; kmod and the kernel look below /lib. -ln -s ../usr/lib/modules "$stage/lib/modules" -ln -s ../usr/lib/firmware "$stage/lib/firmware" - -cp /input/key.pub "$stage/root/.ssh/authorized_keys" -chmod 700 "$stage/root/.ssh" -chmod 600 "$stage/root/.ssh/authorized_keys" - -# Keep the rescue server's host key stable across rebuilds, so the laptop's -# known_hosts does not change under us. Private key stays in local output. -hostkey=/out/dropbear_ed25519_host_key -if [ ! -s "$hostkey" ]; then - umask 077 - dropbearkey -t ed25519 -f "$hostkey" >/dev/null 2>&1 -fi -cp "$hostkey" "$stage/etc/dropbear/dropbear_ed25519_host_key" -chmod 600 "$stage/etc/dropbear/dropbear_ed25519_host_key" -chown "${OUT_UID:-0}:${OUT_GID:-0}" "$hostkey" - -cp -a "/modules/lib/modules/$KERNEL_RELEASE" "$stage/usr/lib/modules/" -# The build tree symlinks point at the builder's paths; they are useless here. -rm -f "$stage/usr/lib/modules/$KERNEL_RELEASE/build" \ - "$stage/usr/lib/modules/$KERNEL_RELEASE/source" -depmod -b "$stage" "$KERNEL_RELEASE" - -# Keep only the modules this initramfs actually loads, with their dependencies. -# The full tree is ~1764 modules and dominates the image: with the PHYs, UFS, -# i2c and simpledrm built in, almost none of it is reachable here, and ABL -# refuses a boot image that grows too large. Everything else belongs in the -# root filesystem, not here. The pruner reads modules.dep and fails loudly -# rather than silently emptying the tree. -modules=qcom_wdt -if grep -qF 'drivers/gpu/drm/panel/panel-samsung-ea8074.ko' \ - "$stage/usr/lib/modules/$KERNEL_RELEASE/modules.builtin"; then - : > "$stage/etc/omamobile-panel-built-in" -else - modules="$modules panel-samsung-ea8074" -fi -python3 /src/tools/dipper/prune-modules.py \ - "$stage/usr/lib/modules/$KERNEL_RELEASE" $modules -depmod -b "$stage" "$KERNEL_RELEASE" - -# The modules the init loads must exist AND match this kernel exactly, or the -# phone boots to a black screen with no watchdog taken over. -for module in $modules; do - path=$(modinfo -b "$stage" -k "$KERNEL_RELEASE" -n "$module") - [ "$(modinfo -F vermagic "$path" | cut -d ' ' -f1)" = "$KERNEL_RELEASE" ] || { - echo "module $module does not match $KERNEL_RELEASE" >&2; exit 1; } -done - -cp /src/initramfs/init "$stage/init" -python3 - "$stage/init" <<'PY' -from pathlib import Path -import sys -p = Path(sys.argv[1]); s = p.read_text() - -# SDM845 leaves the cluster watchdogs running; take them over early. -needle = 'hostname omamobile\n' -assert s.count(needle) == 1, "shared init changed: hostname anchor" -s = s.replace(needle, '''# SDM845's watchdogs keep running until a driver claims them. -modprobe qcom_wdt || echo "omamobile: qcom watchdog module failed" >/dev/kmsg -if [ -c /dev/watchdog0 ]; then - watchdog -t 5 -T 30 /dev/watchdog0 -fi -if [ ! -e /etc/omamobile-panel-built-in ]; then - modprobe panel-samsung-ea8074 || echo "omamobile: panel module failed" >/dev/kmsg -fi -hostname omamobile -''') - -# Bind the rescue sshd to the USB link only, never to every interface. -needle = 'dropbear -R -E -p 22' -assert s.count(needle) == 1, "shared init changed: dropbear anchor" -s = s.replace(needle, 'dropbear -R -E -s -p 172.16.42.1:22') -p.write_text(s) -PY -chmod 755 "$stage/init" - -echo xiaomi,dipper > "$stage/etc/omamobile-compatible" -echo userdata > "$stage/etc/omamobile-ufs-rw" - -# A diagnostic image, for a first boot with no cable attached: it mirrors the -# kernel log into the unused `logdump` partition so Android can read it back. -# See tools/dipper/bringup-patch-init.py. Never write this one to `boot`. -if [ "${DIPPER_BRINGUP:-0}" = 1 ]; then - echo "userdata logdump" > "$stage/etc/omamobile-ufs-rw" - python3 /src/tools/dipper/bringup-patch-init.py "$stage/init" - echo 'BRING-UP IMAGE: logdump mirror on, storage guard widened' > "$stage/etc/omamobile-bringup" -fi -# Bring-up only: boot the Arch root from NFS over the USB link instead of the -# UFS, so a root filesystem can be tried without writing to the phone at all. -if [ -n "${DIPPER_NFSROOT:-}" ]; then - echo "$DIPPER_NFSROOT" > "$stage/etc/omamobile-nfsroot" - echo "NFS ROOT IMAGE: the Arch root comes from $DIPPER_NFSROOT, not the UFS" \ - > "$stage/etc/omamobile-nfsroot-note" -fi -echo 'Xiaomi Mi 8 Omarchy' > "$stage/etc/omamobile-usb-product" - -gcc -Os -static -o "$stage/usr/local/bin/reboot-to" \ - /src/packages/omamobile-device-cheetah/src/reboot-to.c - -# Prove the packaged userspace actually runs on ARM before shipping it. -chroot "$stage" /bin/busybox true -chroot "$stage" /usr/sbin/dropbear -h >/tmp/dropbear-help 2>&1 || [ "$?" = 1 ] -grep -q 'Dropbear' /tmp/dropbear-help - -# Reproducible archive: fixed mtimes, sorted, no owners. -python3 - "$stage" <<'PY' -import os, sys -from pathlib import Path -root = Path(sys.argv[1]) -for path in list(root.rglob('*')) + [root]: - os.utime(path, (1790636353, 1790636353), follow_symlinks=False) -PY -(cd "$stage" && find . -print0 | sort -z | cpio --null --quiet -o -H newc --owner=0:0 --reproducible) \ - | gzip -n -9 > /out/initramfs.cpio.gz -cp /tmp/dropbear-help /out/dropbear-help.txt -chown "${OUT_UID:-0}:${OUT_GID:-0}" /out/initramfs.cpio.gz /out/dropbear-help.txt -echo "dipper initramfs built for $KERNEL_RELEASE; storage guard permits userdata only" diff --git a/tools/dipper/pil-squash.py b/tools/dipper/pil-squash.py deleted file mode 100755 index 9ce19fc01..000000000 --- a/tools/dipper/pil-squash.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: MIT -"""Merge a split Qualcomm firmware (.mdt + .bNN) into the single .mbn image -mainline remoteproc loads. - -The .mdt holds the ELF header and program headers; each loadable segment sits in -.bNN at the offset its program header names. Writing the segments back at those -offsets, under the .mdt's own header, reconstructs the image. - - pil-squash.py [name ...] -""" -# pil-squasher: an .mdt is the ELF header plus program headers; each loadable -# segment lives in .bNN at the offset its program header names. Writing them -# back at those offsets reconstructs the single .mbn image. -import struct, sys -from pathlib import Path - -raw, out = Path(sys.argv[1]), Path(sys.argv[2]) -out.mkdir(parents=True, exist_ok=True) -only = set(sys.argv[3:]) -for mdt in sorted(raw.glob('*.mdt')): - if only and mdt.stem not in only: - continue - d = mdt.read_bytes() - if d[:4] != b'\x7fELF': - print(f"{mdt.name}: not an ELF, skipped"); continue - is64 = d[4] == 2 - if is64: - e_phoff, = struct.unpack_from(' [name ...] -""" -import sys -from pathlib import Path - - -def basename(path: str) -> str: - n = Path(path).name - for suffix in (".ko.zst", ".ko.xz", ".ko.gz", ".ko"): - if n.endswith(suffix): - return n[: -len(suffix)] - return n - - -def main() -> int: - moddir = Path(sys.argv[1]) - wanted = {n.replace("-", "_") for n in sys.argv[2:]} - dep = moddir / "modules.dep" - if not dep.is_file(): - raise SystemExit(f"no {dep}") - - deps, by_name = {}, {} - for line in dep.read_text().splitlines(): - if ":" not in line: - continue - target, rest = line.split(":", 1) - target = target.strip() - deps[target] = rest.split() - by_name[basename(target).replace("-", "_")] = target - - missing = wanted - set(by_name) - if missing: - raise SystemExit(f"not in modules.dep: {', '.join(sorted(missing))}") - - keep, queue = set(), [by_name[n] for n in wanted] - while queue: - cur = queue.pop() - if cur in keep: - continue - keep.add(cur) - queue.extend(deps.get(cur, [])) - - kept_paths = {(moddir / k).resolve() for k in keep} - before = removed = 0 - for f in moddir.rglob("*"): - if not f.is_file() or ".ko" not in f.name: - continue - before += 1 - if f.resolve() not in kept_paths: - f.unlink() - removed += 1 - for d in sorted(moddir.rglob("*"), key=lambda p: -len(p.parts)): - if d.is_dir() and not any(d.iterdir()): - d.rmdir() - - print(f"kept {len(keep)} of {before} modules: " - f"{', '.join(sorted(basename(k) for k in keep))}") - if len(keep) < len(wanted): - raise SystemExit("fewer modules kept than asked for") - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/dipper/push-verified b/tools/dipper/push-verified deleted file mode 100755 index 34762d632..000000000 --- a/tools/dipper/push-verified +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT -# Copy a file to the phone in verified chunks, then optionally write it to a -# partition -- refusing at every step unless the checksum matches. -# -# Why chunks: a single 47 MB stream over the relayed link has silently truncated -# at 32 MiB, and an unverified truncated image written to a partition is exactly -# the mistake this tool exists to make impossible. -set -euo pipefail - -HOST=${HOST:-mi8} -SU=${SU:-/debug_ramdisk/su} -REMOTE_DIR=${REMOTE_DIR:-/data/user/0/org.galexander.sshd/files} -CHUNK_MB=${CHUNK_MB:-4} -RETRIES=${RETRIES:-3} - -src=${1:?usage: push-verified [--to-partition ]} -part="" -if [[ ${2:-} == --to-partition ]]; then part=${3:?partition name}; fi - -[[ -f $src ]] || { echo "no such file: $src" >&2; exit 1; } -size=$(stat -c%s "$src") -want=$(sha256sum "$src" | cut -d' ' -f1) -chunk=$((CHUNK_MB * 1024 * 1024)) -n=$(( (size + chunk - 1) / chunk )) -base=$(basename "$src") -remote=$REMOTE_DIR/$base - -echo "$src: $size bytes, $n chunk(s) of ${CHUNK_MB} MiB, sha256 ${want:0:16}…" -ssh "$HOST" "rm -f '$remote' '$remote'.part" >/dev/null 2>&1 || true - -for ((i = 0; i < n; i++)); do - off=$((i * chunk)) - len=$chunk - (( off + len > size )) && len=$((size - off)) - csum=$(dd if="$src" bs=1M skip=$((i * CHUNK_MB)) count=$CHUNK_MB 2>/dev/null | sha256sum | cut -d' ' -f1) - ok=0 - for ((try = 1; try <= RETRIES; try++)); do - dd if="$src" bs=1M skip=$((i * CHUNK_MB)) count=$CHUNK_MB 2>/dev/null | - ssh "$HOST" "dd of='$remote'.part bs=1M 2>/dev/null" || true - got=$(ssh "$HOST" "sha256sum '$remote'.part 2>/dev/null | cut -d' ' -f1" | tr -d '\r\n') - if [[ $got == "$csum" ]]; then ok=1; break; fi - echo " chunk $((i + 1))/$n attempt $try mismatched; retrying" >&2 - done - (( ok )) || { echo "chunk $((i + 1))/$n failed after $RETRIES attempts" >&2; exit 1; } - ssh "$HOST" "cat '$remote'.part >> '$remote' && rm -f '$remote'.part" - printf '\r %d/%d chunks verified' "$((i + 1))" "$n" -done -echo - -got_size=$(ssh "$HOST" "stat -c%s '$remote'" | tr -d '\r\n') -got_sum=$(ssh "$HOST" "sha256sum '$remote' | cut -d' ' -f1" | tr -d '\r\n') -[[ $got_size == "$size" && $got_sum == "$want" ]] || { - echo "whole-file check failed on the phone: $got_size bytes, ${got_sum:0:16}…" >&2; exit 1; } -echo "uploaded and verified: $remote" - -[[ -n $part ]] || exit 0 - -echo "writing to the $part partition" -blocks=$(( (size + 4095) / 4096 )) -(( size % 4096 == 0 )) || { echo "image is not a multiple of 4096; refusing" >&2; exit 1; } -ssh "$HOST" "$SU -c \" -dev=\\\$(readlink -f /dev/block/by-name/$part) -[ -n \\\"\\\$dev\\\" ] || { echo 'no such partition: $part' >&2; exit 1; } -psize=\\\$(blockdev --getsize64 \\\$dev) -[ \\\"\\\$psize\\\" -ge $size ] || { echo \\\"image $size exceeds \\\$dev (\\\$psize)\\\" >&2; exit 1; } -dd if='$remote' of=\\\$dev bs=1M conv=fsync 2>/dev/null -dd if=\\\$dev bs=4096 count=$blocks 2>/dev/null | sha256sum | cut -d' ' -f1 -\"" | tr -d '\r\n' | { - read -r back - if [[ $back == "$want" ]]; then - echo "$part written and read back byte-exact" - else - echo "READ-BACK MISMATCH: partition holds ${back:0:16}…, expected ${want:0:16}…" >&2 - exit 1 - fi -} -ssh "$HOST" "rm -f '$remote'" diff --git a/tools/dipper/test-board-2.py b/tools/dipper/test-board-2.py deleted file mode 100755 index c1f11e760..000000000 --- a/tools/dipper/test-board-2.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: MIT -"""Check build-board-2.py: it must read upstream's own file and refuse bad input.""" -import importlib.util, os, struct, subprocess, sys, tempfile -from pathlib import Path - -HERE = Path(__file__).resolve().parent -spec = importlib.util.spec_from_file_location("bb2", HERE / "build-board-2.py") -bb2 = importlib.util.module_from_spec(spec); spec.loader.exec_module(bb2) - -fails = [] -def check(c, m): - if not c: fails.append(m) - -# 1. a hand-built file must round-trip through our own parser -name = "bus=snoc,qmi-board-id=0,qmi-chip-id=30214" -data = bytes(range(256)) * 4 -body = bb2.ie(bb2.BD_IE_BOARD_NAME, name.encode()) + bb2.ie(bb2.BD_IE_BOARD_DATA, data) -blob = bb2.MAGIC + b"\0" + b"\0" * ((-(len(bb2.MAGIC) + 1)) % 4) + bb2.ie(bb2.BD_IE_BOARD, body) -got = bb2.parse(blob) -check(got == [(name, len(data))], f"round-trip failed: {got}") - -# 2. the magic must be rejected when wrong, so a truncated download cannot pass -try: - bb2.parse(b"NOT-A-BOARD-FILE" + b"\0" * 8); fails.append("accepted a bad magic") -except ValueError: - pass - -# 3. odd-length payloads must still align, or every later IE is misread -odd = bb2.ie(7, b"abc") -check(len(odd) % 4 == 0, "IE not padded to a 4-byte boundary") -check(struct.unpack_from("= 30, f"only {len(entries)} entries parsed from upstream's file") - check(len(snoc) == len(entries), "some upstream entries did not parse as snoc boards") - check(any("xiaomi_beryllium" in n for n in snoc), "beryllium missing: parse is suspect") - print(f"upstream cross-check: {len(entries)} entries, all snoc") -else: - print("upstream cross-check: SKIPPED (no reference board-2.bin)") - -if fails: - print("FAIL:"); [print(" ", f) for f in fails]; sys.exit(1) -print("test-board-2 OK: round-trips, rejects bad magic, aligns IEs, parses upstream's file") diff --git a/tools/dipper/test-build-boot.py b/tools/dipper/test-build-boot.py deleted file mode 100755 index 688e644f4..000000000 --- a/tools/dipper/test-build-boot.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: MIT -"""Check build-boot.py against the phone's own stock boot header, not invented numbers. - -An optional stock header may be supplied with BOOT_HEADER_REFERENCE. Keep the -capture outside the repository; the comparison is skipped when it is unset. -""" -import gzip, importlib.util, os, struct, subprocess, sys, tempfile -from pathlib import Path - -HERE = Path(__file__).resolve().parent -STOCK = Path(os.environ["BOOT_HEADER_REFERENCE"]) if os.environ.get("BOOT_HEADER_REFERENCE") else None - -spec = importlib.util.spec_from_file_location("bb", HERE / "build-boot.py") -bb = importlib.util.module_from_spec(spec); spec.loader.exec_module(bb) - -fails = [] -def check(cond, msg): - if not cond: fails.append(msg) - -# 1. geometry must equal the stock image's, field by field -if STOCK is not None and STOCK.is_file(): - d = STOCK.read_bytes() - ks, ka, rs, ra, ss, sa, tags, ps, hv, _ = struct.unpack_from("<10I", d, 8) - hdr_size = struct.unpack_from("= ra, - f"our ramdisk_addr {bb.BASE+bb.RAMDISK_OFF:#x} is below stock's {ra:#x}") - # Stock's layout leaves 16 MiB minus the 32 KiB kernel offset, so assert the - # room we actually have rather than a round number. - check(bb.RAMDISK_OFF - bb.KERNEL_OFF >= 16 * 1024 * 1024 - bb.KERNEL_OFF, - f"only {bb.RAMDISK_OFF - bb.KERNEL_OFF} bytes before the ramdisk") - check(tags == bb.BASE + bb.TAGS_OFF, f"tags_addr {tags:#x} != ours {bb.BASE+bb.TAGS_OFF:#x}") - check(ps == bb.PAGE, f"page size {ps} != ours {bb.PAGE}") - check(hv == bb.HDR_VERSION, f"header_version {hv} != ours {bb.HDR_VERSION}") - check(ss == 0, "stock uses a second stage; our packer assumes none") - check(hdr_size == bb.HDR_SIZE, f"header_size {hdr_size} != ours {bb.HDR_SIZE}") - print("stock geometry: matched field by field") -else: - print("stock geometry: SKIPPED (set BOOT_HEADER_REFERENCE to a private stock header)") - -# 2. pack a dummy image and read it back -with tempfile.TemporaryDirectory() as t: - t = Path(t) - kern = t / "Image.gz"; kern.write_bytes(gzip.compress(b"not really a kernel" * 500)) - # a minimal but valid FDT, so the appended-DTB check has something to find - dtb = t / "d.dtb" - body = b"\x00" * 56 - dtb.write_bytes(b"\xd0\x0d\xfe\xed" + struct.pack(">I", 64) + body) - rd = t / "initramfs.cpio.gz"; rd.write_bytes(gzip.compress(b"ramdisk" * 300)) - out = t / "images" - r = subprocess.run([sys.executable, str(HERE / "build-boot.py"), "--kernel", str(kern), - "--dtb", str(dtb), "--ramdisk", str(rd), "--out", str(out)], - capture_output=True, text=True) - check(r.returncode == 0, f"packer failed: {r.stderr.strip()}") - img = (out / "boot.img").read_bytes() - check(img[:8] == b"ANDROID!", "no magic") - check(len(img) % bb.PAGE == 0, "image is not page aligned") - kb = kern.read_bytes() + dtb.read_bytes() - check(struct.unpack_from(" Date: Sat, 7 Nov 2026 23:39:19 +0100 Subject: [PATCH 05/21] NOTES: remove the omitted kernel config path Keep the early-probe lesson without linking to the kernel config removed from this notes-only PR. --- device/dipper/NOTES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 25de7b33c..aa85dfeee 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -70,8 +70,8 @@ Devices probe once, early. A driver that only appears later as a module never ge second chance — the device is left unbound and is not even on the deferred list. Proven twice: the Qualcomm PHYs (so no USB and no storage: `dwc3: failed to initialize core`, `sync_state() pending due to 88e8000.phy`), then i2c (`modprobe i2c-qcom-geni` bound to -nothing, and a hand-written `bind` failed). Everything first light needs is now `=y` in -`device/dipper/kernel.config`, with the reasoning in the file. +nothing, and a hand-written `bind` failed). That is why every driver needed for first +light was built in (`=y`). ### Touch: first failed probe (historical) From 8680364255b4dca2f41ba2be7beff862dc17516b Mon Sep 17 00:00:00 2001 From: quatrixone Date: Sat, 7 Nov 2026 23:51:22 +0100 Subject: [PATCH 06/21] NOTES: omit the USB host address The USB endpoint is project-standard and not needed to record first light; keep the public note free of private-range IPs. --- device/dipper/NOTES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index aa85dfeee..0af44bde1 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -46,8 +46,8 @@ and Wi-Fi keys; quoted here are the facts, never the files. ## 2026-10-29 — first light, and what the hardware said **The phone boots mainline and gives a shell.** `fastboot boot` of our image, kernel -7.3.0-rc6 with our DTB: UFS up (all six LUNs, ext4 mounts), USB NCM gadget, dropbear -on `172.16.42.1`, gpio-keys, 8 CPUs, 5.7 GB RAM. The storage guard works as designed: +7.3.0-rc6 with our DTB: UFS up (all six LUNs, ext4 mounts), USB NCM gadget, dropbear, +gpio-keys, 8 CPUs, 5.7 GB RAM. The storage guard works as designed: `boot`, `recovery` and `persist` read-only, `userdata` and `logdump` writable. ### What had to be fixed before any of that From 0f161356fcb364c0003d6d00f218872956f3fcaf Mon Sep 17 00:00:00 2001 From: quatrixone Date: Sun, 8 Nov 2026 09:15:43 +0100 Subject: [PATCH 07/21] device/dipper: clarify historical kernel and touch results --- device/dipper/NOTES.md | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 0af44bde1..2627942bf 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -1,9 +1,9 @@ # dipper (Xiaomi Mi 8) — bring-up notes -Facts only, each read off the phone. Captures live outside the repo -(`private off-device reference directory (path omitted)/`) because they carry the serial, the cpuid -and Wi-Fi keys; quoted here are the facts, never the files. +Facts only, each read off the phone. Captures remain outside the repository +because they contain device identifiers and Wi-Fi keys; this file records only +the facts needed for review. ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root @@ -45,13 +45,19 @@ and Wi-Fi keys; quoted here are the facts, never the files. ## 2026-10-29 — first light, and what the hardware said -**The phone boots mainline and gives a shell.** `fastboot boot` of our image, kernel -7.3.0-rc6 with our DTB: UFS up (all six LUNs, ext4 mounts), USB NCM gadget, dropbear, -gpio-keys, 8 CPUs, 5.7 GB RAM. The storage guard works as designed: -`boot`, `recovery` and `persist` read-only, `userdata` and `logdump` writable. +**The phone reached a shell on an unpublished kernel tree.** `fastboot boot` of +the image used kernel release +`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` with its matching DTB: UFS up +(all six LUNs, ext4 mounts), USB NCM gadget, dropbear, gpio-keys, 8 CPUs and +5.7 GB RAM. This records the historical first-light tree; kernel PRs #218–#221 +are successor changes and are not the code tested in that boot. The diagnostic +image's guard allowed `userdata` and `logdump` writes; the historical unsafe +write details and current backup coverage still need verification before these +notes can be treated as a recovery record. ### What had to be fixed before any of that -Five defects in the recovered MR !71 work, three of them fatal: +Six defects in the recovered [sdm845-mainline MR !71](https://gitlab.com/sdm845-mainline/linux/-/merge_requests/71) +work, three of them fatal: 1. **`qcom,board-id = <69 0>` (0x45) is polaris's.** dipper reports `0x37`. ABL matches on it and silently refuses the whole boot image otherwise — no kernel output, no panic, @@ -96,14 +102,15 @@ kernel revision; they are not results from the current FTS5 driver: At the time, it was unknown whether GENI/GPI or the FTS5 protocol caused the timeout. -### 2026-10-29 — FTS5 driver update (not yet built or hardware-tested) +### FTS5: historical tap and current upstream series -The live controller is FTS5, so the DTS now declares `st,stmfts5` and -`linux/drivers/input/touchscreen/stmfts.c` carries the upstream FTS5 support and -controller-ready wait fix. The upstream v8 series states it was tested on Xiaomi Mi 8: +The live controller is FTS5. A separate historical RAM boot on 2026-10-30, using +the unpublished kernel release above, registered `stmfts` and a physical tap +produced `ABS_MT_POSITION_X`. That observation is not a test of the current +kernel PRs. The public successor series is [kernel PR #219](https://github.com/derekross/linux-omarchy-mobile/pull/219), +with its binding in [kernel PR #220](https://github.com/derekross/linux-omarchy-mobile/pull/220). +The upstream v8 series states it was tested on Xiaomi Mi 8: [FTS5 driver patch](https://lists.openwall.net/linux-kernel/2026/09/25/2213), [controller-ready fix](https://lists.openwall.net/linux-kernel/2026/09/25/2214), [binding update](https://lists.openwall.net/linux-kernel/2026/09/25/2212). -This is the first protocol-matched driver tried here, but it still needs a kernel build -and attended RAM-boot test. The upstream series provides basic touch only; firmware -loading and wake-on-touch/AP-SLPI handoff are not implemented. +Firmware loading, low-power touch and wake-on-touch/AP-SLPI handoff are not implemented. From 119aee0941d20b944ffc0c3da4d724d1527df901 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Sun, 8 Nov 2026 09:48:22 +0100 Subject: [PATCH 08/21] device/dipper: record known storage activity --- device/dipper/NOTES.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 2627942bf..907b32510 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -51,9 +51,23 @@ the image used kernel release (all six LUNs, ext4 mounts), USB NCM gadget, dropbear, gpio-keys, 8 CPUs and 5.7 GB RAM. This records the historical first-light tree; kernel PRs #218–#221 are successor changes and are not the code tested in that boot. The diagnostic -image's guard allowed `userdata` and `logdump` writes; the historical unsafe -write details and current backup coverage still need verification before these -notes can be treated as a recovery record. +image's guard allowed `userdata` and `logdump` writes. A temporary init widened +the allowlist to include `logdump` and used `dd` to copy the kernel log there +every two seconds. Two diagnostic-image attempts were written to stock +`recovery` from rooted Android. The current `recovery` image has not been +compared with the pre-write backup, and the backup's coverage of `logdump` is +unknown. The current RAM-only image and storage guard leave every UFS partition +read-only; this is a code-path fact, not a new phone check. The mount options +and whether `persist` was mounted during first light are not recorded here. + +Other historical device activity recorded by the owner: NFS-root Omarchy +sessions on 2026-10-30, 2026-10-31 and 2026-11-02; modem starts under +`rmtfs -r`, followed by an XPU violation crash and remoteproc recovery loops; +and a 2026-10-30 partition comparison where `persist`, `modemst1` and `frp` +changed. The intervening boot sequence and the cause of those changes are not +established here, so they are not attributed to stock Android or to Omarchy. +These notes are not a recovery record until the backup checks and intervening +boot sequence are verified. ### What had to be fixed before any of that Six defects in the recovered [sdm845-mainline MR !71](https://gitlab.com/sdm845-mainline/linux/-/merge_requests/71) @@ -61,7 +75,8 @@ work, three of them fatal: 1. **`qcom,board-id = <69 0>` (0x45) is polaris's.** dipper reports `0x37`. ABL matches on it and silently refuses the whole boot image otherwise — no kernel output, no panic, - just a reboot. Two blind attempts from `recovery` were lost to this. + just a reboot. Two blind diagnostic-image attempts were written to stock `recovery` + from rooted Android before this mismatch was corrected. 2. `drm_panel_init()` no longer exists; the panel probe needed the refcounted `devm_drm_panel_alloc()`. 3. `panel-samsung-ea8074.ko` had no `MODULE_LICENSE()`, so modpost refused to link. From 712d72fb819163f9dd0c386d1e9cba73f79d272a Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 09:52:05 +0100 Subject: [PATCH 09/21] device/dipper: record current RAM boot check --- device/dipper/NOTES.md | 61 ++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 907b32510..71a1ae819 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -5,6 +5,22 @@ Facts only, each read off the phone. Captures remain outside the repository because they contain device identifiers and Wi-Fi keys; this file records only the facts needed for review. +## 2026-11-09 — check for the RAM-only image + +A read-only SSH check reported kernel +`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` and root `/dev/sda21` +mounted ext4 read-write. `/sys/block/sda/ro` and +`/sys/block/sda/sda21/ro` were `0`; all other partition `ro` values read `1`. +This does not verify PR #505's RAM-only image: its boot image hash was not +recorded, and these writable values fail that runbook's stop condition. +Systemd logged that setting the `qcom_wdt` timeout to one minute failed; the +watchdog feeder status was not checked. A later USB SSH attempt got no reply, +and neither ADB nor fastboot listed a device. No new boot or deploy was +attempted. The userdata backup is not complete. The existing 15-partition +stock backup manifest still verifies, but the current `recovery` image has +not been compared with it; do not boot again until the userdata backup and +recovery checks are complete and USB SSH is available. + ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root - **SoC** SDM845. Live DT root: `model = "Xiaomi Technologies, Inc. Dipper new MP v2.1"`, @@ -49,25 +65,35 @@ the facts needed for review. the image used kernel release `7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` with its matching DTB: UFS up (all six LUNs, ext4 mounts), USB NCM gadget, dropbear, gpio-keys, 8 CPUs and -5.7 GB RAM. This records the historical first-light tree; kernel PRs #218–#221 -are successor changes and are not the code tested in that boot. The diagnostic +5.7 GB RAM. This records the historical first-light tree; kernel PRs [#218](https://github.com/derekross/linux-omarchy-mobile/pull/218), +[#219](https://github.com/derekross/linux-omarchy-mobile/pull/219), +[#220](https://github.com/derekross/linux-omarchy-mobile/pull/220) and +[#221](https://github.com/derekross/linux-omarchy-mobile/pull/221) are successor +changes and are not the code tested in that boot. The diagnostic image's guard allowed `userdata` and `logdump` writes. A temporary init widened the allowlist to include `logdump` and used `dd` to copy the kernel log there -every two seconds. Two diagnostic-image attempts were written to stock -`recovery` from rooted Android. The current `recovery` image has not been -compared with the pre-write backup, and the backup's coverage of `logdump` is -unknown. The current RAM-only image and storage guard leave every UFS partition +every two seconds during the 2026-10-29 diagnostic boot. Two diagnostic-image +writes to stock `recovery` from rooted Android were also made on 2026-10-29. +The existing 15-partition backup did not include `logdump`; an unverified +`logdump.img` file is not evidence of a checked phone backup. The current +`recovery` image has not been compared with a verified pre-write copy. The +current RAM-only image and storage guard leave every UFS partition read-only; this is a code-path fact, not a new phone check. The mount options and whether `persist` was mounted during first light are not recorded here. -Other historical device activity recorded by the owner: NFS-root Omarchy -sessions on 2026-10-30, 2026-10-31 and 2026-11-02; modem starts under -`rmtfs -r`, followed by an XPU violation crash and remoteproc recovery loops; -and a 2026-10-30 partition comparison where `persist`, `modemst1` and `frp` -changed. The intervening boot sequence and the cause of those changes are not -established here, so they are not attributed to stock Android or to Omarchy. -These notes are not a recovery record until the backup checks and intervening -boot sequence are verified. +The recorded 15-partition snapshot before the radio runs was checksum-verified. +The 2026-10-30 comparison found `boot`, `recovery`, `dtbo`, `vbmeta`, +`fsc`, `devinfo`, `misc`, `logo`, `splash`, `persistbak`, `modemst2` +and `fsg` byte-identical; only `persist`, `modemst1` and `frp` changed. +All five NV partitions were read-only before and after the recorded runs. The +cause of the three differences is not established. Other recorded activity: +NFS-root Omarchy sessions on 2026-10-30, 2026-10-31 and 2026-11-02; modem +starts under `rmtfs -r`, followed by an XPU violation crash and remoteproc +recovery loops. The sequence of boots between the two snapshots (date, stock +Android or RAM image, and actions) has not been reconstructed, so the later +snapshot is not a baseline and the changes are not attributed to Android or +Omarchy. These notes are not a recovery record until that sequence and the +current recovery image are checked. ### What had to be fixed before any of that Six defects in the recovered [sdm845-mainline MR !71](https://gitlab.com/sdm845-mainline/linux/-/merge_requests/71) @@ -122,9 +148,10 @@ At the time, it was unknown whether GENI/GPI or the FTS5 protocol caused the tim The live controller is FTS5. A separate historical RAM boot on 2026-10-30, using the unpublished kernel release above, registered `stmfts` and a physical tap produced `ABS_MT_POSITION_X`. That observation is not a test of the current -kernel PRs. The public successor series is [kernel PR #219](https://github.com/derekross/linux-omarchy-mobile/pull/219), -with its binding in [kernel PR #220](https://github.com/derekross/linux-omarchy-mobile/pull/220). -The upstream v8 series states it was tested on Xiaomi Mi 8: +kernel PRs. The public successor series and its binding are in +[kernel PR #219](https://github.com/derekross/linux-omarchy-mobile/pull/219). +The upstream v8 cover letter states it was tested on Xiaomi Mi 8: +[FTS5 v8 cover letter](https://lists.openwall.net/linux-kernel/2026/09/25/2211), [FTS5 driver patch](https://lists.openwall.net/linux-kernel/2026/09/25/2213), [controller-ready fix](https://lists.openwall.net/linux-kernel/2026/09/25/2214), [binding update](https://lists.openwall.net/linux-kernel/2026/09/25/2212). From c794d6bbe19131b1184a6977f914f3285187d678 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 16:20:16 +0100 Subject: [PATCH 10/21] device/dipper: update recovery and backup record --- device/dipper/NOTES.md | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 71a1ae819..bc5b54118 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -5,21 +5,36 @@ Facts only, each read off the phone. Captures remain outside the repository because they contain device identifiers and Wi-Fi keys; this file records only the facts needed for review. -## 2026-11-09 — check for the RAM-only image +## 2026-11-09 — current recovery and RAM-only image gate -A read-only SSH check reported kernel -`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` and root `/dev/sda21` +A read-only SSH check of the installed kernel +`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` reported root `/dev/sda21` mounted ext4 read-write. `/sys/block/sda/ro` and `/sys/block/sda/sda21/ro` were `0`; all other partition `ro` values read `1`. -This does not verify PR #505's RAM-only image: its boot image hash was not -recorded, and these writable values fail that runbook's stop condition. -Systemd logged that setting the `qcom_wdt` timeout to one minute failed; the -watchdog feeder status was not checked. A later USB SSH attempt got no reply, -and neither ADB nor fastboot listed a device. No new boot or deploy was -attempted. The userdata backup is not complete. The existing 15-partition -stock backup manifest still verifies, but the current `recovery` image has -not been compared with it; do not boot again until the userdata backup and -recovery checks are complete and USB SSH is available. +This is not PR #505's image and fails its RAM-boot stop condition. Systemd +logged that setting the `qcom_wdt` timeout to one minute failed; the watchdog +feeder status was not checked. + +The current `recovery` partition's SHA-256 matches the `recovery.img` in the +checksum-verified 15-partition snapshot captured on 2026-10-29 at 19:01. This +confirms the bytes match that saved copy; the exact order of that capture and +the two diagnostic writes to `recovery` is not established here. `logdump` is +not in the 15-partition backup. A separate live, file-level archive of the +userdata root filesystem has now been created and verified off-device. It is +not a raw partition image or an atomic snapshot; the filesystem remained +mounted during the copy. + +On 2026-11-09 the owner verified that holding Power alone for more than 10 +seconds restarted this handset. The owner then entered fastboot with Volume +Down + Power; read-only fastboot variables reported product `dipper` and an +unlocked bootloader. This verifies the handset's button recovery from the +running system, not recovery from a hang in PR #505's kernel. + +No PR #505 image has been booted. The installed dirty kernel's writable root +and failed watchdog-timeout setting are not results from that image. Before +trying it, rebuild from the public kernel PRs, check the backup manifest, and +record the exact image hash. Keep the stop condition: every partition must +remain read-only, the watchdog must be fed, and USB/SSH must come up. ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root From 599edd077a8c7a07d174b495157592eb803e4a19 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 17:28:27 +0100 Subject: [PATCH 11/21] device/dipper: record PR image RAM boot --- device/dipper/NOTES.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index bc5b54118..09e630c84 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -30,11 +30,22 @@ Down + Power; read-only fastboot variables reported product `dipper` and an unlocked bootloader. This verifies the handset's button recovery from the running system, not recovery from a hang in PR #505's kernel. -No PR #505 image has been booted. The installed dirty kernel's writable root -and failed watchdog-timeout setting are not results from that image. Before -trying it, rebuild from the public kernel PRs, check the backup manifest, and -record the exact image hash. Keep the stop condition: every partition must -remain read-only, the watchdog must be fed, and USB/SSH must come up. +On 2026-11-09, a clean PR #505 image built from the open Dipper kernel series +was started with serial-pinned `fastboot boot`; no partition was flashed. It +reported `7.3.0-rc6-omamobile-push1`, and its `boot.img` SHA-256 was +`93484a91103c294f6c73799ae6cb7161019129b9f89ab331222ae04f10ecf3e1` (matching +the local build manifest). The owner saw the console. `simpledrm` registered +`/dev/fb0`, `gpio-keys` registered an input device, USB networking and SSH +worked, and the `qcom_wdt` driver was bound with its userspace feeder running. +No physical key event was captured in this probe. + +The storage guard removed the whole-disk node `/dev/sda`; its sysfs `ro` value +remained `0` by design. Every UFS partition reported `ro=1`, and all other +whole-disk nodes reported `ro=1`. The kernel log confirmed the guard's actions. +The screen console was visible; the EA8074 panel and FTS5 touchscreen drivers +remain disabled pending their separate hardware tests. The RAM image had no +Arch root, and the probe did not write UFS. The checksum-verified stock +partition snapshot and the private userdata archive were checked before boot. ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root From 47052cc4a07a4b8b33a06504082250af68801776 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 18:03:07 +0100 Subject: [PATCH 12/21] device/dipper: record verified PMIC key boot --- device/dipper/NOTES.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 09e630c84..1c4be8c27 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -30,22 +30,26 @@ Down + Power; read-only fastboot variables reported product `dipper` and an unlocked bootloader. This verifies the handset's button recovery from the running system, not recovery from a hang in PR #505's kernel. -On 2026-11-09, a clean PR #505 image built from the open Dipper kernel series +On 2026-11-09, the final PR #505 image built from the open Dipper kernel series was started with serial-pinned `fastboot boot`; no partition was flashed. It reported `7.3.0-rc6-omamobile-push1`, and its `boot.img` SHA-256 was -`93484a91103c294f6c73799ae6cb7161019129b9f89ab331222ae04f10ecf3e1` (matching -the local build manifest). The owner saw the console. `simpledrm` registered -`/dev/fb0`, `gpio-keys` registered an input device, USB networking and SSH -worked, and the `qcom_wdt` driver was bound with its userspace feeder running. -No physical key event was captured in this probe. +`f2f5cb2e3da8fe992d366dba36e059c0d9106cf14a7d1c8872c61ee144a4474b` (matching +the local build manifest). `simpledrm` registered `/dev/fb0`; USB networking +and SSH worked; and `qcom_wdt` was bound with its userspace feeder running. + +The first image did not register PMIC keys because `qcom-pon` was left modular +and absent from the rescue initramfs. The Dipper kernel fragment now builds it +in. On the final image, `pm8941_pwrkey` and `pm8941_resin` both registered, and +a physical Volume Down press produced `KEY_VOLUMEDOWN` (code 114, value 1). +The owner had already reported seeing the console during the first boot. The storage guard removed the whole-disk node `/dev/sda`; its sysfs `ro` value -remained `0` by design. Every UFS partition reported `ro=1`, and all other +remained `0` by design. All 85 UFS partitions reported `ro=1`, and all other whole-disk nodes reported `ro=1`. The kernel log confirmed the guard's actions. -The screen console was visible; the EA8074 panel and FTS5 touchscreen drivers -remain disabled pending their separate hardware tests. The RAM image had no -Arch root, and the probe did not write UFS. The checksum-verified stock -partition snapshot and the private userdata archive were checked before boot. +The EA8074 panel and FTS5 touchscreen still need separate hardware tests. The +RAM image had no Arch root, and the probe did not write UFS. The checksum- +verified stock partition snapshot and private userdata archive were checked +before boot. ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root From 6886d306b926cf05eda4b51bb51a4332fabf2a0d Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 19:46:06 +0100 Subject: [PATCH 13/21] device/dipper: reconcile the recovery and RAM boot notes --- device/dipper/NOTES.md | 135 ++++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 61 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 1c4be8c27..c5cd63c19 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -5,51 +5,60 @@ Facts only, each read off the phone. Captures remain outside the repository because they contain device identifiers and Wi-Fi keys; this file records only the facts needed for review. -## 2026-11-09 — current recovery and RAM-only image gate - -A read-only SSH check of the installed kernel -`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` reported root `/dev/sda21` -mounted ext4 read-write. `/sys/block/sda/ro` and -`/sys/block/sda/sda21/ro` were `0`; all other partition `ro` values read `1`. -This is not PR #505's image and fails its RAM-boot stop condition. Systemd -logged that setting the `qcom_wdt` timeout to one minute failed; the watchdog -feeder status was not checked. - -The current `recovery` partition's SHA-256 matches the `recovery.img` in the -checksum-verified 15-partition snapshot captured on 2026-10-29 at 19:01. This -confirms the bytes match that saved copy; the exact order of that capture and -the two diagnostic writes to `recovery` is not established here. `logdump` is -not in the 15-partition backup. A separate live, file-level archive of the -userdata root filesystem has now been created and verified off-device. It is -not a raw partition image or an atomic snapshot; the filesystem remained -mounted during the copy. - -On 2026-11-09 the owner verified that holding Power alone for more than 10 -seconds restarted this handset. The owner then entered fastboot with Volume -Down + Power; read-only fastboot variables reported product `dipper` and an -unlocked bootloader. This verifies the handset's button recovery from the -running system, not recovery from a hang in PR #505's kernel. - -On 2026-11-09, the final PR #505 image built from the open Dipper kernel series -was started with serial-pinned `fastboot boot`; no partition was flashed. It -reported `7.3.0-rc6-omamobile-push1`, and its `boot.img` SHA-256 was -`f2f5cb2e3da8fe992d366dba36e059c0d9106cf14a7d1c8872c61ee144a4474b` (matching -the local build manifest). `simpledrm` registered `/dev/fb0`; USB networking -and SSH worked; and `qcom_wdt` was bound with its userspace feeder running. - -The first image did not register PMIC keys because `qcom-pon` was left modular -and absent from the rescue initramfs. The Dipper kernel fragment now builds it -in. On the final image, `pm8941_pwrkey` and `pm8941_resin` both registered, and -a physical Volume Down press produced `KEY_VOLUMEDOWN` (code 114, value 1). -The owner had already reported seeing the console during the first boot. - -The storage guard removed the whole-disk node `/dev/sda`; its sysfs `ro` value -remained `0` by design. All 85 UFS partitions reported `ro=1`, and all other -whole-disk nodes reported `ro=1`. The kernel log confirmed the guard's actions. -The EA8074 panel and FTS5 touchscreen still need separate hardware tests. The -RAM image had no Arch root, and the probe did not write UFS. The checksum- -verified stock partition snapshot and private userdata archive were checked -before boot. +## 2026-11-09 — recovery, old-kernel observation and RAM-only image + +The current `recovery` partition matches the `recovery.img` in the +checksum-verified 15-partition stock snapshot captured on 2026-10-29 at 19:01; +both have SHA-256 +`7691a33e8b65d1ffcbf67b16fd4dc5c4c421420230f230db312512c73abc2221`. This +confirms the bytes match that saved copy. The order of that snapshot and the +two diagnostic writes to `recovery` is not established. `logdump` is not in +the 15-partition backup. A separate live, file-level userdata archive was +verified off-device; it is not a raw partition image or an atomic snapshot, +and the filesystem remained mounted during the copy. + +Before entering fastboot, the handset answered over USB SSH; no restart was +needed to restore SSH. On the installed Android system, holding Power alone +for more than 10 seconds restarted it, then Volume Down + Power entered +fastboot. Read-only fastboot variables reported product `dipper` and an +unlocked bootloader. This attended test was from the installed system, not a +simulated kernel hang. + +An earlier read-only SSH observation, reported on 2026-11-09 at 08:53 UTC, +was on the dirty kernel +`7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty`. It reported `/dev/sda21` +mounted as the root filesystem read-write, with `/sys/block/sda/ro=0` and +`/sys/block/sda/sda21/ro=0`; the other partition `ro` values were `1`. Thus +`/dev/sda` existed and the whole main LUN was writable. The surviving record +does not say how that image was started, the device uptime at the check, or +whether its diagnostic init's `logdump` mirror was running. Do not boot that +old image again. Systemd reported failure to set the `qcom_wdt` timeout to one +minute, but the exact journal line was not retained and the feeder was not +checked. This old-kernel observation is not evidence for PR #505's image. + +The PR #505 RAM image was built from kernel PR #220 head `b288f8e` after FTS5 +PR #219 merged, then started with serial-pinned `fastboot boot`; no partition +was flashed. It reported `7.3.0-rc6-omamobile-push1`. The `boot.img` SHA-256 is +`e2cdb765de21a5869a1db314c19f1fddb668219a51d3c9ce81a1a083536d711e`, matching +its build manifest. The root is the initramfs (`rootfs`), not UFS. `simpledrm` +registered `/dev/fb0`; USB networking and SSH worked; and `qcom_wdt` was bound +with its userspace feeder running. The rescue exposed reboot modes `bootloader` +and `recovery`; running `/usr/local/bin/reboot-to bootloader` over SSH returned +the handset to fastboot without writing UFS. + +`pm8941_pwrkey` and `pm8941_resin` registered. On the earlier final image, a +physical Volume Down press produced `KEY_VOLUMEDOWN` (code 114, value 1), and +Volume Up produced `KEY_VOLUMEUP` (code 115, value 1). The current kernel +image's button events have not yet been rechecked. The owner reported seeing +the console during the first boot. + +The storage guard removed `/dev/sda`; its sysfs `ro` value remained `0` by +design. All 85 UFS partition `ro` values were `1`; the other UFS whole disks +were read-only. `/proc/iomem` reports `0x86200000–0x88efffff` as System RAM and +`0x88f00000–0x890fffff` as reserved, so the TZ range is not reserved in this +RAM boot's map. The EA8074 panel and FTS5 touch input still need separate +hardware tests. The RAM image had no Arch root, and the probe did not write +UFS. The stock partition checksums were verified before boot. ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root @@ -81,8 +90,8 @@ before boot. `fts,tp-vendor = <0x48>`. The running kernel's input device is `N: Name="fts"`. An `atmel,mxt-ts@4a` node exists as the alternate vendor and is not the active one. **Open:** mainline's ST driver is `st,stmfts` (`drivers/input/touchscreen/stmfts.c`), - a different driver from Xiaomi's downstream `st_fts`; whether it binds this controller - is untested and is the largest unknown in this port. No sibling board helps — + a different driver from Xiaomi's downstream `st_fts`; the current FTS5 driver + has not been tested with Dipper's DTS node. No sibling board helps — polaris uses `syna,rmi4-i2c@20`, beryllium a FocalTech/Novatek part. - **Audio** `sdm845-tavil-snd-card` (WCD9340). **Fingerprint** Goodix, capacitive (`fingerprint_goodix`, `uinput-goodix`); no mainline driver, out of scope. @@ -96,20 +105,24 @@ the image used kernel release `7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty` with its matching DTB: UFS up (all six LUNs, ext4 mounts), USB NCM gadget, dropbear, gpio-keys, 8 CPUs and 5.7 GB RAM. This records the historical first-light tree; kernel PRs [#218](https://github.com/derekross/linux-omarchy-mobile/pull/218), -[#219](https://github.com/derekross/linux-omarchy-mobile/pull/219), -[#220](https://github.com/derekross/linux-omarchy-mobile/pull/220) and -[#221](https://github.com/derekross/linux-omarchy-mobile/pull/221) are successor -changes and are not the code tested in that boot. The diagnostic -image's guard allowed `userdata` and `logdump` writes. A temporary init widened -the allowlist to include `logdump` and used `dd` to copy the kernel log there -every two seconds during the 2026-10-29 diagnostic boot. Two diagnostic-image -writes to stock `recovery` from rooted Android were also made on 2026-10-29. -The existing 15-partition backup did not include `logdump`; an unverified -`logdump.img` file is not evidence of a checked phone backup. The current -`recovery` image has not been compared with a verified pre-write copy. The -current RAM-only image and storage guard leave every UFS partition -read-only; this is a code-path fact, not a new phone check. The mount options -and whether `persist` was mounted during first light are not recorded here. +[#219](https://github.com/derekross/linux-omarchy-mobile/pull/219) and +[#220](https://github.com/derekross/linux-omarchy-mobile/pull/220) are later +successor changes and are not the code tested in that boot; FTS5 PR #219 is now +merged upstream. The diagnostic image's guard allowed `userdata` and `logdump` +writes. A temporary init widened the allowlist to include `logdump` and used +`dd` to copy the kernel log there every two seconds during the 2026-10-29 +diagnostic boot. The 2026-11-09 read-only check was on this dirty October +kernel; it found `/dev/sda21` as the read-write root and therefore `/dev/sda` +present and writable. The saved record does not establish whether the mirror +process was still running during that later check, nor the device uptime then. +Two diagnostic-image writes to stock `recovery` from rooted Android were also +made on 2026-10-29. The existing 15-partition backup did not include `logdump`; +an unverified `logdump.img` file is not evidence of a checked phone backup. +The current recovery SHA matches the verified 2026-10-29 19:01 snapshot +described above; the order of that snapshot and the two writes is unknown. The +2026-11-09 PR #505 RAM boot checked every UFS partition flag on the phone; it +did not mount or write UFS. The mount options and whether `persist` was mounted +during first light are not recorded here. The recorded 15-partition snapshot before the radio runs was checksum-verified. The 2026-10-30 comparison found `boot`, `recovery`, `dtbo`, `vbmeta`, From 670b14380b877c90cbaee8717549c3f4275b31cf Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 20:40:43 +0100 Subject: [PATCH 14/21] device-dipper: record complete stock backup --- device/dipper/NOTES.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index c5cd63c19..716d35cf1 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -58,7 +58,15 @@ were read-only. `/proc/iomem` reports `0x86200000–0x88efffff` as System RAM an `0x88f00000–0x890fffff` as reserved, so the TZ range is not reserved in this RAM boot's map. The EA8074 panel and FTS5 touch input still need separate hardware tests. The RAM image had no Arch root, and the probe did not write -UFS. The stock partition checksums were verified before boot. +UFS. The stock partition checksums were verified before boot. After this +session, a read-only backup of all 84 non-`userdata`, non-`super` GPT +partitions was captured from this guarded RAM boot. Each partition's source +SHA-256 and byte count were checked against the decompressed local copy, and +the compressed archive checksums were rechecked. The separate live userdata +archive remains file-level, non-atomic, and is not a raw partition backup. +The backup is stored outside the repository; it must not be published. This +completes the data-capture condition, but a reviewed button-by-button restore +procedure and supported single-slot writer are still required before a flash. ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root From 281ce5bdd118e8478cb0b67ab9c37f2d060c9746 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 21:58:32 +0100 Subject: [PATCH 15/21] device-dipper: record panel and recovery verification --- device/dipper/NOTES.md | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 716d35cf1..9ebc7e1e6 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -10,10 +10,12 @@ the facts needed for review. The current `recovery` partition matches the `recovery.img` in the checksum-verified 15-partition stock snapshot captured on 2026-10-29 at 19:01; both have SHA-256 -`7691a33e8b65d1ffcbf67b16fd4dc5c4c421420230f230db312512c73abc2221`. This -confirms the bytes match that saved copy. The order of that snapshot and the -two diagnostic writes to `recovery` is not established. `logdump` is not in -the 15-partition backup. A separate live, file-level userdata archive was +`7691a33e8b65d1ffcbf67b16fd4dc5c4c421420230f230db312512c73abc2221`. Its +Android boot header contains a gzip-compressed kernel that identifies as +`Linux version 4.9.337-perf-g0b3e38ef6c40`, not the 7.3 diagnostic kernel. This +confirms the current partition holds the stock recovery image. The order of the +snapshot and the two diagnostic writes remains unknown. `logdump` is not in the +15-partition backup. A separate live, file-level userdata archive was verified off-device; it is not a raw partition image or an atomic snapshot, and the filesystem remained mounted during the copy. @@ -56,10 +58,20 @@ The storage guard removed `/dev/sda`; its sysfs `ro` value remained `0` by design. All 85 UFS partition `ro` values were `1`; the other UFS whole disks were read-only. `/proc/iomem` reports `0x86200000–0x88efffff` as System RAM and `0x88f00000–0x890fffff` as reserved, so the TZ range is not reserved in this -RAM boot's map. The EA8074 panel and FTS5 touch input still need separate -hardware tests. The RAM image had no Arch root, and the probe did not write -UFS. The stock partition checksums were verified before boot. After this -session, a read-only backup of all 84 non-`userdata`, non-`super` GPT +RAM boot's map. A separate EA8074 panel test used a RAM-only overlay on +2026-11-09 with kernel `7.3.0-rc6-omamobile-push1` and boot image SHA-256 +`0f0ec9d62ebe57bef9ae8a4804bb23728f624daab824a0bf7dee18f63c2a3d59`. The panel +driver bound to `ae94000.dsi.0`, DRM reported `connected` at `1080x2248`, and +the owner confirmed the console was visible on the lit panel. All 85 partition +flags were `ro=1`; `/dev/sda` was absent, while `/dev/sdb` through `/dev/sdf` +remained present and had `ro=1` on this pre-#484 image. Backlight value 0 was +accepted and restored to 511 (maximum 1023). Framebuffer blanking changed +DRM `dpms` from `On` to `Off` and back to `On`. The FTS5 touch input still needs +a test on the current kernel. The panel log included a missing DSI `vdda` +supply (dummy regulator) and missing `a630_sqe.fw`; the display initialized, +but GPU rendering was not tested. The RAM image had no Arch root, and the probe +did not write UFS. The stock partition checksums were verified before boot. +After this session, a read-only backup of all 84 non-`userdata`, non-`super` GPT partitions was captured from this guarded RAM boot. Each partition's source SHA-256 and byte count were checked against the decompressed local copy, and the compressed archive checksums were rechecked. The separate live userdata @@ -116,7 +128,7 @@ the image used kernel release [#219](https://github.com/derekross/linux-omarchy-mobile/pull/219) and [#220](https://github.com/derekross/linux-omarchy-mobile/pull/220) are later successor changes and are not the code tested in that boot; FTS5 PR #219 is now -merged upstream. The diagnostic image's guard allowed `userdata` and `logdump` +merged into linux-omarchy-mobile. The diagnostic image's guard allowed `userdata` and `logdump` writes. A temporary init widened the allowlist to include `logdump` and used `dd` to copy the kernel log there every two seconds during the 2026-10-29 diagnostic boot. The 2026-11-09 read-only check was on this dirty October @@ -143,8 +155,12 @@ starts under `rmtfs -r`, followed by an XPU violation crash and remoteproc recovery loops. The sequence of boots between the two snapshots (date, stock Android or RAM image, and actions) has not been reconstructed, so the later snapshot is not a baseline and the changes are not attributed to Android or -Omarchy. These notes are not a recovery record until that sequence and the -current recovery image are checked. +Omarchy. The current recovery image matches the 10-29 19:01 snapshot and its +kernel identifies as stock `4.9.337-perf-g0b3e38ef6c40`; the snapshot's order +relative to the two diagnostic writes remains unknown. The 10-29 first-light +boot is recorded as `fastboot boot` from RAM, not a recovery boot. The separate +08:53 old-kernel observation's launch method remains unknown; the surviving +record does not establish its source. ### What had to be fixed before any of that Six defects in the recovered [sdm845-mainline MR !71](https://gitlab.com/sdm845-mainline/linux/-/merge_requests/71) @@ -194,7 +210,7 @@ kernel revision; they are not results from the current FTS5 driver: At the time, it was unknown whether GENI/GPI or the FTS5 protocol caused the timeout. -### FTS5: historical tap and current upstream series +### FTS5: historical tap and published driver series The live controller is FTS5. A separate historical RAM boot on 2026-10-30, using the unpublished kernel release above, registered `stmfts` and a physical tap From 702f1dc098c94722508ecb05c01567c4f8ad15ab Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 22:46:24 +0100 Subject: [PATCH 16/21] device/dipper: record power-hold under RAM kernel --- device/dipper/NOTES.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 9ebc7e1e6..5800f40bf 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -20,11 +20,10 @@ verified off-device; it is not a raw partition image or an atomic snapshot, and the filesystem remained mounted during the copy. Before entering fastboot, the handset answered over USB SSH; no restart was -needed to restore SSH. On the installed Android system, holding Power alone -for more than 10 seconds restarted it, then Volume Down + Power entered -fastboot. Read-only fastboot variables reported product `dipper` and an -unlocked bootloader. This attended test was from the installed system, not a -simulated kernel hang. +needed to restore SSH. Holding Power alone for 10 seconds restarted the phone +back into Android both from the installed system and under the Omarchy Mobile +RAM kernel. Volume Down + Power then entered fastboot. Read-only fastboot +variables reported product `dipper` and an unlocked bootloader. An earlier read-only SSH observation, reported on 2026-11-09 at 08:53 UTC, was on the dirty kernel From 203ac3bad8a3892baca8827acf0f5fd8f7884f8e Mon Sep 17 00:00:00 2001 From: quatrixone Date: Mon, 9 Nov 2026 23:56:57 +0100 Subject: [PATCH 17/21] device/dipper: record NFS-root handover --- device/dipper/NOTES.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 5800f40bf..0191c0e8f 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -25,6 +25,18 @@ back into Android both from the installed system and under the Omarchy Mobile RAM kernel. Volume Down + Power then entered fastboot. Read-only fastboot variables reported product `dipper` and an unlocked bootloader. +A separate NFS-root attempt used a RAM-only image with SHA-256 +`2244d74aea472b0c595b2056ad8618f614e6a9161b5b264c7f898939e626f318`, reusing +the earlier #505 kernel and DTB and repacking its initramfs with +`OMAMOBILE_NFSROOT`. The persistent NFS-root journal recorded NFS mode and +read-only confirmations for all 85 unique UFS partitions and all six UFS +disks; the guard reads each `ro` value back as `1` before logging success. SSH +confirmed `/` was NFS, PID 1 was systemd, and the system was running with +`RuntimeWatchdogUSec=20s`. The exported root was a generic Arch Linux ARM base, +not an Omarchy rootfs. No UFS write was attempted. Direct `uname -r` and +sysfs `ro` output were not captured, and this pre-#484 image does not verify +the post-#484 whole-disk-node absence check. + An earlier read-only SSH observation, reported on 2026-11-09 at 08:53 UTC, was on the dirty kernel `7.3.0-rc6-omamobile-push1-g2a318a96ae9d-dirty`. It reported `/dev/sda21` From cac9ad7e2714850df626cee51edf077f0d7ae573 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Tue, 10 Nov 2026 02:32:57 +0100 Subject: [PATCH 18/21] device/dipper: correct RAM image guard record --- device/dipper/NOTES.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 0191c0e8f..5eab8ec2d 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -49,15 +49,17 @@ old image again. Systemd reported failure to set the `qcom_wdt` timeout to one minute, but the exact journal line was not retained and the feeder was not checked. This old-kernel observation is not evidence for PR #505's image. -The PR #505 RAM image was built from kernel PR #220 head `b288f8e` after FTS5 -PR #219 merged, then started with serial-pinned `fastboot boot`; no partition -was flashed. It reported `7.3.0-rc6-omamobile-push1`. The `boot.img` SHA-256 is -`e2cdb765de21a5869a1db314c19f1fddb668219a51d3c9ce81a1a083536d711e`, matching -its build manifest. The root is the initramfs (`rootfs`), not UFS. `simpledrm` -registered `/dev/fb0`; USB networking and SSH worked; and `qcom_wdt` was bound -with its userspace feeder running. The rescue exposed reboot modes `bootloader` -and `recovery`; running `/usr/local/bin/reboot-to bootloader` over SSH returned -the handset to fastboot without writing UFS. +The image with SHA-256 +`e2cdb765de21a5869a1db314c19f1fddb668219a51d3c9ce81a1a083536d711e` was +previously described here as PR #505's RAM image. On 2026-11-10, I booted that +exact file again with `fastboot boot` and read it over the USB serial shell. +It reported `7.3.0-rc6-omamobile-push1`, but `/dev/sda` existed with +`/sys/block/sda/ro=0`; `/sys/block/sda/sda21/ro=1`. Its initramfs root was +`rootfs`; no UFS write was attempted. This does not verify PR #505's expected +whole-disk-node removal, so this artifact must not be treated as that image or +booted again. SSH host-key verification succeeded, but the configured key was +not authorized. The separate rescue image still provides authenticated SSH +and `reboot-to bootloader` returned the phone to fastboot without writing UFS. `pm8941_pwrkey` and `pm8941_resin` registered. On the earlier final image, a physical Volume Down press produced `KEY_VOLUMEDOWN` (code 114, value 1), and @@ -65,9 +67,13 @@ Volume Up produced `KEY_VOLUMEUP` (code 115, value 1). The current kernel image's button events have not yet been rechecked. The owner reported seeing the console during the first boot. -The storage guard removed `/dev/sda`; its sysfs `ro` value remained `0` by -design. All 85 UFS partition `ro` values were `1`; the other UFS whole disks -were read-only. `/proc/iomem` reports `0x86200000–0x88efffff` as System RAM and +An earlier test record attributed removal of `/dev/sda` to the PR #505 image, +but the recorded image hash is the `e2cdb765…` artifact checked above, where +`/dev/sda` was present and writable. The earlier whole-disk-removal result +cannot be tied to a different retained image, so PR #505's disk-node check +needs a new run against its exact build before it is claimed. The `e2cdb765…` +boot did report all 85 UFS partition flags read-only; no UFS writes were made. +`/proc/iomem` reports `0x86200000–0x88efffff` as System RAM and `0x88f00000–0x890fffff` as reserved, so the TZ range is not reserved in this RAM boot's map. A separate EA8074 panel test used a RAM-only overlay on 2026-11-09 with kernel `7.3.0-rc6-omamobile-push1` and boot image SHA-256 From 453d9f49ae9e6adcc91b5515c3354f7d8b9c2cca Mon Sep 17 00:00:00 2001 From: quatrixone Date: Tue, 10 Nov 2026 03:51:26 +0100 Subject: [PATCH 19/21] docs(dipper): record final PR 505 device test --- device/dipper/NOTES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 5eab8ec2d..96e5204e4 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -97,6 +97,12 @@ The backup is stored outside the repository; it must not be published. This completes the data-capture condition, but a reviewed button-by-button restore procedure and supported single-slot writer are still required before a flash. +## 2026-11-10 — final PR #505 RAM image + +Booted image SHA-256 `0ee4f11d1973085c434e741a2e9dd73af5a9cd157296c25801ed5a92a6b9e9d9` with `fastboot boot`; it was built from PR #505 head `994944d7ecbacd69444221e6951153cb329a374e` and kernel/DTS PR #220 head `055a4019998f22cc0e2a8afef7650274a6ce0657` (touch PR #219 is merged). `uname -r` was `7.3.0-rc6-omamobile-push1`; `/` was the initramfs (`rootfs`). The guard reported the UFS devices read-only. Sysfs showed six disks: `sda` had `ro=0` but its whole-disk `/dev/sda` node was absent; `sdb`–`sdf` each had `ro=1` and present nodes. All 85 partitions had `ro=1`. This matches PR #505's intended missing-node case for `sda`; no UFS write was attempted. + +`qcom_wdt` loaded and `/usr/bin/watchdog -t 5 -T 30 /dev/watchdog0` was running. simpledrm registered `fb0`; USB gadget and authenticated SSH worked. `/proc/iomem` marked `0x85fc0000–0x8a8fffff` reserved, covering the former TZ range. The final image's physical button events were not captured, so the earlier Volume Down/Up observations are not evidence for this kernel. The image's `reboot-to bootloader` helper successfully returned the phone to fastboot; fastboot reported product `dipper` and unlocked `yes`. The only boot operation was `fastboot boot`; no UFS partition was written. + ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root - **SoC** SDM845. Live DT root: `model = "Xiaomi Technologies, Inc. Dipper new MP v2.1"`, From b1a05af478a5e27e8df31d84aacabc51a8dcb29b Mon Sep 17 00:00:00 2001 From: quatrixone Date: Tue, 10 Nov 2026 09:26:56 +0100 Subject: [PATCH 20/21] docs(dipper): record rebased NFS and RAM probes --- device/dipper/NOTES.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index 96e5204e4..d51481958 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -103,6 +103,30 @@ Booted image SHA-256 `0ee4f11d1973085c434e741a2e9dd73af5a9cd157296c25801ed5a92a6 `qcom_wdt` loaded and `/usr/bin/watchdog -t 5 -T 30 /dev/watchdog0` was running. simpledrm registered `fb0`; USB gadget and authenticated SSH worked. `/proc/iomem` marked `0x85fc0000–0x8a8fffff` reserved, covering the former TZ range. The final image's physical button events were not captured, so the earlier Volume Down/Up observations are not evidence for this kernel. The image's `reboot-to bootloader` helper successfully returned the phone to fastboot; fastboot reported product `dipper` and unlocked `yes`. The only boot operation was `fastboot boot`; no UFS partition was written. +## 2026-11-10 — rebased #503 and combined #505 RAM runs + +The rebased PR #503 init was RAM-booted with PR #505's Dipper builder and +kernel/DTS PR #220 at `055a4019998f22cc0e2a8afef7650274a6ce0657`. NFS image +SHA-256: `a2d435a7430e7e4c145c61cdb9866d16929731859d91c7105e6bfcaf9e3e9dd7`; +`uname -r` was `7.3.0-rc6-omamobile-push1`, and `/` was NFS. The initramfs +used BusyBox `mount`; the export was a generic Arch Linux ARM test root, not an +Omarchy rootfs. Direct sysfs reads returned `ro=1` for all six UFS disks and +all 85 partitions. The guard logged each read-back, including `/dev/sda` set +read-only for NFS. Systemd reached the multi-user target with +`RuntimeWatchdogUSec=1min`; SSH remained available. `reboot-to bootloader` +returned the phone to fastboot. No UFS write was attempted. The NFS link was +not deliberately dropped, so hard-mount link-loss recovery remains untested. + +The combined #503/#505 non-NFS RAM image was also booted. SHA-256: +`540b5d31ea73a31ade9a8d8cb5152cf701dc3c2ad8256734790b0ef2db6dbdd0`. +`uname -r` was `7.3.0-rc6-omamobile-push1`; `/` was the initramfs (`rootfs`). +Direct sysfs reads returned `ro=1` for all 85 partitions and disks `sdb`–`sdf`; +`sda` remained `ro=0`, while the guard removed `/dev/sda`. The `qcom_wdt` +module and feeder ran, simpledrm registered `fb0`, USB/SSH worked, and the +former TZ range was reserved in `/proc/iomem`. The rescue SSH host key matched +the build output, and `reboot-to` returned the phone to fastboot. No UFS write +was attempted. Physical input events were not captured on this exact image. + ## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root - **SoC** SDM845. Live DT root: `model = "Xiaomi Technologies, Inc. Dipper new MP v2.1"`, From b0c5132f0e75b61ca2c64aaa1b19ca34695ac539 Mon Sep 17 00:00:00 2001 From: quatrixone Date: Wed, 11 Nov 2026 08:59:53 +0100 Subject: [PATCH 21/21] device/dipper: reconcile RAM session notes --- device/dipper/NOTES.md | 169 +++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 66 deletions(-) diff --git a/device/dipper/NOTES.md b/device/dipper/NOTES.md index d51481958..3a0ec67dd 100644 --- a/device/dipper/NOTES.md +++ b/device/dipper/NOTES.md @@ -5,20 +5,77 @@ Facts only, each read off the phone. Captures remain outside the repository because they contain device identifiers and Wi-Fi keys; this file records only the facts needed for review. -## 2026-11-09 — recovery, old-kernel observation and RAM-only image +## RAM sessions (newest first) + +| Date | `boot.img` SHA-256 | Source, as recorded | `/dev/sda` and UFS partitions | Checks and gaps | +| --- | --- | --- | --- | --- | +| 2026-11-10 | `540b5d31ea73a31ade9a8d8cb5152cf701dc3c2ad8256734790b0ef2db6dbdd0` | Combined #503/#505; kernel/DTS #220 `055a4019998f22cc0e2a8afef7650274a6ce0657` | Node absent, disk `ro=0`; all 85 partitions `ro=1`; `sdb`–`sdf` `ro=1` | Watchdog/feeder, simpledrm, USB/SSH, reserved TZ range, pinned host key and `reboot-to bootloader` passed; physical keys not captured. | +| 2026-11-10 | `a2d435a7430e7e4c145c61cdb9866d16929731859d91c7105e6bfcaf9e3e9dd7` | Rebased #503 NFS image with #220 `055a4019998f22cc0e2a8afef7650274a6ce0657` | `/dev/sda` present, set `ro=1`; six disks and all 85 partitions read back `ro=1` | `uname`, NFS root, multi-user systemd, watchdog and SSH passed; generic Arch test root only; link-loss recovery and Omarchy desktop untested. | +| 2026-11-10 | `0ee4f11d1973085c434e741a2e9dd73af5a9cd157296c25801ed5a92a6b9e9d9` | #505 `994944d7ecbacd69444221e6951153cb329a374e`; kernel/DTS #220 `055a4019998f22cc0e2a8afef7650274a6ce0657` | Node absent, disk `ro=0`; all 85 partitions `ro=1`; `sdb`–`sdf` `ro=1` | Watchdog/feeder, framebuffer, USB/SSH, reserved TZ range and `reboot-to` passed; physical keys not captured. | +| 2026-11-10 | `e2cdb765de21a5869a1db314c19f1fddb668219a51d3c9ce81a1a083536d711e` | Older rescue image; exact source commit unknown; its init differs from the shared init | Node present, disk `ro=0`; all 85 partition flags recorded `ro=1`, including `sda21` | Kernel `7.3.0-rc6-omamobile-push1`, initramfs root; no `logdump` or whole-disk removal in init, so not the October diagnostic init. SSH host key verified but key was not authorized. No UFS write. | +| 2026-11-09 | `e2cdb765de21a5869a1db314c19f1fddb668219a51d3c9ce81a1a083536d711e` | Image was reported booted; exact build/init source unknown | `/dev/sda` reported present with `ro=0`; partition details for this session unknown | The retained 08:53 capture is a dirty-kernel writable-root observation; whether it came from this exact image is unknown. | +| 2026-11-09 | `0f0ec9d62ebe57bef9ae8a4804bb23728f624daab824a0bf7dee18f63c2a3d59` | `linux-omarchy-mobile` panel test tree with EA8074 from #218; exact combined revision unknown | `/dev/sda` absent; all 85 partitions `ro=1`; `sdb`–`sdf` present, `ro=1` | Panel/DRM, backlight 0→511, DPMS off/on passed; `vdda` used a dummy regulator, GPU rendering and touch untested. | +| 2026-11-09 | Same boot as panel test, `0f0ec9d6…` | Same as panel test | Same as panel test | Full backup of 84 non-`userdata`, non-`super` GPT partitions was read from this guarded boot and every source hash/size verified; separate userdata archive was file-level and non-atomic. | +| 2026-11-09 | Unknown; exact image hash not retained | Omarchy Mobile RAM kernel; exact build unknown | Disk and partition flags not recorded | Power-only 10-second restart passed from Android and RAM kernel; no UFS write was attempted. | +| 2026-11-09 | `2244d74aea472b0c595b2056ad8618f614e6a9161b5b264c7f898939e626f318` | Initial NFS-root image reused the earlier #505 kernel and DTB | `/dev/sda` present and set `ro=1`; all six disks and 85 partitions logged `ro=1` | NFS root and SSH worked; systemd reported `RuntimeWatchdogUSec=20s`. Direct `uname`/sysfs reads were not captured. | +| 2026-11-09 | `f2f5cb2e3da8fe992d366dba36e059c0d9106cf14a7d1c8872c61ee144a4474b` | Earlier #505 image after `qcom-pon` was built in; exact kernel/DTS heads unknown | `/dev/sda` absent, disk `ro=0`; all 85 partitions and other disks `ro=1` | PMIC keys registered and Volume Down produced `KEY_VOLUMEDOWN`; watchdog/feeder, framebuffer and USB/SSH worked. | +| 2026-11-09 | `93484a91103c294f6c73799ae6cb7161019129b9f89ab331222ae04f10ecf3e1` | First #505 image before `qcom-pon` was built in; exact kernel/DTS heads unknown | `/dev/sda` absent, disk `ro=0`; all 85 partitions and other disks `ro=1` | Console, framebuffer, USB/SSH and watchdog/feeder worked; no physical key event was captured. | + +The original 10-29 count of 92 `/dev/block/by-name/` entries was not saved as a +name list. The retained backup and kernel records cover 84 non-userdata GPT +partitions plus `userdata`; the other seven names cannot be identified from the +retained artifacts and remain unknown. + +## 2026-11-10 — final PR #505 RAM image + +Booted image SHA-256 `0ee4f11d1973085c434e741a2e9dd73af5a9cd157296c25801ed5a92a6b9e9d9` with `fastboot boot`; it was built from PR #505 head `994944d7ecbacd69444221e6951153cb329a374e` and kernel/DTS PR #220 head `055a4019998f22cc0e2a8afef7650274a6ce0657` (touch PR #219 is merged). `uname -r` was `7.3.0-rc6-omamobile-push1`; `/` was the initramfs (`rootfs`). The guard reported the UFS devices read-only. Sysfs showed six disks: `sda` had `ro=0` but its whole-disk `/dev/sda` node was absent; `sdb`–`sdf` each had `ro=1` and present nodes. All 85 partitions had `ro=1`. This matches PR #505's intended missing-node case for `sda`; no UFS write was attempted. + +`qcom_wdt` loaded and `/usr/bin/watchdog -t 5 -T 30 /dev/watchdog0` was running. simpledrm registered `fb0`; USB gadget and authenticated SSH worked. `/proc/iomem` marked `0x85fc0000–0x8a8fffff` reserved, covering the former TZ range. The final image's physical button events were not captured, so the earlier Volume Down/Up observations are not evidence for this kernel. The image's `reboot-to bootloader` helper successfully returned the phone to fastboot; fastboot reported product `dipper` and unlocked `yes`. The only boot operation was `fastboot boot`; no UFS partition was written. + + +## 2026-11-10 — rebased #503 and combined #505 RAM runs + +The rebased PR #503 init was RAM-booted with PR #505's Dipper builder and +kernel/DTS PR #220 at `055a4019998f22cc0e2a8afef7650274a6ce0657`. NFS image +SHA-256: `a2d435a7430e7e4c145c61cdb9866d16929731859d91c7105e6bfcaf9e3e9dd7`; +`uname -r` was `7.3.0-rc6-omamobile-push1`, and `/` was NFS. The initramfs +used BusyBox `mount`; the export was a generic Arch Linux ARM test root, not an +Omarchy rootfs. Direct sysfs reads returned `ro=1` for all six UFS disks and +all 85 partitions. The guard logged each read-back, including `/dev/sda` set +read-only for NFS. Systemd reached the multi-user target with +`RuntimeWatchdogUSec=1min`; SSH remained available. `reboot-to bootloader` +returned the phone to fastboot. No UFS write was attempted. The NFS link was +not deliberately dropped, so hard-mount link-loss recovery remains untested. + +The combined #503/#505 non-NFS RAM image was also booted. SHA-256: +`540b5d31ea73a31ade9a8d8cb5152cf701dc3c2ad8256734790b0ef2db6dbdd0`. +`uname -r` was `7.3.0-rc6-omamobile-push1`; `/` was the initramfs (`rootfs`). +Direct sysfs reads returned `ro=1` for all 85 partitions and disks `sdb`–`sdf`; +`sda` remained `ro=0`, while the guard removed `/dev/sda`. The `qcom_wdt` +module and feeder ran, simpledrm registered `fb0`, USB/SSH worked, and the +former TZ range was reserved in `/proc/iomem`. The rescue SSH host key matched +the build output, and `reboot-to` returned the phone to fastboot. No UFS write +was attempted. Physical input events were not captured on this exact image. + +## 2026-11-09/10 — recovery and historical RAM observations The current `recovery` partition matches the `recovery.img` in the -checksum-verified 15-partition stock snapshot captured on 2026-10-29 at 19:01; +checksum-verified 15-partition backup of the installed system captured on +2026-10-29 at 19:01; both have SHA-256 `7691a33e8b65d1ffcbf67b16fd4dc5c4c421420230f230db312512c73abc2221`. Its Android boot header contains a gzip-compressed kernel that identifies as `Linux version 4.9.337-perf-g0b3e38ef6c40`, not the 7.3 diagnostic kernel. This -confirms the current partition holds the stock recovery image. The order of the +confirms the current partition holds the installed ROM's recovery image. The order of the snapshot and the two diagnostic writes remains unknown. `logdump` is not in the 15-partition backup. A separate live, file-level userdata archive was verified off-device; it is not a raw partition image or an atomic snapshot, and the filesystem remained mounted during the copy. +The recovery image hash is recorded from the backup, but the backup's `boot.img` +was not present among the accessible artifacts for this review. Its kernel +string and whether it matches the recovery build remain unknown. + Before entering fastboot, the handset answered over USB SSH; no restart was needed to restore SSH. Holding Power alone for 10 seconds restarted the phone back into Android both from the installed system and under the Omarchy Mobile @@ -55,10 +112,13 @@ previously described here as PR #505's RAM image. On 2026-11-10, I booted that exact file again with `fastboot boot` and read it over the USB serial shell. It reported `7.3.0-rc6-omamobile-push1`, but `/dev/sda` existed with `/sys/block/sda/ro=0`; `/sys/block/sda/sda21/ro=1`. Its initramfs root was -`rootfs`; no UFS write was attempted. This does not verify PR #505's expected -whole-disk-node removal, so this artifact must not be treated as that image or -booted again. SSH host-key verification succeeded, but the configured key was -not authorized. The separate rescue image still provides authenticated SSH +`rootfs`; no UFS write was attempted. Offline extraction found init SHA-256 +`ab6db476f5cd26cb84a8346e18da5b2137530091be504c47a23b0a21934277c5`, different +from the checked-in shared init. It contains neither the October `logdump` +mirror nor whole-disk-node removal, so it is not the October diagnostic init +and does not verify PR #505's guard. Do not treat it as #505's image or boot it +again. SSH host-key verification succeeded, but the configured key was not +authorized. The separate rescue image still provides authenticated SSH and `reboot-to bootloader` returned the phone to fastboot without writing UFS. `pm8941_pwrkey` and `pm8941_resin` registered. On the earlier final image, a @@ -70,9 +130,9 @@ the console during the first boot. An earlier test record attributed removal of `/dev/sda` to the PR #505 image, but the recorded image hash is the `e2cdb765…` artifact checked above, where `/dev/sda` was present and writable. The earlier whole-disk-removal result -cannot be tied to a different retained image, so PR #505's disk-node check -needs a new run against its exact build before it is claimed. The `e2cdb765…` -boot did report all 85 UFS partition flags read-only; no UFS writes were made. +cannot be tied to this artifact. The final #505 image and its successful +disk-node check are recorded below. The `e2cdb765…` boot did report all 85 UFS +partition flags read-only; no UFS writes were made. `/proc/iomem` reports `0x86200000–0x88efffff` as System RAM and `0x88f00000–0x890fffff` as reserved, so the TZ range is not reserved in this RAM boot's map. A separate EA8074 panel test used a RAM-only overlay on @@ -87,53 +147,26 @@ DRM `dpms` from `On` to `Off` and back to `On`. The FTS5 touch input still needs a test on the current kernel. The panel log included a missing DSI `vdda` supply (dummy regulator) and missing `a630_sqe.fw`; the display initialized, but GPU rendering was not tested. The RAM image had no Arch root, and the probe -did not write UFS. The stock partition checksums were verified before boot. +did not write UFS. The installed-system backup checksums were verified before +boot. After this session, a read-only backup of all 84 non-`userdata`, non-`super` GPT partitions was captured from this guarded RAM boot. Each partition's source SHA-256 and byte count were checked against the decompressed local copy, and the compressed archive checksums were rechecked. The separate live userdata archive remains file-level, non-atomic, and is not a raw partition backup. -The backup is stored outside the repository; it must not be published. This -completes the data-capture condition, but a reviewed button-by-button restore +The backup is stored outside the repository; it must not be published. After +the last Android boot and before any future flash, the on-device partition +checksums must be taken again and compared with the off-device backup because +Android can rewrite modem partitions. A reviewed button-by-button restore procedure and supported single-slot writer are still required before a flash. -## 2026-11-10 — final PR #505 RAM image - -Booted image SHA-256 `0ee4f11d1973085c434e741a2e9dd73af5a9cd157296c25801ed5a92a6b9e9d9` with `fastboot boot`; it was built from PR #505 head `994944d7ecbacd69444221e6951153cb329a374e` and kernel/DTS PR #220 head `055a4019998f22cc0e2a8afef7650274a6ce0657` (touch PR #219 is merged). `uname -r` was `7.3.0-rc6-omamobile-push1`; `/` was the initramfs (`rootfs`). The guard reported the UFS devices read-only. Sysfs showed six disks: `sda` had `ro=0` but its whole-disk `/dev/sda` node was absent; `sdb`–`sdf` each had `ro=1` and present nodes. All 85 partitions had `ro=1`. This matches PR #505's intended missing-node case for `sda`; no UFS write was attempted. - -`qcom_wdt` loaded and `/usr/bin/watchdog -t 5 -T 30 /dev/watchdog0` was running. simpledrm registered `fb0`; USB gadget and authenticated SSH worked. `/proc/iomem` marked `0x85fc0000–0x8a8fffff` reserved, covering the former TZ range. The final image's physical button events were not captured, so the earlier Volume Down/Up observations are not evidence for this kernel. The image's `reboot-to bootloader` helper successfully returned the phone to fastboot; fastboot reported product `dipper` and unlocked `yes`. The only boot operation was `fastboot boot`; no UFS partition was written. - -## 2026-11-10 — rebased #503 and combined #505 RAM runs - -The rebased PR #503 init was RAM-booted with PR #505's Dipper builder and -kernel/DTS PR #220 at `055a4019998f22cc0e2a8afef7650274a6ce0657`. NFS image -SHA-256: `a2d435a7430e7e4c145c61cdb9866d16929731859d91c7105e6bfcaf9e3e9dd7`; -`uname -r` was `7.3.0-rc6-omamobile-push1`, and `/` was NFS. The initramfs -used BusyBox `mount`; the export was a generic Arch Linux ARM test root, not an -Omarchy rootfs. Direct sysfs reads returned `ro=1` for all six UFS disks and -all 85 partitions. The guard logged each read-back, including `/dev/sda` set -read-only for NFS. Systemd reached the multi-user target with -`RuntimeWatchdogUSec=1min`; SSH remained available. `reboot-to bootloader` -returned the phone to fastboot. No UFS write was attempted. The NFS link was -not deliberately dropped, so hard-mount link-loss recovery remains untested. - -The combined #503/#505 non-NFS RAM image was also booted. SHA-256: -`540b5d31ea73a31ade9a8d8cb5152cf701dc3c2ad8256734790b0ef2db6dbdd0`. -`uname -r` was `7.3.0-rc6-omamobile-push1`; `/` was the initramfs (`rootfs`). -Direct sysfs reads returned `ro=1` for all 85 partitions and disks `sdb`–`sdf`; -`sda` remained `ro=0`, while the guard removed `/dev/sda`. The `qcom_wdt` -module and feeder ran, simpledrm registered `fb0`, USB/SSH worked, and the -former TZ range was reserved in `/proc/iomem`. The rescue SSH host key matched -the build output, and `reboot-to` returned the phone to fastboot. No UFS write -was attempted. Physical input events were not captured on this exact image. - -## 2026-10-29 — stock facts, read-only over SSH with the owner's Magisk root +## 2026-10-29 — installed-system facts, read-only over SSH with the owner's Magisk root - **SoC** SDM845. Live DT root: `model = "Xiaomi Technologies, Inc. Dipper new MP v2.1"`, `compatible = "qcom,sdm845-mtp", "qcom,sdm845", "qcom,mtp"`, `qcom,msm-id = <0x141 0x20001>`, `qcom,board-id = <0x37 0x00>`. 6 GB RAM. `androidboot.cert=M1803E1A` (Mi 8 Global), `hwversion=3.13.0`. -- **Stock on the phone now** is a custom Android 14 (SDK 34) ROM with Magisk 30.7, not MIUI; +- **The installed system** is a custom Android 14 (SDK 34) ROM with Magisk 30.7, not MIUI; its build fingerprint is a spoofed MIUI 8.1 string, and `ro.boot.verifiedbootstate=green` with `flash.locked=1` contradict the owner's unlocked bootloader. **No boot-state claim may be made from Android on this phone; read it in fastboot.** Running kernel 4.9.337. @@ -142,11 +175,10 @@ was attempted. Physical input events were not captured on this exact image. (113 GiB). Only the bootloader chain is slotted: `xbl`, `xbl_config`, `abl`, `tz`, `hyp`, `aop`, `cmnlib`, `cmnlib64`, `devcfg`, `keymaster`, `qupfw`, `storsec`. **There is therefore no known-good OS slot to fall back to**, which the shared Pixel - safety model assumes. A full stock backup is a precondition, not a nicety. -- **Boot image** is Android header v1, page size 4096, `second_size = 0`, and the kernel + safety model assumes. A full backup of the installed system is a precondition, not a nicety. +- **Boot image** uses Android header v1, page size 4096, `second_size = 0`, and the kernel blob ends with **two concatenated FDTs of ~480 KB each** (`d00dfeed`, version 17): the - base DTB is appended to the kernel and ABL selects one by msm-id/board-id. Hence - `BOOT_METHOD=android-v1-appended-dtb`. + base DTB is appended to the kernel and ABL selects one by msm-id/board-id. - **Display** Samsung **EA8074**, 1080x2248, command mode, 60 Hz, notch; physical 68 x 142 mm. Confirmed twice: `msm_drm.dsi_display0=dsi_ss_ea8074_notch_fhd_cmd_display` on the kernel command line, and the live DT node `qcom,mdss_dsi_ss_notch_fhd_ea8074_cmd` @@ -163,7 +195,8 @@ was attempted. Physical input events were not captured on this exact image. - **Audio** `sdm845-tavil-snd-card` (WCD9340). **Fingerprint** Goodix, capacitive (`fingerprint_goodix`, `uinput-goodix`); no mainline driver, out of scope. **Buttons** `qpnp_pon` plus `gpio-keys`. -- **UFS** host at `1d84000.ufshc`. Stock `system` is dm-verity over the `system` partition. +- **UFS** host at `1d84000.ufshc`. The installed Android `system` is dm-verity over the + `system` partition. ## 2026-10-29 — first light, and what the hardware said @@ -182,16 +215,19 @@ diagnostic boot. The 2026-11-09 read-only check was on this dirty October kernel; it found `/dev/sda21` as the read-write root and therefore `/dev/sda` present and writable. The saved record does not establish whether the mirror process was still running during that later check, nor the device uptime then. -Two diagnostic-image writes to stock `recovery` from rooted Android were also +Two diagnostic-image writes to the `recovery` partition from rooted Android were also made on 2026-10-29. The existing 15-partition backup did not include `logdump`; an unverified `logdump.img` file is not evidence of a checked phone backup. -The current recovery SHA matches the verified 2026-10-29 19:01 snapshot -described above; the order of that snapshot and the two writes is unknown. The -2026-11-09 PR #505 RAM boot checked every UFS partition flag on the phone; it -did not mount or write UFS. The mount options and whether `persist` was mounted -during first light are not recorded here. +The current recovery SHA matches the verified 2026-10-29 19:01 backup +described above; the order of that backup and the two writes is unknown. The +image previously attributed to PR #505 was `e2cdb765…`; its `/dev/sda` node was +present and writable, so it does not verify #505's guard. The final #505 image +and its successful check are recorded above. The mount options and whether +`persist` was mounted during first light are not recorded here. + +The recorded 15-partition backup of the installed system before the radio runs +was checksum-verified. -The recorded 15-partition snapshot before the radio runs was checksum-verified. The 2026-10-30 comparison found `boot`, `recovery`, `dtbo`, `vbmeta`, `fsc`, `devinfo`, `misc`, `logo`, `splash`, `persistbak`, `modemst2` and `fsg` byte-identical; only `persist`, `modemst1` and `frp` changed. @@ -199,11 +235,11 @@ All five NV partitions were read-only before and after the recorded runs. The cause of the three differences is not established. Other recorded activity: NFS-root Omarchy sessions on 2026-10-30, 2026-10-31 and 2026-11-02; modem starts under `rmtfs -r`, followed by an XPU violation crash and remoteproc -recovery loops. The sequence of boots between the two snapshots (date, stock +recovery loops. The sequence of boots between the two backups (date, installed Android or RAM image, and actions) has not been reconstructed, so the later -snapshot is not a baseline and the changes are not attributed to Android or -Omarchy. The current recovery image matches the 10-29 19:01 snapshot and its -kernel identifies as stock `4.9.337-perf-g0b3e38ef6c40`; the snapshot's order +backup is not a baseline and the changes are not attributed to Android or +Omarchy. The installed ROM's current recovery image matches the 10-29 19:01 +backup and its kernel identifies as `4.9.337-perf-g0b3e38ef6c40`; the backup's order relative to the two diagnostic writes remains unknown. The 10-29 first-light boot is recorded as `fastboot boot` from RAM, not a recovery boot. The separate 08:53 old-kernel observation's launch method remains unknown; the surviving @@ -214,16 +250,17 @@ Six defects in the recovered [sdm845-mainline MR !71](https://gitlab.com/sdm845- work, three of them fatal: 1. **`qcom,board-id = <69 0>` (0x45) is polaris's.** dipper reports `0x37`. ABL matches on - it and silently refuses the whole boot image otherwise — no kernel output, no panic, - just a reboot. Two blind diagnostic-image attempts were written to stock `recovery` - from rooted Android before this mismatch was corrected. + it and silently refuses the whole boot image otherwise — no kernel output, + no panic, just a reboot. Two blind diagnostic-image attempts were written to + the `recovery` partition from rooted Android before this mismatch was + corrected. 2. `drm_panel_init()` no longer exists; the panel probe needed the refcounted `devm_drm_panel_alloc()`. 3. `panel-samsung-ea8074.ko` had no `MODULE_LICENSE()`, so modpost refused to link. 4. The touch node named `focaltech,ea8074` at `0x38`; the chip is ST at `0x49`. 5. Its Kconfig entry was copied from an SPI panel (`depends on SPI`, `select DRM_MIPI_DBI`) for what is a `mipi_dsi_driver`. -6. `ts_int_default` carried `bias-pull-down` from beryllium; dipper's own stock tree says +6. `ts_int_default` carried `bias-pull-down` from beryllium; dipper's vendor tree says `ts_active { pins = "gpio31", "gpio32"; drive-strength = <16>; bias-pull-up; }`. ### And two kernel-config lessons, both found on the hardware @@ -245,7 +282,7 @@ kernel revision; they are not results from the current FTS5 driver: one user each. - `stmfts` binds and fails with **`-110`** from `wait_for_completion_timeout` — it sends its first command and never sees the reply interrupt. -- The interrupt pin bias was corrected to pull-up per the stock tree. **No change.** +- The interrupt pin bias was corrected to pull-up per the vendor tree. **No change.** - `i2cdetect` output is incoherent: in `-r` mode every even address reads as present and every register as `0x00`; in quick-write mode `0x49` is not detected at all, while `stmfts`'s own `i2c_smbus_write_byte` to `0x49` returns success.