diff --git a/.gitignore b/.gitignore index 14b43f718..543e21d76 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ out/ *.img keys/ logs/ +local/ # Python bytecode from running package code in place __pycache__/ diff --git a/device/tegu/NOTES.md b/device/tegu/NOTES.md index 31ad87f8e..83401833d 100644 --- a/device/tegu/NOTES.md +++ b/device/tegu/NOTES.md @@ -512,3 +512,135 @@ condition and a known-good B rollback. Preserve stock A and the storage guard. This entry is not an installation or diagnostic-flashing runbook. The gated retest and required evidence are in [BRINGUP-M1](BRINGUP-M1.md). + + +## 2026-10-28: second contributor's native boot and touch + +These results are from the PR #74 contributor's own Pixel 9a, a second +phone; they do not replace the first owner's results above. The last +verified Android build on this phone's slot A was `CP3A.261005.005` +(Android 17, October 2026). Subsequent stock recovery attempts failed; +slot A is not currently a qualified rollback on this phone. Recovery for +these trials uses privately retained, checksum-verified B images. Arch now +occupies userdata. No compatibility claim is made for the other owner's +`BP3A.250905.014` build or for booting September headers on this phone. + +Kernel: `7.3.0-rc6-omamobile-push1-g9ea0e19f8dc2`, from the private +`omamobile-tegu-release` branch, based on public `omamobile` commit +`33267e524` plus the then-reviewed clock/binding changes and prototype tegu +board, USB, UFS and touch changes. It is not the tree now proposed in +[linux-omarchy-mobile #80](https://github.com/derekross/linux-omarchy-mobile/pull/80) +and [#81](https://github.com/derekross/linux-omarchy-mobile/pull/81). +Those public board and touch PRs are the integration target; the private +prototype overlays have been removed from this package PR. + +The guarded `DEVICE=tegu bin/omamobile flash` path wrote only `boot_b`, +`init_boot_b`, `vendor_boot_b`, `vendor_kernel_boot_b` and `dtbo_b`, selected +B and rebooted. A second trial used an initramfs without builder SSH keys. +Both reached native Arch, Hyprland and the Omarchy shell on existing +userdata. The second boot retained all 1,783 matching modules. With device +package `0.1.1-2`, the 35-second timer loaded the Exynos mailbox before ACPM; +ACPM reported 16 usable channels and the S3908 registered at 35.48 seconds. +The owner had confirmed physical taps and swipes on the earlier prototype; +this kernel's new-boot check confirmed automatic input registration. Camera +inspection confirmed the password screen and keyboard after enabling DPMS. + +This prototype uses ABL's simple framebuffer, not the native DRM panel +path in the other owner's integration. Its private image recipe used +October 2026 headers/AVB metadata and a DECON trigger write. Those settings +are not in the shared descriptor: it retains main's oldest-owner header +values, no AVB footer override or display register write, and an inactive +DTB selector pending public-kernel and cross-owner qualification. + +`tools/phone-smoke` on that boot passed the required boot, storage-guard, +root, kernel-health, USB and session checks: 62 guarded partitions, ext4 on +userdata, no oops/BUG/WARN, and no failed systemd units. It found the +1080x2424 display and Synaptics touch input. GPU had no render node; buttons, +Wi-Fi, Bluetooth, battery/charging, audio, sensors and cameras were absent +or skipped. Clean installation, slot-success marking and those peripherals +remain unqualified. The review's later persistent touch marker is covered +by mocked failure/retry tests, not a new hardware cold-boot claim. + +### Follow-up: recovery and persistent-marker device tests + +On the same second phone and private `g9ea0e19f8dc2` kernel, native aarch64 +package builds ran with checks enabled. Device package `0.1.1-3` passed a +normal reboot: the timer registered touch and removed its marker. A second +reboot with a deliberately retained, synced marker left touch absent and +logged that startup was skipped. With host kernel-log streaming and a +hardware watchdog, explicit `--retry` restored touch and cleared the marker. +A fresh SSH connection succeeded, the watchdog stopped cleanly, and the +camera confirmed the Omarchy lock screen after DPMS enable. Package +`0.1.1-4` then passed native build/check, installation integrity and retry +checks; its modular-touch behavior on the public kernel remains untested. + +The stock-A recovery result above is superseded: all five live A boot-image +hashes matched the retained official October stock images. Selecting A +and requesting recovery reached Android's `No command` screen; recovery +ADB and shell responded, reporting slot A and `CP3A.261005.005`. Recovery +returned to fastboot and B returned to Omarchy without an image write or +userdata reset. This verifies recovery boot, not a full Android boot or +factory reset. As in the repository installer, restoring Android requires +resetting the userdata occupied by Arch; seamless dual boot is not claimed. +No newer metadata has been added to the shared tegu descriptor. + +### Public base and oldest-header control on the second phone + +The public board/touch base at `9386dfaa1d5d1b537ac23e47b65106ee679cfc2a` +built with the tegu fragment boots as +`7.3.0-rc6-omamobile-push1-g9386dfaa1d5d`. Its first five-image B trial +used Android 16 / September 2025 headers without AVB footers and returned +to fastboot: the screen reported `bootfailure`, and `enter-reason` reported +`boot failure`. No precise verification error or kernel crash log was +available, so that attempt alone did not establish a metadata rejection. + +A controlled second trial kept every original image payload byte-identical +and added hash footers using the image tool's AOSP test key, rollback index +**0**, OS version **16**, and security patch **2025-09-05**. The same guarded +B-only flash path then booted Arch on userdata and restored USB/SSH. ACPM +reported 16 usable channels at 0.22 seconds; the guarded timer loaded the +modular touchscreen at 36.1 seconds, registered S3908 input and cleared +its marker. Smoke checks at 97 seconds passed boot, all 62 storage guards, +root, kernel health, USB, touch and buttons. + +This base has no display driver: no framebuffer/DRM connector or graphical +session appeared, Plymouth failed, and the camera retained the Google logo. +Native-display qualification remains separate. Software `reboot-to bootloader` +also returned to normal boot, requiring physical fastboot. These results +show that this newer phone can boot the oldest shared header values with +index-zero footers; they do not qualify footers on the other owner's phone. +The shared descriptor remains unchanged, without an active selector or +footer/trigger overrides. No stock-A image or protected partition was written. + +### Native DRM and package persistence on the second phone + +The pinned display source tree `1175a53bf9b229319aa183b389071add6645eddc` +booted as `7.3.0-rc6-omamobile-push1-gde2e0689c517`, using the same older +headers and index-zero footer policy above, without an initramfs trigger +write. The initial boot exposed a userspace blocker: Arch's +`kernel-modules-hook` cleanup had removed the unowned, preinstalled modules +for the next kernel during the preceding base-kernel boot. Restoring the +matching archive and loading the drivers under log capture and a watchdog +produced a native `card0-DSI-1` connector and Omarchy on camera. The owner +confirmed physical touch response. + +Device package `0.1.1-6` skips that cleanup while installed, enables native +DSI brightness commands following the other Tensor packages, and limits +refresh to the tested 60 Hz. Native aarch64 package builds/checks and +installation integrity checks passed. Backlight restoration passed after +enabling DSI commands. Temporary bring-up blacklists were removed. + +A subsequent reboot retained all 1,782 modules and automatically initialized +native DRM at 3.66 seconds, then touch through the guarded timer. The panel +reported 1080x2424 at 60 Hz; DPMS wake restored the visible lock screen. +At 223 seconds, all required smoke checks passed: boot, 62-partition storage +guard, ext4 root, kernel health, USB and the Hyprland/Omarchy session. Touch +and buttons also passed. The firewall and backlight service were active +or completed successfully. The persistent marker was cleared. + +Remaining limitations: Plymouth's early splash daemon crashes in `strcmp` +with no active console; no GPU render node is present; Wi-Fi, Bluetooth, +battery/charging, audio, sensors and cameras are not qualified by this +candidate. This tests an existing Arch installation, not a clean install. +No boot-success writer was enabled, and shared footer activation still +requires the other owner's boot result. Stock A was not written. diff --git a/device/tegu/kernel.config b/device/tegu/kernel.config new file mode 100644 index 000000000..4694ae357 --- /dev/null +++ b/device/tegu/kernel.config @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# The USB gadget must come up in the initramfs before rootfs modules exist. +CONFIG_PHY_SNPS_EUSB2=y +# The public tegu board supplies that PHY through S2MPG14 over ACPM. +# Keep the whole supply chain available before mounting userdata. +CONFIG_EXYNOS_MBOX=y +CONFIG_EXYNOS_ACPM_PROTOCOL=y +CONFIG_MFD_SEC_ACPM=y +CONFIG_REGULATOR_S2MPS11=y +# Native DRM takes over the TG4C panel; no initramfs trigger write is needed. +CONFIG_DRM_PANEL_GOOGLE_TG4C=m +# Keep touch behind the persistent userspace hang marker. +CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_SPI=m diff --git a/device/tegu/kernel.sources b/device/tegu/kernel.sources new file mode 100644 index 000000000..10fe45cdc --- /dev/null +++ b/device/tegu/kernel.sources @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: MIT +# Public board/touch base: linux-omarchy-mobile PRs #80 and #81. +REPOSITORY https://github.com/W4HO-ham/linux-omarchy-mobile.git +BASE 9386dfaa1d5d1b537ac23e47b65106ee679cfc2a +# Native TG4C display: #88 drivers, #89 panel, #90 display bindings/DTS. +# GPU and CPU DVFS changes are separate qualification steps. +PICK 8770c91fde131ae79d6c547936bdea197b1bec45 +PICK 0caf5f7d50c4eaca94e717b363309e122391bff0 +PICK 3d414e3162f42162477389033bdc9a508e72ee0b +PICK 223b98abf9bef5a2d74688155678052b1464aa46 +PICK ee633720ec86339915ef30a08a78750a6b2e19b3 +PICK 0cfc47a0cb900269e0608bbccd33f33e50ed5c5a +PICK de5d1aa13a4886785b3476ddc8a70887fffd6f70 +TREE 1175a53bf9b229319aa183b389071add6645eddc diff --git a/device/tegu/prepare-kernel b/device/tegu/prepare-kernel new file mode 100755 index 000000000..5e5c04934 --- /dev/null +++ b/device/tegu/prepare-kernel @@ -0,0 +1,44 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Prepare the pinned public tegu source in a new worktree. No build or flash. +# Usage: device/tegu/prepare-kernel EXISTING_KERNEL_REPOSITORY NEW_WORKTREE +set -euo pipefail +[[ $# == 2 ]] || { echo "usage: $0 KERNEL_REPOSITORY NEW_WORKTREE" >&2; exit 2; } +repo=$1 +destination=$2 +manifest=$(dirname -- "${BASH_SOURCE[0]}")/kernel.sources +destination=$(cd -- "$(dirname -- "$destination")" && printf '%s/%s' "$PWD" "$(basename -- "$destination")") +[[ ! -e $destination && ! -L $destination ]] || { echo 'destination already exists; use a new worktree' >&2; exit 1; } +git -C "$repo" rev-parse --git-dir >/dev/null + +repository= base= tree= +picks=() +while read -r key value extra; do + case $key in ''|'#'*) continue ;; esac + [[ -z $extra ]] || { echo 'malformed kernel.sources entry' >&2; exit 1; } + case $key in + REPOSITORY) + [[ -z $repository && $value == https://github.com/*/*.git ]] || exit 1 + repository=$value ;; + BASE|PICK|TREE) + [[ $value =~ ^[0-9a-f]{40}$ ]] || exit 1 + case $key in + BASE) [[ -z $base ]] || exit 1; base=$value ;; + PICK) picks+=("$value") ;; + TREE) [[ -z $tree ]] || exit 1; tree=$value ;; + esac ;; + *) echo "unknown kernel.sources key: $key" >&2; exit 1 ;; + esac +done < "$manifest" +[[ -n $repository && -n $base && -n $tree ]] || exit 1 + +# Keep the caller's branches intact and preserve the public commits' authors. +git -C "$repo" fetch --no-tags "$repository" "$base" "${picks[@]}" +git -C "$repo" worktree add --detach "$destination" "$base" +for commit in "${picks[@]}"; do + git -C "$destination" cherry-pick "$commit" +done +actual=$(git -C "$destination" rev-parse 'HEAD^{tree}') +[[ $actual == "$tree" ]] || { echo 'prepared kernel source tree does not match manifest' >&2; exit 1; } +printf 'Prepared tegu source tree %s\n' "$actual" +echo 'Build using the repository kernel workflow with this KERNEL_DIR and a separate KERNEL_OUT.' diff --git a/packages/omamobile-device-tegu/LICENSE b/packages/omamobile-device-tegu/LICENSE new file mode 100644 index 000000000..aecd59624 --- /dev/null +++ b/packages/omamobile-device-tegu/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-tegu/PKGBUILD b/packages/omamobile-device-tegu/PKGBUILD new file mode 100644 index 000000000..c613fdb71 --- /dev/null +++ b/packages/omamobile-device-tegu/PKGBUILD @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: MIT +pkgname=omamobile-device-tegu +pkgver=$(cat "${startdir:-.}/version") +pkgrel=6 +pkgdesc="Omarchy Mobile boot and touch support for the Google Pixel 9a (tegu)" +arch=(aarch64) +url="https://github.com/derekross/omarchy-mobile" +license=(MIT) +depends=(bash coreutils grep kmod systemd omamobile-keyring) +provides=(omamobile-device) +conflicts=(omamobile-device) +backup=(etc/pacman.d/omamobile-mirrorlist) +install=omamobile-device-tegu.install +makedepends=(gcc) + +build() { + "$startdir/build" "$srcdir/build" +} + +check() { + "$startdir/test/all" +} + +package() { + "$startdir/install" "$pkgdir" "$srcdir/build" +} diff --git a/packages/omamobile-device-tegu/README.md b/packages/omamobile-device-tegu/README.md new file mode 100644 index 000000000..19625dd89 --- /dev/null +++ b/packages/omamobile-device-tegu/README.md @@ -0,0 +1,61 @@ + +# Pixel 9a device package + +Boot and touch userspace policy for `tegu`: guarded storage visibility, the +USB gadget network address, a bounded reboot watchdog, and delayed touch +startup. The package also provides `reboot-to` and the device descriptor. +It skips Arch's old-kernel module cleanup while installed: modules shipped +as tarballs are not pacman-owned, and must survive until their B-slot kernel +boots, as well as remain available for rollback. + +Installing the package does not mark slot B successful or start Wi-Fi, +charging, audio, sensors, cameras, or other peripherals. When the tegu +touchscreen DT child is enabled, a timer loads the touchscreen after early +boot and checks that touch input registered. Before loading any drivers, +it writes and syncs a persistent marker at +`/var/lib/omamobile/tegu-touch-started`. A failed or hung start leaves that +marker behind, so subsequent boots skip the attempt. After inspecting the +previous boot's journal, explicitly retry with +`sudo /usr/lib/omamobile/tegu-touch-start --retry`. Success removes the marker. +The tegu kernel fragment builds touch as a module, and the package blocks +its automatic loading so the marker gates it. The public board needs ACPM +and its PMIC built in for early USB power; on older modular kernels the +service loads those dependencies first. The marker cannot gate built-in +drivers. The delay allows userspace to start; this package provides no USB rescue. + +The packaged descriptor matches main's staged descriptor: Android 16 and +September 2025 header values, no AVB footer override or display register write, +and no active DTB selector. Image building remains gated pending qualification +against the public board DTS in kernel PRs +[#80](https://github.com/derekross/linux-omarchy-mobile/pull/80) and +[#81](https://github.com/derekross/linux-omarchy-mobile/pull/81). +Those trees differ from the private prototype that produced the recorded +hardware results. In particular, the public board also uses ACPM for USB PHY +supplies: its boot ordering must be qualified with this package's module +policy. Boot, native DRM at 60 Hz, touch and module retention have passed +on the second contributor's phone; see `device/tegu/NOTES.md` for the exact +source and image metadata. Cross-owner footer qualification and clean +installation remain pending. This is not yet an installable release. + +## Building the public kernel candidate + +`device/tegu/kernel.sources` pins the public board, touch and native TG4C +display changes and the resulting source-tree hash. From the repository root, +prepare a new worktree without changing an existing kernel branch: + +```sh +device/tegu/prepare-kernel "$HOME/android/mainline/linux" "$HOME/android/mainline/wt-tegu" +KERNEL_DIR="$HOME/android/mainline/wt-tegu" \ +KERNEL_OUT="$HOME/android/mainline/out-tegu" DEVICE=tegu bin/omamobile kernel +``` + +Use the toolchain and AOSP prerequisites in `CONTRIBUTING.md`. If +`omamobile.local.conf` sets `KERNEL_DIR` or `KERNEL_OUT`, update those values +too: that file takes precedence over the environment. The preparation step +fetches only public source commits and checks the resulting tree; it does +not build images or touch the phone. The pinned candidate excludes GPU and +CPU-frequency changes, which need separate qualification. Its intended +display path is native DRM, without a shared framebuffer register write. +The native path has passed on one phone. Shared descriptor activation +awaits the other owner's footer qualification; no newer rollback metadata +is introduced here. diff --git a/packages/omamobile-device-tegu/bin/omamobile-tegu-touch-start b/packages/omamobile-device-tegu/bin/omamobile-tegu-touch-start new file mode 100755 index 000000000..330dbfe2e --- /dev/null +++ b/packages/omamobile-device-tegu/bin/omamobile-tegu-touch-start @@ -0,0 +1,71 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +set -euo pipefail + +# Tests use a scratch root with fake commands, as omamobile-firstboot does. +root=${OMAMOBILE_TEGU_ROOT:-} +if [[ -n $root ]]; then + [[ $root == /* && $root != / && -d $root ]] || exit 2 +fi +base=$root/sys/firmware/devicetree/base +state=$root/var/lib/omamobile +marker=$state/tegu-touch-started + +case ${1:-} in + ''|--retry) ;; + *) echo 'usage: tegu-touch-start [--retry]' >&2; exit 2 ;; +esac +[[ -f $base/compatible ]] || exit 0 +[[ $(tr -d '\0' < "$base/compatible") == *google,zumapro-tegu* ]] || exit 0 + +# Public kernel PR #81 uses /soc; the first-light prototype used /soc@0. +touch_node= +for node in "$base"/soc{,@0}/usi@111d00c0/spi@111d0000/touchscreen@0; do + [[ -d $node ]] && { touch_node=$node; break; } +done +[[ -n $touch_node ]] || exit 0 +# Missing status means enabled in DT. Respect disabled parents as well. +node=$touch_node +while [[ $node != "$base" ]]; do + if [[ -f $node/status ]]; then + case $(tr -d '\0' < "$node/status") in + okay|ok) ;; + *) exit 0 ;; + esac + fi + node=${node%/*} +done + +[[ ${1:-} == --retry ]] && rm -f "$marker" +if [[ -e $marker ]]; then + echo 'tegu touch: previous start did not finish; leaving touch power alone' + echo 'inspect the previous boot log, then run /usr/lib/omamobile/tegu-touch-start --retry' + exit 0 +fi + +# Persist before loading any driver. Keep the marker on failures and hangs +# so the next boot cannot repeat the same hardware operation automatically. +umask 077 +mkdir -p "$state" +date -Is > "$marker" +sync -f "$marker" 2>/dev/null || sync + +# On current mainline kernels the Exynos mailbox is modular. ACPM can probe +# without it, but then all channels are skipped and the PMIC cannot power touch. +modprobe exynos_mailbox +modprobe acpm_protocol +modprobe sec_acpm +# Public boards need ACPM for early USB power; gate the touch driver itself. +modprobe synaptics_tcm + +for ((i = 0; i < 20; i++)); do + if grep -F 'Name="Synaptics TouchComm Touchscreen"' "$root/proc/bus/input/devices" >/dev/null; then + rm -f "$marker" + sync -f "$state" 2>/dev/null || sync + exit 0 + fi + sleep 0.5 +done + +echo 'tegu touchscreen did not bind after ACPM and S2MPG14 started' >&2 +exit 1 diff --git a/packages/omamobile-device-tegu/build b/packages/omamobile-device-tegu/build new file mode 100755 index 000000000..1d7d8eeb2 --- /dev/null +++ b/packages/omamobile-device-tegu/build @@ -0,0 +1,7 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +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-tegu/device.conf b/packages/omamobile-device-tegu/device.conf new file mode 100644 index 000000000..80bc14ffc --- /dev/null +++ b/packages/omamobile-device-tegu/device.conf @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: MIT +# Pixel 9a first-light descriptor. See NOTES.md. +# Data only: this is a staged port, not an installable release. +CODENAME=tegu +NAME="Pixel 9a" +USB_PRODUCT="Pixel 9a (M1)" +SOC=zumapro +COMPATIBLE="google,zumapro-tegu" +PACKAGE=omamobile-device-tegu + +DTB=exynos/google/zumapro-tegu.dtb +# Deliberately no SOC_IDS: this loader uses /soc_compatible matching. +# Stock IPOP candidates: product_id 0x9875, major 0, minor 0/1, pkg_mode 1 +# (NOTES.md). Shared support is reviewed separately in #27. +# SOC_COMPATIBLE="a0-ipop:0x9875:0:0:1 a1-ipop:0x9875:0:1:1" +# Keep both selector keys unset: #27 accepts either one. Activate only +# with the public DTB and required AVB footer values in a later PR. +# Do not use a dummy soc_id or borrow gs201's values to bypass the check. + +DTBO_SOURCE=tegu-m1-overlay.dts +DTBO_BOARD_ID=0x60b06 +DTBO_BOARD_REV=0x10000 +VENDOR_CMDLINE="console=tty0 clk_ignore_unused pd_ignore_unused printk.devkmsg=on bootconfig" +VENDOR_PAGESIZE=0x800 +# Official BP3A init_boot header; both OTA/AVB and stock-A checks: NOTES.md. +OS_VERSION=16.0.0 +OS_PATCH_LEVEL=2025-09 +BOOT_METHOD=android-v4 +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_INIT=/initramfs/init +PANEL_SIZE=1080x2424 +# No BRINGUP_PROBE or SIMPLEFB_TRIG_CON: those gs201 display accesses do +# not apply here. The prototype's G4 trigger handling needs its own change. diff --git a/packages/omamobile-device-tegu/etc/omamobile-mirrorlist b/packages/omamobile-device-tegu/etc/omamobile-mirrorlist new file mode 100644 index 000000000..b272b8fca --- /dev/null +++ b/packages/omamobile-device-tegu/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-tegu/install b/packages/omamobile-device-tegu/install new file mode 100755 index 000000000..6958f3521 --- /dev/null +++ b/packages/omamobile-device-tegu/install @@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Install tested boot and touch policy; boot-success and other peripherals +# require separate device qualification. +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 -Dm755 bin/omamobile-tegu-touch-start "$destination/usr/lib/omamobile/tegu-touch-start" +while IFS= read -r -d '' file; do + install -Dm644 "$file" "$destination/usr/lib/${file#vendor/}" +done < <(find vendor -type f -print0) +install -d "$destination/usr/lib/systemd/system/timers.target.wants" +ln -sfn ../omamobile-tegu-touch-start.timer \ + "$destination/usr/lib/systemd/system/timers.target.wants/omamobile-tegu-touch-start.timer" +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-tegu/LICENSE" +install -Dm644 version "$destination/usr/share/omamobile/device-tegu/version" diff --git a/packages/omamobile-device-tegu/omamobile-device-tegu.install b/packages/omamobile-device-tegu/omamobile-device-tegu.install new file mode 100644 index 000000000..60517fa32 --- /dev/null +++ b/packages/omamobile-device-tegu/omamobile-device-tegu.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-tegu/src/reboot-to.c b/packages/omamobile-device-tegu/src/reboot-to.c new file mode 100644 index 000000000..f79e948ed --- /dev/null +++ b/packages/omamobile-device-tegu/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-tegu/test/all b/packages/omamobile-device-tegu/test/all new file mode 100755 index 000000000..a0b6d0731 --- /dev/null +++ b/packages/omamobile-device-tegu/test/all @@ -0,0 +1,45 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT + +bash -n build install omamobile-device-tegu.install bin/omamobile-tegu-touch-start +test "$(sha256sum device.conf | cut -d' ' -f1)" = \ + "$(sha256sum ../../device/tegu/device.conf | cut -d' ' -f1)" +./build "$tmp/build" +./install "$tmp/root" "$tmp/build" + +for file in \ + usr/bin/reboot-to \ + usr/lib/omamobile/tegu-touch-start \ + usr/lib/modprobe.d/10-omamobile-tegu-touch.conf \ + usr/lib/modprobe.d/omamobile-tegu-display.conf \ + usr/lib/systemd/system/linux-modules-cleanup.service.d/10-omamobile-tegu.conf \ + usr/lib/systemd/system/omamobile-tegu-touch-start.service \ + usr/lib/systemd/system/omamobile-tegu-touch-start.timer \ + usr/lib/udev/rules.d/10-omamobile-storage.rules \ + usr/lib/systemd/network/20-usb-gadget.network \ + usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf \ + usr/lib/systemd/system.conf.d/10-omamobile-reboot-watchdog.conf \ + usr/share/omamobile/device.conf \ + usr/share/omamobile/device-tegu/version \ + etc/pacman.d/omamobile-mirrorlist; do + test -f "$tmp/root/$file" +done +grep -q 'KERNEL=="sda", MODE="0000"' "$tmp/root/usr/lib/udev/rules.d/10-omamobile-storage.rules" +grep -q 'Address=172.16.42.1/24' "$tmp/root/usr/lib/systemd/network/20-usb-gadget.network" +test "$(readlink "$tmp/root/usr/lib/systemd/system/timers.target.wants/omamobile-tegu-touch-start.timer")" = ../omamobile-tegu-touch-start.timer +for absent in \ + usr/lib/omamobile/tegu-clock-floor \ + usr/lib/systemd/system/omamobile-tegu-clock-floor.service \ + 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-camera-start; do + test ! -e "$tmp/root/$absent" +done +test/touch-start +echo 'ok - tegu package stages boot policy and guarded touch startup' diff --git a/packages/omamobile-device-tegu/test/touch-start b/packages/omamobile-device-tegu/test/touch-start new file mode 100755 index 000000000..b9e3878bb --- /dev/null +++ b/packages/omamobile-device-tegu/test/touch-start @@ -0,0 +1,80 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Exercise the persistent hang marker without loading hardware drivers. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +script=$PWD/bin/omamobile-tegu-touch-start +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +export OMAMOBILE_TEGU_ROOT=$tmp/root +export TEST_LOG=$tmp/calls +export TEST_MARKER=$OMAMOBILE_TEGU_ROOT/var/lib/omamobile/tegu-touch-started +base=$OMAMOBILE_TEGU_ROOT/sys/firmware/devicetree/base +input=$OMAMOBILE_TEGU_ROOT/proc/bus/input/devices +mkdir -p "$base" "$tmp/bin" "${input%/*}" +export PATH=$tmp/bin:$PATH +cat > "$tmp/bin/modprobe" <<'EOF' +#!/bin/bash +set -euo pipefail +test -s "$TEST_MARKER" +grep -qx synced "$TEST_LOG" +echo "$1" >> "$TEST_LOG" +[[ ${FAIL_MODULE:-} != "$1" ]] +EOF +cat > "$tmp/bin/sync" <<'EOF' +#!/bin/bash +echo synced >> "$TEST_LOG" +EOF +printf '#!/bin/bash\nexit 0\n' > "$tmp/bin/sleep" +chmod +x "$tmp/bin/"* +printf 'google,zumapro-tegu\0' > "$base/compatible" + +# Both the public /soc path (implicit status) and prototype /soc@0 path. +for soc in soc soc@0; do + touch_node=$base/$soc/usi@111d00c0/spi@111d0000/touchscreen@0 + mkdir -p "$touch_node" + [[ $soc != soc@0 ]] || printf 'okay\0' > "$touch_node/status" + printf 'N: Name="Synaptics TouchComm Touchscreen"\n' > "$input" + : > "$TEST_LOG" + "$script" + test ! -e "$TEST_MARKER" + actual=$(grep -v '^synced$' "$TEST_LOG") + test "$actual" = $'exynos_mailbox\nacpm_protocol\nsec_acpm\nsynaptics_tcm' + rm -r "$base/$soc" +done +echo 'ok - both DT paths start mailbox before ACPM and remove a successful marker' + +mkdir -p "$touch_node" +printf 'disabled\0' > "${touch_node%/*}/status" +: > "$TEST_LOG" +"$script" +test ! -s "$TEST_LOG" +rm "${touch_node%/*}/status" +printf 'google,zuma-husky\0' > "$base/compatible" +"$script" +test ! -s "$TEST_LOG" +printf 'google,zumapro-tegu\0' > "$base/compatible" +echo 'ok - disabled ancestors and other boards do not load drivers' + +if FAIL_MODULE=acpm_protocol "$script"; then + echo 'not ok - driver failure was ignored' >&2; exit 1 +fi +test -s "$TEST_MARKER" +: > "$TEST_LOG" +"$script" > "$tmp/skipped" +test ! -s "$TEST_LOG" +test -s "$TEST_MARKER" +echo 'ok - failure retains the marker and the next start skips all drivers' + +"$script" --retry +test ! -e "$TEST_MARKER" +echo 'ok - explicit retry can recover and clear the marker' + +: > "$input" +: > "$TEST_LOG" +if "$script" 2> "$tmp/timeout"; then + echo 'not ok - missing input was accepted' >&2; exit 1 +fi +test -s "$TEST_MARKER" +grep -q 'did not bind' "$tmp/timeout" +echo 'ok - input timeout also retains the marker' diff --git a/packages/omamobile-device-tegu/vendor/NetworkManager/conf.d/10-omamobile-usb.conf b/packages/omamobile-device-tegu/vendor/NetworkManager/conf.d/10-omamobile-usb.conf new file mode 100644 index 000000000..252de6e15 --- /dev/null +++ b/packages/omamobile-device-tegu/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-tegu/vendor/modprobe.d/10-omamobile-tegu-touch.conf b/packages/omamobile-device-tegu/vendor/modprobe.d/10-omamobile-tegu-touch.conf new file mode 100644 index 000000000..0253c9ecf --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/modprobe.d/10-omamobile-tegu-touch.conf @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT +# Explicitly loaded by the guarded touch service. ACPM is built in when +# required for early USB power; these entries also cover modular kernels. +blacklist acpm_protocol +blacklist sec_acpm +blacklist synaptics_tcm diff --git a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-display.conf b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-display.conf new file mode 100644 index 000000000..ce6eccd16 --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-display.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT +# Native DSI commands provide panel brightness, as on the other Tensor phones. +options gs_dsim_cmd allow_tx=1 +# Keep the qualified refresh rate until 120 Hz is tested on this package. +options gs_decon max_refresh=60 diff --git a/packages/omamobile-device-tegu/vendor/systemd/network/20-usb-gadget.network b/packages/omamobile-device-tegu/vendor/systemd/network/20-usb-gadget.network new file mode 100644 index 000000000..4e30191f6 --- /dev/null +++ b/packages/omamobile-device-tegu/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-tegu/vendor/systemd/system.conf.d/10-omamobile-reboot-watchdog.conf b/packages/omamobile-device-tegu/vendor/systemd/system.conf.d/10-omamobile-reboot-watchdog.conf new file mode 100644 index 000000000..9764faba8 --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system.conf.d/10-omamobile-reboot-watchdog.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile: if shutdown hangs (a driver stuck in remove(), say), let the +# hardware watchdog reset the phone after a minute instead of leaving it +# on the shutdown splash until someone holds Power. systemd's default is +# 10 minutes. Nothing holds the watchdog while the system runs. +[Manager] +RebootWatchdogSec=1min diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/linux-modules-cleanup.service.d/10-omamobile-tegu.conf b/packages/omamobile-device-tegu/vendor/systemd/system/linux-modules-cleanup.service.d/10-omamobile-tegu.conf new file mode 100644 index 000000000..1a70b8ccd --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/linux-modules-cleanup.service.d/10-omamobile-tegu.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT +[Unit] +# Our B-slot kernels use modules tarballs, not pacman-owned kernel packages. +# Keep running, next-boot and rollback modules while this device package exists. +ConditionPathExists=!/usr/share/omamobile/device-tegu/version diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-touch-start.service b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-touch-start.service new file mode 100644 index 000000000..dde2b337f --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-touch-start.service @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MIT +[Unit] +Description=Start Pixel 9a touchscreen power and input +ConditionPathExistsGlob=/sys/firmware/devicetree/base/soc*/usi@111d00c0/spi@111d0000/touchscreen@0 + +[Service] +Type=oneshot +ExecStart=/usr/lib/omamobile/tegu-touch-start diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-touch-start.timer b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-touch-start.timer new file mode 100644 index 000000000..abb45e9fd --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-touch-start.timer @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: MIT +[Unit] +Description=Start Pixel 9a touchscreen after early boot + +[Timer] +OnBootSec=35s +AccuracySec=1s +Unit=omamobile-tegu-touch-start.service + +[Install] +WantedBy=timers.target diff --git a/packages/omamobile-device-tegu/vendor/udev/rules.d/10-omamobile-storage.rules b/packages/omamobile-device-tegu/vendor/udev/rules.d/10-omamobile-storage.rules new file mode 100644 index 000000000..89c02cf30 --- /dev/null +++ b/packages/omamobile-device-tegu/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-tegu/version b/packages/omamobile-device-tegu/version new file mode 100644 index 000000000..17e51c385 --- /dev/null +++ b/packages/omamobile-device-tegu/version @@ -0,0 +1 @@ +0.1.1 diff --git a/tests/all b/tests/all index af0151821..554fd87a0 100755 --- a/tests/all +++ b/tests/all @@ -20,7 +20,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; 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-tegu/test/all; do echo "# $t" "$t" done