diff --git a/AGENTS.md b/AGENTS.md index 4b065f2c8..915cdb18f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -101,6 +101,7 @@ tools/phone-ssh CMD -> run anything; stream files with ssh 'cat > f' < f | `tools/install-phone` | The installer: fastboot checks, the owner's answers into a local image copy, then only slot B's images and `userdata`. Asks the human to type the codename; `--dry-run` first. Never run it without the human's go | | `tools/phone-provision` | After a fresh install: Google's files from the user's factory image and the phone's own data from the backup. `--fingerprint` copies Trusty's state but never starts the service | | `tools/build-packages`, `tools/repo-push` | Maintainer only: the signed `[omamobile]` repository, built on the laptop with no phone (needs `keys/`, never committed); the release key's layout is in [RELEASES](docs/RELEASES.md) §10 (`tools/release-key-init`, run once); `tools/repo-publish` publishes to `pkgs.omamobile.org` (development daily from `origin/main`, stable on the maintainer's go). `tools/repo-build` builds on a connected phone instead: an opt-in shortcut for Mesa, Hyprland and libcamera, never a requirement | +| `tools/local-key-init`, `tools/fetch-published`, `--local` | A contributor's port: its own packages signed with a local key in `keys//`, the project's published packages fetched with their signatures checked, everything under `out//` (RELEASES §10, review lesson L-7). Never the maintainer's `keys/` or `out/repo` | | `tools/publish-kernel` | Maintainer only: publish `omamobile` to GitHub on a squashed upstream base | Logs from these tools land in `logs/` (gitignored). Quote the relevant lines in the plan, not whole logs, and check them for identifiers first. diff --git a/device/panther/BRINGUP-M1.md b/device/panther/BRINGUP-M1.md new file mode 100644 index 000000000..e10f94bc4 --- /dev/null +++ b/device/panther/BRINGUP-M1.md @@ -0,0 +1,295 @@ + +# Pixel 7 (panther) first light + +Status (2026-10-27): slot B boots the Arch root on `userdata` into +Hyprland and the Omarchy lock screen, on simpledrm over the bootloader's +framebuffer. SSH answers at `172.16.42.1`, and `bin/omamobile push` +rewrites slot B and reboots into it with no fastboot. The power and +volume keys work (the power key wakes the screen); there is no touch yet: +the FocalTech FT3658 on SPI0 has no mainline driver. Kernel 7.3.0-rc6, +local branch `panther-first-light` on `omamobile-int`; the board file is in +review against `omamobile` as +[linux-omarchy-mobile#108](https://github.com/derekross/linux-omarchy-mobile/pull/108). Stock Android is on slot A, with its +`userdata` erased. + +## What booted + +The board file enables the USB PHY and dwc3 (gadget networking and the +ACM console), a ramoops region at stock's address, and a +`simple-framebuffer` on the bootloader's splash at `0xfac00000`. The SoC +tree stops both cluster watchdogs. Everything else stays undescribed or +disabled: panel, touch, GPU, UFS, PMICs, buses. The descriptor's +`SIMPLEFB_TRIG_CON` is the only display-register write; there is no +`BRINGUP_PROBE`. Steps 1-3 below were the first boot, with no framebuffer +node and no trigger. + +## Runbook + +Each step: commands, Expect/Pass, Stop, Rollback, risk. + +1. **Check the images (laptop, read-only).** + `DEVICE=panther bin/omamobile images`, then unpack `vendor_kernel_boot.img` + and `dtbo.img` and decompile: two DTBs with `soc_id` 0x9855001 and + 0x9855000, compatible `google,gs201-panther`, and one dtbo entry with + board id 0x30406, rev 0x10000. + Stop: any other board id, or a cheetah compatible. Risk: none. + +2. **Flash slot B and boot (phone in fastboot).** + `DEVICE=panther bin/omamobile flash` writes `boot_b`, `init_boot_b`, + `vendor_boot_b`, `vendor_kernel_boot_b` and `dtbo_b`, sets slot B + active and reboots. + Expect: the unlocked-bootloader warning, then the bootloader logo stays + on the panel; within about a minute the laptop sees a "Pixel 7 (M1)" USB + device and `tools/phone-ssh uname -r` answers at 172.16.42.1. + Stop: no USB device after 3 minutes. Rollback: slot B is not marked + successful, so after the bootloader's retries the phone falls back to + slot A by itself; otherwise hold Volume Down + Power about 20 s for + fastboot and `fastboot --set-active=a`. Slot A is stock, and with Arch + on `userdata` it boots to recovery: decline the data reset, go back to + fastboot, and take a fresh read-only backup of `persist`, `efs`, + `efs_backup`, `modem_userdata`, the modems and `devinfo` from the next + Linux boot (NOTES.md, 2026-10-27). Risk: low (slot B only). + +3. **Read the scanout address and the trigger (read-only, over SSH).** + One register per call; DECON0 and DPP0 are powered because the logo is + being scanned out. + `tools/phone-ssh devmem 0x1c0b0040` (DPP0 `RDMA_BASEADDR_Y8`), then + `tools/phone-ssh devmem 0x1c240030` (DECON0 `TRIG_CON`). `devmem ADDR` + only, never a second argument: that is a write. + Expect: a DRAM address for the splash carve-out, and the trigger mask + ABL left. Stop: the session dies (an unpowered block). Risk: low. + +4. **Next boot (one change):** a `simple-framebuffer` node and `no-map` + carve-out at the address read in step 3, sized 1080 x 2400 x 4; then + `SIMPLEFB_TRIG_CON` once the step 3 value is understood. + +5. **Boot 4: UFS behind the guard (one change).** `&ufs_0`, `&ufs_0_phy` + and the always-on UFS VCC (gpp0-1, boot-on, from Google's + `gs201-ufs.dtsi`, not overridden for panther), plus + `omamobile.ufs-probe` and `omamobile.initramfs` on the command line so + the init never mounts stock's `userdata`. Fastboot by the buttons, then + `DEVICE=panther bin/omamobile flash`. + Expect: the `ufs-probe` report in `dmesg`; every partition `set + read-only` except the five `_b` boot images and `userdata` (`left + writable (allowlist)`), `/dev/sda` removed, nothing `FAILED`; the + partition numbers match stock's `/dev/block/by-name` (`userdata` sda31, + `devinfo` sdd1, `efs` sda5, `persist` sda1). + Stop: any `FAILED` or `WARNING ... NOT read-only` line; a UFS error + storm. Rollback: boot 3's images to slot B, or slot A. Risk: low (the + guard runs before any partition node is used; nothing writes). + +6. **The Arch root on `userdata` (laptop, then the installer).** + A contributor's local build (docs/RELEASES.md §10): `tools/local-key-init + panther`, `tools/fetch-published out/panther/published`, `tools/build-packages + --local panther --import out/panther/published` with the panther package + and the tree's newer `omamobile-omarchy`, `omamobile-shell` and + `omamobile-firstboot`, then `KERNEL_OUT=~/android/mainline/out + tools/build-rootfs --local panther`. The boot images drop + `omamobile.initramfs`, so the init hands over to Arch. Then, phone in + fastboot, run by the owner (it asks for the user, password and SSH key): + `tools/install-phone --device panther --images ~/android/mainline/out/images + --rootfs out/panther/omamobile-rootfs--aarch64.img.zst --dry-run`, + and without `--dry-run` after reading every command. + Expect: the initramfs grows the root to the partition, `arch: switching + to Arch Linux on /dev/sda31`, `omamobile-firstboot` creates the user, + SSH as root and as the user. Stop: the init stays in the initramfs + (`arch:` line says why). Rollback: boot 4's images keep the initramfs + (`omamobile.initramfs`); slot A is stock, but its `userdata` is now + erased (factory reset needed to boot it). Risk: medium (erases + `userdata`; no other partition is written). + +## Results + +### 2026-10-26: first light (steps 1-3) + +Kernel `7.3.0-rc6-omamobile-push1-g1cb4bd36f3be-dirty` (`omamobile-int` +plus the local `gs201-panther.dts`), slot B, not marked successful. + +- **Step 1 passed.** Two DTBs, `soc_id` 0x9855001 and 0x9855000, compatible + `google,gs201-panther`; one dtbo entry, id 0x30406, rev 0x10000; the + initramfs allowlist is slot B's five images and `userdata`. Only the USB + PHY and dwc3 are `okay`; UFS is disabled. +- **Step 2 passed.** `bin/omamobile flash` wrote the five `_b` images and + SSH answered 7.5 s into the boot. The host saw `1d6b:0104` and gave + `172.16.42.2/24` to the `cdc_ncm` link. Both cluster watchdogs report + inactive. ramoops registered at `0xfd3ff000`. No oops or driver error. + The init logs `arch: no userdata partition`, as expected with UFS off. + The panel kept the bootloader logo. +- **Step 3 passed.** DPP0 `RDMA_BASEADDR_Y8` (`0x1c0b0040`) reads + `0xfac00000`, the address the Pixel 7 Pro's ABL also uses. DECON0 + `TRIG_CON` (`0x1c240030`) reads `0x3070`, the hardware trigger masked, + the value felix's ABL leaves on DECON1. The session stayed up after both. +- **Scanout geometry.** DPP0 `RDMA_SRC_SIZE` (`0x1c0b0010`) reads + `0x09600438`, 1080 x 2400 with no stride padding, and `RDMA_IN_CTRL_0` + (`0x1c0b0008`) reads `0xff400000`: image format 0, ARGB8888 + (`gs-decon.c`). The framebuffer node uses those values. +- **`reboot-to bootloader` did not reach fastboot** (NOTES.md); fastboot + was reached by the buttons for the next flash. + +### 2026-10-26: boot 2, the bootloader's framebuffer + +Same kernel, DTB with `framebuffer@fac00000` and a `no-map` carve-out of +1080 x 2400 x 4 bytes. Flashed through fastboot; SSH 7.6 s into the boot. + +- The kernel reserved `0xfac00000..0xfb5e33ff` (10125 KiB) `nomap`. +- `simpledrm` bound `chosen:framebuffer@fac00000` as minor 0: `/dev/dri/card0` + and `/dev/fb0`, virtual size 1080,2400, stride 4320. No oops or driver + error. +- The panel kept the bootloader logo, as expected with DECON0's hardware + trigger still masked. + +- **Trigger, by hand.** Over SSH, DECON0 `TRIG_CON` (`0x1c240030`) read + `0x3070`, was written once with `0x3061` (unmask, `HW_TRIG_EN`) and read + back `0x3061`. The panel switched from the bootloader logo to the Linux + console; the session stayed up. Boot 3 moves that write into the init + (`SIMPLEFB_TRIG_CON`). + +### 2026-10-26: boot 3, the trigger in the init + +Same kernel and DTB as boot 2; the descriptor sets `SIMPLEFB_TRIG_CON` +(`0x1c240030 0x3061`). Fastboot by the buttons; SSH 4.5 s into the boot. + +- DECON0 `TRIG_CON` read `0x3061` with nothing written over SSH, and the + init logged no `simplefb trigger failed`. +- simpledrm bound the framebuffer as in boot 2. No oops or driver error. +- The panel showed the Linux console after the bootloader logo, with no + SSH step. + +### 2026-10-26: boot 4, UFS behind the guard + +Same kernel; DTB with `&ufs_0`, `&ufs_0_phy`, the UFS VCC and +`omamobile.ufs-probe omamobile.initramfs`. Fastboot by the buttons; SSH +7.6 s into the boot. + +- **Guard passed.** 4 disks (sda 119 GiB, sdb, sdc, sdd) and 55 + partitions. `/dev/sda` removed; every partition `set read-only` except + `boot_b`, `init_boot_b`, `vendor_boot_b`, `vendor_kernel_boot_b`, + `dtbo_b` (sda20-24) and `userdata` (sda31), the only six with `ro=0`. + No `FAILED` or `NOT read-only` line, and no UFS error, abort or reset in + `dmesg`. +- **Map matches stock.** All 55 names and numbers equal stock's + `/dev/block/by-name` (stock's four extra entries are the whole-disk + aliases). `persist` sda1, `efs` sda5, `efs_backup` sda6, + `modem_userdata` sda7, `modem_a` sda19, `modem_b` sda29, `devinfo` sdd1. +- The init stayed in the initramfs (`omamobile.initramfs`); `userdata` was + not mounted or checked. + +- **Seen, not acted on.** `cma: Failed to reserve 384 MiB`: this phone has + 7.3 GiB of `MemTotal` against cheetah's 11.2 GiB. The `debug@fd3f0000` + overlap with `debug_kinfo_reserved` comes from gs201.dtsi. + +### 2026-10-27: the Arch root (step 6) + +Local build (contributor key, `out/panther`), boot 4's DTB without +`omamobile.initramfs`. `tools/install-phone` (the owner, phone in fastboot +by the buttons) wrote the five `_b` images and `userdata`, set slot B +active and rebooted. + +- The installer only sees the current slot's bootloader; slot A's + (`cloudripper-17.0-15902555`, the stock capture with `current-slot:a`) + was confirmed with `--bootloader-slots-match`. +- **Handover passed.** `arch: switching to Arch Linux on /dev/sda31`, root + ext4 grown to 109 GiB; `omamobile-firstboot` exited 0 and made the user + (`wheel`, `video`, `input`, `audio`); SSH as root and as the user. + Hyprland, omarchy-shell and the on-screen keyboard started, and the + session locked as designed. +- **The guard holds in Arch.** Only sda20-24 and sda31 have `ro=0`; + `/dev/sda` is gone, `devinfo` (sdd1) is read-only. +- **The screen went dark** 60 s after the lock: the idle cycle set DPMS + off, and `/proc/bus/input/devices` is empty, so nothing can wake it. + `hyprctl dispatch 'hl.dsp.dpms({ action = "enable" })'` over SSH brought + the lock screen back, and `omarchy-toggle-idle stay-awake` (as the user) + keeps it on until there is an input device. +- `systemd-firstboot.service` failed on the first boot (`status=208/STDIN`, + no console), leaving the system `degraded`; omamobile-firstboot had done + the setup. It does not run again: the next boot was `running`. +- No RTC and no network route, so the clock is wrong (the image's date) + and unsynchronised. + +### 2026-10-27: the push loop + +`DEVICE=panther bin/omamobile push` with the same images: the module +tarball's checksum already matched, the five `_b` images were written and +read back equal, and `reboot-to omamobile` rebooted into slot B. SSH +answered with a new boot id 5.5 s into the boot; the system came up +`running`, with Hyprland and stay awake. The development loop no longer +needs fastboot or the buttons, as long as the new kernel reaches SSH. + +### 2026-10-27: boot 5, the keys + +One change, through `bin/omamobile push`: a `gpio-keys` node with cheetah's +pins, which Google's `gs201-common.dtsi` gives every gs201 board (power +`gpa10-0`, PMIC_PWRON_OD_L; volume down `gpa10-1`; volume up `gpa8-5`). +Same kernel image; SSH 5.5 s into the boot. + +- `input: gpio-keys as /devices/platform/gpio-keys/input/input0`, and + logind watches `event0`. No pinctrl error. +- Read from `event0` over SSH while the owner pressed: `KEY_VOLUMEUP` (115) + and `KEY_VOLUMEDOWN` (114), each a press and a release. +- Power: logind logged `Power key pressed short` (and ignores it, as the + device package configures); a press turned the screen off (DPMS 0) and + the next one woke it (DPMS 1). The screen can now be woken without SSH. +- A buffered `od` under `timeout` loses its output: capture with + `timeout N cat /dev/input/eventX > file`, then decode the file. + +### 2026-10-27: boot 6 lost to the slot B retry budget, not to the driver + +Boot 6 (the FT3658 driver built in, SPI0 and the touch node) was pushed +and never answered SSH; ABL fell back to slot A, whose stock Android went +to recovery (`reboot,recovery`: its `userdata` is now Arch). pstore was +empty there. The data reset was declined, and a fresh backup was taken +afterwards (NOTES.md, 2026-10-27). + +- `devinfo` slot bytes (0x30-0x37 and the version only, read-only from + boot 7): version **3.19** (cheetah's verified layout is 3.15); slot A + retry 2, successful; slot B retry **2**, active, not successful, one + boot after `fastboot --set-active=b`. +- So `--set-active` gives slot B three boots, and with nothing marking it + successful every boot spends one: the install's boot, the push-loop + test and boot 5 used them, and boot 6 found none left. Panther has no + `omamobile-boot-success` (it writes `devinfo`, L-36), so until the + layout is checked on 3.19 every reboot counts: `bin/omamobile flash` + (it sets slot B active) restores the budget, `push` does not. +- Boot 7 (fastboot, `--set-active=b`): boot 6's DTB with the driver as a + module and `modprobe.blacklist=focaltech_ft3658`. It booted; SPI0 probed + (`spi0.0`, `spi:ft3658`). `modprobe focaltech_ft3658` by hand did not + crash: the chip ID read failed (`-EBADMSG`, ID 0x00), the probe gave + up cleanly. +- Pins, read-only: `gpp23-2` (reset) output high, out of reset; + `gpa7-0` (interrupt) EINT, no pull, low. +- The FT3658 never drives MISO: a debug build of the module (raw response + dump; loaded with `insmod`, no reboot) read `00` in every byte of every + chip-ID read, in SPI mode 0 and 3, at 10 and 1 MHz. SPI0 itself is + cheetah's configuration, which works with its S3908. +- Two suspects, neither visible from user space yet: + - **The AP/AoC SPI select, `gph1-0`** ("Low: AP, High: AOC", Google's + `gs201-common-touch.dtsi`). Stock asks for the bus through TBN before + every touch reset (`tbn: AP request bus ... SUCCESS!`). `gph1` is on + the HSI1 pin controller, which is disabled in `gs201.dtsi` (no CMU_HSI1 + driver) on both phones, so its level here is unknown. AOC2AP + (`gpa8-7`, far-alive) reads 0. + - **The supplies**, S2MPG12 LDO25M (1.8 V) and LDO26M (3.3 V): no PMIC + regulator driver; cheetah's touch relies on ABL leaving them on. +- PMU registers are not read from user space (cheetah's + RADIOS-CAMERA-PLAN.md: one `/dev/mem` read in the G3D range reset the + phone). + +### 2026-10-27: boot 8, the HSI1 pin controller + +One change, through `push` (slot B's last-but-one retry): `&pinctrl_hsi1` +enabled, as cheetah's MODEM-PLAN M0.4. It registered (`gph0`, `gph1`) and +changed no pin. + +- **The bus select is on the AP side.** `gph1-0`: input, DAT 0, pull-down, + as on cheetah. Not the cause. +- SPI0 pins in their functions: `gpp20-0/1/2` function 3, `gpp20-3` (CS) + output high. +- **ABL hands over the touch held in reset:** before any driver runs, + `gpp23-2` is an output driven low. +- A debug module with a 10 ms reset pulse and up to 3.8 s of chip-ID reads + still saw only zeros. With the driver, the timing, the SPI mode and + speed, the controller and the bus select ruled out, the supplies are + left: LDO25M (1.8 V) and LDO26M (3.3 V) of the S2MPG12, which on this + phone ABL most likely leaves off. Reading or switching them needs the + S2MPG12 over ACPM: the core (`CONFIG_MFD_SEC_ACPM`) reads the PMIC but + has no regulator cell yet (cheetah's SUSPEND-PLAN.md). diff --git a/device/panther/NOTES.md b/device/panther/NOTES.md new file mode 100644 index 000000000..5c5377bd8 --- /dev/null +++ b/device/panther/NOTES.md @@ -0,0 +1,44 @@ + +# Pixel 7 (panther) bring-up notes + +Findings from real hardware, newest first. [BRINGUP-M1.md](BRINGUP-M1.md) is the first-light record. + +The board file (`gs201-panther.dts`) is in review as [linux-omarchy-mobile#108](https://github.com/derekross/linux-omarchy-mobile/pull/108); this repository's images were built from the local branch it came from. + +## 2026-10-27: boot 6's fallback was a stock boot, and a new backup + +When slot B ran out of retries (boot 6, [BRINGUP-M1.md](BRINGUP-M1.md)), ABL booted stock Android on slot A, which went to recovery because its `userdata` is now Arch. The data reset that recovery offers was **declined**: the phone was taken to fastboot with `adb reboot bootloader` and slot B flashed again. + +- **Stock recovery wrote to the protected partitions.** Read back over SSH from Linux (read-only, each checked `ro=1` and by `PARTNAME`) and compared against the 2026-10-26 baseline: `modem_a` and `modem_b` match; `efs`, `efs_backup` and `modem_userdata` differ only in their F2FS checkpoint areas, `persist` in its ext4 superblock and journal (it now reads "needs journal recovery"), and `devinfo` in slot B's retry byte and two flag bytes. That is what a mount by recovery leaves, with no sign of data rewritten. +- **New backup.** All seven were read again and checksum-matched; that copy, kept off the repository with its `SHA256SUMS`, is the baseline from 2026-10-27. Any later stock boot, a fallback included, means another one. + +## 2026-10-26: UFS behind the guard, and a fresh backup + +- **UFS enumerates** (4 LUNs, 55 partitions, the same names and numbers as stock) and the initramfs guard leaves only slot B's five boot images and `userdata` writable. Details: [BRINGUP-M1.md](BRINGUP-M1.md), boot 4. +- **Fresh read-only backup.** `persist`, `efs`, `efs_backup`, `modem_userdata`, `modem_a`, `modem_b` and `devinfo` were read over SSH from the guarded initramfs (each checked `ro=1` and by `PARTNAME` first) and checksum-matched against the phone; the copy and its `SHA256SUMS` stay off the repository. All seven differ from the copy taken under LineageOS that morning, as expected: the factory image rewrote `modem_a`/`modem_b` (radio) and the slot flags in `devinfo`, and stock's first boot writes `efs`, `efs_backup`, `persist` and `modem_userdata`. This copy is the baseline from now on. + +## 2026-10-26: first light + +- **Console on the panel from boot** (boot 3): `simple-framebuffer` on `0xfac00000`, 1080x2400 ARGB8888, and the init writes DECON0 `TRIG_CON` `0x3061` (`SIMPLEFB_TRIG_CON`). Written by hand over SSH first (boot 2), then from the init. +- **Slot B boots** our kernel (`7.3.0-rc6`) with USB networking and SSH at `root@172.16.42.1`. Both cluster watchdogs are stopped, ramoops is at stock's `0xfd3ff000`. Slot B is not marked successful; slot A stays stock. +- **The bootloader scans the logo out of `0xfac00000`** (DPP0 `RDMA_BASEADDR_Y8`, read once over SSH), the same carve-out as the Pixel 7 Pro, which runs the same `cloudripper` ABL. +- **The splash is 1080x2400 ARGB8888** with no stride padding (DPP0 `RDMA_SRC_SIZE` `0x09600438`, `RDMA_IN_CTRL_0` format 0). +- **DECON0 `TRIG_CON` reads `0x3070`**: the hardware trigger is masked, so the panel keeps the logo until it is unmasked. +- **`reboot-to bootloader` did not reach fastboot.** `syscon-reboot-mode` is bound (`SYSIP_DAT0`, `mode-bootloader` 0xfc), but the phone rebooted straight back into slot B, and `/sys/fs/pstore` was empty on the next boot, so ramoops did not survive that reset. Not investigated yet; fastboot by the buttons meanwhile. +- **CMA:** the kernel's 384 MiB CMA reservation fails on this phone's 8 GB (`MemTotal` 7660972 kB). Nothing at first light needs it. + +## 2026-10-26: stock facts + +Captured on stock `CP3A.261005.002.A1` (Android 17, security patch 2026-10-05) on slot A, and from a rooted LineageOS 24 build on the same phone before it was restored. The captures stay off the repository. + +| Fact | Value | Source | +| --- | --- | --- | +| SoC | GS201, MP1.0, package mode 0, SoC rev 2. Same B0 match as cheetah (`soc_id` 0x09855001) | [V] `getprop` ro.boot.hw.soc.pkg_mode, ro.boot.hw.soc.rev; live DT `/soc_id` | +| Board id | 0x30406, rev 0x10000, dtbo index 22 | [V] `ro.boot.cdt_hwid`, `ro.boot.dtbo_idx`; Google `gs201-panther-mp.dts:14-15` | +| Bootloader | `cloudripper-17.0-15902555`, the same ABL as the Pixel 7 Pro; radio `g5300q-260604-260807-B-16036236`. Both slots flashed from the factory image | [V] `fastboot getvar` | +| Boot images | `boot`, `init_boot`, `vendor_boot`, `vendor_kernel_boot`, `dtbo` on both slots, the same sizes as cheetah (64, 8, 64, 64 and 16 MiB) | [V] `fastboot getvar all` | +| Panel | `sdc-s6e3fc3-p10` (`samsung,s6e3fc3-p10`), 1080x2400, DSI 0 on DECON0 | [V] ABL's `exynos_drm.panel_name`, live DT, `dumpsys display` | +| Touch | FocalTech, `focaltech,ts` in the stock DT. Not cheetah's Synaptics: the TouchComm driver does not apply | [V] live DT | +| Charger, TCPC, gauge | MAX77759, as on cheetah | [V] live DT | +| Reserved memory | Every stock `reserved-memory` region that Google's tree describes matches gs201.dtsi. `sec_dram`, `sec_pt` and `pkvm_guest_firmware` are injected by the bootloader (not in Google's DTS); `cp_aoc_rmem` (0x197fd000) is AoC SRAM, not DRAM | [V] live DT against the built cheetah DTB; Google `gs201-rmem.dtsi` | +| Framebuffer | Not described in Google's tree: ABL injects it. Not copied from cheetah's `0xfac00000`; to be read from DPP0 on the first boot | [I] | diff --git a/device/panther/device.conf b/device/panther/device.conf new file mode 100644 index 000000000..ccd81f126 --- /dev/null +++ b/device/panther/device.conf @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: MIT +# Device descriptor: Google Pixel 7 (panther), first light. +# +# Same rules as device/cheetah/device.conf. No shell. + +# --- Identity --- +CODENAME=panther +NAME="Pixel 7" +USB_PRODUCT="Pixel 7 (M1)" +SOC=gs201 +COMPATIBLE="google,gs201-panther" +# Storage guard and USB networking only (packages/omamobile-device-panther). +# It has no bootctl source, so the initramfs gets the freestanding devmem +# and reboot-to, as on felix. +PACKAGE=omamobile-device-panther + +# --- Kernel and device tree --- +DTB=exynos/google/gs201-panther.dtb +# Stock: pkg_mode 0, soc rev 2, soc_id 0x9855001 in the live DT. Built +# value first; the packer rewrites a second copy for A0. +SOC_IDS="b0:0x9855001 a0:0x9855000" +# No DTB_OVERLAYS at first light. + +# --- Bootloader glue --- +# ro.boot.dtbo_idx 22, ro.boot.cdt_hwid 0x00030406 00010000. +DTBO_SOURCE=panther-m1-overlay.dts +DTBO_BOARD_ID=0x30406 +DTBO_BOARD_REV=0x10000 +VENDOR_CMDLINE="console=tty0 earlycon=exynos4210,0x10A00000 clk_ignore_unused pd_ignore_unused printk.devkmsg=on bootconfig" +VENDOR_PAGESIZE=0x800 +# Stock CP3A.261005.002.A1, security patch 2026-10-05. +OS_VERSION=17.0.0 +OS_PATCH_LEVEL=2026-10 + +# --- Storage guard --- +# All five images exist on slot B (fastboot getvar all). UFS stays +# disabled in the first-light DTS; the guard is packed regardless. +BOOT_IMAGES="boot init_boot vendor_boot vendor_kernel_boot dtbo" +UFS_RW="boot_b init_boot_b vendor_boot_b vendor_kernel_boot_b dtbo_b userdata" + +# --- Initramfs --- +# SIMPLEFB_TRIG_CON is DECON0 TRIG_CON, which drives this phone's only +# panel: ABL leaves 0x3070 (trigger masked); 0x3061 unmasks it and the +# Linux console appears (BRINGUP-M1.md, boot 2). No BRINGUP_PROBE: those +# reads were done by hand, one register per call. +INITRAMFS_INIT=/initramfs/init +SIMPLEFB_TRIG_CON="0x1c240030 0x3061" +# Panel, portrait (dumpsys display: 1080x2400). Splash only with "splash" +# on the command line, which this phone's bootargs do not have. +PANEL_SIZE=1080x2400 diff --git a/device/panther/panther-m1-overlay.dts b/device/panther/panther-m1-overlay.dts new file mode 100644 index 000000000..e9884bc4a --- /dev/null +++ b/device/panther/panther-m1-overlay.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Empty board overlay for the Pixel 7 bootloader (ABL). + * + * ABL picks a dtbo entry by board_id/board_rev and applies it on top of + * the base DTB. The stock overlay references Google labels that do not + * exist in the mainline DTB, so this one changes nothing. + * + * board_id 0x30406 and board_rev 0x10000 match ro.boot.cdt_hwid + * 0x00030406 00010000 and ro.boot.dtbo_idx 22. + */ +/dts-v1/; +/plugin/; + +/ { + board_id = <0x30406>; + board_rev = <0x10000>; + + fragment@0 { + target-path = "/"; + __overlay__ { + }; + }; +}; diff --git a/docs/DEVICES.md b/docs/DEVICES.md index 9540d4abc..414657381 100644 --- a/docs/DEVICES.md +++ b/docs/DEVICES.md @@ -27,6 +27,7 @@ The status of each device, as verified on real hardware. Rows in the matrix have | Pixel 4 XL ([notes](../device/coral/NOTES.md)) | coral | SM8150 (Snapdragon 855) | WIP (direct ABL v2 boot on the test handset's slot A; slot-B install and §3.1 entry pending; [notes](../device/coral/BRINGUP-M1.md)) | testing (read-only `blockdev` guard + RAM `overlayfs`) | testing (1440x3040@60Hz S6E3HC2 DSC 1.1 KMS, DPMS, brightness) | testing (Adreno 640 / FD640 Mesa Freedreno, Hyprland) | testing (FTS SPI multitouch + read-only flash guard) | testing (power via `qcom-pon` + volume via `gpio-keys`) | testing (CDC ECM + ACM + SSH; stays up with host USB switched off) | testing (`WCN3990` `ath10k_snoc` + `rmtfs -r`, WPA2/DHCP/HTTPS; radio sessions ran before the modem baseline) | WIP (`WCN3990` `hci_qca` `hci0` up + BLE scan; audio/pairing open) | WIP (PM8150B ADC `VBAT_SNS` voltage + FG temp; aftermarket pack on test unit: no reply from `1-0036`) | testing (PM8150B SMB5 charger with `4.20 V` / `500 mA` kernel clamp) | testing (`CS40L25A` I2C click waveform) | testing (PM8150L flash LEDs + quick-settings tile) | no | - | testing (QDSP6 + dual `CS35L36` amps capped at `-26 dB` + `IA8508` SPI mic DSP) | testing (`SLPI` + `fastrpc` + RAM-backed `hexagonrpcd` + QMI SSC: 7 sensors + Soli radar) | WIP (`MPSS` boots with `rmtfs -r` + patched `tqftpserv`, SIM detected; no IPA/voice yet; radio sessions ran before the modem baseline) | no | testing (`CAMSS` + `IMX363`, `IMX481`, `IMX520`, dual `OV7251` NIR; `libcamera` softISP) | no | - | | Pixel 9a ([notes](../device/tegu/NOTES.md)) | tegu | zumapro (Tensor G4) | WIP ([#28](https://github.com/derekross/omarchy-mobile/issues/28): the SoC's clocks and bindings are merged into linux-omarchy-mobile; the SoC and board device tree is in review, [kernel #80](https://github.com/derekross/linux-omarchy-mobile/pull/80)) | WIP | WIP (DSI panel, 1080x2424; unpublished kernel) | WIP (Panthor, the desktop renders; unpublished kernel) | WIP | WIP (gpio-keys; unpublished kernel) | WIP | WIP (brcmfmac joins WPA2; driver in review, [kernel #56](https://github.com/derekross/linux-omarchy-mobile/pull/56)) | WIP (powered; unpublished kernel) | WIP (the gauge reads; unpublished kernel) | no | no | no | no | WIP (audio and sensors; unpublished kernel) | WIP (speakers capped, mics, A2DP; unpublished kernel) | WIP (accelerometer, light, proximity; unpublished kernel) | no | no | no | no | no | | Pixel 8 Pro ([notes](../device/husky/NOTES.md)) | husky | zuma (Tensor G3) | WIP ([#1](https://github.com/derekross/omarchy-mobile/issues/1): our kernel boots from slot B; the zuma device tree is merged ([kernel #13](https://github.com/derekross/linux-omarchy-mobile/pull/13))) | testing (UFS at HS-G4 behind the read-only guard; Arch on `userdata`; [UFS-PLAN](../device/husky/UFS-PLAN.md)) | WIP (simple-framebuffer console) | no | no | no | testing (USB and SSH) | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | +| Pixel 7 ([notes](../device/panther/NOTES.md)) | panther | gs201 (Tensor G2) | WIP (slot B, not marked successful; Arch and Hyprland boot; [BRINGUP-M1](../device/panther/BRINGUP-M1.md); board file in review, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | testing (UFS behind the read-only guard; Arch on `userdata`; in review, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | WIP (simple-framebuffer: console and the Hyprland lock screen) | no | no (FocalTech FT3658, no mainline driver) | testing (gpio-keys: power, volume; in review, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | testing (USB and SSH; in review, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | | *Template* | *codename* | *SoC* | | | | | | | | | | | | | | | | | | | | | | | ## cheetah (Pixel 7 Pro) in detail @@ -62,7 +63,6 @@ Devices we'd like to support, with the closest starting point. Open an issue to | Device | Codename | SoC | Starting point | | --- | --- | --- | --- | -| Pixel 7 | panther | gs201 | **WIP, community port:** its board device tree and FocalTech FT3658 touch driver are in review ([kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108), [kernel #109](https://github.com/derekross/linux-omarchy-mobile/pull/109)), and its device package too ([#79](https://github.com/derekross/omarchy-mobile/pull/79)) | | Pixel 7a | lynx | gs201 | **WIP, community port: [#36](https://github.com/derekross/omarchy-mobile/issues/36)**, in the matrix above: Arch on `userdata` from slot B with USB and SSH; UFS and touch are in the published kernel ([kernel #91](https://github.com/derekross/linux-omarchy-mobile/pull/91), [kernel #93](https://github.com/derekross/linux-omarchy-mobile/pull/93)), its device package is merged, and Wi-Fi is parked at the chip's boot ROM ([plan](../device/lynx/WIFI-PLAN.md)) | | Pixel Fold | felix | gs201 | **WIP, community port: [#3](https://github.com/derekross/omarchy-mobile/issues/3)**; as panther, with two panels (DECON1 drives the cover, DECON0 the inner panel) | | Pixel Tablet | tangorpro | gs201 | as panther; no modem | diff --git a/docs/RELEASES.md b/docs/RELEASES.md index ac95d4de3..b43a977ce 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -317,6 +317,16 @@ CI never holds the signing key and never sees a factory image. The maintainer do - Rotation and revocation go through `omamobile-keyring`'s `omamobile-trusted` and `omamobile-revoked`, as Arch's keyring does. - **Publishing** (`tools/repo-publish`): `pkgs.omamobile.org` has two channels, `development/aarch64` and `stable/aarch64`. `repo-publish development` builds what changed (`build-packages --all`), checks every package's checksum and signature against `omamobile-keyring`'s trusted keys, and uploads packages first, then the index, then the pruning; each channel keeps the current and the previous index's files. `repo-publish stable` promotes development's signed files unchanged, after asking. The maintainer's laptop runs it daily from a clean `origin/main` checkout (`--from-main`, `tools/systemd/omamobile-publish.timer`), and `--remind` opens a "Ready for stable" issue when development has differed from stable for three days. Experimental phones' device packages are published to development only. The server account needs the `deployers` group. - Never commit, paste or upload a key, a passphrase or `keys/`. CI gets no key. +- **Contributors' builds** (review lesson L-7). A port's own packages are signed with a local key that only that contributor's machine trusts, and everything lands under `out//` and `keys//`, never in the maintainer's `keys/` or `out/repo`: + + ```sh + tools/local-key-init panther # once: keys/panther/{gnupg,fingerprint,public.asc} + tools/fetch-published out/panther/published # pkgs.omamobile.org/development, each signature checked + tools/build-packages --local panther --import out/panther/published packages/omamobile-device-panther + KERNEL_OUT=... tools/build-rootfs --local panther # out/panther/omamobile-rootfs-*.img.zst + ``` + + `tools/fetch-published` accepts the index and each package only when a key in `omamobile-keyring`'s `omamobile-trusted`, and not in `omamobile-revoked`, signed it, and each package only when it matches the signed index's SHA-256. `build-packages --local` keeps those packages' own `.sig` files, so only what it builds and the repository index carry the local key. The build image of `build-packages` and `build-rootfs --local` trusts the local key too (`ALARM_LOCAL_KEY`, locally signed in that image only). **The phone does not:** after the first boot, `pacman` refuses that `[omamobile]` index until the owner adds the key by hand (`pacman-key --add public.asc`, then `pacman-key --lsign-key `). No package carries a contributor's key. ## 11. Release checklist diff --git a/packages/omamobile-device-panther/LICENSE b/packages/omamobile-device-panther/LICENSE new file mode 100644 index 000000000..aecd59624 --- /dev/null +++ b/packages/omamobile-device-panther/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-panther/PKGBUILD b/packages/omamobile-device-panther/PKGBUILD new file mode 100644 index 000000000..832821fa8 --- /dev/null +++ b/packages/omamobile-device-panther/PKGBUILD @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: MIT +# Maintainer: Derek Ross +pkgname=omamobile-device-panther +pkgver=$(cat "${startdir:-.}/version") +pkgrel=1 +pkgdesc="Omarchy Mobile support for the Google Pixel 7 (panther): storage guard and USB networking" +arch=(aarch64) +url="https://github.com/derekross/omarchy-mobile" +license=(MIT) +depends=(bash systemd omamobile-keyring) +provides=(omamobile-device) +conflicts=(omamobile-device) +backup=(etc/pacman.d/omamobile-mirrorlist) +install=omamobile-device-panther.install +makedepends=(gcc) + +build() { + "$startdir/build" "$srcdir/build" +} + +check() { + "$startdir/test/all" +} + +package() { + "$startdir/install" "$pkgdir" "$srcdir/build" +} diff --git a/packages/omamobile-device-panther/README.md b/packages/omamobile-device-panther/README.md new file mode 100644 index 000000000..b4013c0de --- /dev/null +++ b/packages/omamobile-device-panther/README.md @@ -0,0 +1,18 @@ +# omamobile-device-panther + +Omarchy Mobile's first userspace package for the Google Pixel 7 (codename panther, Tensor G2 / gs201). It hides the Android partitions from desktop tools, holds the USB address, and gives pacman the same `[omamobile]` repository as the Pixel 7 Pro. It does not drive the radio, the charger, or a camera, and it does not mark a boot slot successful. + +| 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 | +| `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. The long press stays the PMIC reset | +| `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-panther.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. On this phone `reboot-to bootloader` does not reach fastboot yet (device/panther/NOTES.md) | +| `device.conf` | `/usr/share/omamobile/device.conf` | The descriptor, the same bytes as `device/panther/device.conf` | + +`./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, Wi-Fi, the charger, cameras, and the slot-B image hook. Those stay out until each one has its own runbook. diff --git a/packages/omamobile-device-panther/build b/packages/omamobile-device-panther/build new file mode 100755 index 000000000..5dacf6c60 --- /dev/null +++ b/packages/omamobile-device-panther/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} +mkdir -p "$out" +${CC:-cc} ${CFLAGS:--O2} -Wall -Wextra -o "$out/reboot-to" src/reboot-to.c ${LDFLAGS:-} diff --git a/packages/omamobile-device-panther/device.conf b/packages/omamobile-device-panther/device.conf new file mode 100644 index 000000000..ccd81f126 --- /dev/null +++ b/packages/omamobile-device-panther/device.conf @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: MIT +# Device descriptor: Google Pixel 7 (panther), first light. +# +# Same rules as device/cheetah/device.conf. No shell. + +# --- Identity --- +CODENAME=panther +NAME="Pixel 7" +USB_PRODUCT="Pixel 7 (M1)" +SOC=gs201 +COMPATIBLE="google,gs201-panther" +# Storage guard and USB networking only (packages/omamobile-device-panther). +# It has no bootctl source, so the initramfs gets the freestanding devmem +# and reboot-to, as on felix. +PACKAGE=omamobile-device-panther + +# --- Kernel and device tree --- +DTB=exynos/google/gs201-panther.dtb +# Stock: pkg_mode 0, soc rev 2, soc_id 0x9855001 in the live DT. Built +# value first; the packer rewrites a second copy for A0. +SOC_IDS="b0:0x9855001 a0:0x9855000" +# No DTB_OVERLAYS at first light. + +# --- Bootloader glue --- +# ro.boot.dtbo_idx 22, ro.boot.cdt_hwid 0x00030406 00010000. +DTBO_SOURCE=panther-m1-overlay.dts +DTBO_BOARD_ID=0x30406 +DTBO_BOARD_REV=0x10000 +VENDOR_CMDLINE="console=tty0 earlycon=exynos4210,0x10A00000 clk_ignore_unused pd_ignore_unused printk.devkmsg=on bootconfig" +VENDOR_PAGESIZE=0x800 +# Stock CP3A.261005.002.A1, security patch 2026-10-05. +OS_VERSION=17.0.0 +OS_PATCH_LEVEL=2026-10 + +# --- Storage guard --- +# All five images exist on slot B (fastboot getvar all). UFS stays +# disabled in the first-light DTS; the guard is packed regardless. +BOOT_IMAGES="boot init_boot vendor_boot vendor_kernel_boot dtbo" +UFS_RW="boot_b init_boot_b vendor_boot_b vendor_kernel_boot_b dtbo_b userdata" + +# --- Initramfs --- +# SIMPLEFB_TRIG_CON is DECON0 TRIG_CON, which drives this phone's only +# panel: ABL leaves 0x3070 (trigger masked); 0x3061 unmasks it and the +# Linux console appears (BRINGUP-M1.md, boot 2). No BRINGUP_PROBE: those +# reads were done by hand, one register per call. +INITRAMFS_INIT=/initramfs/init +SIMPLEFB_TRIG_CON="0x1c240030 0x3061" +# Panel, portrait (dumpsys display: 1080x2400). Splash only with "splash" +# on the command line, which this phone's bootargs do not have. +PANEL_SIZE=1080x2400 diff --git a/packages/omamobile-device-panther/etc/omamobile-mirrorlist b/packages/omamobile-device-panther/etc/omamobile-mirrorlist new file mode 100644 index 000000000..b272b8fca --- /dev/null +++ b/packages/omamobile-device-panther/etc/omamobile-mirrorlist @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT +# Where pacman gets Omarchy Mobile's packages ([omamobile] in /etc/pacman.conf). +# While the project is private, the repository lives on the phone and is +# filled from the build machine (tools/repo-push). Once it's public, this +# becomes a URL, delivered by a package update. +Server = file:///var/lib/omamobile/repo/$arch diff --git a/packages/omamobile-device-panther/install b/packages/omamobile-device-panther/install new file mode 100755 index 000000000..d00d6c57f --- /dev/null +++ b/packages/omamobile-device-panther/install @@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Stage omamobile-device-panther 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} +[[ $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/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" +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-panther/LICENSE" +install -Dm644 version "$destination/usr/share/omamobile/device-panther/version" diff --git a/packages/omamobile-device-panther/omamobile-device-panther.install b/packages/omamobile-device-panther/omamobile-device-panther.install new file mode 100644 index 000000000..60517fa32 --- /dev/null +++ b/packages/omamobile-device-panther/omamobile-device-panther.install @@ -0,0 +1,24 @@ +# 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 +} + +post_install() { + add_repository +} + +post_upgrade() { + add_repository +} diff --git a/packages/omamobile-device-panther/src/reboot-to.c b/packages/omamobile-device-panther/src/reboot-to.c new file mode 100644 index 000000000..f79e948ed --- /dev/null +++ b/packages/omamobile-device-panther/src/reboot-to.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +// reboot-to: reboot with a reason the Pixel bootloader understands, +// e.g. "reboot-to bootloader" lands in fastboot. +// The kernel's syscon-reboot-mode driver stores the reason in the PMU +// before the reset; busybox reboot can't pass one. +#include +#include +#include + +/* From (stable ABI); musl's sysroot has no kernel headers */ +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 + +int main(int argc, char **argv) +{ + const char *reason = argc > 1 ? argv[1] : "bootloader"; + + sync(); + syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, + LINUX_REBOOT_CMD_RESTART2, reason); + perror("reboot"); + return 1; +} diff --git a/packages/omamobile-device-panther/test/all b/packages/omamobile-device-panther/test/all new file mode 100755 index 000000000..1375af84c --- /dev/null +++ b/packages/omamobile-device-panther/test/all @@ -0,0 +1,89 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Tests for omamobile-device-panther. 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" + cmp -s vendor/udev/rules.d/10-omamobile-storage.rules \ + ../omamobile-device-cheetah/vendor/udev/rules.d/10-omamobile-storage.rules \ + || fail "the storage rule drifted from the cheetah package" + pass "the storage rule matches the cheetah package" + 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" + cmp -s omamobile-device-panther.install \ + ../omamobile-device-cheetah/omamobile-device-cheetah.install \ + || fail "the pacman install script drifted from the cheetah package" + pass "the pacman install script matches the cheetah package" +fi +grep -q 'omamobile-keyring' PKGBUILD || fail "pacman needs omamobile-keyring" +grep -q '^install=omamobile-device-panther.install$' PKGBUILD \ + || fail "the pacman install script is not named" +[[ -f etc/omamobile-mirrorlist && -f omamobile-device-panther.install ]] \ + || fail "the pacman mirrorlist or install script is missing" +pass "pacman gets the keyring, the mirrorlist, and the install script" +if [[ -f ../../device/panther/device.conf ]]; then + cmp -s device.conf ../../device/panther/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-panther/version \ + usr/share/licenses/omamobile-device-panther/LICENSE \ + etc/pacman.d/omamobile-mirrorlist; do + [[ -f $tmp/root/$f ]] || fail "install stages $f" +done +grep -q 'KERNEL=="sda", MODE="0000"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" \ + || fail "the whole-disk node is 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-panther$' "$tmp/root/usr/share/omamobile/device.conf" \ + || fail "the installed descriptor is panther" +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 \ + usr/lib/systemd/logind.conf.d/10-omamobile-lid.conf; 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" diff --git a/packages/omamobile-device-panther/vendor/NetworkManager/conf.d/10-omamobile-usb.conf b/packages/omamobile-device-panther/vendor/NetworkManager/conf.d/10-omamobile-usb.conf new file mode 100644 index 000000000..252de6e15 --- /dev/null +++ b/packages/omamobile-device-panther/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-panther/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf b/packages/omamobile-device-panther/vendor/systemd/logind.conf.d/10-omamobile-power-key.conf new file mode 100644 index 000000000..a1e2cb0eb --- /dev/null +++ b/packages/omamobile-device-panther/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-panther/vendor/systemd/network/20-usb-gadget.network b/packages/omamobile-device-panther/vendor/systemd/network/20-usb-gadget.network new file mode 100644 index 000000000..4e30191f6 --- /dev/null +++ b/packages/omamobile-device-panther/vendor/systemd/network/20-usb-gadget.network @@ -0,0 +1,14 @@ +# 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 +Gateway=172.16.42.2 +DNS=1.1.1.1 +DNS=9.9.9.9 +ConfigureWithoutCarrier=yes diff --git a/packages/omamobile-device-panther/vendor/udev/rules.d/10-omamobile-storage.rules b/packages/omamobile-device-panther/vendor/udev/rules.d/10-omamobile-storage.rules new file mode 100644 index 000000000..89c02cf30 --- /dev/null +++ b/packages/omamobile-device-panther/vendor/udev/rules.d/10-omamobile-storage.rules @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile storage guard, continued in Arch. The initramfs marks every UFS +# partition read-only except slot B's boot images and userdata, and removes +# the whole-disk node of the main LUN. udev would recreate /dev/sda, so make +# the whole-disk node inaccessible and keep desktop tools from touching any +# Android partition. +SUBSYSTEM=="block", KERNEL=="sda", MODE="0000", ENV{UDISKS_IGNORE}="1" +SUBSYSTEM=="block", KERNEL=="sd[a-d][0-9]*", ENV{ID_PART_ENTRY_NAME}!="userdata", ENV{UDISKS_IGNORE}="1" diff --git a/packages/omamobile-device-panther/version b/packages/omamobile-device-panther/version new file mode 100644 index 000000000..6e8bf73aa --- /dev/null +++ b/packages/omamobile-device-panther/version @@ -0,0 +1 @@ +0.1.0 diff --git a/tests/all b/tests/all index 1f32c172b..609391bd4 100755 --- a/tests/all +++ b/tests/all @@ -6,11 +6,14 @@ # first-boot growth, the bring-up overlays, the simplefb trigger, the init's per-board steps, the storage guard's packed # allowlist and the USB product string, bin/omamobile's boot-image layouts # and flash against a fake fastboot, omamobile-firstboot's own tests, and the -# smoke test of the newest root image in out/ if there is one, and the -# felix and lynx device packages' own tests, and tools/alarm-wake-test's check. +# smoke test of the newest root image in out/ if there is one, the felix, +# lynx and panther device packages' own tests, tools/alarm-wake-test's +# check, and a contributor's local builds (tools/local-key-init, +# tools/fetch-published, --local). set -euo pipefail cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." for f in tools/install-phone tools/phone-provision tools/build-rootfs tools/build-packages tools/make-bundle \ + tools/local-key-init tools/fetch-published \ tools/lib/alarm.sh tools/lib/alarm-setup rootfs/build-inside tests/*; do [[ -f $f ]] || continue # tests/owl is the OWL conformance suite's folder bash -n "$f" || { echo "not ok - $f parses" >&2; exit 1; } @@ -20,7 +23,7 @@ sh -n device/flame/initramfs/init sh -n device/flame/initramfs/build bash -n tools/build-flame-probe echo "ok - scripts parse" -for t in tests/pr-check tests/kernel-pr-check tests/alarm-wake-test tests/install-phone tests/phone-provision tests/initramfs-grow tests/images-layout tests/device-overlays tests/simplefb-trigger tests/initramfs-steps tests/storage-guard tests/usb-product tests/boot-method tests/flame-probe packages/omamobile-firstboot/test/all packages/omamobile-device-felix/test/all packages/omamobile-device-lynx/test/all; do +for t in tests/pr-check tests/kernel-pr-check tests/alarm-wake-test tests/install-phone tests/phone-provision tests/initramfs-grow tests/images-layout tests/device-overlays tests/simplefb-trigger tests/initramfs-steps tests/storage-guard tests/usb-product tests/boot-method tests/flame-probe packages/omamobile-firstboot/test/all packages/omamobile-device-felix/test/all packages/omamobile-device-lynx/test/all packages/omamobile-device-panther/test/all tests/local-builds; do echo "# $t" "$t" done diff --git a/tests/local-builds b/tests/local-builds new file mode 100755 index 000000000..fc7c1fc5d --- /dev/null +++ b/tests/local-builds @@ -0,0 +1,107 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# A contributor's local builds (no phone, no network, no Docker): every run +# happens in a copy of the repository, so the real keys/ and out/ are never +# touched. tools/local-key-init makes keys/NAME once; tools/fetch-published +# takes only what a trusted, unrevoked Omarchy Mobile key signed, against a +# fake server (file://) and a test keyring; build-packages and build-rootfs +# --local refuse before any build without the local key, and never fall +# back to the maintainer's keys/ or out/repo. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +pass() { printf 'ok - %s\n' "$1"; } +command -v gpg >/dev/null && command -v gpgv >/dev/null || { pass "# skip: no gpg"; exit 0; } +t=$(mktemp -d) +export GNUPGHOME=$t/home && mkdir -m 700 "$GNUPGHOME" # never the user's ~/.gnupg +trap 'gpgconf --homedir "$t/signer" --kill gpg-agent 2>/dev/null || true; gpgconf --homedir "$t/other" --kill gpg-agent 2>/dev/null || true; rm -rf "$t"' EXIT + +R=$t/repo +mkdir -p "$R/tools/lib" "$R/device/panther" "$R/packages" +cp tools/local-key-init tools/fetch-published tools/build-packages tools/build-rootfs "$R/tools/" +cp tools/lib/alarm.sh tools/lib/alarm-setup "$R/tools/lib/" +cp device/panther/device.conf "$R/device/panther/" +cp -a packages/omamobile-device-panther "$R/packages/" +run() { (cd "$R" && "$@") > "$t/log" 2>&1; } + +# --- tools/local-key-init --- +if run tools/local-key-init nosuch; then fail "local-key-init refuses a codename without a descriptor"; fi +run tools/local-key-init panther || { cat "$t/log"; fail "local-key-init makes keys/panther"; } +fpr=$(cat "$R/keys/panther/fingerprint") +[[ $fpr =~ ^[0-9A-F]{40}$ ]] || fail "the fingerprint is 40 hex digits" +[[ $(gpg --show-keys --with-colons "$R/keys/panther/public.asc" | awk -F: '$1 == "fpr" {print $10; exit}') == "$fpr" ]] \ + || fail "public.asc is the key named in fingerprint" +[[ $(stat -c %a "$R/keys/panther/gnupg") == 700 ]] || fail "the keyring directory is private" +if run tools/local-key-init panther; then fail "local-key-init refuses to replace an existing key"; fi +gpgconf --homedir "$R/keys/panther/gnupg" --kill gpg-agent 2>/dev/null || true +pass "local-key-init makes one signing key in keys/panther, once" + +# --- tools/fetch-published --- +mkdir -m 700 "$t/signer" "$t/other" +GNUPGHOME=$t/signer gpg --batch --quiet --passphrase '' --quick-generate-key "test signer " ed25519 sign never +GNUPGHOME=$t/other gpg --batch --quiet --passphrase '' --quick-generate-key "someone else " ed25519 sign never +signer=$(GNUPGHOME=$t/signer gpg --with-colons --list-keys | awk -F: '$1 == "fpr" {print $10; exit}') +kr=$R/packages/omamobile-keyring && mkdir -p "$kr" +GNUPGHOME=$t/signer gpg --batch --armor --export "$signer" > "$kr/omamobile.gpg" +echo "$signer:4:" > "$kr/omamobile-trusted" +: > "$kr/omamobile-revoked" + +srv=$t/srv/development/aarch64 && mkdir -p "$srv" +sign() { GNUPGHOME=$t/$1 gpg --batch --yes --quiet --detach-sign -o "$2.sig" "$2"; } +make_index() { # make_index SIGNER: an index of foo whose checksum matches the file + local sum + sum=$(sha256sum < "$srv/foo-1-1-any.pkg.tar.zst" | cut -d' ' -f1) + rm -rf "$t/db" && mkdir -p "$t/db/foo-1-1" + printf '%%FILENAME%%\nfoo-1-1-any.pkg.tar.zst\n\n%%SHA256SUM%%\n%s\n' "$sum" > "$t/db/foo-1-1/desc" + tar -czf "$srv/omamobile.db" -C "$t/db" foo-1-1 + sign "$1" "$srv/omamobile.db" +} +echo "package bytes" > "$srv/foo-1-1-any.pkg.tar.zst" +sign signer "$srv/foo-1-1-any.pkg.tar.zst" +make_index signer +fetch() { (cd "$R" && OMAMOBILE_PKGS_URL=file://$t/srv tools/fetch-published "$t/got") > "$t/log" 2>&1; } + +fetch || { cat "$t/log"; fail "fetch-published takes a trusted index and package"; } +[[ -f $t/got/foo-1-1-any.pkg.tar.zst && -f $t/got/foo-1-1-any.pkg.tar.zst.sig ]] || fail "the package comes with its signature" +pass "fetch-published takes what a trusted key signed, with its .sig" + +make_index other +if fetch; then fail "refuses an index signed by an untrusted key"; fi +grep -q 'index is not signed by a trusted' "$t/log" || { cat "$t/log"; fail "says the index is untrusted"; } +make_index signer +sign other "$srv/foo-1-1-any.pkg.tar.zst" +rm -rf "$t/got" +if fetch; then fail "refuses a package signed by an untrusted key"; fi +grep -q 'foo-1-1-any.pkg.tar.zst is not signed by a trusted' "$t/log" || { cat "$t/log"; fail "says the package is untrusted"; } +sign signer "$srv/foo-1-1-any.pkg.tar.zst" +echo "tampered" >> "$srv/foo-1-1-any.pkg.tar.zst" +rm -rf "$t/got" +if fetch; then fail "refuses a package that does not match the index"; fi +grep -q 'does not match the index' "$t/log" || { cat "$t/log"; fail "says the package does not match"; } +pass "fetch-published refuses an untrusted index, an untrusted package and a changed package" + +echo "package bytes" > "$srv/foo-1-1-any.pkg.tar.zst" +sign signer "$srv/foo-1-1-any.pkg.tar.zst" +make_index signer +echo "$signer revoked" > "$kr/omamobile-revoked" +if fetch; then fail "refuses a revoked key"; fi +pass "fetch-published refuses a revoked key" + +# --- build-packages and build-rootfs --local --- +mv "$R/keys/panther" "$t/panther-key" +if run tools/build-packages --local panther packages/omamobile-device-panther; then fail "build-packages --local refuses without the local key"; fi +grep -q 'no local key in keys/panther' "$t/log" || { cat "$t/log"; fail "says the local key is missing"; } +mkdir -p "$R/keys/gnupg" && echo "$signer" > "$R/keys/fingerprint" +if run tools/build-packages --local panther packages/omamobile-device-panther; then fail "build-packages --local never falls back to keys/"; fi +if run tools/build-packages --local nosuch packages/omamobile-device-panther; then fail "build-packages --local refuses an unknown codename"; fi +[[ ! -e $R/out/repo ]] || fail "build-packages --local made nothing in out/repo" +pass "build-packages --local refuses without keys/NAME, and never uses keys/ or out/repo" + +if (cd "$R" && DEVICE=cheetah tools/build-rootfs --local panther) > "$t/log" 2>&1; then fail "build-rootfs --local refuses another DEVICE"; fi +grep -q 'builds device panther, not DEVICE=cheetah' "$t/log" || { cat "$t/log"; fail "says the device does not match"; } +if run tools/build-rootfs --local panther; then fail "build-rootfs --local refuses without keys/panther/public.asc"; fi +grep -q 'no keys/panther/public.asc' "$t/log" || { cat "$t/log"; fail "says the public key is missing"; } +mv "$t/panther-key" "$R/keys/panther" +if run tools/build-rootfs --local panther; then fail "build-rootfs --local refuses without out/panther/repo"; fi +grep -q 'no \[omamobile\] repository in out/panther/repo' "$t/log" || { cat "$t/log"; fail "says out/panther/repo is missing"; } +pass "build-rootfs --local checks the device, the key and out/NAME/repo" diff --git a/tools/build-packages b/tools/build-packages index 465dbb87c..7dc9fbbf0 100755 --- a/tools/build-packages +++ b/tools/build-packages @@ -19,6 +19,13 @@ # --import DIR copy prebuilt *.pkg.tar.{zst,xz} from DIR into the repository # (for example Mesa from an earlier build), then sign it # --list print what would be built and what is up to date +# --local NAME a contributor's build for device NAME (review lesson L-7): +# the repository is out/NAME/repo/aarch64, the signing key +# keys/NAME (tools/local-key-init), and the build image also +# trusts that key. Imported packages keep their own .sig +# (tools/fetch-published), so only what is built here +# carries the local key. Never the maintainer's keys/ or +# out/repo # # Mesa, Hyprland and libcamera are large C/C++ builds: under qemu-user on a # laptop they take hours (Mesa the longest). They're built only when named or @@ -30,7 +37,7 @@ source tools/lib/alarm.sh SLOW=(mesa hyprland libcamera) repo=out/repo/aarch64 -all=0 force=0 nocheck=0 container_check=0 list=0 imports=() dirs=() +all=0 force=0 nocheck=0 container_check=0 list=0 imports=() dirs=() local_name= while (($#)); do case $1 in --all) all=1 ;; @@ -39,7 +46,8 @@ while (($#)); do --check-in-container) container_check=1 ;; --list) list=1 ;; --import) imports+=("${2:?--import needs a directory}"); shift ;; - -h|--help) sed -n '3,22p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + --local) local_name=${2:?--local needs a device codename}; shift ;; + -h|--help) sed -n '3,29p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; -*) alarm_die "unknown option $1" ;; *) dirs+=("${1%/}") ;; esac @@ -48,7 +56,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-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) @@ -65,10 +73,20 @@ if ((${#dirs[@]} == 0)) && ((${#imports[@]} == 0)); then fi for d in "${dirs[@]}"; do [[ -f $d/PKGBUILD ]] || alarm_die "no PKGBUILD in $d"; done +keydir=keys +if [[ -n $local_name ]]; then + [[ $local_name =~ ^[a-z0-9]+$ && -f device/$local_name/device.conf ]] \ + || alarm_die "--local needs a device codename with a device//device.conf" + repo=out/$local_name/repo/aarch64 + keydir=keys/$local_name + [[ -f $keydir/fingerprint && -d $keydir/gnupg && -f $keydir/public.asc ]] \ + || alarm_die "no local key in $keydir (run: tools/local-key-init $local_name)" + export ALARM_LOCAL_KEY=$ROOT/$keydir/public.asc +fi mkdir -p "$repo" -export GNUPGHOME=$ROOT/keys/gnupg -[[ -f keys/fingerprint && -d $GNUPGHOME ]] || alarm_die "no signing key in keys/ (maintainer only; see docs/RELEASES.md §10)" -key=$(cat keys/fingerprint) +export GNUPGHOME=$ROOT/$keydir/gnupg +[[ -f $keydir/fingerprint && -d $GNUPGHOME ]] || alarm_die "no signing key in keys/ (maintainer only; see docs/RELEASES.md §10)" +key=$(cat "$keydir/fingerprint") # The version makepkg will produce, from the PKGBUILD's own fields. Our # PKGBUILDs read pkgver from a version file through $startdir. @@ -111,7 +129,9 @@ pkginfo() { if command -v bsdtar >/dev/null; then bsdtar -xOf "$1" .PKGINFO; else tar -xOf "$1" .PKGINFO; fi } -# Put package files in the repository, replacing older files of the same name +# Put package files in the repository, replacing older files of the same name. +# A local build keeps an imported package's own signature (its .sig beside +# it); everything else is signed by sign_and_index. add_to_repo() { local file name base for file; do @@ -125,6 +145,7 @@ add_to_repo() { done cp -f "$file" "$repo/$base" rm -f "$repo/$base.sig" + if [[ -n $local_name && -f $file.sig ]]; then cp -f "$file.sig" "$repo/$base.sig"; fi echo " $base" done } diff --git a/tools/build-rootfs b/tools/build-rootfs index dff1872a5..c5a893f8d 100755 --- a/tools/build-rootfs +++ b/tools/build-rootfs @@ -30,6 +30,7 @@ # to the whole userdata partition on the first boot. # # tools/build-rootfs [--version V] [--allow-missing "PKG..."] [--keep-raw] +# [--local NAME] # DEVICE device//device.conf (default cheetah) # KERNEL_OUT kernel build with modules-.tar.zst # (default ~/android/mainline/out-int: bin/omamobile modules) @@ -37,6 +38,12 @@ # (say "mesa hyprland libcamera libcamera-ipa # gst-plugin-libcamera vulkan-panfrost" for a test image # without the slow builds; the MANIFEST lists them) +# --local NAME a contributor's image for device NAME (review lesson +# L-7): the repository is out/NAME/repo (build-packages +# --local NAME), the image goes to out/NAME/, and the +# build image trusts keys/NAME's public key. DEVICE +# defaults to NAME. The phone does not trust that key: +# see docs/RELEASES.md §10 set -euo pipefail # debugfs and friends live in /sbin on Debian-like hosts export PATH=$PATH:/usr/sbin:/sbin @@ -44,21 +51,32 @@ cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." ROOT=$PWD source tools/lib/alarm.sh +DEVICE_SET=${DEVICE:+1} # --local defaults DEVICE to its codename DEVICE=${DEVICE:-cheetah} KERNEL_OUT=${KERNEL_OUT:-$HOME/android/mainline/out-int} VERSION=$(date +%Y.%m.%d) -ALLOW_MISSING="" KEEP_RAW=0 +ALLOW_MISSING="" KEEP_RAW=0 LOCAL="" while (($#)); do case $1 in --version) VERSION=${2:?}; shift ;; --allow-missing) ALLOW_MISSING=${2:?}; shift ;; --keep-raw) KEEP_RAW=1 ;; - -h|--help) sed -n '3,40p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + --local) LOCAL=${2:?}; shift ;; + -h|--help) sed -n '3,47p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; *) alarm_die "unknown argument $1" ;; esac shift done [[ $VERSION =~ ^[0-9A-Za-z._-]+$ ]] || alarm_die "bad version '$VERSION'" +outrel=out +if [[ -n $LOCAL ]]; then + [[ $LOCAL =~ ^[a-z0-9]+$ ]] || alarm_die "--local needs a device codename" + [[ -n $DEVICE_SET ]] || DEVICE=$LOCAL + [[ $DEVICE == "$LOCAL" ]] || alarm_die "--local $LOCAL builds device $LOCAL, not DEVICE=$DEVICE" + [[ -f keys/$LOCAL/public.asc ]] || alarm_die "no keys/$LOCAL/public.asc (run: tools/local-key-init $LOCAL)" + export ALARM_LOCAL_KEY=$ROOT/keys/$LOCAL/public.asc + outrel=out/$LOCAL +fi [[ $DEVICE =~ ^[a-z0-9]+$ ]] || alarm_die "DEVICE must be a codename" conf=device/$DEVICE/device.conf [[ -f $conf ]] || alarm_die "no $conf" @@ -67,16 +85,16 @@ DEVICE_PACKAGE=$(sed -n 's/^PACKAGE=\([a-z0-9-]*\)$/\1/p' "$conf") 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" -repo=out/repo/aarch64 +repo=$outrel/repo/aarch64 [[ -f $repo/omamobile.db ]] || - alarm_die "no [omamobile] repository in out/repo: build it first with tools/build-packages (or tools/repo-build)" + alarm_die "no [omamobile] repository in $outrel/repo: build it first with tools/build-packages${LOCAL:+ --local $LOCAL} (or tools/repo-build)" [[ -f $KERNEL_OUT/include/config/kernel.release ]] || alarm_die "no kernel build in $KERNEL_OUT (KERNEL_OUT=...)" 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" name=omamobile-rootfs-$VERSION-aarch64 -out=$ROOT/out +out=$ROOT/$outrel mkdir -p "$out" work=$out/.rootfs-$VERSION rm -rf "$work"; mkdir -p "$work" @@ -92,7 +110,7 @@ start=$(date +%s) alarm_say "Building $name for $DEVICE (kernel $release)" 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/out/repo:/repo:ro" -v "$modules:/modules:ro" \ + -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" \ diff --git a/tools/fetch-published b/tools/fetch-published new file mode 100755 index 000000000..a96ad2d02 --- /dev/null +++ b/tools/fetch-published @@ -0,0 +1,76 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Download Omarchy Mobile's published packages (pkgs.omamobile.org, +# docs/RELEASES.md §10) with their signatures, for a contributor's local +# repository: tools/build-packages --local CODENAME --import DIR keeps those +# signatures, so only the port's own packages carry the local key. +# +# tools/fetch-published [--channel development|stable] DIR +# +# The index and every package must be signed by a key that +# packages/omamobile-keyring trusts and has not revoked, and every package +# must match the SHA-256 the signed index gives for it; anything else stops +# the run. Files already in DIR that still verify are not downloaded again. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +die() { printf 'error: %s\n' "$*" >&2; exit 1; } + +channel=development dir="" +while (($#)); do + case $1 in + --channel) channel=${2:?}; shift ;; + -h|--help) sed -n '3,13p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + -*) die "unknown option $1" ;; + *) [[ -z $dir ]] || die "one DIR only"; dir=$1 ;; + esac + shift +done +[[ $channel =~ ^(development|stable)$ ]] || die "--channel is development or stable" +[[ -n $dir ]] || die "usage: tools/fetch-published [--channel development|stable] DIR" +url=${OMAMOBILE_PKGS_URL:-https://pkgs.omamobile.org}/$channel/aarch64 +command -v gpgv >/dev/null && command -v curl >/dev/null || die "gpgv and curl are needed" + +keyring=packages/omamobile-keyring +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +mkdir -m 700 "$tmp/gnupg" +GNUPGHOME=$tmp/gnupg gpg --batch --quiet --no-default-keyring --keyring "$tmp/omamobile.kbx" \ + --import "$keyring/omamobile.gpg" 2>/dev/null || die "cannot read $keyring/omamobile.gpg" +mapfile -t trusted < <(cut -d: -f1 "$keyring/omamobile-trusted" | grep -E '^[0-9A-F]{40}$') +mapfile -t revoked < <(grep -oE '^[0-9A-F]{40}' "$keyring/omamobile-revoked" 2>/dev/null || true) +((${#trusted[@]})) || die "no trusted keys in $keyring/omamobile-trusted" + +# verify SIG FILE: the primary key behind a good signature must be trusted +# and not revoked (a subkey's VALIDSIG names its primary last) +verify() { + local primary + primary=$(gpgv --keyring "$tmp/omamobile.kbx" --status-fd 1 "$1" "$2" 2>/dev/null \ + | awk '$2 == "VALIDSIG" {print $NF}' | tail -1) || true + [[ -n $primary && " ${trusted[*]} " == *" $primary "* && " ${revoked[*]} " != *" $primary "* ]] +} + +mkdir -p "$dir" +echo "==> $url" +curl -fsS --globoff -o "$tmp/omamobile.db" "$url/omamobile.db" || die "cannot fetch the index" +curl -fsS --globoff -o "$tmp/omamobile.db.sig" "$url/omamobile.db.sig" || die "the index has no signature" +verify "$tmp/omamobile.db.sig" "$tmp/omamobile.db" || die "the index is not signed by a trusted Omarchy Mobile key" + +mkdir -p "$tmp/db" && tar -xzf "$tmp/omamobile.db" -C "$tmp/db" +n=0 +for desc in "$tmp"/db/*/desc; do + file=$(awk '/^%FILENAME%$/ {getline; print; exit}' "$desc") + sum=$(awk '/^%SHA256SUM%$/ {getline; print; exit}' "$desc") + [[ $file =~ ^[A-Za-z0-9@._+:-]+\.pkg\.tar\.(zst|xz)$ && $sum =~ ^[0-9a-f]{64}$ ]] \ + || die "$(basename "$(dirname "$desc")"): unexpected index entry" + if [[ -f $dir/$file && -f $dir/$file.sig ]] \ + && [[ $(sha256sum < "$dir/$file" | cut -d' ' -f1) == "$sum" ]] && verify "$dir/$file.sig" "$dir/$file"; then + echo " have $file" + else + curl -fsS --globoff -o "$dir/$file" "$url/$file" || die "cannot fetch $file" + curl -fsS --globoff -o "$dir/$file.sig" "$url/$file.sig" || die "$file has no signature" + [[ $(sha256sum < "$dir/$file" | cut -d' ' -f1) == "$sum" ]] || die "$file does not match the index" + verify "$dir/$file.sig" "$dir/$file" || die "$file is not signed by a trusted Omarchy Mobile key" + echo " got $file" + fi + n=$((n + 1)) +done +echo "==> $n packages in $dir, each signed by a trusted Omarchy Mobile key" diff --git a/tools/lib/alarm-setup b/tools/lib/alarm-setup index 8d97a5541..4202e4369 100755 --- a/tools/lib/alarm-setup +++ b/tools/lib/alarm-setup @@ -3,7 +3,7 @@ # Runs once inside a fresh Arch Linux ARM container (tools/lib/alarm.sh, # alarm_build_image): keyrings, the build pacman.conf, base-devel and the # unprivileged "builder" account makepkg needs. /setup holds Omarchy's and -# Omarchy Mobile's keyring files. +# Omarchy Mobile's keyring files, and local.asc when a local key is in use. set -euo pipefail pacman-key --init >/dev/null 2>&1 @@ -11,6 +11,14 @@ pacman-key --populate archlinuxarm >/dev/null 2>&1 install -m644 /setup/omarchy.gpg /setup/omarchy-trusted /setup/omarchy-revoked \ /setup/omamobile.gpg /setup/omamobile-trusted /setup/omamobile-revoked /usr/share/pacman/keyrings/ pacman-key --populate omarchy omamobile >/dev/null 2>&1 +# A contributor's local key (ALARM_LOCAL_KEY): trusted in this image only +if [[ -f /setup/local.asc ]]; then + pacman-key --add /setup/local.asc >/dev/null 2>&1 + for fpr in $(gpg --show-keys --with-colons /setup/local.asc | awk -F: '$1 == "fpr" {print $10; exit}'); do + pacman-key --lsign-key "$fpr" >/dev/null 2>&1 + echo "local key trusted: $fpr" + done +fi # The order the phone uses: Omarchy's aarch64 builds before Arch Linux ARM's. # [omamobile] is added per run (file:///repo), when a repository exists. diff --git a/tools/lib/alarm.sh b/tools/lib/alarm.sh index 4cfcf18e1..151db306a 100644 --- a/tools/lib/alarm.sh +++ b/tools/lib/alarm.sh @@ -31,6 +31,11 @@ OMARCHY_CHANNEL=${OMARCHY_CHANNEL:-stable} # The keyring that signs [omarchy], taken from this (Omarchy) laptop, which # already trusts it: the container can't bootstrap that trust on its own. OMARCHY_KEYRING_DIR=${OMARCHY_KEYRING_DIR:-/usr/share/pacman/keyrings} +# A contributor's local signing key (tools/local-key-init; --local in +# build-packages and build-rootfs): the path of its exported public key. +# When set, the build image also trusts that key, locally signed, and only +# there: phones and the published repository never see it. +ALARM_LOCAL_KEY=${ALARM_LOCAL_KEY:-} alarm_say() { printf '\e[1m==> %s\e[0m\n' "$*"; } alarm_die() { printf '\e[31merror:\e[0m %s\n' "$*" >&2; exit 1; } @@ -90,7 +95,8 @@ alarm_base_image() { } # The build image: the base plus initialised keyrings (Arch Linux ARM's, -# Omarchy's from this laptop, Omarchy Mobile's from packages/), the build +# Omarchy's from this laptop, Omarchy Mobile's from packages/, and +# $ALARM_LOCAL_KEY when set, which is part of the image's hash), the build # pacman.conf, base-devel, arch-install-scripts and a "builder" user with # this laptop's uid. Prints its tag. $1: the repository root. alarm_build_image() { @@ -102,6 +108,10 @@ alarm_build_image() { ctx=$(mktemp -d) cp "$OMARCHY_KEYRING_DIR"/omarchy{.gpg,-trusted,-revoked} "$ctx/" cp "$root"/packages/omamobile-keyring/omamobile{.gpg,-trusted,-revoked} "$ctx/" + if [[ -n $ALARM_LOCAL_KEY ]]; then + [[ -f $ALARM_LOCAL_KEY ]] || alarm_die "no local key $ALARM_LOCAL_KEY" + cp "$ALARM_LOCAL_KEY" "$ctx/local.asc" + fi cp "$root/tools/lib/alarm-setup" "$ctx/setup" hash=$( (echo "$base $OMARCHY_CHANNEL $(id -u)"; cat "$ctx"/*) | sha256sum | cut -c1-16) tag=omamobile-alarm-build:$hash diff --git a/tools/local-key-init b/tools/local-key-init new file mode 100755 index 000000000..04d736932 --- /dev/null +++ b/tools/local-key-init @@ -0,0 +1,38 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Make a contributor's local signing key for a device port's own packages +# (docs/RELEASES.md §10, "Contributors' builds"; review lesson L-7). It is +# not Omarchy Mobile's key: phones and the published repository never trust +# it. Run once per port: +# +# tools/local-key-init CODENAME +# +# keys/CODENAME/ gets a keyring (gnupg/) holding one ed25519 signing key +# without a passphrase, its fingerprint and its public key (public.asc). +# tools/build-packages --local CODENAME signs with it, and the build image of +# build-packages and build-rootfs --local CODENAME trusts it. keys/ is +# gitignored: never commit, paste or upload it. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +die() { printf 'error: %s\n' "$*" >&2; exit 1; } + +name=${1:-} +[[ $name =~ ^[a-z0-9]+$ ]] || die "usage: tools/local-key-init CODENAME" +[[ -f device/$name/device.conf ]] || die "no device/$name/device.conf" +dir=keys/$name +[[ ! -e $dir ]] || die "$dir exists; remove it first to make a new key" +command -v gpg >/dev/null || die "gpg is needed" + +mkdir -p "$dir/gnupg" +chmod 700 "$dir" "$dir/gnupg" +export GNUPGHOME=$PWD/$dir/gnupg +uid="Omarchy Mobile local build ($name) " +gpg --batch --quiet --passphrase '' --quick-generate-key "$uid" ed25519 sign never +fpr=$(gpg --batch --with-colons --list-secret-keys | awk -F: '$1 == "fpr" {print $10; exit}') +[[ $fpr =~ ^[0-9A-F]{40}$ ]] || die "no fingerprint for the new key" +echo "$fpr" > "$dir/fingerprint" +gpg --batch --armor --export "$fpr" > "$dir/public.asc" +gpgconf --kill gpg-agent 2>/dev/null || true +echo "local key for $name: $fpr" +echo " keyring: $dir/gnupg" +echo " public key: $dir/public.asc"