Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/omamobile-device-panther/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pkgname=omamobile-device-panther
pkgver=$(cat "${startdir:-.}/version")
pkgrel=1
pkgdesc="Omarchy Mobile support for the Google Pixel 7 (panther): storage guard, USB networking, GPU, haptics, suspend-to-idle, USB after a replug and display brightness"
pkgdesc="Omarchy Mobile support for the Google Pixel 7 (panther): storage guard, USB networking, GPU, haptics, suspend-to-idle, USB after a replug, display brightness, Wi-Fi"
arch=(aarch64)
url="https://github.com/derekross/omarchy-mobile"
license=(MIT)
Expand Down
7 changes: 5 additions & 2 deletions packages/omamobile-device-panther/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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 brings USB back after a replug, 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.
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 brings USB back after a replug, brings up Wi-Fi with the Pixel 7 Pro's files, and gives pacman the same `[omamobile]` repository as the Pixel 7 Pro. It does not drive the modem, the charger, or a camera, and it does not mark a boot slot successful.

| Path | Installs to | What it does |
| --- | --- | --- |
Expand All @@ -9,9 +9,12 @@ Omarchy Mobile's first userspace package for the Google Pixel 7 (codename panthe
| `vendor/udev/rules.d/72-omamobile-feedbackd.rules` | `/usr/lib/udev/rules.d` | Lets feedbackd drive the CS40L26 haptics (`cs40l26_vibra`). Same rule as the Pixel 7 Pro; the driver needs the phone's own `cs40l26.wmfw` (`tools/extract-vendor-firmware -d panther`) |
| `vendor/systemd/network/20-usb-gadget.network` | `/usr/lib/systemd/network` | Sets usb0 to 172.16.42.1/24 after handover |
| `bin/omamobile-usb-rescue`, `vendor/systemd/system/omamobile-usb-rescue.service` | `/usr/bin`, `/usr/lib/systemd/system` (enabled for `multi-user.target`) | Brings USB back after a replug: the MAX77759 opens its USB2 data switch on unplug, and with no Type-C driver nothing closes it. While VBUS is valid, puts the switch back to 0x09 on the chip's I2C bus (USI13, which the board file enables). Reads two registers and writes that one; stands aside once a Type-C driver owns the chip. Same script and unit as the Pixel 7 Pro; needs `i2c-tools` |
| `bin/omamobile-wifi-start`, `vendor/systemd/system/omamobile-wifi.service`, `vendor/modprobe.d/omamobile-wifi.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled for `multi-user.target`), `/usr/lib/modprobe.d` | Brings up Wi-Fi (BCM4389 on PCIe) at boot: the PCIe controller, then brcmfmac, behind a hang marker, so a bring-up that hangs the phone skips Wi-Fi on the next boot (`omamobile-wifi-start --retry`). The modules are blacklisted for autoload so only this guard loads them, and the unit runs only when the DTB enables the controller. Same script, unit and drop-in as the Pixel 7 Pro. The firmware is the phone's own (`tools/extract-vendor-firmware -d panther`) |
| `bin/omamobile-wlan-mac`, `vendor/udev/rules.d/80-omamobile-wlan-mac.rules` | `/usr/bin`, `/usr/lib/udev/rules.d` | Gives the Wi-Fi link the MAC address the bootloader writes into the device tree, before NetworkManager takes it. Same as the Pixel 7 Pro |
| `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/modprobe.d/omamobile-display.conf` | `/usr/lib/modprobe.d` | Lets `gs_dsim_cmd` send DCS packets to the panel (`allow_tx=1`), so the panel driver can set the brightness and turn the display off and on. The driver ships with sending off; brightness passed DISPLAY-PLAN gate D2 on the Pixel 7 |
| `vendor/systemd/sleep.conf.d/10-omamobile.conf` | `/usr/lib/systemd/sleep.conf.d` | Suspend means suspend-to-idle: the kernel offers `deep`, but Linux has no gs201 sleep sequence, and the phone doesn't wake from it. No hibernation. Same drop-in as the Pixel 7 Pro |
| `bin/omamobile-sleep`, `vendor/systemd/system-sleep/omamobile` | `/usr/bin`, `/usr/lib/systemd/system-sleep` (a link to the script) | Unloads Wi-Fi before every suspend and reloads it through the guarded service after, unless `/etc/omamobile/wifi-keep-across-sleep` exists; after a wake that fails in the Wi-Fi device it goes back to unloading for the rest of the boot. Also logs the wake reason and restarts fprintd after a wake. Wi-Fi staying loaded across suspend hasn't run on a Pixel 7. Same script as the Pixel 7 Pro |
| `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 |
Expand All @@ -20,4 +23,4 @@ Omarchy Mobile's first userspace package for the Google Pixel 7 (codename panthe

`./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.
Not in this package: the boot-success marker, the modem, the charger, cameras, and the slot-B image hook. Those stay out until each one has its own runbook.
102 changes: 102 additions & 0 deletions packages/omamobile-device-panther/bin/omamobile-sleep
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# systemd-sleep hook (device/cheetah/SUSPEND-PLAN.md, section 6.2), linked
# from /usr/lib/systemd/system-sleep/omamobile. systemd-sleep runs it as
# omamobile-sleep pre|post suspend|hibernate|hybrid-sleep|suspend-then-hibernate
# Only "systemctl suspend" (through logind) gets here; tests that write
# /sys/power/state directly bypass it.
#
# pre: unload Wi-Fi unless it is allowed to stay up across sleep (the
# brcmfmac D3 handshake for BCM4389 is new; stage S5), and note the
# suspend failure count.
# post: reload Wi-Fi if pre unloaded it (through the hang-safe service), log
# the wake reason, and if the suspend failed in the Wi-Fi device, fall
# back to unloading Wi-Fi for the rest of this boot and reload it now
# (a chip stuck in D3 only comes back with a reload of the stack),
# and restart fprintd if it runs: a fingerprint exchange cut by the
# freeze left it waiting for a reply that never came, and every unlock
# by fingerprint failed until a restart (SUSPEND-PLAN P2).
#
# Wi-Fi stays loaded across sleep only with /etc/omamobile/wifi-keep-across-sleep
# present (create it once stage S5 passes on the running kernel).
set -uo pipefail

keep=/etc/omamobile/wifi-keep-across-sleep
run=/run/omamobile
unloaded=$run/wifi-unloaded-for-sleep
fallback=$run/wifi-sleep-fallback
failcount=$run/sleep-fail-count
wifi_pci=0000:01:00.0

log() { echo "omamobile-sleep: $*"; }

wifi_loaded() { [[ -d /sys/module/brcmfmac || -d /sys/module/pcie_gs201 ]]; }

wifi_unload() {
wifi_loaded || return 0
# brcmfmac_wcc holds brcmfmac; removing it first unbinds the device cleanly.
if modprobe -r brcmfmac_wcc brcmfmac pcie_gs201; then
touch "$unloaded"
log "Wi-Fi unloaded for sleep"
else
log "Wi-Fi unload failed; sleeping with it loaded"
fi
}

wifi_reload() {
[[ -e $unloaded ]] || return 0
rm -f "$unloaded"
# --no-block: we run inside systemd-suspend.service.
systemctl --no-block restart omamobile-wifi.service
log "Wi-Fi reload queued"
}

wake_reason() {
local irq name
irq=$(cat /sys/power/pm_wakeup_irq 2>/dev/null) || irq=
if [[ -n $irq ]]; then
name=$(awk -v i="$irq:" '$1 == i { $1 = ""; print; exit }' /proc/interrupts | tr -s ' ')
log "woken by IRQ $irq:${name:- (unknown)}"
else
log "no wake IRQ recorded"
fi
}

case "${1:-}/${2:-}" in
pre/suspend)
mkdir -p "$run"
cat /sys/power/suspend_stats/fail > "$failcount" 2>/dev/null || true
if [[ -e $keep && ! -e $fallback ]]; then
log "Wi-Fi stays up across sleep ($keep)"
else
wifi_unload
fi
;;
post/suspend)
wifi_reload
wake_reason
# --no-block, as above; try-restart leaves a stopped fprintd alone.
systemctl --no-block try-restart fprintd.service
before=$(cat "$failcount" 2>/dev/null || echo 0)
after=$(cat /sys/power/suspend_stats/fail 2>/dev/null || echo 0)
if ((after > before)); then
dev=$(cat /sys/power/suspend_stats/last_failed_dev 2>/dev/null)
log "suspend failed (last failed device: ${dev:-unknown})"
if [[ $dev == "$wifi_pci" ]]; then
touch "$fallback"
log "Wi-Fi refused D3; unloading it for sleep until the next boot"
# The chip may be stuck in D3: only a reload of the whole stack
# (which power-cycles it) brings it back.
wifi_unload
wifi_reload
fi
fi
;;
pre/*|post/*)
;;
*)
echo "Usage: omamobile-sleep pre|post suspend" >&2
exit 1
;;
esac
exit 0
62 changes: 62 additions & 0 deletions packages/omamobile-device-panther/bin/omamobile-wifi-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# Bring up Wi-Fi at boot, hang-safe (device/cheetah/WIFI-BATTERY-PLAN.md).
#
# Order: the PCIe controller (powers the chip, trains the link), then
# brcmfmac. The chip's DMA buffers come from its restricted DMA pool (DT);
# that keeps driver bugs away from the rest of RAM, but is not a firewall
# against the chip's firmware. A marker file is written and synced before
# anything touches the hardware, and removed once the interface exists. If the
# phone hangs during bring-up, the next boot finds the marker and skips Wi-Fi;
# run "omamobile-wifi-start --retry" to try again.
# omamobile-wifi-start [--retry]
set -uo pipefail

state=/var/lib/omamobile
marker=$state/wifi-bringup-started
controller=/sys/bus/platform/devices/14520000.pcie
pool=/proc/device-tree/reserved-memory/wifi-dma-pool

log() { echo "omamobile-wifi: $*"; }

[[ ${1:-} == --retry ]] && rm -f "$marker"

if [[ -e $marker ]]; then
log "the last bring-up ($(cat "$marker" 2>/dev/null)) never finished; Wi-Fi stays off this boot."
log "after checking the previous boot's log, retry with: omamobile-wifi-start --retry"
exit 0
fi

mkdir -p "$state"
date -Is > "$marker"
sync -f "$marker" 2>/dev/null || sync

finish() { rm -f "$marker"; sync -f "$state" 2>/dev/null || sync; }

# 1. Only with the controller enabled and the DMA pool present (both from DT).
if [[ ! -e $controller ]]; then
log "the PCIe controller is not enabled in this DTB; nothing to do"
finish; exit 0
fi
if [[ ! -d $pool ]] || { [[ -e $pool/status ]] && [[ $(tr -d '\0' < "$pool/status") != okay ]]; }; then
log "no Wi-Fi DMA pool in this DTB; not powering the Wi-Fi chip"
finish; exit 1
fi

# 2. Link, then the driver. Explicit modprobe works despite the autoload blacklist.
modprobe pcie_gs201 || { log "pcie_gs201 failed"; finish; exit 1; }
modprobe brcmfmac || { log "brcmfmac failed"; finish; exit 1; }

# 3. Done once brcmfmac has an interface.
for _ in $(seq 60); do
for dev in /sys/class/net/*; do
if [[ $(readlink -f "$dev/device/driver" 2>/dev/null) == */brcmfmac ]]; then
log "up: ${dev##*/}"
finish; exit 0
fi
done
sleep 0.5
done
log "no Wi-Fi interface after 30 s (the hardware answered; see dmesg)"
finish
exit 1
20 changes: 20 additions & 0 deletions packages/omamobile-device-panther/bin/omamobile-wlan-mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# Give the Wi-Fi interface the phone's real MAC address, as Android does.
# The bootloader writes it into the device tree at every boot
# (/chosen/config/wlan_mac1). brcmfmac doesn't read it there, so without
# this the chip comes up with a random address.
# omamobile-wlan-mac IFACE (run by udev when brcmfmac adds the link)
set -euo pipefail

iface=${1:?Usage: omamobile-wlan-mac IFACE}
source=/proc/device-tree/chosen/config/wlan_mac1
[[ -s $source ]] || exit 0
mac=$(tr -d '\0' < "$source" | tr 'A-F' 'a-f')

# A unicast, globally administered address only, as Google's driver checks.
[[ $mac =~ ^[0-9a-f]{2}(:[0-9a-f]{2}){5}$ ]] || exit 0
(( (16#${mac:0:2} & 3) == 0 )) || exit 0

ip link set dev "$iface" down
ip link set dev "$iface" address "$mac"
23 changes: 19 additions & 4 deletions packages/omamobile-device-panther/install
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/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.
# mark a slot successful or start the modem, the charger, or a camera. Wi-Fi
# starts at boot only through its hang-safe guard (omamobile-wifi.service).
# ./install DESTDIR [BUILDDIR]
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
Expand All @@ -15,9 +16,18 @@ install -Dm644 vendor/systemd/system/omamobile-usb-rescue.service \
install -d "$destination/usr/lib/systemd/system/multi-user.target.wants"
ln -sfn ../omamobile-usb-rescue.service \
"$destination/usr/lib/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service"
for tool in omamobile-wifi-start omamobile-wlan-mac; do
install -Dm755 "bin/$tool" "$destination/usr/bin/$tool"
done
for unit in omamobile-wifi.service; do
install -Dm644 "vendor/systemd/system/$unit" "$destination/usr/lib/systemd/system/$unit"
done
ln -sfn ../omamobile-wifi.service \
"$destination/usr/lib/systemd/system/multi-user.target.wants/omamobile-wifi.service"
install -Dm644 vendor/udev/rules.d/10-omamobile-storage.rules \
"$destination/usr/lib/udev/rules.d/10-omamobile-storage.rules"
for rules in 20-omamobile-gpu-always-on.rules 72-omamobile-feedbackd.rules; do
for rules in 20-omamobile-gpu-always-on.rules 72-omamobile-feedbackd.rules \
80-omamobile-wlan-mac.rules; do
install -Dm644 "vendor/udev/rules.d/$rules" "$destination/usr/lib/udev/rules.d/$rules"
done
install -Dm644 vendor/systemd/network/20-usb-gadget.network \
Expand All @@ -26,8 +36,13 @@ 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/systemd/sleep.conf.d/10-omamobile.conf \
"$destination/usr/lib/systemd/sleep.conf.d/10-omamobile.conf"
install -Dm644 vendor/modprobe.d/omamobile-display.conf \
"$destination/usr/lib/modprobe.d/omamobile-display.conf"
install -Dm755 bin/omamobile-sleep "$destination/usr/bin/omamobile-sleep"
install -d "$destination/usr/lib/systemd/system-sleep"
ln -sfn "$(readlink vendor/systemd/system-sleep/omamobile)" \
"$destination/usr/lib/systemd/system-sleep/omamobile"
for conf in omamobile-display.conf omamobile-wifi.conf; do
install -Dm644 "vendor/modprobe.d/$conf" "$destination/usr/lib/modprobe.d/$conf"
done
install -Dm644 vendor/NetworkManager/conf.d/10-omamobile-usb.conf \
"$destination/usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf"
install -Dm644 device.conf \
Expand Down
Loading