diff --git a/packages/omamobile-device-husky/README.md b/packages/omamobile-device-husky/README.md index dc8829212..0f8c81840 100644 --- a/packages/omamobile-device-husky/README.md +++ b/packages/omamobile-device-husky/README.md @@ -16,6 +16,7 @@ Omarchy Mobile's first userspace package for the Google Pixel 8 Pro (codename hu | `bin/omamobile-husky-aoc-start` + `vendor/systemd/system/omamobile-husky-aoc.service` + `vendor/modprobe.d/omamobile-husky-aoc.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link), `/usr/lib/modprobe.d` | Starts the AoC audio DSP and the two speaker amplifiers, hang-safe, as the Pixel 7 Pro's `omamobile-aoc-start` does: Trusty, the GSA mailbox, the AoC System MMU, mailbox and core with the firmware load off, the service front ends, the sound card's driver and the CS35L41 amplifiers, then the `aoc.bin` firmware load and a wait for the card. A marker is written and synced before any of it and a start that never returns leaves it behind, so the next boot leaves the AoC off until `omamobile-husky-aoc-start --retry`. The unit is skipped by its condition on a kernel without the AoC node (154b0000.aoc). The modprobe file only blacklists the stack so nothing else loads it out of order; no `speaker_protection` option, the card driver's analog ceiling stays at 10. `aoc.bin` comes from the phone's own vendor partition, never from this package. The kernel side is not merged yet (the Trusty, GSA, AoC and sound card drivers are on the maintainer's list), so today this does nothing on the published kernel | | `vendor/modprobe.d/omamobile-max77759.conf` | `/usr/lib/modprobe.d` | Keeps max77759_charger, gpio_max77759, nvmem_max77759 and tcpci_maxim from autoloading: binding the PMIC creates the charger cell, which programs charge limits from the battery node. Blacklist only, so a runbook can still load them by hand. The fuel gauge and the MFD core are not blacklisted | | `vendor/systemd/system/plymouth-quit.service.d/10-omamobile-retain-splash.conf` | `/usr/lib/systemd/system/plymouth-quit.service.d` | Makes `plymouth quit` keep its last frame on screen (`--retain-splash`) until Hyprland draws, instead of a black screen. The same three unit lines as cheetah and raven (the comments differ): gs-decon has no fbdev console to hand back, and on raven a plain quit hung for 27 s and held the session back. It only does anything with `splash` on the kernel command line, which husky's descriptor gets from #278; without it Plymouth never runs and the drop-in is inert. Booted from the package on a Pixel 8 Pro (2026-11-02, kernel 7.3.0-rc6-omamobile-push1-g5899fec2bd28): Plymouth started at 3.30 s and its quit, with --retain-splash, finished at 4.94 s without a hang | +| `bin/omamobile-bt-addr` + `vendor/systemd/system/omamobile-bt-addr@.service` + `vendor/udev/rules.d/80-omamobile-bt-addr.rules` | `/usr/bin`, `/usr/lib/systemd/system`, `/usr/lib/udev/rules.d` | Gives the BCM4398 its real Bluetooth address from the bootloader's device tree (`/chosen/config/bt_addr`) when the controller appears, powering it on once first, as on the Pixel 9a. The 9a's script, rule and unit with the chip named; the test checks. Without it the controller keeps its placeholder (43:98:D0:..), the same on every 8 Pro. The address is read at run time and never stored in the package. Bluetooth then comes up powered at every boot | | `etc/omamobile-mirrorlist` | `/etc/pacman.d/omamobile-mirrorlist` | Where pacman finds the `[omamobile]` repository. Same file as the Pixel 7 Pro package | | `omamobile-device-husky.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 | diff --git a/packages/omamobile-device-husky/bin/omamobile-bt-addr b/packages/omamobile-device-husky/bin/omamobile-bt-addr new file mode 100755 index 000000000..998bcac65 --- /dev/null +++ b/packages/omamobile-device-husky/bin/omamobile-bt-addr @@ -0,0 +1,69 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Give the Bluetooth controller the phone's real address, as Android does. +# The bootloader writes it into the device tree at every boot +# (/chosen/config/bt_addr); the BCM4398 otherwise comes up with a +# placeholder (43:98:D0:..). +# omamobile-bt-addr hciN (started by udev through omamobile-bt-addr@.service) +set -euo pipefail + +hci=${1:?Usage: omamobile-bt-addr hciN} +index=${hci#hci} +[[ $index =~ ^[0-9]+$ ]] || { echo "not a controller: $hci" >&2; exit 1; } +source=/proc/device-tree/chosen/config/bt_addr +[[ -s $source ]] || exit 0 +addr=$(tr -d '\0' < "$source" | tr 'a-f' 'A-F') + +# A unicast, globally administered address only, like the Wi-Fi one. +[[ $addr =~ ^[0-9A-F]{2}(:[0-9A-F]{2}){5}$ ]] || exit 0 +(( (16#${addr:0:2} & 3) == 0 )) || exit 0 + +# udev starts us when the controller appears, before hci_bcm has finished +# downloading its firmware (about 7 s); it answers info only after that. +for _ in {1..60}; do + info=$(btmgmt --index "$index" info 2> /dev/null || true) + [[ $info == *"current settings:"* ]] && break + sleep 0.5 +done +[[ $info == *"current settings:"* ]] || { echo "$hci never finished its setup" >&2; exit 1; } + +# Set Public Address needs the controller powered off. Set on a controller +# that has never been powered, though, the kernel withdraws the index to +# reconfigure it and it never comes back (seen at every boot). So power it +# on once first, then cycle it around the change, and leave it on. +powered=$(grep -c 'current settings:.*powered' <<< "$info" || true) +if ((!powered)); then + btmgmt --index "$index" power on > /dev/null + info=$(btmgmt --index "$index" info 2> /dev/null || true) + grep -q 'current settings:.*powered' <<< "$info" || { + echo "$hci did not power on before address configuration" >&2 + exit 1 + } +fi +btmgmt --index "$index" power off > /dev/null +btmgmt --index "$index" public-addr "$addr" > /dev/null + +# Set Public Address acknowledges before HCI_CONFIG work finishes. The +# management index is absent until that work has added it again. btmgmt +# can exit zero even for Invalid Index, so wait for a real Read Info reply. +for _ in {1..100}; do + info=$(btmgmt --index "$index" info 2> /dev/null || true) + [[ $info == *"current settings:"* ]] && break + sleep 0.1 +done +[[ $info == *"current settings:"* ]] || { + echo "$hci did not return after address configuration" >&2 + exit 1 +} + +btmgmt --index "$index" power on > /dev/null +info=$(btmgmt --index "$index" info 2> /dev/null || true) +grep -q 'current settings:.*powered' <<< "$info" || { + echo "$hci did not power on after address configuration" >&2 + exit 1 +} +[[ ${info^^} == *"ADDR $addr "* ]] || { + echo "$hci address does not match the bootloader" >&2 + exit 1 +} +exit 0 diff --git a/packages/omamobile-device-husky/install b/packages/omamobile-device-husky/install index 8c258e53f..f2a8c7ed0 100755 --- a/packages/omamobile-device-husky/install +++ b/packages/omamobile-device-husky/install @@ -39,6 +39,11 @@ install -Dm644 vendor/systemd/system/omamobile-usb-rescue.service \ "$destination/usr/lib/systemd/system/omamobile-usb-rescue.service" ln -sfn ../omamobile-usb-rescue.service \ "$destination/usr/lib/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service" +install -Dm755 bin/omamobile-bt-addr "$destination/usr/bin/omamobile-bt-addr" +install -Dm644 vendor/systemd/system/omamobile-bt-addr@.service \ + "$destination/usr/lib/systemd/system/omamobile-bt-addr@.service" +install -Dm644 vendor/udev/rules.d/80-omamobile-bt-addr.rules \ + "$destination/usr/lib/udev/rules.d/80-omamobile-bt-addr.rules" install -Dm644 vendor/systemd/system/plymouth-quit.service.d/10-omamobile-retain-splash.conf \ "$destination/usr/lib/systemd/system/plymouth-quit.service.d/10-omamobile-retain-splash.conf" install -Dm755 bin/omamobile-husky-aoc-start "$destination/usr/bin/omamobile-husky-aoc-start" diff --git a/packages/omamobile-device-husky/test/all b/packages/omamobile-device-husky/test/all index c213e5cb3..6266fb212 100755 --- a/packages/omamobile-device-husky/test/all +++ b/packages/omamobile-device-husky/test/all @@ -77,6 +77,8 @@ for f in usr/bin/reboot-to \ usr/bin/omamobile-usb-rescue \ usr/lib/systemd/system/omamobile-usb-rescue.service \ usr/lib/systemd/system/plymouth-quit.service.d/10-omamobile-retain-splash.conf \ + usr/bin/omamobile-bt-addr usr/lib/systemd/system/omamobile-bt-addr@.service \ + usr/lib/udev/rules.d/80-omamobile-bt-addr.rules \ usr/share/omamobile/device.conf \ usr/share/omamobile/device-husky/version \ usr/share/licenses/omamobile-device-husky/LICENSE \ @@ -243,3 +245,20 @@ net=vendor/systemd/network/20-usb-gadget.network metric=$(sed -n '/^\[Route\]/,/^\[/{s/^Metric=//p}' "$net") [[ ${metric:-0} -gt 700 ]] || fail "usb0's gateway goes after Wi-Fi (600) and mobile data (700)" pass "USB is the last gateway" + +# The Bluetooth address: the 9a's script, rule and unit, with the chip name +# (and the placeholder it describes) changed for the BCM4398. +# Only from the repository, as the cheetah comparisons above. +tegu=../omamobile-device-tegu +if [[ -d $tegu ]]; then + for f in bin/omamobile-bt-addr vendor/systemd/system/omamobile-bt-addr@.service \ + vendor/udev/rules.d/80-omamobile-bt-addr.rules; do + diff <(sed -e s/BCM4383/BCM4398/g -e "s/(43:89:00:00:..)/(43:98:D0:..)/" "$tegu/$f") "$f" >/dev/null || + fail "$f is the 9a's with the BCM4398 named" + done + pass "the Bluetooth address script, rule and unit are the 9a's with the BCM4398 named" +fi +bash -n bin/omamobile-bt-addr || fail "the Bluetooth address script parses" +grep -q 'chosen/config/bt_addr' bin/omamobile-bt-addr || fail "the Bluetooth address comes from the bootloader's DT" +grep -q 'DRIVERS=="hci_uart_bcm"' vendor/udev/rules.d/80-omamobile-bt-addr.rules || fail "the rule matches the BCM UART controller only" +pass "the Bluetooth address is read at run time, with the 9a's script" diff --git a/packages/omamobile-device-husky/vendor/systemd/system/omamobile-bt-addr@.service b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-bt-addr@.service new file mode 100644 index 000000000..bb8cf5fb0 --- /dev/null +++ b/packages/omamobile-device-husky/vendor/systemd/system/omamobile-bt-addr@.service @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: MIT +# Started by 80-omamobile-bt-addr.rules for the BCM4398 Bluetooth controller. +# A service rather than a udev RUN, because udev's sandbox has no Bluetooth +# sockets. +[Unit] +Description=Set the Bluetooth address of %i from the bootloader +Before=bluetooth.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/omamobile-bt-addr %i diff --git a/packages/omamobile-device-husky/vendor/udev/rules.d/80-omamobile-bt-addr.rules b/packages/omamobile-device-husky/vendor/udev/rules.d/80-omamobile-bt-addr.rules new file mode 100644 index 000000000..f48227450 --- /dev/null +++ b/packages/omamobile-device-husky/vendor/udev/rules.d/80-omamobile-bt-addr.rules @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MIT +# Omarchy Mobile: give the BCM4398 Bluetooth controller its real address +# (omamobile-bt-addr@.service). +ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]*", DRIVERS=="hci_uart_bcm", TAG+="systemd", ENV{SYSTEMD_WANTS}+="omamobile-bt-addr@%k.service" diff --git a/packages/omamobile-device-husky/version b/packages/omamobile-device-husky/version index 0e24a92ff..7ac4e5e38 100644 --- a/packages/omamobile-device-husky/version +++ b/packages/omamobile-device-husky/version @@ -1 +1 @@ -0.1.12 +0.1.13