From 76923f48cac8513c9d7f43ae9c2008fd11bece26 Mon Sep 17 00:00:00 2001 From: DarekM <149845949+aninmucek@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:36:16 +0000 Subject: [PATCH 1/6] tools/husky-deadman: run on the Pixel 8a too, with its own current guard The Pixel 8a has the Pixel 8 Pro's MAX77759 on the same bus (10cb0000.i2c), the same fuel gauge power supply and the same SoC watchdog (10060000.watchdog), so the dead-man tool works on it as it is, except for two things: the phone half refused any board but google,zuma-husky, and its current guard (1.7 A) was sized for the 8 Pro's DT charge current of 1.485 A. The phone half now names the board from the device tree's first compatible: google,zuma-husky keeps 1.7 A, google,zuma-akita gets 1.5 A above its DT's 1.32 A, and any other board is still refused before anything is applied. Every other limit, the undo and the watchdog path are unchanged. The desktop half's text no longer says the 8 Pro only. Read-only check on a Pixel 8a: the board function reads "Pixel 8a" and 1500000, and "tools/husky-deadman dump" reads the battery and the charger's registers. Co-Authored-By: Claude Opus 5.5 --- tools/husky-deadman | 9 +++++---- tools/husky-deadman-phone | 29 +++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/tools/husky-deadman b/tools/husky-deadman index 988e1cbf4..91c996eaf 100755 --- a/tools/husky-deadman +++ b/tools/husky-deadman @@ -1,8 +1,9 @@ #!/bin/bash # SPDX-License-Identifier: MIT # -# husky-deadman: run one MAX77759 charger bring-up step on the Pixel 8 Pro -# under a dead-man switch and a battery guard (device/husky/BATTERY-NOTES.md, M5). Ported from +# husky-deadman: run one MAX77759 charger bring-up step on a zuma phone (the +# Pixel 8 Pro or the Pixel 8a) under a dead-man switch and a battery guard +# (device/husky/BATTERY-NOTES.md, M5; device/akita/BRINGUP-M4.md). Ported from # tools/usbc-deadman (cheetah). The step runs DETACHED on the phone # (tools/husky-deadman-phone, started with systemd-run) and undoes itself # unless this script gets back in over a NEW SSH login and confirms, or when @@ -59,12 +60,12 @@ Physical recovery, in order: (the screen goes black and the boot logo returns). Linux on slot B boots with max77759_charger blocked in modprobe.d. 2. Unplug the cable. Force a restart: hold Power + Volume Up for 15 to 30 s - (Power alone does nothing on the 8 Pro under our kernel). It boots slot B + (a short Power press only wakes the screen). It boots slot B again. EVERY reset spends one of slot B's three boot tries; at zero the bootloader falls back to slot A and its first boot wipes userdata. Count the boots since your last "bin/omamobile flash" (it gives B three again), and when one is left, flash your known-good image set instead of resetting. - 3. Whether a reset puts the charger registers back is NOT known for husky: + 3. Whether a reset puts the charger registers back is NOT known: keep the phone on a cable only while you watch it, and check the battery temperature by hand. 4. Fastboot by hand: force a restart as in 2, then Power + Volume Down until diff --git a/tools/husky-deadman-phone b/tools/husky-deadman-phone index 49530c3be..22664e855 100755 --- a/tools/husky-deadman-phone +++ b/tools/husky-deadman-phone @@ -2,8 +2,9 @@ # SPDX-License-Identifier: MIT # # husky-deadman-phone: the phone half of tools/husky-deadman. Runs ONE charger -# bring-up step on the Pixel 8 Pro detached from SSH, under a dead-man switch -# and a battery guard. Ported from tools/usbc-deadman-phone (cheetah); the +# bring-up step on a zuma phone (the Pixel 8 Pro or the Pixel 8a, the same +# MAX77759 on the same bus) detached from SSH, under a dead-man switch and a +# battery guard. Ported from tools/usbc-deadman-phone (cheetah); the # Type-C / USB data-switch parts are left out on purpose: on husky the USB # gadget is built in and nothing here loads tcpci_maxim (that is M6). # @@ -49,11 +50,27 @@ confirm_s=90 grace_s=60 ilim=500000 use_wd=1 soak_s=600 allow_soc=0 gpid= # Guard limits (uV, uA, 0.1 C). The DT caps the float voltage at 4.2 V. -V_TRIP=4300000 V_MIN=3000000 I_TRIP=1700000 T_MAX=450 T_MIN=50 +# I_TRIP is per board (board() below): above the DT's charge current +# (constant-charge-current-max-microamp) with some room. +V_TRIP=4300000 V_MIN=3000000 I_TRIP= T_MAX=450 T_MIN=50 # Preconditions SOC_MIN=30 SOC_MAX=80 START_V_MAX=4150000 START_T_MIN=100 START_T_MAX=400 ILIM_MAX=900000 +# The boards this runs on: BOARD names the phone, I_TRIP its current guard. +# google,zuma-husky Pixel 8 Pro, DT charge current 1.485 A: 1.7 A +# google,zuma-akita Pixel 8a, DT charge current 1.32 A: 1.5 A +board() { + local c + c=$(tr '\0' '\n' < /proc/device-tree/compatible 2>/dev/null | head -1) + case $c in + google,zuma-husky) BOARD="Pixel 8 Pro" I_TRIP=1700000 ;; + google,zuma-akita) BOARD="Pixel 8a" I_TRIP=1500000 ;; + *) BOARD= I_TRIP= ;; + esac +} +BOARD= ; board + log() { local m="husky-deadman: $*" echo "$m" > /dev/kmsg 2>/dev/null @@ -123,8 +140,8 @@ refuse() { log "refusing: $*"; echo "refused: $*" > $D/result; } preflight() { # preflight STEP local v t s - tr '\0' '\n' < /proc/device-tree/compatible 2>/dev/null | grep -qx 'google,zuma-husky' || - { refuse "this is not a Pixel 8 Pro (device tree compatible is not google,zuma-husky)"; return 1; } + [[ -n $BOARD && $I_TRIP =~ ^[0-9]+$ ]] || + { refuse "this is not a Pixel 8 Pro or a Pixel 8a (the device tree's first compatible is not google,zuma-husky or google,zuma-akita)"; return 1; } [[ -n "$BUS" ]] || { refuse "no i2c bus for 10cb0000.i2c"; return 1; } command -v i2cget >/dev/null || { refuse "i2c-tools missing"; return 1; } [[ -d $PSY ]] || { refuse "no battery power supply $PSY (load max17042_battery)"; return 1; } @@ -313,7 +330,7 @@ run() { mkdir -p $D guard_kill rm -f $D/confirm $D/result $D/trip $D/guard.last - log "=== step $step: confirm ${confirm_s}s, grace ${grace_s}s, soak ${soak_s}s, watchdog $use_wd, ilim $ilim; udc $(udc_state); battery v=$(psy voltage_now) t=$(psy temp) soc=$(psy capacity)" + log "=== step $step on the ${BOARD:-unknown board} (current guard ${I_TRIP:-none} uA): confirm ${confirm_s}s, grace ${grace_s}s, soak ${soak_s}s, watchdog $use_wd, ilim $ilim; udc $(udc_state); battery v=$(psy voltage_now) t=$(psy temp) soc=$(psy capacity)" preflight "$step" || return 1 if ((use_wd)); then wd_arm || { refuse "cannot open $WD, held by: $(wd_holders) (stop that, or --no-watchdog)"; return 1; } From 9fb0d2375f4c8d0ed32460013a3b2354ce8d2d73 Mon Sep 17 00:00:00 2001 From: DarekM <149845949+aninmucek@users.noreply.github.com> Date: Fri, 13 Nov 2026 01:42:16 +0000 Subject: [PATCH 2/6] omamobile-device-akita 0.1.4: the USB replug rescue and the MAX77759 blacklist The Pixel 8a's battery chips are the Pixel 8 Pro's, on the same bus, so husky's omamobile-usb-rescue and its unit come over byte for byte, enabled by a wants link, and the test checks they stay husky's. On the 8a an unplug opened the MAX77759's USB2 data switch (0x25:0x93 read 0x00), and the rescue brought the link back on the replug with no reboot (device/akita/BRINGUP-M4.md, M4.4). Without hsi2c_11 in the board file (linux-omarchy-mobile#246) it finds no bus and exits 0. omamobile-max77759.conf has husky's settings: the charger, GPIO, NVMEM and Type-C drivers don't autoload, so the charger runs only under tools/husky-deadman; the gauge and the MFD core do. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-device-akita/PKGBUILD | 4 +- packages/omamobile-device-akita/README.md | 8 ++-- .../bin/omamobile-usb-rescue | 46 +++++++++++++++++++ packages/omamobile-device-akita/install | 8 ++++ packages/omamobile-device-akita/test/all | 36 ++++++++++++++- .../vendor/modprobe.d/omamobile-max77759.conf | 12 +++++ .../omamobile-usb-rescue.service | 1 + .../system/omamobile-usb-rescue.service | 14 ++++++ packages/omamobile-device-akita/version | 2 +- 9 files changed, 123 insertions(+), 8 deletions(-) create mode 100755 packages/omamobile-device-akita/bin/omamobile-usb-rescue create mode 100644 packages/omamobile-device-akita/vendor/modprobe.d/omamobile-max77759.conf create mode 120000 packages/omamobile-device-akita/vendor/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service create mode 100644 packages/omamobile-device-akita/vendor/systemd/system/omamobile-usb-rescue.service diff --git a/packages/omamobile-device-akita/PKGBUILD b/packages/omamobile-device-akita/PKGBUILD index 4d4eecb6f..f39c2682c 100644 --- a/packages/omamobile-device-akita/PKGBUILD +++ b/packages/omamobile-device-akita/PKGBUILD @@ -3,11 +3,11 @@ pkgname=omamobile-device-akita pkgver=$(cat "${startdir:-.}/version") pkgrel=1 -pkgdesc="Omarchy Mobile support for the Google Pixel 8a (akita): storage guard and USB networking" +pkgdesc="Omarchy Mobile support for the Google Pixel 8a (akita): storage guard, USB networking and the USB replug rescue" arch=(aarch64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) -depends=(bash systemd omamobile-keyring) +depends=(bash systemd omamobile-keyring i2c-tools) provides=(omamobile-device) conflicts=(omamobile-device) backup=(etc/pacman.d/omamobile-mirrorlist) diff --git a/packages/omamobile-device-akita/README.md b/packages/omamobile-device-akita/README.md index 102ca29b1..e7f40d9cb 100644 --- a/packages/omamobile-device-akita/README.md +++ b/packages/omamobile-device-akita/README.md @@ -1,14 +1,16 @@ # omamobile-device-akita -Omarchy Mobile's first userspace package for the Google Pixel 8a (codename akita, Tensor G3 / zuma). Like the Pixel 8 Pro's first package, 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. +Omarchy Mobile's first userspace package for the Google Pixel 8a (codename akita, Tensor G3 / zuma). Like the Pixel 8 Pro's first package, 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 keeps the USB link across an unplug, as the Pixel 8 Pro's does. 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 ([BRINGUP-M2](../../device/akita/BRINGUP-M2.md) test 8) | -| `vendor/systemd/network/20-usb-gadget.network` | `/usr/lib/systemd/network` | Sets usb0 to 172.16.42.1/24 after handover, as the last gateway. A replug needs a reboot: this package does not close the MAX77759's USB2 switch again (the Pixel 8 Pro's rescue needs its `hsi2c_11` bus, which akita's board file doesn't have yet). Same file as the Pixel 8 Pro package | +| `vendor/systemd/network/20-usb-gadget.network` | `/usr/lib/systemd/network` | Sets usb0 to 172.16.42.1/24 after handover, as the last gateway. A replug needs the USB rescue below: without it the link can stay dead until a reboot. Same file as the Pixel 8 Pro package | | `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. akita's forced-reset combination under our kernel is untested; on the Pixel 8 Pro it is Power + Volume Up held 15-30 s | | `vendor/NetworkManager/conf.d/10-omamobile-usb.conf` | `/usr/lib/NetworkManager/conf.d` | Keeps NetworkManager off that link. Same file as the Pixel 8 Pro package | | `vendor/systemd/sleep.conf.d/10-omamobile.conf` | `/usr/lib/systemd/sleep.conf.d` | Suspend means suspend-to-idle. The kernel's default on the 8a is `deep` (`/sys/power/mem_sleep` reads `s2idle [deep]`), which Linux can't wake from on zuma yet. No hibernation: there is no swap. The settings are the Pixel 7 Pro's; the test checks. Suspend itself is still untested on Tensor G3 (the Pixel 8 Pro's UFS-PLAN, U6) | +| `bin/omamobile-usb-rescue` + `vendor/systemd/system/omamobile-usb-rescue.service` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link) | Keeps the USB link across an unplug. The MAX77759's Type-C side can open its USB2 data switch (TCPC 0x25, register 0x93) when VBUS drops, and with no Type-C driver nothing closes it again until the bootloader runs, so the phone stays off the bus after a replug. While VBUS is valid the script writes 0x09 back (the only register it writes) and logs every change of the switch, VBUS and the UDC state to the journal. It stands aside once a Type-C driver owns 0x25. It needs `hsi2c_11` in the board file (kernel #246): without it the script says so and exits. Tested on a Pixel 8a ([BRINGUP-M4](../../device/akita/BRINGUP-M4.md), M4.4 and M4.6): after an unplug the switch read 0x00 and the link came back two seconds after the replug, with no reboot. The same bytes as the Pixel 8 Pro package; the test checks | +| `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, so the charger runs only under `tools/husky-deadman`. Blacklist only, so a runbook can still load them by hand. The fuel gauge and the MFD core are not blacklisted. The Pixel 8 Pro's settings (the comment differs); the test checks | | `etc/omamobile-mirrorlist` | `/etc/pacman.d/omamobile-mirrorlist` | Where pacman finds the `[omamobile]` repository. Same file as the Pixel 7 Pro package | | `omamobile-device-akita.install` | pacman hook | Adds `[omamobile]` to `pacman.conf` before `[omarchy]`, once, and keeps the channel a phone follows. Same script as the Pixel 7 Pro package | | `src/reboot-to.c` | `/usr/bin/reboot-to` | Reboot with a reason the bootloader understands (`reboot-to bootloader` reaches fastboot on akita, [BRINGUP-M1](../../device/akita/BRINGUP-M1.md) test 3). Same bytes as the Pixel 7 Pro package; the test checks | @@ -16,4 +18,4 @@ Omarchy Mobile's first userspace package for the Google Pixel 8a (codename akita `./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, the USB replug rescue, the display start and the slot-B image hook. Each one stays out until it has its own runbook. There is no lid drop-in: akita has no hinge. Whether Plymouth needs the Pixel 8 Pro's retain-splash drop-in on simpledrm is still open ([BRINGUP-M2](../../device/akita/BRINGUP-M2.md), open questions). +Not in this package: the boot-success marker, Wi-Fi, the charger, cameras, the display start and the slot-B image hook. Each one stays out until it has its own runbook. There is no lid drop-in: akita has no hinge. Whether Plymouth needs the Pixel 8 Pro's retain-splash drop-in on simpledrm is still open ([BRINGUP-M2](../../device/akita/BRINGUP-M2.md), open questions). diff --git a/packages/omamobile-device-akita/bin/omamobile-usb-rescue b/packages/omamobile-device-akita/bin/omamobile-usb-rescue new file mode 100755 index 000000000..0be80ae5a --- /dev/null +++ b/packages/omamobile-device-akita/bin/omamobile-usb-rescue @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Keep the USB link working across unplugs on the Pixel 8 Pro. Ported from the +# Pixel 7 Pro's omamobile-usb-rescue; the bus here is 10cb0000.i2c (hsi2c_11). +# The MAX77759's Type-C side opens its USB2 data switch (TCPC vendor register +# USBSW_CTRL, 0x93) on unplug, and with no Type-C driver yet nothing closes it +# again, so the phone stays off the bus after a replug until the bootloader +# runs at the next boot. While VBUS is valid, put the switch back to 0x09 +# (D+/D- connected), as the bootloader leaves it. Stands aside once a Type-C +# driver owns the chip. Only reads 0x25:0x93 and 0x69:0xb5 and writes +# 0x25:0x93. It also logs every change of the switch, VBUS and the UDC state +# to the journal (to explain the next loss). +set -uo pipefail + +chg=0x69 tcpc=0x25 +log() { echo "omamobile-usb-rescue: $*"; } + +bus= +for d in /sys/bus/i2c/devices/i2c-*; do + readlink -f "$d" | grep -q 10cb0000.i2c && { bus=${d##*-}; break; } +done +[[ -n $bus ]] || { log "no I2C bus for 10cb0000.i2c"; exit 0; } + +rd() { i2cget -f -y "$bus" "$1" "$2" 2>/dev/null; } +# VBUS as the charger sees it: CHG_DETAILS_00.CHGIN_DTLS (bits 6:5) == 3. +vbus_valid() { local v; v=$(rd $chg 0xb5) || return 1; (( ((v >> 5) & 3) == 3 )); } +tcpm_owns() { [[ -e /sys/bus/i2c/devices/$bus-0025/driver ]]; } +udc_state() { cat /sys/class/udc/*/state 2>/dev/null | head -1; } + +log "watching the USB data switch on I2C bus $bus" +last= +while :; do + if tcpm_owns; then + log "a Type-C driver owns the chip; nothing to do" + exit 0 + fi + sw=$(rd $tcpc 0x93) + if vbus_valid; then vb=1; else vb=0; fi + now="usbsw=${sw:-?} vbus=$vb udc=$(udc_state)" + [[ $now != "$last" ]] && { log "$now"; last=$now; } + if (( vb )) && [[ -n $sw && $sw != 0x09 ]]; then + log "VBUS valid, USBSW_CTRL $sw: closing the data switch" + i2cset -f -y "$bus" $tcpc 0x93 0x09 + fi + sleep 2 +done diff --git a/packages/omamobile-device-akita/install b/packages/omamobile-device-akita/install index 17c516fdc..e5e368303 100755 --- a/packages/omamobile-device-akita/install +++ b/packages/omamobile-device-akita/install @@ -19,6 +19,14 @@ install -Dm644 vendor/NetworkManager/conf.d/10-omamobile-usb.conf \ "$destination/usr/lib/NetworkManager/conf.d/10-omamobile-usb.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-max77759.conf \ + "$destination/usr/lib/modprobe.d/omamobile-max77759.conf" +install -Dm755 bin/omamobile-usb-rescue "$destination/usr/bin/omamobile-usb-rescue" +install -Dm644 vendor/systemd/system/omamobile-usb-rescue.service \ + "$destination/usr/lib/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" install -Dm644 device.conf \ "$destination/usr/share/omamobile/device.conf" install -Dm644 etc/omamobile-mirrorlist \ diff --git a/packages/omamobile-device-akita/test/all b/packages/omamobile-device-akita/test/all index 8dc567dd4..beb78135c 100755 --- a/packages/omamobile-device-akita/test/all +++ b/packages/omamobile-device-akita/test/all @@ -55,6 +55,17 @@ if [[ -f ../omamobile-device-husky/vendor/systemd/network/20-usb-gadget.network ../omamobile-device-husky/vendor/NetworkManager/conf.d/10-omamobile-usb.conf \ || fail "the NetworkManager drop-in drifted from the husky package" pass "the USB link's network files match the husky package" + # The USB replug rescue too: the same chips on the same bus (BRINGUP-M4). + cmp -s bin/omamobile-usb-rescue ../omamobile-device-husky/bin/omamobile-usb-rescue \ + || fail "the USB rescue drifted from the husky package" + cmp -s vendor/systemd/system/omamobile-usb-rescue.service \ + ../omamobile-device-husky/vendor/systemd/system/omamobile-usb-rescue.service \ + || fail "the USB rescue unit drifted from the husky package" + # Its comment names the 8a: the settings are what must match + max=vendor/modprobe.d/omamobile-max77759.conf + [[ $(grep -v '^#' "$max") == "$(grep -v '^#' "../omamobile-device-husky/$max")" ]] \ + || fail "the MAX77759 blacklist's settings drifted from the husky package" + pass "the USB rescue, its unit and the MAX77759 blacklist's settings match the husky package" fi grep -q 'omamobile-keyring' PKGBUILD || fail "pacman needs omamobile-keyring" grep -q '^install=omamobile-device-akita.install$' PKGBUILD \ @@ -79,14 +90,17 @@ for f in usr/bin/reboot-to \ usr/lib/systemd/logind.conf.d/10-omamobile-power-key.conf \ usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf \ usr/lib/systemd/sleep.conf.d/10-omamobile.conf \ + usr/lib/modprobe.d/omamobile-max77759.conf \ + usr/bin/omamobile-usb-rescue \ + usr/lib/systemd/system/omamobile-usb-rescue.service \ usr/share/omamobile/device.conf \ usr/share/omamobile/device-akita/version \ usr/share/licenses/omamobile-device-akita/LICENSE \ etc/pacman.d/omamobile-mirrorlist; do [[ -f $tmp/root/$f ]] || fail "install stages $f" done -[[ $(find "$tmp/root" -type f -o -type l | wc -l) -eq 10 ]] \ - || fail "install stages exactly these ten files: $(cd "$tmp/root" && find . -type f -o -type l | sort | tr '\n' ' ')" +[[ $(find "$tmp/root" -type f -o -type l | wc -l) -eq 14 ]] \ + || fail "install stages exactly these fourteen files (the rescue's wants link is the fourteenth): $(cd "$tmp/root" && find . -type f -o -type l | sort | tr '\n' ' ')" grep -qx 'MemorySleepMode=s2idle' "$tmp/root/usr/lib/systemd/sleep.conf.d/10-omamobile.conf" \ || fail "suspend must use s2idle: the kernel's default is deep, which zuma can't wake from yet" grep -qx 'AllowHibernation=no' "$tmp/root/usr/lib/systemd/sleep.conf.d/10-omamobile.conf" \ @@ -113,6 +127,24 @@ for absent in usr/bin/omamobile-boot-success usr/bin/omamobile-bootctl \ [[ ! -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 the radio, the charger or a camera" + +conf=vendor/modprobe.d/omamobile-max77759.conf +! grep -qE '^install ' "$conf" || fail "the MAX77759 file only blacklists, a manual modprobe must still work" +for m in max77759_charger tcpci_maxim gpio_max77759 nvmem_max77759; do + grep -qx "blacklist $m" "$conf" || fail "$m is kept from autoloading" +done +! grep -qE '^blacklist (max17042_battery|max77759)$' "$conf" || fail "the fuel gauge and the MFD core keep autoloading" +pass "the MAX77759 cell drivers and the Type-C driver are blacklisted, the gauge and the MFD core are not" +bash -n bin/omamobile-usb-rescue || fail "the USB rescue parses" +grep -q '10cb0000.i2c' bin/omamobile-usb-rescue || fail "the USB rescue watches akita's bus (hsi2c_11)" +grep -q 'i2cset -f -y "$bus" $tcpc 0x93 0x09' bin/omamobile-usb-rescue || fail "the USB rescue closes the data switch" +[[ $(grep -c 'i2cset' bin/omamobile-usb-rescue) -eq 1 ]] || fail "the USB rescue writes one register only" +grep -q '^ExecStart=/usr/bin/omamobile-usb-rescue$' vendor/systemd/system/omamobile-usb-rescue.service \ + || fail "the USB rescue unit runs the script" +[[ $(readlink "$tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service") == ../omamobile-usb-rescue.service ]] \ + || fail "the USB rescue is enabled by a wants link" +grep -q 'i2c-tools' PKGBUILD || fail "the USB rescue needs i2cget and i2cset" +pass "the USB replug rescue is installed, enabled by a wants link, and writes one register" [[ ! -e $tmp/root/usr/lib/systemd/logind.conf.d/10-omamobile-lid.conf ]] \ || fail "akita has no lid: no lid drop-in" pass "no lid drop-in" diff --git a/packages/omamobile-device-akita/vendor/modprobe.d/omamobile-max77759.conf b/packages/omamobile-device-akita/vendor/modprobe.d/omamobile-max77759.conf new file mode 100644 index 000000000..b8bbdd87b --- /dev/null +++ b/packages/omamobile-device-akita/vendor/modprobe.d/omamobile-max77759.conf @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: MIT +# MAX77759 on the Pixel 8a, as on the Pixel 8 Pro (device/akita/BRINGUP-M4.md). +# Binding the PMIC (0x66) also creates its charger, GPIO and NVMEM cells, and +# the charger driver programs the charge limits from the battery node, so none +# of the cell drivers may load on their own: the charger runs only under +# tools/husky-deadman. The fuel gauge (max17042_battery) and the MFD core +# (max77759) still autoload. tcpci_maxim would take over the USB-C port we use +# for SSH: it waits for a Type-C step. +blacklist max77759_charger +blacklist tcpci_maxim +blacklist gpio_max77759 +blacklist nvmem_max77759 diff --git a/packages/omamobile-device-akita/vendor/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service b/packages/omamobile-device-akita/vendor/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service new file mode 120000 index 000000000..ccd7fb792 --- /dev/null +++ b/packages/omamobile-device-akita/vendor/systemd/system/multi-user.target.wants/omamobile-usb-rescue.service @@ -0,0 +1 @@ +../omamobile-usb-rescue.service \ No newline at end of file diff --git a/packages/omamobile-device-akita/vendor/systemd/system/omamobile-usb-rescue.service b/packages/omamobile-device-akita/vendor/systemd/system/omamobile-usb-rescue.service new file mode 100644 index 000000000..74f725055 --- /dev/null +++ b/packages/omamobile-device-akita/vendor/systemd/system/omamobile-usb-rescue.service @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: MIT +# Close the USB data switch after each replug (omamobile-usb-rescue). +[Unit] +Description=Reconnect USB after a replug (MAX77759 data switch) +After=systemd-modules-load.service + +[Service] +ExecStartPre=-/usr/bin/modprobe i2c-dev +ExecStart=/usr/bin/omamobile-usb-rescue +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/packages/omamobile-device-akita/version b/packages/omamobile-device-akita/version index b1e80bb24..845639eef 100644 --- a/packages/omamobile-device-akita/version +++ b/packages/omamobile-device-akita/version @@ -1 +1 @@ -0.1.3 +0.1.4 From 59b49d0689e662db1ea5fb72ccbb77054a4c18a7 Mon Sep 17 00:00:00 2001 From: DarekM <149845949+aninmucek@users.noreply.github.com> Date: Fri, 13 Nov 2026 01:42:16 +0000 Subject: [PATCH 3/6] device/akita: the pack-EEPROM and ATL gauge-model overlays Two bring-up overlays from M4, never default. pack-eeprom-test.dtso is husky's: it enables hsi2c_9 so the pack's ID (EEPROM byte 0x17) can be read; this phone's reads 1, the ATL pack. gauge-model-atl.dtso loads Google's atl-a1-1k model into the fuel gauge, generated by tools/gen-gauge-overlay.py from zuma-akita-battery-data.dtsi (android-16.0.0_r0.10), with the header written for akita. Co-Authored-By: Claude Opus 5.5 --- device/akita/overlays/gauge-model-atl.dtso | 38 +++++++++++++++++++++ device/akita/overlays/pack-eeprom-test.dtso | 26 ++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 device/akita/overlays/gauge-model-atl.dtso create mode 100644 device/akita/overlays/pack-eeprom-test.dtso diff --git a/device/akita/overlays/gauge-model-atl.dtso b/device/akita/overlays/gauge-model-atl.dtso new file mode 100644 index 000000000..4d174b7c7 --- /dev/null +++ b/device/akita/overlays/gauge-model-atl.dtso @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Bring-up overlay, never default (BRINGUP-M4, M4.2): load Google's ModelGauge + * m5 model "atl-a1-1k" into the Pixel 8a's fuel gauge. The node is picked by + * the pack's ID, byte 0x17 of its EEPROM: 0 default-a1-0k (Google's fallback + * for an unknown pack), 1 atl-a1-1k, 2 cos-a1-2k, 4 lwn-a1-4k. The 8a this was + * written on reads 1. Generated by tools/gen-gauge-overlay.py from Google's + * public, GPL-2.0-only dts/zuma-akita-battery-data.dtsi (kernel/devices/google/ + * akita, tag android-16.0.0_r0.10, + * https://android.googlesource.com/kernel/devices/google/akita/+/refs/tags/android-16.0.0_r0.10/dts/zuma-akita-battery-data.dtsi): + * maxim,fg-model = that node's 48 u16 table words, maxim,fg-params = its + * parameter words in the order of struct max77759_fg_params (DesignCap 0x08c3, + * 4486 mAh at 2 mAh per unit, what the stock gauge reports). The driver loads + * it only while the gauge reports power-on reset (Status bit 1), then clears + * that bit. The table and the parameters are Copyright 2022 Google LLC, from + * that file. + */ +/dts-v1/; +/plugin/; + +&hsi2c_11 { + fuel-gauge@36 { + maxim,fg-model = /bits/ 16 < + 0xa4a0 0xb520 0xb8b0 0xbbf0 0xbd30 0xbdf0 0xbef0 0xc000 + 0xc1c0 0xc420 0xc820 0xcbb0 0xcef0 0xd270 0xd5a0 0xdd30 + 0x0090 0x0d30 0x0a00 0x0620 0x3c00 0x1c00 0x0960 0x0ce0 + 0x0bf0 0x05f0 0x07d0 0x07f0 0x05d0 0x05b0 0x06f0 0x06f0 + 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 + 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 0x0200 + >; + maxim,fg-params = /bits/ 16 < + 0xf060 0x1438 0x260e 0x4217 0x0090 0x5f00 0x08c3 0x08c3 + 0x3200 0x0230 0x08c3 0xa561 0x2080 0x0e80 0x0580 0x0400 + 0x09a0 0x1002 0x0580 0xed51 0x1eba 0x0014 0x6070 0x1900 + 0x2241 0x0613 0x2d00 0x0400 + >; + }; +}; diff --git a/device/akita/overlays/pack-eeprom-test.dtso b/device/akita/overlays/pack-eeprom-test.dtso new file mode 100644 index 000000000..355c5257b --- /dev/null +++ b/device/akita/overlays/pack-eeprom-test.dtso @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Bring-up probe, never default (BRINGUP-M4, M4.2b): switches on USI9 and + * hsi2c_9, the bus of the battery pack's EEPROM, whose byte 0x17 is the + * battery ID that picks the fuel gauge's model. The EEPROM node itself is in + * the board file (read-only). CMU_PERIC1 and its sysreg are on in the board + * file already; repeating them is harmless. As husky's pack-eeprom-test.dtso. + */ +/dts-v1/; +/plugin/; + +&cmu_peric1 { + status = "okay"; +}; + +&sysreg_peric1 { + status = "okay"; +}; + +&usi9 { + status = "okay"; +}; + +&hsi2c_9 { + status = "okay"; +}; From 77201bea38a28b58e15f8db50d2afe66ef4f856e Mon Sep 17 00:00:00 2001 From: DarekM <149845949+aninmucek@users.noreply.github.com> Date: Fri, 13 Nov 2026 01:42:17 +0000 Subject: [PATCH 4/6] device/akita: BRINGUP-M4, battery and charging The M4 runbook and its results (tests 36 to 47): the gauge with the ATL model, the bootloader's charger state, the USB rescue, charging under tools/husky-deadman on a laptop port and a wall charger (gate h), and the PMIC's interrupt for the RTC alarm. NOTES gets an M4 section, and BRINGUP-M2 notes that M2.7's lost USB link is now confirmed to be the charger's data switch. Co-Authored-By: Claude Opus 5.5 --- device/akita/BRINGUP-M2.md | 2 +- device/akita/BRINGUP-M4.md | 212 +++++++++++++++++++++++++++++++++++++ device/akita/NOTES.md | 12 +++ 3 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 device/akita/BRINGUP-M4.md diff --git a/device/akita/BRINGUP-M2.md b/device/akita/BRINGUP-M2.md index 52a1f426a..83820a05b 100644 --- a/device/akita/BRINGUP-M2.md +++ b/device/akita/BRINGUP-M2.md @@ -320,7 +320,7 @@ Findings: - **The two `exynos-clkout` lines stay "new" on purpose.** The driver had no `google,zuma-pmu` entry in this kernel. linux-omarchy-mobile#209 adds it (merged 2026-11-10, after this kernel was built), so akita's next kernel should stop printing them. `phone-smoke`'s known list is shared by every phone, and on the Pixel 7 Pro and the 9a the same lines mean NFC's clock is missing, so they aren't listed there (#584, closed). - **The other error lines are known:** `unable to open an initial console`, `systemd-gpt-auto-generator` exiting with 1, and `gkr-pam: couldn't unlock the login keyring` (auto-login). - **The lock screen blanks the display after 10 s without input,** whatever `omarchy-toggle-idle` says. That's the lock's own timer, by design. With no touch or key input yet, the screen can only be woken over SSH (`omarchy-shell lock wake`, run as the user). The power key isn't an input device yet: a short press does nothing, and a long press is the PMIC reset. -- **The USB link didn't come back after the host lost power.** The laptop crashed and restarted while the phone ran the M2.6 root. After that, the phone never appeared on USB again, even on a replug, while the display stayed up. Volume Down + Power reached fastboot, which enumerated at once on the same cable and port. This is probably the same as on the Pixel 7 Pro and the 9a, not checked on akita: there the charger IC opens the USB2 data switch when VBUS drops, and with no Type-C driver yet nothing closes it again. A laptop losing power looks like an unplug to the phone. Until that's fixed, the way back is the button combination. +- **The USB link didn't come back after the host lost power.** The laptop crashed and restarted while the phone ran the M2.6 root. After that, the phone never appeared on USB again, even on a replug, while the display stayed up. Volume Down + Power reached fastboot, which enumerated at once on the same cable and port. This is probably the same as on the Pixel 7 Pro and the 9a, not checked on akita: there the charger IC opens the USB2 data switch when VBUS drops, and with no Type-C driver yet nothing closes it again. A laptop losing power looks like an unplug to the phone. Until that's fixed, the way back is the button combination. **Since confirmed on akita** ([BRINGUP-M4](BRINGUP-M4.md), M4.4): after an unplug the switch read 0x00, and `omamobile-usb-rescue` brought the link back on the replug. - **The clock:** first boot read Oct 26 (not today, but not before the release key's creation date, 2026-10-26), so the keyring imported the release key with full trust, and no gpg line says "created in the future". The clock was set from the laptop over SSH afterwards. From then on it survives a reboot: systemd stores the time at shutdown (`/var/lib/systemd/timesync/clock`), so the second boot came up at the last shutdown's time, behind only by the time the phone was off. - **`/sys/power/mem_sleep` still reads `s2idle [deep]`** (the kernel's default). The package's drop-in (`MemorySleepMode=s2idle`) applies when systemd suspends. Suspend wasn't tried, and the auto-sleep toggle (`omamobile-sleep`) is off. - The logs are private (`~/android/reference/akita-m2.7-omarchy-20261110/`). The images, modules and root image are kept as `~/omamobile-kernel/known-good/akita-m2.7-gabcd6aac51cf`. diff --git a/device/akita/BRINGUP-M4.md b/device/akita/BRINGUP-M4.md new file mode 100644 index 000000000..0023f39e7 --- /dev/null +++ b/device/akita/BRINGUP-M4.md @@ -0,0 +1,212 @@ + +# akita M4: battery and charging + +**Status (2026-11-13):** **M4 is complete on the phone.** The fuel gauge reads the 8a's ATL pack with its own model, the bootloader's charger state is recorded, the USB link survives an unplug, Linux charged the battery under the dead-man tool on a laptop port and a wall charger (gate h), and the PMIC's interrupt gives the RTC an alarm ([Results](#results)). + +The kernel side is linux-omarchy-mobile#246 (the gauge and PMIC, the pack's EEPROM and the PMIC's interrupt), open as of 2026-11-13. Until it merges, the published kernel has no `hsi2c_11` on akita, so the gauge, the USB rescue and the dead-man tool have nothing to talk to. + +M3 is complete ([BRINGUP-M3](BRINGUP-M3.md)). + +## Goal + +1. **See the battery:** level, voltage, current and temperature in the status bar and UPower, from the fuel gauge, with the 8a's own battery model. +2. **Know what charges it:** read what the bootloader leaves the charger doing, without changing it. +3. **Charge under Linux, safely:** the charger driver loaded only under a dead-man tool, with a person at the phone, at limits below stock's. + +Out of scope: +- USB-C host mode and VBUS out; +- PD fast charging; +- the PCA9468 direct charger; +- wireless charging; +- suspend. + +Slot A stays stock. Only slot B's boot images and `userdata` are written. + +## What akita inherits + +The 8a's battery hardware is the 8 Pro's: the same chips, at the same addresses, on the same bus, with the same interrupt lines. So most of the work is husky's, merged or documented: + +- **Kernel (merged on `omamobile`):** + - CMU_PERIC1, USI11 and `hsi2c_11` (kernel #163, #175); + - zuma-husky's gauge, PMIC and disabled Type-C nodes (#205); + - the `simple-battery` node. + + The drivers are already in akita's build as modules: `MFD_MAX77759`, `BATTERY_MAX17042`, `CHARGER_MAX77759`, `TYPEC_TCPCI_MAXIM`, `GPIO_MAX77759`, `NVMEM_MAX77759`. +- **Method:** husky's [BATTERY-NOTES](../husky/BATTERY-NOTES.md), especially: + - its runbook (M1 to M5); + - the gauge-model lessons (§5: the fallback model read 10 points high); + - the dead-man tool (§6, `tools/husky-deadman` and `-phone`); + - the charger baseline (§10a). +- **The USB link after an unplug:** husky's `omamobile-usb-rescue` closes the Type-C chip's USB data switch (0x25:0x93) that the charger opens when VBUS drops. That's probably the cause of M2.7's lost link (BRINGUP-M2, not checked on akita), so it belongs here too. +- **The PMIC interrupt:** linux-omarchy-mobile#243 gave husky's S2MPG14 its interrupt (GIC SPI 74, the VGPIO2AP sysreg, `wakeup-source`), so its RTC has an alarm. The 8a's stock tree has the same interrupt (`<0 0x4a 4 0>`, `s2mpg14,wakeup = "enabled"`), and stock's `/proc/interrupts` shows `rtc-alarm0` on it. #243's author suggested akita take the same three lines. + +## Facts + +From G/ (`zuma-akita-battery.dtsi`, `zuma-akita-battery-data.dtsi`, `zuma-akita-charging.dtsi`, `zuma-akita-typec.dtsi`) and R/ (the stock live tree and `/sys/class/power_supply`, captured before the wipe): + +| Item | akita | husky | Source | +| --- | --- | --- | --- | +| Bus | `hsi2c_11` at 400 kHz, pins `gpp21-0`/`gpp21-1` | the same | [V] G/ | +| Bus pins' pull | PULL_NONE in G/'s battery file, but **PULL_UP** in the stock phone's live tree (`pin-pud` 3) | **PULL_UP** in `omamobile` (Google's final husky value, kernel #163) | [V] G/, R/ (M4.0): the same, so akita needs no override | +| Fuel gauge | MAX77759 FG at 0x36, interrupt `gpa7-7` | the same | [V] G/ | +| PMIC | MAX77759 at 0x66 (Google names it `max77729pmic`), interrupt `gpa8-0`; PMIC_ID 0x3b, rev 0x02, OTP 0x31 | the same | [V] G/, M4.3 | +| Charger | 0x69 (the PMIC's dummy client) | the same | [V] G/ | +| Type-C | MAX77759 TCPC at 0x25; SBU mux on `gpa7-5` | 0x25, interrupt `gpa8-3`, disabled | [V] G/; the interrupt is [I] | +| Pack EEPROM | `at,24c08` at 0x50 on `hsi2c_9` (pins `gpp19-4`/`gpp19-5`, no pull) | the same | [V] G/, R/ | +| Gauge sense resistor | 5 mΩ (`maxim,rsense-default = <500>`, in 10 µΩ units) | 5 mΩ | [V] R/ | +| Pack | design 4486 mAh (gauge), `google,chg-battery-capacity = <4404>` | 4950 mAh | [V] R/ `charge_full_design` 4486000; G/ | +| Battery models | four, by the pack's ID (EEPROM byte 0x17): `default-a1-0k` (0), `atl-a1-1k` (1), `cos-a1-2k` (2), `lwn-a1-4k` (4); **this phone's pack reads 1, ATL** | ATL, after reading its EEPROM | [V] G/ `zuma-akita-battery-data.dtsi`, M4.2 | +| Stock's top charge voltage | 4.48 V (`google,fv-max-uv`) | 4.48 V | [V] G/ | +| On stock, plugged in (R/) | 67 %, Charging, 4.05 V, 28.4 C, 89 cycles, `charge_full` 4238 mAh; the main charger at a 1.5 A limit, 5 V | — | [V] R/ | + +**The plan's own limits** are husky's conservative ones, scaled to the 8a: **4.2 V** and **0.3 C (1.32 A)**. Raising either needs a review. + +**Private:** R/'s `power-supplies.txt` includes the battery's serial number. It's never quoted or committed. + +## Design + +1. **One board-file change per step,** each in its own commit. Nodes go in disabled where a step needs them off, and the drivers are blocked in `modprobe.d` until their step, as on husky: + - `simple-battery` with the 8a's values; + - `&hsi2c_11` with the gauge and PMIC, and the Type-C node disabled; + - `&hsi2c_9` with the pack EEPROM. +2. **The gauge model** comes from Google's public `zuma-akita-battery-data.dtsi`, the model matching the pack's ID, never the fallback. husky's §5.6 shows why. +3. **The charger** is loaded only through a dead-man tool. That's `tools/husky-deadman`, which now tells the two phones apart by the device tree and guards each with its own current limit (M4.0). Whether it should be renamed, or akita should get a copy, is the maintainer's choice. It covers: + - preflight checks; + - a 2-second guard on voltage, temperature and current; + - an undo that sets the charger to "system from USB, battery not charged"; + - a watchdog drill. +4. **The USB rescue comes before any charging** (M4.4), so moving the cable to a wall charger and back doesn't cut the laptop off. **The PMIC interrupt** is a small, separate change at the end (M4.7). + +## Runbook + +Each boot needs the human's go and changes one thing. **Each step's results end with slot B's tries left.** Before any step that can reset the phone, B must have at least 2 tries: `--set-active=b` first. + +### M4.0 Laptop only +- **Read in full:** G/'s four battery files, and husky's merged nodes and BATTERY-NOTES §4 to §10a. +- **Settle the bus pull:** PULL_NONE (akita's G/) or PULL_UP (`omamobile`'s, from husky). +- **Read the dead-man tools,** and decide with the maintainer how akita gets one. +- **Back up again:** a fresh read-only backup of the NV partitions (`tools/nv-backup`), as husky did before battery work. + +### M4.1 The bus, read only +- **Change:** `hsi2c_11` enabled, with the gauge and PMIC nodes present, and **every** `max77759*`, `max17042_battery` and `tcpci_maxim` module blocked in `modprobe.d`. +- **Pass:** + - `exynos5-hsi2c` binds; + - clients 0x36 and 0x66 appear, unbound; + - no I2C errors in the log. +- **No I2C probe tools** are run in this step. + +### M4.2 The gauge +- **Change:** load `max17042_battery` by hand, then with the pack's model. +- **Pass:** + - percentage, voltage, current and temperature appear in UPower and the status bar; + - the temperature moves, and isn't stuck at 22.0 C (husky's tell for a missing model); + - the level is plausible against the voltage. +- **The pack ID:** read the EEPROM on `hsi2c_9` (read only) to pick the model. + +### M4.3 The PMIC (MFD), and the charger's state, read only +- **Change:** bind `max77759`. +- **Pass:** + - PMIC_ID reads 0x3b; + - its interrupt lines stay flat. +- **Then record the bootloader's charger state** from the driver's probe and read-only register reads: mode, float voltage, fast-charge current, input limit. **This answers whether the phone is charging today.** + +### M4.4 The USB rescue +- **Why it comes before charging:** every one of husky's charger runs had `omamobile-usb-rescue` running (BATTERY-NOTES §7). Moving the cable from the laptop to a wall charger and back opens the Type-C chip's USB data switch (0x25:0x93). Without the rescue, the link stays down until a reboot, so the laptop can't get back in to confirm the dead-man tool or read its log. This is probably M2.7's lost link too. +- **Change:** husky's `omamobile-usb-rescue` on akita's bus. It needs the MFD from M4.3 to read VBUS (`CHG_DETAILS_00`). While VBUS is valid, it writes 0x09 to 0x25:0x93 whenever the switch isn't 0x09, and logs each change. +- **Pass:** + - unplug and replug the laptop's cable: the link comes back without the buttons, and the journal shows `usbsw=0x00` then `0x09`; + - the same after a few minutes on a wall charger, then back on the laptop. + +### M4.5 The dead-man drill +- **Change:** run the tool's `noop` and `wd-drill` steps, with no charger change. +- **Pass:** both undo cleanly. The drill's watchdog reset costs a try, so check B's tries first. + +### M4.6 The charger, under the dead-man tool (gate h) +- **Change:** load `max77759_charger` through the tool, at 4.2 V / 1.32 A limits, with **a person at the phone** and the USB rescue running. A desktop USB port first, then a wall charger, then back to the laptop to confirm and read the guard's log. +- **Pass:** + - the battery takes current on the wall charger, and the guard never trips; + - the link comes back on the laptop after the wall charger; + - the undo leaves "system from USB, battery not charged"; + - a reboot afterwards comes up the same. + +### M4.7 The PMIC interrupt +- **Change:** the three lines from #243. +- **Pass:** the `s2mpg14-pmic` count stays flat at rest, and `rtcwake -m no -s 60` fires `rtc-alarm0` on time. + +## Risks + +- **Charging is the one step here that can hurt the hardware.** That's why it runs only under the dead-man tool, at limits below stock's, with a person present, and why every register write is read back and undone. +- **The wrong gauge model** reads the level wrong (husky: 10 points high), and the charger's decisions would follow it. Read the pack's ID first. +- **Slot B's tries:** the watchdog drill and reboots spend them. +- **Register access** is to the external MAX77759 over I2C only (`i2cget`/`i2cset`, as husky's tools do), never the SoC's own registers (AGENTS.md §1). + +## Open questions + +- ~~Is the phone charging today?~~ Yes: the bootloader leaves the charger charging, to a 4.35 V float with a 500 mA input limit (test 40). +- ~~Which pack?~~ ATL (`atl-a1-1k`), from its EEPROM (test 38). +- ~~The bus pins' pull?~~ Pulled up, as `omamobile` has it (M4.0). +- **One dead-man tool for husky and akita, or a copy?** It's one tool for now (M4.0); the maintainer chooses. +- ~~Does a reset restore the charger's registers?~~ A reboot through the bootloader does: the charger came back in its usual state after the undo had turned charging off (test 46). +- **The charge current reads higher than the input limit allows** (test 45). Not settled. +- **The charger driver's voltage units:** `constant_charge_voltage_max` reads `4200`, which looks like millivolts where sysfs uses microvolts (test 45). That's `max77759_charger`. + +## Results + +Test numbers continue from [BRINGUP-M3](BRINGUP-M3.md)'s. The logs are private (`~/android/reference/akita-m4.1-bus-20261112/`, `akita-m4.2a-gauge-20261112/`; the dead-man runs in `logs/`, not committed). + +### 2026-11-12: the laptop, the bus and the gauge (M4.0 to M4.2) + +- **M4.0:** + - **The bus pull:** the stock phone's live tree has `hsi2c11-bus` pulled up (`pin-pud` 3), overriding G/'s `PULL_NONE`. That's `zuma-pinctrl.dtsi`'s value, so akita needs no override. + - **The dead-man tool:** its husky-only parts were the compatible check, the names and the 1.7 A current guard (sized for husky's 1.485 A). The bus (`10cb0000.i2c`) and the gauge's power supply are the same. So `tools/husky-deadman` now picks the board from the device tree: the Pixel 8 Pro keeps 1.7 A, the Pixel 8a gets 1.5 A (for its 1.32 A), and any other board is refused. + - **A fresh read-only NV backup** (`tools/nv-backup`), verified. The first try failed safely on SSH timeouts, with no cause found; the second completed. +- **The kernel:** `omamobile` at `2db2bc35b`, plus #246's commits as they were tested: `…g2a02a03a60cf` (the gauge and PMIC), then `…g27a64aba0dc3` (adds the pack's EEPROM). +- **The hold file:** a modprobe file on the phone blacklisted every battery driver for M4.1, and was narrowed one driver per step. + +| # | Test | Seen | Meaning | +| --- | --- | --- | --- | +| 36 | The bus, read only (M4.1) | `10cb0000.i2c` bound to `exynos5-hsi2c` under its USI. Clients 0x36 (`max77759-fg`) and 0x66 (`max77759`) present, unbound. No battery module loaded, no I2C errors, the bus's interrupt at 0. `tools/phone-smoke`: every row ok, 0 new | The bus works; nothing touched the chips | +| 37 | The gauge, loaded by hand, no model (M4.2a) | `max170xx_battery`: 93 %, 4.311 V, about 0 A, **22.0 C and not moving**, design capacity 3000 mAh (the driver's default). UPower shows it | husky's tell for a missing model. 4.31 V on the cable already suggests the bootloader keeps the pack charged | +| 38 | The pack's ID (M4.2b) | With `pack-eeprom-test.dtso`: "1024 byte 24c08 EEPROM, read-only" on `hsi2c_9`. Byte 0x17 read 1, three times | **The ATL pack** (`atl-a1-1k`) | +| 39 | The ATL model (M4.2c) | With `gauge-model-atl.dtso` too: before loading, the gauge's Status had its power-on-reset bit set and its registers were at their defaults. `modprobe max17042_battery`: "battery model loaded (DesignCap 0x8c3)". After: Status 0, design capacity 4486 mAh (stock's), **89 %** (93 % with the default model), 4.312 V, **35.9 to 36.0 C and moving**. UPower 89 %, 20.1 Wh | The gauge reads the 8a's pack with its own model | + +Slot B: 2 tries left. + +### 2026-11-12: the PMIC, the charger's state and the USB rescue (M4.3, M4.4) + +| # | Test | Seen | Meaning | +| --- | --- | --- | --- | +| 40 | The PMIC, loaded by hand (M4.3) | `max77759` binds and creates its charger, GPIO and NVMEM cells, whose drivers stay blacklisted. The same two messages as on husky (the GPIO cell's DMA mask, the NVMEM cell's missing node). Its interrupt lines stay flat. PMIC_ID 0x3b, rev 0x02, OTP 0x31. **The charger, read only:** mode 0x05 (charging, with the buck on), fast charge 0x1d (about 1.93 A), float 0x23 (4.35 V), input limit 0x13 (500 mA). husky's bootloader leaves exactly the same | **The phone has been charging on the cable all along,** under the bootloader's settings | +| 41 | The USB rescue (M4.4): husky's script, unchanged, run as a test unit | **An unplug:** the journal shows `usbsw=0x00 vbus=0`. **The replug, 13 s later:** `usbsw=0x00 vbus=1`, then "closing the data switch", then `usbsw=0x09`; the laptop saw the phone again a second later. SSH works, no reboot | **The cause of M2.7's lost link is confirmed on akita:** the charger side opens the USB2 data switch when VBUS drops | +| 42 | The rescue across a wall charger | Laptop, then a wall charger for 3 minutes, then the laptop. The switch stayed at 0x09 this time, so the rescue wrote nothing, and the link came back | The switch opens only sometimes; the rescue covers it either way | + +Slot B: 2 tries left. + +### 2026-11-12 and 13: the dead-man tool and the charger (M4.5, M4.6, gate h) + +| # | Test | Seen | Meaning | +| --- | --- | --- | --- | +| 43 | `tools/husky-deadman noop`, then `wd-drill` (M4.5) | **noop:** the guard tripped at once, on 4.3125 V against its 4.3 V limit (the bootloader's 4.35 V float), and the tool undid the step and disarmed the watchdog: exit 7. **wd-drill:** the watchdog reset the phone, which came back in 26 s with the charger driver unloaded and the charger at the bootloader's values | The trip path and the watchdog work on akita. The board check names the 8a and uses 1.5 A | +| 44 | `noop` again, at 65 % and 4.06 V (M4.6) | Confirmed over a new SSH login after 6 s, soaked 30 s with the guard at 4.07 V, 34.1 C, +1.0 A, then undone by hand | The confirm path works too | +| 45 | `tools/husky-deadman b3-charger --soak 1500` (gate h) | **The first try refused,** changing nothing: the PMIC driver wasn't loaded. (This boot had it blacklisted; the package's file doesn't.) **After `modprobe max77759`:** the charger driver logged "battery 34.4 C, 4099 mV: band 20-42 C, float 4200 mV, charge 1320000 uA", and the step confirmed after 5 s. **Over 25 minutes:** about 5 minutes on the laptop's port, then a wall charger for 10 minutes, then the laptop again. **The battery went from 65 % to 72 %,** at most 4.165 V and 34 to 35 C, with the current tapering from 1.0 A to 0.75 A near the float. **The guard never tripped.** The link came back by itself after the wall charger. **The undo:** the driver unloaded, mode 0x04 (no charging), the other registers back at the bootloader's values | **Gate (h) passed:** Linux charges the 8a within this battery node's limits | +| 46 | A reboot through fastboot | The bootloader set the charger back to its usual state (mode 0x05, 0x1d, 0x23, 0x13). The battery charging at 0.80 A, 72 %, 35.0 C. No failed units | The undo's "no charging" lasts only until the next reboot | + +Slot B: 2 tries left. + +### 2026-11-13: the PMIC's interrupt (M4.7) + +The kernel: `…g8136602c700c`, #246's third commit added. + +| # | Test | Seen | Meaning | +| --- | --- | --- | --- | +| 47 | The PMIC's interrupt and the RTC alarm | No "no RTC alarm" line; `rtc0` has `wakealarm`. `s2mpg14-pmic` is on GIC 106 (SPI 74) with `rtc-alarm0` under it, both at 0 for about 90 s at rest. `rtcwake -m no -s 60` set 01:08:50; the alarm fired between 01:08:49 and 01:08:54 (`s2mpg14-pmic` 0 to 2, `rtc-alarm0` 0 to 1). No failed units, the 2 known error lines | The same as #243 on the 8 Pro: the RTC has an alarm | + +Slot B: 2 tries left. + +Findings: + +- **The charge current reads higher than the input limit allows.** In test 45 the gauge read about +1.0 A into the battery, with the input limit at 500 mA. At 4.1 V that's about 4.1 W, more than 5 V × 0.5 A. The gauge's sense resistor matches stock's (5 mΩ), and the level rose about as fast as that current says (7 % of 4486 mAh in 25 minutes is about 0.75 A on average). So either the input limit isn't what register 0xc2 reads back as, or the port gives more than the limit. It needs settling before any higher limits. The guard errs on the safe side if the gauge over-reads. +- **The guard keeps only its latest reading,** so there's no record of the wall-charger phase beyond "it never tripped". A reading a minute in its log would fix that. +- **Before `b3-charger`, the PMIC driver must be loaded.** With the package's blacklist it autoloads, as on husky. The test boots here had it blacklisted by hand. +- **The USB link was lost once,** when the rescue wasn't running (its test unit wasn't enabled after a reboot). Holding Volume Down and Power for over a minute power-cycled the phone back into slot B, not into fastboot, and that boot cost a try. With the package, the rescue is enabled at every boot. +- **The kyber message:** Omarchy 4.5's `60-omarchy-io-scheduler.rules` fails to set `kyber` on some of the UFS units with "Device or resource busy" (`sda`, `sdc` and `sdd` in one boot; it varies). udev ignores it, and nothing else is affected. diff --git a/device/akita/NOTES.md b/device/akita/NOTES.md index 590d957d2..0c9398858 100644 --- a/device/akita/NOTES.md +++ b/device/akita/NOTES.md @@ -11,6 +11,18 @@ Sources: - `S/`: Google's GPL zuma SoC device tree, [kernel/devices/google/zuma](https://android.googlesource.com/kernel/devices/google/zuma/+/refs/tags/android-16.0.0_r0.10/dts/) at the same tag. - `H/`: [husky's notes](../husky/NOTES.md) and [descriptor](../husky/device.conf), for what the two zuma phones share. +## 2026-11-13: battery and charging (M4) + +The battery: the fuel gauge, the charger's state, the USB link across an unplug, charging under Linux (gate h) and the PMIC's interrupt. The steps and results are in [BRINGUP-M4](BRINGUP-M4.md). The kernel side is linux-omarchy-mobile#246. + +- **The battery hardware is husky's** [V]: the MAX77759 gauge (0x36) and PMIC (0x66, its charger at 0x69) on `hsi2c_11`, with the same interrupt lines, and the pack's 24c08 EEPROM on `hsi2c_9` (G/, R/). The bus is pulled up, as in `zuma-pinctrl.dtsi` (R/'s live tree overrides G/'s `PULL_NONE`). +- **This phone's pack is the ATL one** [V] (EEPROM byte 0x17 = 1). With Google's `atl-a1-1k` model the gauge reads a real temperature and 4486 mAh. Without a model it reads 22.0 C, stuck, and a level 4 points high. +- **The bootloader charges the phone on the cable** [V]: mode 0x05, a 4.35 V float, a 500 mA input limit, the same values as husky's. A reboot through the bootloader puts them back even after Linux has turned charging off. +- **M2.7's lost USB link is the charger's data switch** [V]: on an unplug the MAX77759 can open its USB2 switch (0x25:0x93), and nothing closes it until the bootloader runs. husky's `omamobile-usb-rescue` closes it again, and the package now ships it. +- **Linux charged the battery** [V] under `tools/husky-deadman`, at 4.2 V and 1.32 A, on a laptop port and a wall charger. The guard never tripped. The charge current reads higher than the 500 mA input limit allows, which isn't settled yet. +- **The PMIC's interrupt** [V] (GIC SPI 74, as stock's) gives `rtc0` its alarm: `rtcwake` fires on time. +- **Omarchy 4.5's kyber rule** fails on some UFS units with "Device or resource busy" (`60-omarchy-io-scheduler.rules`). udev ignores it. + ## 2026-11-11: buttons and touch (M3) The buttons (gate f) and touch (gate g), so the phone is usable by hand. The steps and results are in [BRINGUP-M3](BRINGUP-M3.md). The kernel side is linux-omarchy-mobile#238 (the buttons and `mem_sleep_default=s2idle`, merged), #240 (the S2MPG14 supply setter) and #241 (the touch supplies, the touchscreen and the panel size). From 59e10b0ce6ba2ebd1eb8539124af62a3b1b6270b Mon Sep 17 00:00:00 2001 From: DarekM <149845949+aninmucek@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:47:59 +0000 Subject: [PATCH 5/6] tools/husky-deadman: per-phone recovery text and step lists; akita README and M4.6 stop and rollback From #718's review. The desktop half's recovery text now speaks for each phone: the Pixel 8 Pro's lines as they were (Power + Volume Up for 15 to 30 s; whether a reset restores the charger is not known for husky), and for the Pixel 8a what BRINGUP-M4 measured, with "not tested" where it wasn't. board() also sets the steps each phone may run (both: noop, wd-drill, b3-charger), and preflight refuses any other step before anything is applied, so a step for one phone's hardware can't run on the other. akita's package README says the default boot has no gauge model (22.0 C and a level about 4 points high), and BRINGUP-M4's M4.6 gets its stop conditions (the guard's trips, the exit codes) and its rollback. Co-Authored-By: Claude Opus 5.5 --- device/akita/BRINGUP-M4.md | 2 ++ packages/omamobile-device-akita/README.md | 2 +- tools/husky-deadman | 34 +++++++++++++++-------- tools/husky-deadman-phone | 14 ++++++---- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/device/akita/BRINGUP-M4.md b/device/akita/BRINGUP-M4.md index 0023f39e7..7d659d6f9 100644 --- a/device/akita/BRINGUP-M4.md +++ b/device/akita/BRINGUP-M4.md @@ -128,6 +128,8 @@ Each boot needs the human's go and changes one thing. **Each step's results end - the link comes back on the laptop after the wall charger; - the undo leaves "system from USB, battery not charged"; - a reboot afterwards comes up the same. +- **Stop conditions:** the tool undoes the step by itself when the guard (every 2 s, on the gauge) reads over 4.3 V, over 45 C or under 5 C, more than 1.5 A in or out, or 3 unreadable readings in a row (exit 7), and when no new SSH login confirms within 90 s (exit 3). The person at the phone stops it by unplugging the cable if the phone gets hot. Exit 5 means it refused before applying anything (the reason is printed: the battery outside 30–80 %, over 4.15 V or outside 10–40 C, the stuck 22.0 C of a missing model, the PMIC driver not loaded, `b3-charger` already run in this boot, a step this phone may not run); exit 6 means the apply failed and was undone; exit 4 means no answer from the phone. +- **Rollback:** after a clean soak (exit 0) the step stays applied with **nothing guarding it**, so run `tools/husky-deadman undo b3-charger` at once: it unloads the driver and leaves mode 0x04 (no charging) with the other registers back at the bootloader's values; check with `tools/husky-deadman dump`. If the undo can't unload the driver, it still forces charging off. If the phone stops answering, the watchdog resets it, and the boot comes up with the charger driver blacklisted. A reboot through the bootloader brings back its own charging (test 46). ### M4.7 The PMIC interrupt - **Change:** the three lines from #243. diff --git a/packages/omamobile-device-akita/README.md b/packages/omamobile-device-akita/README.md index e7f40d9cb..788d5451c 100644 --- a/packages/omamobile-device-akita/README.md +++ b/packages/omamobile-device-akita/README.md @@ -18,4 +18,4 @@ Omarchy Mobile's first userspace package for the Google Pixel 8a (codename akita `./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, the display start and the slot-B image hook. Each one stays out until it has its own runbook. There is no lid drop-in: akita has no hinge. Whether Plymouth needs the Pixel 8 Pro's retain-splash drop-in on simpledrm is still open ([BRINGUP-M2](../../device/akita/BRINGUP-M2.md), open questions). +Not in this package: the boot-success marker, Wi-Fi, the charger, cameras, the display start and the slot-B image hook. Each one stays out until it has its own runbook. **The fuel gauge has no battery model by default.** Neither of BRINGUP-M4's overlays (`pack-eeprom-test`, `gauge-model-atl`) is in `device.conf`, so on a kernel with linux-omarchy-mobile#246 the gauge runs on the driver's default model: the bar shows 22.0 C, not moving, and a level about 4 points high ([BRINGUP-M4](../../device/akita/BRINGUP-M4.md), tests 37 and 39). There is no lid drop-in: akita has no hinge. Whether Plymouth needs the Pixel 8 Pro's retain-splash drop-in on simpledrm is still open ([BRINGUP-M2](../../device/akita/BRINGUP-M2.md), open questions). diff --git a/tools/husky-deadman b/tools/husky-deadman index 91c996eaf..ca8be9f7c 100755 --- a/tools/husky-deadman +++ b/tools/husky-deadman @@ -59,17 +59,29 @@ Physical recovery, in order: 1. Wait 2 minutes: the phone undoes the step, then its watchdog resets it (the screen goes black and the boot logo returns). Linux on slot B boots with max77759_charger blocked in modprobe.d. - 2. Unplug the cable. Force a restart: hold Power + Volume Up for 15 to 30 s - (a short Power press only wakes the screen). It boots slot B - again. EVERY reset spends one of slot B's three boot tries; at zero the - bootloader falls back to slot A and its first boot wipes userdata. Count - the boots since your last "bin/omamobile flash" (it gives B three again), - and when one is left, flash your known-good image set instead of resetting. - 3. Whether a reset puts the charger registers back is NOT known: - keep the phone on a cable only while you watch it, and check the - battery temperature by hand. - 4. Fastboot by hand: force a restart as in 2, then Power + Volume Down until - "Fastboot Mode"; flash your known-good image set. + 2. Unplug the cable. Force a restart: + - Pixel 8 Pro: hold Power + Volume Up for 15 to 30 s (Power alone does + nothing on the 8 Pro under our kernel). + - Pixel 8a: not tested. Volume Down + Power held for over a minute + restarted it into slot B once (device/akita/BRINGUP-M4.md, findings). + It boots slot B again. EVERY reset spends one of slot B's three boot + tries; at zero the bootloader falls back to slot A and its first boot + wipes userdata. Count the boots since your last "bin/omamobile flash" + (it gives B three again), and when one is left, flash your known-good + image set instead of resetting. + 3. The charger registers after a reset: + - Pixel 8 Pro: whether a reset puts the charger registers back is NOT + known for husky: keep the phone on a cable only while you watch it, + and check the battery temperature by hand. + - Pixel 8a: a reboot through the bootloader put the bootloader's values + back (BRINGUP-M4, test 46); a forced restart is not tested, so watch + it the same way. + 4. Fastboot by hand: + - Pixel 8 Pro: force a restart as in 2, then Power + Volume Down until + "Fastboot Mode"; flash your known-good image set. + - Pixel 8a: Volume Down + Power reached fastboot once (BRINGUP-M2, + after the host lost power), and once came back into slot B instead + (BRINGUP-M4); how long to hold which key is not known. TXT } diff --git a/tools/husky-deadman-phone b/tools/husky-deadman-phone index 22664e855..059c0524d 100755 --- a/tools/husky-deadman-phone +++ b/tools/husky-deadman-phone @@ -57,19 +57,21 @@ V_TRIP=4300000 V_MIN=3000000 I_TRIP= T_MAX=450 T_MIN=50 SOC_MIN=30 SOC_MAX=80 START_V_MAX=4150000 START_T_MIN=100 START_T_MAX=400 ILIM_MAX=900000 -# The boards this runs on: BOARD names the phone, I_TRIP its current guard. +# The boards this runs on: BOARD names the phone, I_TRIP its current guard, +# STEPS the steps it may run (any other step is refused before anything is +# applied, so a step for one phone's hardware can't run on the other). # google,zuma-husky Pixel 8 Pro, DT charge current 1.485 A: 1.7 A # google,zuma-akita Pixel 8a, DT charge current 1.32 A: 1.5 A board() { local c c=$(tr '\0' '\n' < /proc/device-tree/compatible 2>/dev/null | head -1) case $c in - google,zuma-husky) BOARD="Pixel 8 Pro" I_TRIP=1700000 ;; - google,zuma-akita) BOARD="Pixel 8a" I_TRIP=1500000 ;; - *) BOARD= I_TRIP= ;; + google,zuma-husky) BOARD="Pixel 8 Pro" I_TRIP=1700000 STEPS="noop wd-drill b3-charger" ;; + google,zuma-akita) BOARD="Pixel 8a" I_TRIP=1500000 STEPS="noop wd-drill b3-charger" ;; + *) BOARD= I_TRIP= STEPS= ;; esac } -BOARD= ; board +BOARD= STEPS= ; board log() { local m="husky-deadman: $*" @@ -142,6 +144,8 @@ preflight() { # preflight STEP local v t s [[ -n $BOARD && $I_TRIP =~ ^[0-9]+$ ]] || { refuse "this is not a Pixel 8 Pro or a Pixel 8a (the device tree's first compatible is not google,zuma-husky or google,zuma-akita)"; return 1; } + [[ " $STEPS " == *" $1 "* ]] || + { refuse "step $1 is not one the $BOARD may run ($STEPS)"; return 1; } [[ -n "$BUS" ]] || { refuse "no i2c bus for 10cb0000.i2c"; return 1; } command -v i2cget >/dev/null || { refuse "i2c-tools missing"; return 1; } [[ -d $PSY ]] || { refuse "no battery power supply $PSY (load max17042_battery)"; return 1; } From 8436bfb0b652b2db5ed6ca40c7649ce55730d707 Mon Sep 17 00:00:00 2001 From: DarekM <149845949+aninmucek@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:54:37 +0000 Subject: [PATCH 6/6] device/akita: BRINGUP-M4 test 48, the package's own boot From #718's review: omamobile-device-akita 0.1.4 built and installed on the phone, the hand-made modprobe file and test unit gone, one reboot. The MFD core and the gauge autoload, the charger and Type-C drivers don't, the rescue starts from the package's wants link and closed the data switch after an unplug, and phone-smoke is clean. Co-Authored-By: Claude Opus 5.5 --- device/akita/BRINGUP-M4.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/device/akita/BRINGUP-M4.md b/device/akita/BRINGUP-M4.md index 7d659d6f9..7bab37235 100644 --- a/device/akita/BRINGUP-M4.md +++ b/device/akita/BRINGUP-M4.md @@ -205,6 +205,17 @@ The kernel: `…g8136602c700c`, #246's third commit added. Slot B: 2 tries left. + +### 2026-11-14: the package's own boot (#718's review) + +The kernel: `…g8136602c700c`, as for test 47. The hand-made modprobe file and the test rescue unit were moved off the phone. omamobile-device-akita 0.1.4 was built on the phone from this branch (`tools/phone-install-package`) and installed, then one reboot through fastboot. + +| # | Test | Seen | Meaning | +| --- | --- | --- | --- | +| 48 | The package's blacklist, rescue and dependency, one boot | `pacman -Q`: `omamobile-device-akita 0.1.4-1`, `i2c-tools 4.4-4`. i2c-tools was already installed, as a dependency of `ddcutil` from the Omarchy image, and now lists both as "Required By". `/etc/modprobe.d` has no battery file. **`lsmod`:** `max77759` and `max17042_battery`, and no charger, GPIO, NVMEM or Type-C driver; no `max77759-charger` power supply. **The rescue:** `active (running)` from `/usr/bin`, pulled in by `multi-user.target` through the package's wants link (systemd lists the unit as "disabled", as on husky). **An unplug and a replug:** `usbsw=0x00 vbus=0`, then `usbsw=0x00 vbus=1`, "closing the data switch", and `usbsw=0x09` two seconds later, with no reboot. `tools/phone-smoke` (`59e10b0`): every required row ok, battery ok (89 %, charging under the bootloader, 36 °C), no failed units, the 2 known error lines and 0 new; GPU not ok, as before | The package does what the test boots did by hand | + +Slot B: 2 tries left. + Findings: - **The charge current reads higher than the input limit allows.** In test 45 the gauge read about +1.0 A into the battery, with the input limit at 500 mA. At 4.1 V that's about 4.1 W, more than 5 V × 0.5 A. The gauge's sense resistor matches stock's (5 mΩ), and the level rose about as fast as that current says (7 % of 4486 mAh in 25 minutes is about 0.75 A on average). So either the input limit isn't what register 0xc2 reads back as, or the port gives more than the limit. It needs settling before any higher limits. The guard errs on the safe side if the gauge over-reads.