From 023717d9cfe40db5fca1c4bc70035e59225f3e1b Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Tue, 3 Nov 2026 11:05:29 +0000 Subject: [PATCH 01/15] omamobile-modem 0.1.17: run on the Pixel 6 Pro's S5123 The runtime only knew cheetah's S5300. The Pixel 6 Pro (raven, gs101) runs the same stock rfsd and cbd in the chroot, with two differences: - its NV partitions are ext4, not f2fs, so each copy is mounted as what it is (blkid), and f2fs is only loaded when a copy needs it; - props.conf names cheetah, so on a gs101 board the profile checks that the per-phone props.conf says raven and gs101 before any daemon runs, or cbd and rfsd would take the other board's paths. omamobile-device-raven already provides omamobile-modem-policy, so the package installs on raven as it is; nothing here changes what cheetah runs (its copies are f2fs and its board check returns at once). Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-modem/PKGBUILD | 2 +- .../lib/omamobile-modem-nv-overlay | 4 +-- packages/omamobile-modem/modem/props.conf | 1 + packages/omamobile-modem/profiles/modem.conf | 31 ++++++++++++++++--- .../systemd/omamobile-modem.service | 2 +- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/omamobile-modem/PKGBUILD b/packages/omamobile-modem/PKGBUILD index f010fc4bc..67221801e 100644 --- a/packages/omamobile-modem/PKGBUILD +++ b/packages/omamobile-modem/PKGBUILD @@ -3,7 +3,7 @@ pkgname=omamobile-modem pkgver=$(cat "${startdir:-.}/version") pkgrel=1 -pkgdesc="Omarchy Mobile modem runtime for the Pixel 7 Pro: stock rfsd and cbd in a vendor chroot on RAM copies of NV, with a per-phone overlay for the modem's own NV writes" +pkgdesc="Omarchy Mobile modem runtime for the Pixel 7 Pro and 6 Pro: stock rfsd and cbd in a vendor chroot on RAM copies of NV, with a per-phone overlay for the modem's own NV writes" arch=(aarch64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) diff --git a/packages/omamobile-modem/lib/omamobile-modem-nv-overlay b/packages/omamobile-modem/lib/omamobile-modem-nv-overlay index b5cc770a7..266387dea 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-nv-overlay +++ b/packages/omamobile-modem/lib/omamobile-modem-nv-overlay @@ -27,8 +27,8 @@ of the partitions, checked against the off-repo backup's checksums before anything here runs; the overlay is bound to those checksums, so a new backup sets it aside. -Granularity: whole files. rfsd keeps the modem's NV as files in the three f2fs -filesystems (nv_normal.bin and nv_protected.bin, each with a salted MD5 beside +Granularity: whole files. rfsd keeps the modem's NV as files in the three NV +filesystems (f2fs on gs201, ext4 on gs101; nv_normal.bin and nv_protected.bin, each with a salted MD5 beside it), not as raw blocks, so a file is the unit that can be allowed or refused. Store layout (written only by capture): diff --git a/packages/omamobile-modem/modem/props.conf b/packages/omamobile-modem/modem/props.conf index fad706c5f..581a1a6e5 100644 --- a/packages/omamobile-modem/modem/props.conf +++ b/packages/omamobile-modem/modem/props.conf @@ -7,6 +7,7 @@ # What Android's init would have set from the bootloader. The slot is the # one the RAM copy of the modem image is named after (by-name/modem_a). +# cheetah's; a gs101 phone (raven) overrides both in $STATE/props.conf ro.boot.hardware.platform=gs201 ro.hardware=cheetah ro.build.type=user diff --git a/packages/omamobile-modem/profiles/modem.conf b/packages/omamobile-modem/profiles/modem.conf index 8efcb772b..c1dc441fe 100644 --- a/packages/omamobile-modem/profiles/modem.conf +++ b/packages/omamobile-modem/profiles/modem.conf @@ -15,7 +15,8 @@ # since the backup, so take a fresh backup first. # - The chroot gets loop devices of the copies: the modem image read-only # (by-name/modem_a and /mnt/vendor/modem_img), efs, efs_backup and -# modem_userdata read-write (f2fs), and a copy of persist/modem. +# modem_userdata read-write (f2fs on gs201, ext4 on gs101: mounted as +# what the copy is), and a copy of persist/modem. # - The NV overlay (MODEM-PLAN "NV overlay", off unless # /etc/omamobile/modem-nv-overlay-enable exists): the modem's own # writes to allowed files (nv_normal.bin and its checksum, never the @@ -104,6 +105,22 @@ modem_cdt_check() { return 0 } +# The device the daemons are told about: the package's props.conf says +# cheetah (gs201); on a gs101 phone the per-phone $STATE/props.conf, read +# after it, must say raven, or cbd and rfsd would take the other board's +# paths. $1: the file. +modem_device_check() { + local f=$1 hw plat + grep -qa 'google,gs101' /proc/device-tree/compatible 2>/dev/null || return 0 + hw=$(sed -n 's/^ro\.hardware=//p' "$f" 2>/dev/null | tail -1) + plat=$(sed -n 's/^ro\.boot\.hardware\.platform=//p' "$f" 2>/dev/null | tail -1) + if [[ $hw != raven || $plat != gs101 ]]; then + say "a gs101 phone: $f needs ro.hardware=raven and ro.boot.hardware.platform=gs101" + return 1 + fi + return 0 +} + profile_check() { local ok=0 n p d modem_once_check @@ -123,8 +140,7 @@ profile_check() { [[ -s $NV_SUMS ]] || { say "no $NV_SUMS (checksums from the off-repo backup)"; ok=1; } [[ -x $MODEM_CP ]] || { say "no $MODEM_CP"; ok=1; } [[ -x $MODEM_NV_OVERLAY ]] || { say "no $MODEM_NV_OVERLAY"; ok=1; } - grep -qw f2fs /proc/filesystems || modprobe -q f2fs 2>/dev/null || - { say "no f2fs in the kernel (CONFIG_F2FS_FS)"; ok=1; } + modem_device_check "$STATE/props.conf" || ok=1 return $ok } @@ -160,7 +176,7 @@ modem_gnss_nodes() { modem_gnss() { [[ $MODEM_GNSS == 1 ]] && modem_gnss_nodes; } profile_setup() { - local p l mnt=$ROOT/mnt/vendor + local p l t mnt=$ROOT/mnt/vendor mkdir -p "$NV" mount -t tmpfs -o mode=0700,nosuid,nodev,noexec,size=640m modem-nv "$NV" for p in modem_a efs efs_backup modem_userdata persist; do modem_copy "$p"; done @@ -174,8 +190,13 @@ profile_setup() { mount -t ext4 -o ro,noatime,noload "$l" "$mnt/modem_img" modem_autoclear "$l" for p in efs efs_backup modem_userdata; do + t=$(blkid -o value -s TYPE "$NV/$p.img") + [[ $t == ext4 || $t == f2fs ]] || die "$p is $t, not ext4 or f2fs: stopping" + if [[ $t == f2fs ]] && ! grep -qw f2fs /proc/filesystems; then + modprobe -q f2fs || die "no f2fs in the kernel (CONFIG_F2FS_FS)" + fi l=$(modem_loop "$NV/$p.img" rw) - mount -t f2fs -o noatime "$l" "$mnt/$p" + mount -t "$t" -o noatime "$l" "$mnt/$p" modem_autoclear "$l" done # The overlay over the verified copies (it records the base first, then diff --git a/packages/omamobile-modem/systemd/omamobile-modem.service b/packages/omamobile-modem/systemd/omamobile-modem.service index 8f1de2d7f..d7c0670bd 100644 --- a/packages/omamobile-modem/systemd/omamobile-modem.service +++ b/packages/omamobile-modem/systemd/omamobile-modem.service @@ -32,7 +32,7 @@ # captures them every 30 minutes; both do nothing without # /etc/omamobile/modem-nv-overlay-enable. [Unit] -Description=Omarchy Mobile modem (S5300: rfsd and cbd on RAM copies of NV) +Description=Omarchy Mobile modem (S5300 or S5123: rfsd and cbd on RAM copies of NV) Requires=omamobile-modem-inhibit.service After=omamobile-modem-inhibit.service systemd-modules-load.service omamobile-aoc.service omamobile-audio.service Wants=omamobile-modem-nv-overlay.timer From 35847c90d52cd54a48bf5e5e1ce87e2846041426 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Wed, 21 Oct 2026 07:46:05 +0100 Subject: [PATCH 02/15] omamobile-modem 0.1.17: tell the user when the modem crashes On raven the modem's PCIe link died 93 minutes into a boot. Nothing said so: sitd exited, mobile data had no bearer, and the next crash record's kernel lines were only this tool's own umts_boot0 opens, since the dead link's one repeated message had pushed everything else out. - A critical notification in every session when the CP leaves ONLINE: no calls, texts or data until a restart, and where the record is. - The record's kernel lines take the PCIe link driver's lines too, drop CPIF's open/release lines for this tool's ioctls, and fold a repeated message into one line and a count, so the start of a flood survives. Co-Authored-By: Claude Opus 5.5 --- .../omamobile-modem/lib/omamobile-modem-cp | 69 ++++++++++++++++++- packages/omamobile-modem/test/all | 17 +++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-modem/lib/omamobile-modem-cp b/packages/omamobile-modem/lib/omamobile-modem-cp index 9f0166ce5..208d1f28a 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-cp +++ b/packages/omamobile-modem/lib/omamobile-modem-cp @@ -28,6 +28,8 @@ import fcntl import hashlib import os from pathlib import Path +import pwd +import shutil import struct import subprocess import sys @@ -123,6 +125,68 @@ def power_off(): ALLOW.write_text(previous) +# The modem's kernel lines: CPIF and the PCIe link to the modem. Not +# CPIF's open/release lines for umts_boot0: this tool's own ioctls. +KERNEL_KEYS = ('cpif', 'mif:', 'pcie-cp', '.pcie:', 's51xx') +KERNEL_NOISE = ('bootdump_open', 'bootdump_release') + + +def kernel_lines(kernel, keep=150): + """The modem's last kernel lines, a run of the same message folded + into one line with its count (a dead link repeats one message + thousands of times, and would push out how it started).""" + out, last, count = [], None, 0 + for line in kernel: + low = line.lower() + if not any(k in low for k in KERNEL_KEYS) or any(n in low for n in KERNEL_NOISE): + continue + text = line.split('] ', 1)[-1] + if text == last: + count += 1 + continue + if count: + out.append(f' (repeated {count} more times)') + out.append(line) + last, count = text, 0 + if count: + out.append(f' (repeated {count} more times)') + return out[-keep:] + + +def notify(title, body): + """A critical notification in every logged-in session, as root.""" + cmd = os.environ.get('OMAMOBILE_NOTIFY_CMD') + if cmd: + subprocess.run([cmd, title, body], timeout=30, check=False) + return + if os.geteuid() != 0: + return + try: + uids = [int(u) for u in os.listdir('/run/user') if u.isdigit() and int(u) >= 1000] + except OSError: + return + for uid in uids: + bus = f'/run/user/{uid}/bus' + if not os.path.exists(bus): + continue + try: + user = pwd.getpwuid(uid).pw_name + except KeyError: + continue + if shutil.which('omarchy-notification-send'): + send = ['omarchy-notification-send', '-u', 'critical', title, body] + elif shutil.which('notify-send'): + send = ['notify-send', '-u', 'critical', '-a', 'Omarchy Mobile', title, body] + else: + return + env = ['env', f'DBUS_SESSION_BUS_ADDRESS=unix:path={bus}', f'XDG_RUNTIME_DIR=/run/user/{uid}'] + try: + subprocess.run(['runuser', '-u', user, '--'] + env + send, timeout=15, check=False, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + except (OSError, subprocess.SubprocessError): + pass + + def record_crash(): """Before anything else touches the CP, keep what it left (stock's cbd would collect a dump; that path is not used here). Root-only, never in @@ -145,7 +209,7 @@ def record_crash(): entry.append(f'boot log unavailable: {error}') try: kernel = subprocess.run(['dmesg'], capture_output=True, text=True, timeout=10).stdout.splitlines() - entry += [line for line in kernel if 'cpif' in line.lower() or 'mif:' in line][-60:] + entry += kernel_lines(kernel) except (OSError, subprocess.SubprocessError) as error: entry.append(f'kernel log unavailable: {error}') say(entry[0]) @@ -217,6 +281,9 @@ def watch(marker=None): (RUN / 'crashed').write_text(STATES.get(now, str(now)) + '\n') say('the CP left ONLINE: crash recorded; nothing restarts it. ' 'Reboot to recover (the reboot powers it off).') + notify('Cellular stopped', + 'The modem crashed: no calls, texts or mobile data until the phone restarts. ' + f'Details: {CRASH_LOG}') time.sleep(seconds) diff --git a/packages/omamobile-modem/test/all b/packages/omamobile-modem/test/all index 020ea7209..fb45ac140 100755 --- a/packages/omamobile-modem/test/all +++ b/packages/omamobile-modem/test/all @@ -419,5 +419,22 @@ printf 'ro.boot.cdt_hwid=TESTID\n' > "$t/p4"; cdt "$t/p4" || fail "the persist c cdt "$t/missing" && fail "a missing props file is refused" pass "board id required" +# The crash record's kernel lines: the modem's lines only, without this +# tool's own umts_boot0 opens, and a flood folded into one line and a count +python3 - "$cp" <<'PY' || fail "crash record folds a repeated kernel line" +import importlib.machinery, importlib.util, sys +loader = importlib.machinery.SourceFileLoader('cp', sys.argv[1]) +cp = importlib.util.module_from_spec(importlib.util.spec_from_loader('cp', loader)) +loader.exec_module(cp) +log = ['[1.0] gs201-pcie-cp 11920000.pcie: link-down recovery requested', + '[1.1] wlan: unrelated'] +log += [f'[2.{i}] cpif: s51xx_pcie_send_doorbell_int: cmd reg = 0xffff' for i in range(5000)] +log += ['[3.0] cpif: bootdump_open: umts_boot0 (opened 2) by python3', + '[3.1] cpif: link down for 5000 ms and recovery did not clear it: force crash'] +out = cp.kernel_lines(log) +assert out == [log[0], log[2], ' (repeated 4999 more times)', log[-1]], out +assert len(cp.kernel_lines(log[2:3] * 3 + [f'[4.{i}] cpif: x{i}' for i in range(300)])) == 150 +PY +pass "crash record folds a repeated kernel line" # The NV overlay: its own tests (synthetic NV-like files only). test/nv-overlay From 88bfcb4d719dc3b0cedde587bc5ff1d2929392ea Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Tue, 27 Oct 2026 17:38:02 +0000 Subject: [PATCH 03/15] omamobile-modem-sit 0.3.31: end in one line when the CP goes away When the CP crashed under it, sitd died with a traceback through the SIT read (EOFError: SIT channel closed). If the CP is no longer ONLINE after an EOFError, OSError or RuntimeError, it now exits with "the modem went away (...): calls, SMS and data are off until the phone restarts"; omamobile-modem.service has the crash record and the notification. With the CP still ONLINE the error is raised as before. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-modem-sit/lib/service.py | 12 ++++++++++++ .../omamobile-modem-sit/test/test_service.py | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/omamobile-modem-sit/lib/service.py b/packages/omamobile-modem-sit/lib/service.py index cacfc0508..3008a89bf 100644 --- a/packages/omamobile-modem-sit/lib/service.py +++ b/packages/omamobile-modem-sit/lib/service.py @@ -969,6 +969,18 @@ def stop(*_): if not serve_one(service, connection, clients): connection.close() service.broadcast() + except (EOFError, OSError, RuntimeError) as error: + try: + online = cp.online() + except OSError: + online = False + if online: + raise + # The CP crashed under us: omamobile-modem.service records it, tells + # the user and leaves the modem alone until a reboot. Say so in one + # line, not as a traceback through the SIT read. + raise SystemExit('the modem went away (%s): calls, SMS and data are ' + 'off until the phone restarts' % error) from None finally: try: if service and service.live() and not service.release_unconfirmed: diff --git a/packages/omamobile-modem-sit/test/test_service.py b/packages/omamobile-modem-sit/test/test_service.py index 5cd82e4d5..3d6f3af50 100644 --- a/packages/omamobile-modem-sit/test/test_service.py +++ b/packages/omamobile-modem-sit/test/test_service.py @@ -248,6 +248,22 @@ def test_unconfirmed_release_turns_radio_off_and_keeps_call_ownership(self): self.assertTrue(self.service.release_unconfirmed) self.assertEqual(self.service.live(), [call]) self.assertTrue(json.loads((self.root/'active.json').read_text())) + def run_main_with_channel_closed(self,online): + # raven, 2026-10-27: the CP crashed during start-up and sitd died with + # a traceback from the SIT read. + with patch('sys.argv',['omamobile-sitd']), \ + patch.object(app_service.paths,'STATE',self.root), \ + patch.object(app_service.cp,'online',side_effect=[True]+online), \ + patch.object(app_service,'Sit'), \ + patch.object(app_service,'database'), \ + patch.object(app_service,'Service',side_effect=EOFError('SIT channel closed')), \ + patch.object(app_service.signal,'signal'): + app_service.main() + def test_a_crashed_cp_ends_the_service_in_one_line(self): + with self.assertRaises(SystemExit) as raised: self.run_main_with_channel_closed([False]) + self.assertIn('the modem went away (SIT channel closed)',str(raised.exception.code)) + def test_a_closed_channel_with_the_cp_online_still_raises(self): + with self.assertRaises(EOFError): self.run_main_with_channel_closed([True]) class RefusedAudioTests(unittest.TestCase): From df941a88596a54fb53d917fe3c029377ce028452 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Mon, 2 Nov 2026 08:27:21 +0000 Subject: [PATCH 04/15] MODEM-PLAN (raven): section 11, the link dies at system suspend What the modem watcher and sitd changes in this series answer: two suspends with the CP ONLINE, two crashes, and the kernel fixes on test since. Co-Authored-By: Claude Opus 5.5 --- device/raven/MODEM-PLAN.md | 101 +++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/device/raven/MODEM-PLAN.md b/device/raven/MODEM-PLAN.md index 5c2d1dbed..a1c78912f 100644 --- a/device/raven/MODEM-PLAN.md +++ b/device/raven/MODEM-PLAN.md @@ -784,3 +784,104 @@ binary: a single-module `make` had rebuilt nothing): - **Next:** what kills the link (the crash record should now keep it); then recovery without a reboot (a CP power cycle that reaches ONLINE). + +## 11. The link dies at system suspend (2026-10-27, `g97f09c8cfada`) + +- **What happened:** the owner took the phone out unplugged and found no + modem. Boot 13:24: the CP came up clean (NV copies matching the + backup), sitd polled the SIM for 54 minutes (it never reported ready + that boot). At 14:18:45 `omamobile-sleepd` suspended (s2idle, "dark and + locked for 11 s", the first time that boot with no USB host). In the + suspend the PM core logged `pcieport 0001:00:00.0: Unable to change + power state from D0 to D3hot, device inaccessible`, then `D3cold to D0` + and `Data Link Layer Link Active not set in 100 msec`; UFS logged its + `dme-set: attr-id 0x4021 ... failed` in the same resume (the M2.5 + pattern). After resume the link trained (`Gen3 x2`), but CPIF's + `s51xx_pcie_restore_state` couldn't set D0 and the doorbell read + `0xffff` (no bus mastering). At 14:18:58 the dead-link check (§10's + fix) forced the crash: `link down for 8968 ms and recovery did not + clear it`, reason 22, ONLINE to CRASH_EXIT. rfsd's NV validation came + out clean; the watcher recorded the crash (its notification sends no + log line, so the journal can't confirm it). + sitd died with a traceback (`EOFError: SIT channel closed`, from its + bring-up SIM poll). The owner rebooted at 15:11. +- **Not a one-off:** the next boot (15:11) lost the CP the same way at + its first suspend, 54 s after boot (crash at 15:12:28, 5072 ms after + the failed resume), and the 21 suspends after it ran without a modem; + nobody noticed. Two suspends with the CP ONLINE, two crashes. §10's + 93-minute link death may have been the same thing before the dead-link + check existed. +- **Fixes:** + - omamobile-modem 0.1.11: a crash raises a notification ("Cellular + stopped") with the crash record's path; + - omamobile-modem-sit 0.3.5: when the CP is gone, sitd exits with one + line ("the modem went away ...") instead of a traceback. + - During bring-up the watcher also held a logind sleep inhibitor while + the CP was ONLINE. It isn't in the package: it would cost every + phone's battery for a raven kernel problem, and the kernel fixes + below make it unnecessary. +- **Next:** CPIF's system suspend. The root port has to stay reachable + across s2idle, or CPIF has to take the link down itself first (what + its `s5100_pm_notifier` does on stock is still to read). Separately: + why the SIM never became ready at 13:24. + +**Suspend with the modem up, first fix (2026-10-28, `gdd5e1655ef91`).** The +cause, from the kernel log and Google's raven `pcie-exynos-rc.c`: with the +link idle, `cp_link_down()` leaves the CP PCIe controller unclocked and its +PHY isolated, so the PCI core's save, D3hot and restore of the root port in +a system sleep read all ones and leave it marked D3cold; nothing below it +can then be brought to D0. Google's driver takes the PHY out of isolation +in `prepare` and isolates it again in `complete`. `pcie-gs201-cp` now does +the same (PHY inited, root port config allowed, PERST# asserted, endpoint +closed); not published yet. + +- **S2 (one `rtcwake -m freeze -s 20`, modem ONLINE): passed.** No + "inaccessible" on the root port; the link came straight back; CP ONLINE + 35 s later, SIM 2 on LTE with data, no UFS error handler, no crash. The + endpoint logged "Unable to change power state from D3hot to D0, device + inaccessible" at resume (its link was down) without harm. +- **S3 (five cycles, 30 s awake between):** cycles 1 and 2 were woken by the + modem (`cp2ap_wakeup`) after 2 and 5 s, CP ONLINE after each. Cycle 3 + slept **558 s** (the RTC alarm didn't fire; IRQ 111, the PMIC, woke it) + and the CP was still ONLINE at resume, but the first poweron after it got + `s51xx_pcie_restore_state: Can't set D0`, doorbells read `cmd reg 0xffff`, + and the dead-link check crashed the CP 21 s after resume. Cycles 4-5 ran + with the CP down. No UFS errors in any cycle. +- **Next:** the endpoint. The PCI core also suspends and resumes it with the + link down, fails, and keeps a wrong power state; after a long sleep CPIF's + D0 restore trips over it. Read the PCI core's and CPIF's D0 paths, keep the + endpoint's bookkeeping sane across the sleep (or restore it before CPIF's + restore), then S2/S3 again with a long sleep. + +**Second fix and the soak (2026-10-28, `g378edcff3ed7`).** `pcie-gs201-cp` +now also waits, on every poweron after the first, for the endpoint's Vendor +ID (every 10 ms, up to 1 s) before its state is restored (not published +yet), on the theory that after a long sleep the endpoint wasn't ready +0.1 ms after the link came up (PCIe r6.0 sec 6.6.1). + +- Two 300 s sleeps, three of 20 s: all CP ONLINE 60 s later; the modem woke + the first after 77 s, the PMIC the second after 165 s. +- Two 900 s sleeps asked: the modem woke the phone after 8 and 6 s. +- **Soak, 30 min of back-to-back sleeps (5 s awake between): passed.** 18 + sleeps in 2387 s, about 2234 s asleep, three of about 10 min (591, 591, + 600 s); woken by the modem 14 times, the RTC 3, the power key once. CP + ONLINE after every wake, no crash, no UFS error handler, both SIMs + registered. The new wait never logged (the endpoint answered at once + every time), so the 558 s failure didn't recur but the wait is not proven + to be what prevents it; it stays as a guard. +- **Trial in daily use from 2026-10-28 13:25:** suspend with the modem up + and no sleep inhibitor. Watch for "Cellular stopped" and + `/var/log/omamobile/modem-crashes.log`. + +**The trial's first crash, a race (2026-10-28 14:09, `gdcdd42db122d`).** +During the drain baseline (17 suspends in 20 min, POWER-PLAN) the root +port failed as before the hooks ("Unable to change power state from D0 to +D3hot, device inaccessible"), right after a "PHY isolated": the link went +down between prepare and the PCI core's suspend of the root port, and +cp_link_down() isolated the PHY again. CPIF's restore then got "Can't set +D0" and the dead-link check crashed the CP. The endpoint wait logged +nothing (the endpoint answered at once), so the earlier "slow endpoint" +theory is ruled out. The fix (not published yet): from prepare to complete, +cp_link_down() takes the link down but keeps the PHY inited and the root +port reachable; complete isolates it. On the phone as `g244c690c1fd1`, the +trial continuing. From 65d80bb86ee27a7f970594ad44de38cddeaec629 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Tue, 3 Nov 2026 14:04:50 +0000 Subject: [PATCH 05/15] omamobile-modem 0.1.17: check the gs101 board named by its compatible modem_device_check required ro.hardware=raven on every gs101 phone, so a Pixel 6 (google,gs101-oriole) or 6a (google,gs101-bluejay) with its own props.conf would have been refused. The board now comes from the first google,gs101- compatible, and props.conf must name that board with platform gs101. Other SoCs return at once, as before. Review of #389. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-modem/modem/props.conf | 2 +- packages/omamobile-modem/profiles/modem.conf | 15 +++++++++------ packages/omamobile-modem/test/all | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/packages/omamobile-modem/modem/props.conf b/packages/omamobile-modem/modem/props.conf index 581a1a6e5..da1bf5d2d 100644 --- a/packages/omamobile-modem/modem/props.conf +++ b/packages/omamobile-modem/modem/props.conf @@ -7,7 +7,7 @@ # What Android's init would have set from the bootloader. The slot is the # one the RAM copy of the modem image is named after (by-name/modem_a). -# cheetah's; a gs101 phone (raven) overrides both in $STATE/props.conf +# cheetah's; a gs101 phone overrides both in $STATE/props.conf, naming its board ro.boot.hardware.platform=gs201 ro.hardware=cheetah ro.build.type=user diff --git a/packages/omamobile-modem/profiles/modem.conf b/packages/omamobile-modem/profiles/modem.conf index c1dc441fe..7aeb94255 100644 --- a/packages/omamobile-modem/profiles/modem.conf +++ b/packages/omamobile-modem/profiles/modem.conf @@ -107,15 +107,18 @@ modem_cdt_check() { # The device the daemons are told about: the package's props.conf says # cheetah (gs201); on a gs101 phone the per-phone $STATE/props.conf, read -# after it, must say raven, or cbd and rfsd would take the other board's -# paths. $1: the file. +# after it, must name this board (raven for google,gs101-raven, oriole for +# google,gs101-oriole, ...), or cbd and rfsd would take another board's +# paths. $1: the file; MODEM_DT_COMPATIBLE: the compatible list (tests). modem_device_check() { - local f=$1 hw plat - grep -qa 'google,gs101' /proc/device-tree/compatible 2>/dev/null || return 0 + local f=$1 board hw plat + board=$(tr '\0' '\n' < "${MODEM_DT_COMPATIBLE:-/proc/device-tree/compatible}" 2>/dev/null | + sed -n 's/^google,gs101-//p' | head -1) + [[ -n $board ]] || return 0 hw=$(sed -n 's/^ro\.hardware=//p' "$f" 2>/dev/null | tail -1) plat=$(sed -n 's/^ro\.boot\.hardware\.platform=//p' "$f" 2>/dev/null | tail -1) - if [[ $hw != raven || $plat != gs101 ]]; then - say "a gs101 phone: $f needs ro.hardware=raven and ro.boot.hardware.platform=gs101" + if [[ $hw != "$board" || $plat != gs101 ]]; then + say "a gs101 phone ($board): $f needs ro.hardware=$board and ro.boot.hardware.platform=gs101" return 1 fi return 0 diff --git a/packages/omamobile-modem/test/all b/packages/omamobile-modem/test/all index fb45ac140..da263e862 100755 --- a/packages/omamobile-modem/test/all +++ b/packages/omamobile-modem/test/all @@ -419,6 +419,25 @@ printf 'ro.boot.cdt_hwid=TESTID\n' > "$t/p4"; cdt "$t/p4" || fail "the persist c cdt "$t/missing" && fail "a missing props file is refused" pass "board id required" +# The board the daemons are told about: on a gs101 phone, props.conf names +# that board (from google,gs101-); other SoCs aren't checked here +dev() { bash -c 'say() { :; }; eval "$(sed -n "/^modem_device_check() {/,/^}/p" profiles/modem.conf)"; modem_device_check "$1"' _ "$1"; } +compat() { printf '%s\0' "$@" > "$t/compat"; } +export MODEM_DT_COMPATIBLE=$t/compat +printf 'ro.hardware=raven\nro.boot.hardware.platform=gs101\n' > "$t/raven.props" +printf 'ro.hardware=oriole\nro.boot.hardware.platform=gs101\n' > "$t/oriole.props" +compat google,gs101-raven google,gs101; dev "$t/raven.props" || fail "raven with raven's props passes" +dev "$t/oriole.props" && fail "raven with oriole's props is refused" +compat google,gs101-oriole google,gs101; dev "$t/oriole.props" || fail "oriole with oriole's props passes" +dev "$t/raven.props" && fail "oriole with raven's props is refused" +printf 'ro.hardware=bluejay\nro.boot.hardware.platform=gs101\n' > "$t/bluejay.props" +compat google,gs101-bluejay google,gs101; dev "$t/bluejay.props" || fail "bluejay with bluejay's props passes" +printf 'ro.hardware=raven\nro.boot.hardware.platform=gs201\n' > "$t/badplat.props" +compat google,gs101-raven google,gs101; dev "$t/badplat.props" && fail "a gs101 board with another platform is refused" +compat google,gs201-cheetah google,gs201; dev "$t/missing" || fail "cheetah (gs201) isn't checked here" +unset MODEM_DT_COMPATIBLE +pass "a gs101 board's props name that board" + # The crash record's kernel lines: the modem's lines only, without this # tool's own umts_boot0 opens, and a flood folded into one line and a count python3 - "$cp" <<'PY' || fail "crash record folds a repeated kernel line" From 10b59529907040795e681c9da429d3ffb864b5b0 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Tue, 3 Nov 2026 14:04:50 +0000 Subject: [PATCH 06/15] MODEM-PLAN (raven): section 11 names the releases the fixes land in The crash notice is omamobile-modem 0.1.17, and the sitd exit lands in whichever omamobile-modem-sit release #389 merges as (0.3.28 went to #364). Review of #389. Co-Authored-By: Claude Opus 5.5 --- device/raven/MODEM-PLAN.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/device/raven/MODEM-PLAN.md b/device/raven/MODEM-PLAN.md index a1c78912f..fc99931cb 100644 --- a/device/raven/MODEM-PLAN.md +++ b/device/raven/MODEM-PLAN.md @@ -812,10 +812,11 @@ binary: a single-module `make` had rebuilt nothing): 93-minute link death may have been the same thing before the dead-link check existed. - **Fixes:** - - omamobile-modem 0.1.11: a crash raises a notification ("Cellular + - omamobile-modem 0.1.14: a crash raises a notification ("Cellular stopped") with the crash record's path; - - omamobile-modem-sit 0.3.5: when the CP is gone, sitd exits with one - line ("the modem went away ...") instead of a traceback. + - omamobile-modem-sit, in the release #389 lands in: when the CP is + gone, sitd exits with one line ("the modem went away ...") instead of + a traceback. - During bring-up the watcher also held a logind sleep inhibitor while the CP was ONLINE. It isn't in the package: it would cost every phone's battery for a raven kernel problem, and the kernel fixes From 4e57b14d191cbd60b66bf7168885c50ba71b2354 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Tue, 3 Nov 2026 16:47:11 +0000 Subject: [PATCH 07/15] omamobile-modem-sit 0.3.31, omamobile-modem 0.1.17: numbers after #373, #398 and #416 main took modem-sit 0.3.29 (#373) and 0.3.30 (#416), and modem 0.1.15 and 0.1.16 (#382, #398), while this waited: the sitd exit lands as 0.3.31 and the modem changes as 0.1.17. The NV overlay's note now says the copies are f2fs on gs201 and ext4 on gs101; it works on the mounted copies, so nothing else in it changes for raven. Co-Authored-By: Claude Opus 5.5 --- device/raven/MODEM-PLAN.md | 2 +- packages/omamobile-modem/lib/omamobile-modem-nv-overlay | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/device/raven/MODEM-PLAN.md b/device/raven/MODEM-PLAN.md index fc99931cb..6de9d0b5b 100644 --- a/device/raven/MODEM-PLAN.md +++ b/device/raven/MODEM-PLAN.md @@ -812,7 +812,7 @@ binary: a single-module `make` had rebuilt nothing): 93-minute link death may have been the same thing before the dead-link check existed. - **Fixes:** - - omamobile-modem 0.1.14: a crash raises a notification ("Cellular + - omamobile-modem 0.1.17: a crash raises a notification ("Cellular stopped") with the crash record's path; - omamobile-modem-sit, in the release #389 lands in: when the CP is gone, sitd exits with one line ("the modem went away ...") instead of diff --git a/packages/omamobile-modem/lib/omamobile-modem-nv-overlay b/packages/omamobile-modem/lib/omamobile-modem-nv-overlay index 266387dea..b44444b80 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-nv-overlay +++ b/packages/omamobile-modem/lib/omamobile-modem-nv-overlay @@ -28,8 +28,9 @@ anything here runs; the overlay is bound to those checksums, so a new backup sets it aside. Granularity: whole files. rfsd keeps the modem's NV as files in the three NV -filesystems (f2fs on gs201, ext4 on gs101; nv_normal.bin and nv_protected.bin, each with a salted MD5 beside -it), not as raw blocks, so a file is the unit that can be allowed or refused. +filesystems (f2fs on gs201, ext4 on gs101: nv_normal.bin and nv_protected.bin, +each with a salted MD5 beside it), not as raw blocks, so a file is the unit +that can be allowed or refused. Store layout (written only by capture): MANIFEST header, binding, entries, its own checksum (0600) From 6b53f21e5e36ee8d948e2002455cfd873a4778d3 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Tue, 3 Nov 2026 17:10:21 +0000 Subject: [PATCH 08/15] omamobile-modem 0.1.17: the overlay test finds the typed NV mount test/nv-overlay checks that the overlay is applied after the NV copies are mounted and before the checksum check, by finding the mount line in profile_setup. That line is now `mount -t "$t"` (each copy mounted as what it is, ext4 on gs101), so the search came back empty and the test ended non-zero after every check had passed. CI caught it; my local runs only read the ok lines. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-modem/test/nv-overlay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/omamobile-modem/test/nv-overlay b/packages/omamobile-modem/test/nv-overlay index 9e78f6a77..e66d0944a 100755 --- a/packages/omamobile-modem/test/nv-overlay +++ b/packages/omamobile-modem/test/nv-overlay @@ -272,7 +272,7 @@ pass "set-aside copies bounded" # the CP power-off; the CLI's commands; the units. conf=profiles/modem.conf setup=$(sed -n '/^profile_setup() {$/,/^}$/p' $conf) -m=$(grep -n 'mount -t f2fs -o noatime "$l" "$mnt/$p"' <<<"$setup" | cut -d: -f1); a=$(grep -n 'MODEM_NV_OVERLAY" apply' <<<"$setup" | cut -d: -f1); c=$(grep -n 'MODEM_CP" nv-check' <<<"$setup" | cut -d: -f1) +m=$(grep -n 'mount -t "$t" -o noatime "$l" "$mnt/$p"' <<<"$setup" | cut -d: -f1); a=$(grep -n 'MODEM_NV_OVERLAY" apply' <<<"$setup" | cut -d: -f1); c=$(grep -n 'MODEM_CP" nv-check' <<<"$setup" | cut -d: -f1) [[ -n $m && -n $a && -n $c && $m -lt $a && $a -lt $c ]] || fail "apply runs after the f2fs mounts and before nv-check (mount=$m apply=$a check=$c)" grep -q 'modem_copy "\$p"; done' <<<"$setup" || fail "the base copies are still read and checked first" stop=$(sed -n '/^profile_stop() {$/,/^}$/p' $conf) From e02396445dfab3e83e5a58b0092a3b4d89f4ed8c Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Wed, 4 Nov 2026 07:42:17 +0000 Subject: [PATCH 09/15] =?UTF-8?q?omamobile-modem=200.1.17:=20review=20fixe?= =?UTF-8?q?s:=20blkid=20message,=20notify=20in=20the=20journal,=20=C2=A711?= =?UTF-8?q?=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review on #389: - profile_setup: blkid finding no type no longer stops the start under set -e before the "is ..., not ext4 or f2fs" message; it prints it. - notify() says in the journal whom it notified ("notified N of M session(s)", or why none), so a crash report can confirm it. - MODEM-PLAN §11: a dated line that the sleep inhibitor is in the package since omamobile-modem 0.1.13 after all, and where the three CPIF suspend fixes it describes are pushed. Co-Authored-By: Claude Opus 5.5 --- device/raven/MODEM-PLAN.md | 8 ++++++++ packages/omamobile-modem/lib/omamobile-modem-cp | 12 +++++++++--- packages/omamobile-modem/profiles/modem.conf | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/device/raven/MODEM-PLAN.md b/device/raven/MODEM-PLAN.md index 6de9d0b5b..ad437852e 100644 --- a/device/raven/MODEM-PLAN.md +++ b/device/raven/MODEM-PLAN.md @@ -821,11 +821,19 @@ binary: a single-module `make` had rebuilt nothing): the CP was ONLINE. It isn't in the package: it would cost every phone's battery for a raven kernel problem, and the kernel fixes below make it unnecessary. + (2026-11-04: since omamobile-modem 0.1.13 it is in the package after + all, as `omamobile-modem-inhibit`, which cheetah's MODEM-PLAN 6.3 asks + for on every phone.) - **Next:** CPIF's system suspend. The root port has to stay reachable across s2idle, or CPIF has to take the link down itself first (what its `s5100_pm_notifier` does on stock is still to read). Separately: why the SIM never became ready at 13:24. +The three `pcie-gs201-cp` fixes below are on the branch +[`omamobile-gs101-cpif-suspend`](https://github.com/robotosaith/linux-omarchy-mobile/commits/omamobile-gs101-cpif-suspend) +(on `omamobile-gs101-cpif`, not yet signed off), as they ran on +`omamobile-gs101-int-power`. + **Suspend with the modem up, first fix (2026-10-28, `gdd5e1655ef91`).** The cause, from the kernel log and Google's raven `pcie-exynos-rc.c`: with the link idle, `cp_link_down()` leaves the CP PCIe controller unclocked and its diff --git a/packages/omamobile-modem/lib/omamobile-modem-cp b/packages/omamobile-modem/lib/omamobile-modem-cp index 208d1f28a..cccdebffd 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-cp +++ b/packages/omamobile-modem/lib/omamobile-modem-cp @@ -158,13 +158,16 @@ def notify(title, body): cmd = os.environ.get('OMAMOBILE_NOTIFY_CMD') if cmd: subprocess.run([cmd, title, body], timeout=30, check=False) + say(f'notified: {title} (through {cmd})') return if os.geteuid() != 0: + say(f'not notified: {title} (not root)') return try: uids = [int(u) for u in os.listdir('/run/user') if u.isdigit() and int(u) >= 1000] except OSError: - return + uids = [] + sent = 0 for uid in uids: bus = f'/run/user/{uid}/bus' if not os.path.exists(bus): @@ -178,13 +181,16 @@ def notify(title, body): elif shutil.which('notify-send'): send = ['notify-send', '-u', 'critical', '-a', 'Omarchy Mobile', title, body] else: + say(f'not notified: {title} (no notification tool)') return env = ['env', f'DBUS_SESSION_BUS_ADDRESS=unix:path={bus}', f'XDG_RUNTIME_DIR=/run/user/{uid}'] try: - subprocess.run(['runuser', '-u', user, '--'] + env + send, timeout=15, check=False, - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + if subprocess.run(['runuser', '-u', user, '--'] + env + send, timeout=15, check=False, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: + sent += 1 except (OSError, subprocess.SubprocessError): pass + say(f'notified {sent} of {len(uids)} session(s): {title}') def record_crash(): diff --git a/packages/omamobile-modem/profiles/modem.conf b/packages/omamobile-modem/profiles/modem.conf index 7aeb94255..6eaebe96c 100644 --- a/packages/omamobile-modem/profiles/modem.conf +++ b/packages/omamobile-modem/profiles/modem.conf @@ -193,8 +193,8 @@ profile_setup() { mount -t ext4 -o ro,noatime,noload "$l" "$mnt/modem_img" modem_autoclear "$l" for p in efs efs_backup modem_userdata; do - t=$(blkid -o value -s TYPE "$NV/$p.img") - [[ $t == ext4 || $t == f2fs ]] || die "$p is $t, not ext4 or f2fs: stopping" + t=$(blkid -o value -s TYPE "$NV/$p.img" || true) + [[ $t == ext4 || $t == f2fs ]] || die "$p is ${t:-of no known type}, not ext4 or f2fs: stopping" if [[ $t == f2fs ]] && ! grep -qw f2fs /proc/filesystems; then modprobe -q f2fs || die "no f2fs in the kernel (CONFIG_F2FS_FS)" fi From 127ae3102371210d2d6ae310d19534ef33d4840b Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Wed, 4 Nov 2026 07:47:59 +0000 Subject: [PATCH 10/15] device-raven 0.1.31: sitd waits for CP ONLINE, as on cheetah Booting #389's head on raven (2026-11-04, ge1e6adb69bbf): omamobile-modem is READY once CPIF's ports exist and the CP comes ONLINE about 3 s later, so omamobile-sitd, ordered only after the modem unit, started at once and exited ("CP is not ONLINE") at every boot. The wait for ONLINE that now ships the same two drop-ins: sitd's ExecStartPre waits for ONLINE (up to cbd's own 120 s), and the data fallback is skipped without the modem's port. Cheetah is unchanged. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-device-raven/README.md | 2 +- packages/omamobile-device-raven/test/all | 8 ++++++++ .../omamobile-sit-data.service.d/20-cp-online.conf | 9 +++++++++ .../system/omamobile-sitd.service.d/20-cp-online.conf | 11 +++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 packages/omamobile-device-raven/vendor/systemd/system/omamobile-sit-data.service.d/20-cp-online.conf create mode 100644 packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/20-cp-online.conf diff --git a/packages/omamobile-device-raven/README.md b/packages/omamobile-device-raven/README.md index 0a0873bc5..5726a3cf3 100644 --- a/packages/omamobile-device-raven/README.md +++ b/packages/omamobile-device-raven/README.md @@ -15,7 +15,7 @@ the counterpart of `omamobile-device-cheetah`. Bring-up and results: | The user may switch the panel off (`bl_power`) and inhibit the touchscreen, for Omarchy's display off | `udev/rules.d/20-omamobile-display.rules` | | Wi-Fi power save on | `NetworkManager/conf.d/omamobile-raven-wifi-powersave.conf` | | Sleep (s2idle) once locked with the panel off, behind `omarchy-toggle omamobile-sleep on` (the watcher, `omamobile-sleepd`, is omamobile-shell's); Wi-Fi stays connected across sleep (unloaded instead after a D3 failure, or with `/etc/omamobile/wifi-unload-for-sleep`) | `omamobile-sleep` (`system-sleep/omamobile`), `sleep.conf.d/10-omamobile.conf` | -| Modem bring-up only: its PCIe driver and CPIF never load at boot, and the modem's units aren't enabled (as on main; `systemctl enable --now omamobile-modem omamobile-sitd` to use it, MODEM-PLAN) | `modprobe.d/omamobile-raven-modem.conf` | +| Modem bring-up only: its PCIe driver and CPIF never load at boot, and the modem's units aren't enabled (as on main; `systemctl enable --now omamobile-modem omamobile-sitd` to use it, MODEM-PLAN); once enabled, sitd waits for CP ONLINE and the data fallback needs the modem's port, as on cheetah | `modprobe.d/omamobile-raven-modem.conf`, `omamobile-sitd.service.d/`, `omamobile-sit-data.service.d/` | | Bluetooth on at boot; the session waits (at most 15 s) for the adapter | `bluetooth.service` (enabled), `sddm.service.d/`, `omamobile-wait-bluetooth` | | The speakers through speaker protection at stage media (raven's own limits: AUDIO-PLAN R6), the microphones with them; stage c9 and earpiece mode stay off on raven | `omamobile-speaker-protection.service` from omamobile-audio 0.5.15 (enabled); `snd_soc_cs35l41_spi` blacklisted here too, so only that service loads it | `omamobile-raven.conf` | diff --git a/packages/omamobile-device-raven/test/all b/packages/omamobile-device-raven/test/all index de62c046a..e1a0af004 100755 --- a/packages/omamobile-device-raven/test/all +++ b/packages/omamobile-device-raven/test/all @@ -110,6 +110,14 @@ grep -q "'omamobile-audio>=0.5.15'" PKGBUILD || fail "device-raven depends on om || fail "raven never sets aoc_alsa_dev speaker_protection (it would allow stage c9)" pass "speakers through protection at stage media, the microphones with them" +# The modem's units, when enabled: sitd waits for CP ONLINE (as on cheetah) +d=$tmp/root/usr/lib/systemd/system/omamobile-sitd.service.d/20-cp-online.conf +grep -qx 'ExecStartPre=/usr/lib/omamobile-vendor/omamobile-modem-cp wait-online 120' "$d" || fail "sitd waits for CP ONLINE with the cbd timeout" +grep -q '^\[Service\]' "$d" && ! grep -q '^\[Unit\]' "$d" || fail "the sitd drop-in only adds to [Service]" +d=$tmp/root/usr/lib/systemd/system/omamobile-sit-data.service.d/20-cp-online.conf +grep -qx 'ConditionPathExists=/dev/umts_ipc0' "$d" || fail "sit-data is skipped without the modem's port" +pass "sitd waits for the CP; sit-data needs the modem's port" + # Policy that keeps the phone safe at boot for m in tcpci_maxim gpio_max77759; do grep -qx "blacklist $m" vendor/modprobe.d/omamobile-raven.conf || fail "$m stays blacklisted" diff --git a/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sit-data.service.d/20-cp-online.conf b/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sit-data.service.d/20-cp-online.conf new file mode 100644 index 000000000..9e8403780 --- /dev/null +++ b/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sit-data.service.d/20-cp-online.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: MIT +# The data fallback only with a modem. omamobile-sit-data requires sitd, but +# a sitd skipped by its own condition (no /dev/umts_ipc0: the modem unit was +# skipped on a phone that isn't provisioned) counts as started, and the +# fallback would then wait 60 s for a bearer, fail, and be restarted every +# 10 s for the whole boot. With the modem up the port exists, and +# `omamobile-sit data on` works as before. +[Unit] +ConditionPathExists=/dev/umts_ipc0 diff --git a/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/20-cp-online.conf b/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/20-cp-online.conf new file mode 100644 index 000000000..206b527a2 --- /dev/null +++ b/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/20-cp-online.conf @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: MIT +# Raven's sitd waits for the CP, as the Pixel 7 Pro's does (device-cheetah's +# drop-in of the same name). omamobile-modem.service is ready once CPIF's +# ports exist, before cbd has booted the CP (about 3 s more on raven), and a +# sitd started on that alone exits ("CP is not ONLINE": at every raven boot +# with the modem enabled, 2026-11-04). 120 s is the profile's own cbd +# timeout: a CP that never comes up fails sitd here, and the data fallback +# and the Phone and Messages bridge, ordered after it, stay down until the +# reboot. +[Service] +ExecStartPre=/usr/lib/omamobile-vendor/omamobile-modem-cp wait-online 120 From b9e280de89501f37ed3e9d8038291709ba5eeaba Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Wed, 11 Nov 2026 12:56:17 +0000 Subject: [PATCH 11/15] omamobile-modem 0.1.21, modem-sit 0.3.35, device-raven 0.1.35: numbers after today's main main has moved past this branch's numbers (omamobile-modem 0.1.20, modem-sit 0.3.34 and device-raven 0.1.34 have shipped), so the three packages take the next ones. Raven's MODEM-PLAN section 11 names the modem's crash notice by the release this lands in, as it already does for modem-sit's, rather than by a number that moves. device-raven's test/all keeps both the speaker-protection block from #401 and this branch's sitd/sit-data drop-in block. Co-Authored-By: Claude Opus 5.5 --- device/raven/MODEM-PLAN.md | 4 ++-- packages/omamobile-device-raven/version | 2 +- packages/omamobile-modem-sit/version | 2 +- packages/omamobile-modem/version | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/device/raven/MODEM-PLAN.md b/device/raven/MODEM-PLAN.md index ad437852e..dc865c568 100644 --- a/device/raven/MODEM-PLAN.md +++ b/device/raven/MODEM-PLAN.md @@ -812,8 +812,8 @@ binary: a single-module `make` had rebuilt nothing): 93-minute link death may have been the same thing before the dead-link check existed. - **Fixes:** - - omamobile-modem 0.1.17: a crash raises a notification ("Cellular - stopped") with the crash record's path; + - omamobile-modem, in the release #389 lands in: a crash raises a + notification ("Cellular stopped") with the crash record's path; - omamobile-modem-sit, in the release #389 lands in: when the CP is gone, sitd exits with one line ("the modem went away ...") instead of a traceback. diff --git a/packages/omamobile-device-raven/version b/packages/omamobile-device-raven/version index 9dd179330..a52e04166 100644 --- a/packages/omamobile-device-raven/version +++ b/packages/omamobile-device-raven/version @@ -1 +1 @@ -0.1.34 +0.1.35 diff --git a/packages/omamobile-modem-sit/version b/packages/omamobile-modem-sit/version index 9f558ed0f..1ff34fb37 100644 --- a/packages/omamobile-modem-sit/version +++ b/packages/omamobile-modem-sit/version @@ -1 +1 @@ -0.3.34 +0.3.35 diff --git a/packages/omamobile-modem/version b/packages/omamobile-modem/version index baa983785..790629964 100644 --- a/packages/omamobile-modem/version +++ b/packages/omamobile-modem/version @@ -1 +1 @@ -0.1.20 +0.1.21 From f1e100f3a20e6f81788dad77e9af4e2884d56c04 Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Wed, 11 Nov 2026 12:40:25 +0000 Subject: [PATCH 12/15] omamobile-modem: send the crash notice in PID 1's mount namespace The watcher runs in the profile's private mount namespace, which is made at boot before the user's /run/user/ tmpfs is mounted; inside it that directory stays empty, so after a crash notify() found no session bus and said nothing (review on #389: unit start 14:42:49, /run/user/1000 mounted 14:43:11, the bus socket missing from inside the namespace). notify() now looks for sessions through /proc/1/root/run/user, at each call, and runs the send under nsenter --target 1 --mount when its mount namespace differs from PID 1's. The profile's own isolation is left as it is. On raven on 2026-11-11 the one notice that arrived came from a modem started by hand after login, as this predicts. The test runs notify() with the bus absent, then present: nothing is sent the first time, one send through nsenter the second. Co-Authored-By: Claude Opus 5.5 --- .../omamobile-modem/lib/omamobile-modem-cp | 40 ++++++++++++++----- packages/omamobile-modem/test/all | 31 ++++++++++++++ 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/packages/omamobile-modem/lib/omamobile-modem-cp b/packages/omamobile-modem/lib/omamobile-modem-cp index cccdebffd..efeef9f01 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-cp +++ b/packages/omamobile-modem/lib/omamobile-modem-cp @@ -153,6 +153,31 @@ def kernel_lines(kernel, keep=150): return out[-keep:] +def host_view(): + """(root, prefix): where PID 1's /run/user is seen from here, and the + command prefix that runs a program in PID 1's mount namespace. The + watcher runs in the profile's private mount namespace, made at boot + before the user's /run/user/ is mounted, so inside it that + directory stays empty; /proc/1/root reads through PID 1's mounts, and + nsenter runs the send there. Both are empty when the namespaces match.""" + try: + same = os.readlink('/proc/self/ns/mnt') == os.readlink('/proc/1/ns/mnt') + except OSError: + same = True + return ('', []) if same else ('/proc/1/root', ['nsenter', '--target', '1', '--mount', '--']) + + +def sessions(root=''): + """(uid, bus) for each logged-in user with a session bus under + root/run/user, read at the call: a bus that appears after the modem + started is found.""" + try: + uids = sorted(int(u) for u in os.listdir(f'{root}/run/user') if u.isdigit() and int(u) >= 1000) + except OSError: + return [] + return [(uid, f'/run/user/{uid}/bus') for uid in uids if os.path.exists(f'{root}/run/user/{uid}/bus')] + + def notify(title, body): """A critical notification in every logged-in session, as root.""" cmd = os.environ.get('OMAMOBILE_NOTIFY_CMD') @@ -163,15 +188,10 @@ def notify(title, body): if os.geteuid() != 0: say(f'not notified: {title} (not root)') return - try: - uids = [int(u) for u in os.listdir('/run/user') if u.isdigit() and int(u) >= 1000] - except OSError: - uids = [] + root, prefix = host_view() + found = sessions(root) sent = 0 - for uid in uids: - bus = f'/run/user/{uid}/bus' - if not os.path.exists(bus): - continue + for uid, bus in found: try: user = pwd.getpwuid(uid).pw_name except KeyError: @@ -185,12 +205,12 @@ def notify(title, body): return env = ['env', f'DBUS_SESSION_BUS_ADDRESS=unix:path={bus}', f'XDG_RUNTIME_DIR=/run/user/{uid}'] try: - if subprocess.run(['runuser', '-u', user, '--'] + env + send, timeout=15, check=False, + if subprocess.run(prefix + ['runuser', '-u', user, '--'] + env + send, timeout=15, check=False, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: sent += 1 except (OSError, subprocess.SubprocessError): pass - say(f'notified {sent} of {len(uids)} session(s): {title}') + say(f'notified {sent} of {len(found)} session(s): {title}' + (" (in PID 1's mount namespace)" if prefix else '')) def record_crash(): diff --git a/packages/omamobile-modem/test/all b/packages/omamobile-modem/test/all index da263e862..9bfb5571e 100755 --- a/packages/omamobile-modem/test/all +++ b/packages/omamobile-modem/test/all @@ -122,6 +122,37 @@ import sys; g = {"__name__": "cp"}; exec(open(sys.argv[1]).read(), g); print(g[" fail "a bad watch interval leaves other subcommands alone" pass "watch interval" +# The crash notice reaches a session whose bus appears after the modem +# started: the watcher's private mount namespace is made at boot, before +# /run/user/ is mounted, so it looks through PID 1's view at each call +# and sends in PID 1's mount namespace (#389 review) +mkdir -p "$t/host/run/user/1000" "$t/host/run/user/0" +out=$(python3 - "$cp" "$t/host" 2>/dev/null <<'PY' +import os, sys, types +g = {"__name__": "cp"} +exec(open(sys.argv[1]).read(), g) +host = sys.argv[2] +calls = [] +g["host_view"] = lambda: (host, ["nsenter", "--target", "1", "--mount", "--"]) +g["os"].geteuid = lambda: 0 +g["shutil"].which = lambda name: "/usr/bin/" + name if name == "notify-send" else None +g["pwd"].getpwuid = lambda uid: types.SimpleNamespace(pw_name="owner") +g["subprocess"].run = lambda argv, **kw: calls.append(argv) or types.SimpleNamespace(returncode=0) +g["notify"]("Cellular stopped", "test") +print("before", len(calls)) +open(host + "/run/user/1000/bus", "w").close() +g["notify"]("Cellular stopped", "test") +print("after", len(calls), " ".join(calls[-1][:8]) if calls else "") +print("sessions", g["sessions"](host)) +PY +) +[[ $out == *"before 0"* ]] || fail "no bus yet: nothing sent ($out)" +[[ $out == *"after 1 nsenter --target 1 --mount -- runuser -u owner"* ]] || fail "the bus that appeared later is used, through PID 1's mount namespace ($out)" +[[ $out == *"[(1000, '/run/user/1000/bus')]"* ]] || fail "sessions: uids from 1000 only, the bus path as the session sees it ($out)" +view=$(python3 -c 'import sys; g = {"__name__": "cp"}; exec(open(sys.argv[1]).read(), g); print(g["host_view"]())' "$cp") +[[ $view == "('', [])" ]] || fail "the same mount namespace as PID 1: no prefix ($view)" +pass "crash notice through PID 1's mount namespace, bus found at each call" + mkdir -p "$t/efs" "$t/efs_backup" for f in efs/nv_normal.bin efs/nv_protected.bin efs_backup/nv_protected.bak; do printf 'made-up %s' "$f" > "$t/$f" From 4dbfd18bd22e19a3e5c6d5387f5c00632b8baedf Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Wed, 11 Nov 2026 12:53:04 +0000 Subject: [PATCH 13/15] omamobile-modem: send the crash notice as a transient unit of PID 1's Entering PID 1's mount namespace wasn't enough. On raven, with the modem started at boot before login, the watcher found the session through /proc/1/root but the send failed: omarchy-notification-send's busctl --user, run from inside the profile's PID namespace and cgroup, was refused ("Failed to connect to user scope bus via local transport: Operation not permitted"). The watcher now asks PID 1 for the send: systemd-run --uid= with the session's bus address, waiting for it. PID 1 starts it in the host's namespaces and its own cgroup, and its output reaches the journal. A failed send logs its exit code and last line instead of nothing, and nsenter and runuser are gone. Tested on raven, 2026-11-11, 7.3.0-rc6-omamobile-push1-ge1e6adb69bbf: modem started 12:51:42 with no session, the bus absent inside the watcher's namespace, the user logged in, then the modem stopped: "notified 1 of 1 session(s): Cellular stopped". The first version of this fix, on the same steps, logged "notified 0 of 1" with the busctl error above. Co-Authored-By: Claude Opus 5.5 --- .../omamobile-modem/lib/omamobile-modem-cp | 55 +++++++++++-------- packages/omamobile-modem/test/all | 24 ++++---- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/packages/omamobile-modem/lib/omamobile-modem-cp b/packages/omamobile-modem/lib/omamobile-modem-cp index efeef9f01..72fa23fde 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-cp +++ b/packages/omamobile-modem/lib/omamobile-modem-cp @@ -28,7 +28,6 @@ import fcntl import hashlib import os from pathlib import Path -import pwd import shutil import struct import subprocess @@ -153,18 +152,29 @@ def kernel_lines(kernel, keep=150): return out[-keep:] -def host_view(): - """(root, prefix): where PID 1's /run/user is seen from here, and the - command prefix that runs a program in PID 1's mount namespace. The - watcher runs in the profile's private mount namespace, made at boot - before the user's /run/user/ is mounted, so inside it that - directory stays empty; /proc/1/root reads through PID 1's mounts, and - nsenter runs the send there. Both are empty when the namespaces match.""" +def host_root(): + """Where PID 1's /run/user is seen from here. The watcher runs in the + profile's private mount namespace, made at boot before the user's + /run/user/ is mounted, so inside it that directory stays empty; + /proc/1/root reads through PID 1's mounts. Empty when the namespaces + match.""" try: same = os.readlink('/proc/self/ns/mnt') == os.readlink('/proc/1/ns/mnt') except OSError: same = True - return ('', []) if same else ('/proc/1/root', ['nsenter', '--target', '1', '--mount', '--']) + return '' if same else '/proc/1/root' + + +def send_command(uid, bus, send): + """The send as a transient unit of PID 1's, as the user: it runs in the + host's namespaces and its own cgroup, never the profile's. From inside + the profile, busctl --user (omarchy-notification-send) is refused even + in PID 1's mount namespace ("Failed to connect to user scope bus via + local transport: Operation not permitted", raven, 2026-11-11). Its + output goes to the journal.""" + return ['systemd-run', '--quiet', '--wait', '--collect', f'--uid={uid}', + f'--setenv=DBUS_SESSION_BUS_ADDRESS=unix:path={bus}', + f'--setenv=XDG_RUNTIME_DIR=/run/user/{uid}', '--'] + send def sessions(root=''): @@ -188,14 +198,9 @@ def notify(title, body): if os.geteuid() != 0: say(f'not notified: {title} (not root)') return - root, prefix = host_view() - found = sessions(root) + found = sessions(host_root()) sent = 0 for uid, bus in found: - try: - user = pwd.getpwuid(uid).pw_name - except KeyError: - continue if shutil.which('omarchy-notification-send'): send = ['omarchy-notification-send', '-u', 'critical', title, body] elif shutil.which('notify-send'): @@ -203,14 +208,20 @@ def notify(title, body): else: say(f'not notified: {title} (no notification tool)') return - env = ['env', f'DBUS_SESSION_BUS_ADDRESS=unix:path={bus}', f'XDG_RUNTIME_DIR=/run/user/{uid}'] try: - if subprocess.run(prefix + ['runuser', '-u', user, '--'] + env + send, timeout=15, check=False, - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: - sent += 1 - except (OSError, subprocess.SubprocessError): - pass - say(f'notified {sent} of {len(found)} session(s): {title}' + (" (in PID 1's mount namespace)" if prefix else '')) + result = subprocess.run(send_command(uid, bus, send), timeout=15, check=False, + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + except (OSError, subprocess.SubprocessError) as error: + say(f'not notified: uid {uid}: {error}') + continue + if result.returncode == 0: + sent += 1 + else: + # The last line only: it says why (a missing bus, a refused + # unit), and the notification text isn't repeated. + why = (result.stderr or b'').decode(errors='replace').strip().splitlines()[-1:] or ['no message'] + say(f'not notified: uid {uid}: exit {result.returncode}: {why[0][:200]}') + say(f'notified {sent} of {len(found)} session(s): {title}') def record_crash(): diff --git a/packages/omamobile-modem/test/all b/packages/omamobile-modem/test/all index 9bfb5571e..cfffb3800 100755 --- a/packages/omamobile-modem/test/all +++ b/packages/omamobile-modem/test/all @@ -124,34 +124,34 @@ pass "watch interval" # The crash notice reaches a session whose bus appears after the modem # started: the watcher's private mount namespace is made at boot, before -# /run/user/ is mounted, so it looks through PID 1's view at each call -# and sends in PID 1's mount namespace (#389 review) +# /run/user/ is mounted, so it looks through PID 1's view at each call, +# and sends as a transient unit of PID 1's, outside the profile (#389 review) mkdir -p "$t/host/run/user/1000" "$t/host/run/user/0" out=$(python3 - "$cp" "$t/host" 2>/dev/null <<'PY' -import os, sys, types +import sys, types g = {"__name__": "cp"} exec(open(sys.argv[1]).read(), g) host = sys.argv[2] calls = [] -g["host_view"] = lambda: (host, ["nsenter", "--target", "1", "--mount", "--"]) +g["host_root"] = lambda: host g["os"].geteuid = lambda: 0 -g["shutil"].which = lambda name: "/usr/bin/" + name if name == "notify-send" else None -g["pwd"].getpwuid = lambda uid: types.SimpleNamespace(pw_name="owner") -g["subprocess"].run = lambda argv, **kw: calls.append(argv) or types.SimpleNamespace(returncode=0) +g["shutil"].which = lambda name: "/usr/bin/" + name if name == "omarchy-notification-send" else None +g["subprocess"].run = lambda argv, **kw: calls.append(argv) or types.SimpleNamespace(returncode=0, stderr=b"") g["notify"]("Cellular stopped", "test") print("before", len(calls)) open(host + "/run/user/1000/bus", "w").close() g["notify"]("Cellular stopped", "test") -print("after", len(calls), " ".join(calls[-1][:8]) if calls else "") +print("after", len(calls), " ".join(calls[-1]) if calls else "") print("sessions", g["sessions"](host)) PY ) [[ $out == *"before 0"* ]] || fail "no bus yet: nothing sent ($out)" -[[ $out == *"after 1 nsenter --target 1 --mount -- runuser -u owner"* ]] || fail "the bus that appeared later is used, through PID 1's mount namespace ($out)" +[[ $out == *"after 1 systemd-run --quiet --wait --collect --uid=1000 --setenv=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus --setenv=XDG_RUNTIME_DIR=/run/user/1000 -- omarchy-notification-send -u critical Cellular stopped test"* ]] || + fail "the bus that appeared later is used, through a transient unit as the user ($out)" [[ $out == *"[(1000, '/run/user/1000/bus')]"* ]] || fail "sessions: uids from 1000 only, the bus path as the session sees it ($out)" -view=$(python3 -c 'import sys; g = {"__name__": "cp"}; exec(open(sys.argv[1]).read(), g); print(g["host_view"]())' "$cp") -[[ $view == "('', [])" ]] || fail "the same mount namespace as PID 1: no prefix ($view)" -pass "crash notice through PID 1's mount namespace, bus found at each call" +view=$(python3 -c 'import sys; g = {"__name__": "cp"}; exec(open(sys.argv[1]).read(), g); print(repr(g["host_root"]()))' "$cp") +[[ $view == "''" ]] || fail "the same mount namespace as PID 1: its own /run ($view)" +pass "crash notice outside the profile, bus found at each call" mkdir -p "$t/efs" "$t/efs_backup" for f in efs/nv_normal.bin efs/nv_protected.bin efs_backup/nv_protected.bak; do From 268780603aee7a433da7fa5f1f915ddc65255bba Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Thu, 12 Nov 2026 07:00:58 +0000 Subject: [PATCH 14/15] omamobile-modem 0.1.22, device-raven 0.1.36: numbers after #403 #403 merged and shipped omamobile-modem 0.1.21 and device-raven 0.1.35, the numbers this branch also carried. The lines were equal, so the merge of main raised no conflict, and the Pixel 6 Pro's package would have kept its old build. Both take the next numbers. modem-sit stays at 0.3.35; other open pull requests claim it too, and it is set at merge. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-device-raven/version | 2 +- packages/omamobile-modem/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-device-raven/version b/packages/omamobile-device-raven/version index a52e04166..072d0fa39 100644 --- a/packages/omamobile-device-raven/version +++ b/packages/omamobile-device-raven/version @@ -1 +1 @@ -0.1.35 +0.1.36 diff --git a/packages/omamobile-modem/version b/packages/omamobile-modem/version index 790629964..7e72641b4 100644 --- a/packages/omamobile-modem/version +++ b/packages/omamobile-modem/version @@ -1 +1 @@ -0.1.21 +0.1.22 From a0a0bf3f704517aebf46a0edf49dfa74dfc2e96e Mon Sep 17 00:00:00 2001 From: saiththerobo Date: Thu, 12 Nov 2026 16:00:13 +0000 Subject: [PATCH 15/15] omamobile-modem: no crash notice during the unit's own stop The watcher took every move away from ONLINE for a crash, and a stop powers the CP off while it is still polling, so a deliberate `systemctl stop omamobile-modem` (run before every push on the 7 Pro) put "Cellular stopped: The modem crashed" on the screen once the notice could reach the session. profile_stop writes /run/omamobile-modem/intent-$INVOCATION_ID, holding the ID, before the power-off, and the watcher runs under the same invocation. It now makes the same test rfsd's job makes (a 32-hex ID, a regular file that isn't a symlink, its content the ID) and, when it holds, logs that the modem was stopped and sends nothing. The crash record on a stop stays as it is (#532). test/watch-stop.py drives watch() through ONLINE then OFFLINE: with this invocation's intent nothing is sent; without one, with another ID's, or with a symlinked one, one notice. Co-Authored-By: Claude Opus 5.5 --- .../omamobile-modem/lib/omamobile-modem-cp | 36 +++++++-- packages/omamobile-modem/test/all | 5 ++ packages/omamobile-modem/test/watch-stop.py | 79 +++++++++++++++++++ 3 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 packages/omamobile-modem/test/watch-stop.py diff --git a/packages/omamobile-modem/lib/omamobile-modem-cp b/packages/omamobile-modem/lib/omamobile-modem-cp index 72fa23fde..c0d1ca5ce 100755 --- a/packages/omamobile-modem/lib/omamobile-modem-cp +++ b/packages/omamobile-modem/lib/omamobile-modem-cp @@ -14,7 +14,8 @@ date and boot id, which the unit's clean stop removes); when it leaves ONLINE afterwards, record the crash once and keep running (nothing restarts - or powers off the CP) + or powers off the CP); the user is told unless + this invocation's stop intent is in place baseband-version FILE the firmware version in a modem.bin's TOC nv-check EFS EFS_BACKUP the stock salted MD5 of the three NV files in the RAM copies; exit 1 on a mismatch @@ -28,6 +29,7 @@ import fcntl import hashlib import os from pathlib import Path +import re import shutil import struct import subprocess @@ -277,6 +279,22 @@ def watch_seconds(): return seconds +def stop_intended(): + """This unit invocation's orderly stop is under way: profile_stop wrote + $RUN/intent-, holding that ID, before the power-off. The + same test as rfsd's job in the profile (spawn_modem_rfsd): a 32-hex ID, a + regular file that isn't a symlink, its content the ID.""" + invocation = os.environ.get('INVOCATION_ID', '') + if not re.fullmatch(r'[0-9a-f]{32}', invocation): + return False + intent = RUN / f'intent-{invocation}' + try: + return (not intent.is_symlink() and intent.is_file() + and intent.read_text().rstrip('\n') == invocation) + except OSError: + return False + + def watch(marker=None): seconds = watch_seconds() was_online = False @@ -316,11 +334,17 @@ def watch(marker=None): record_crash() RUN.mkdir(parents=True, exist_ok=True) (RUN / 'crashed').write_text(STATES.get(now, str(now)) + '\n') - say('the CP left ONLINE: crash recorded; nothing restarts it. ' - 'Reboot to recover (the reboot powers it off).') - notify('Cellular stopped', - 'The modem crashed: no calls, texts or mobile data until the phone restarts. ' - f'Details: {CRASH_LOG}') + # A stop powers the CP off while this still polls: no notice + # then (#389 review). The record stays for now (#532). + if stop_intended(): + say("the CP left ONLINE during this invocation's stop: the modem was stopped, " + 'nothing sent') + else: + say('the CP left ONLINE: crash recorded; nothing restarts it. ' + 'Reboot to recover (the reboot powers it off).') + notify('Cellular stopped', + 'The modem crashed: no calls, texts or mobile data until the phone restarts. ' + f'Details: {CRASH_LOG}') time.sleep(seconds) diff --git a/packages/omamobile-modem/test/all b/packages/omamobile-modem/test/all index 29ac894ff..a0d00d21b 100755 --- a/packages/omamobile-modem/test/all +++ b/packages/omamobile-modem/test/all @@ -44,6 +44,11 @@ pass "rfsd's exit ends the profile except during this invocation's orderly stop" python3 test/power-off.py || fail "omamobile-modem-cp power-off" pass "power-off confirms OFFLINE from the device, never from its absence" +# The crash notice: not during this invocation's orderly stop (its intent +# file, as rfsd's job tests it), once otherwise (#389 review) +python3 test/watch-stop.py || fail "omamobile-modem-cp watch through a stop" +pass "no crash notice during this invocation's stop" + # The stop witness: profile_stop, with a stand-in CP helper and capture. A # failed power-off still captures the NV but fails the stop and leaves no # witness; a confirmed one writes its invocation's witness once; no main diff --git a/packages/omamobile-modem/test/watch-stop.py b/packages/omamobile-modem/test/watch-stop.py new file mode 100644 index 000000000..7401bcdf4 --- /dev/null +++ b/packages/omamobile-modem/test/watch-stop.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""omamobile-modem-cp watch when the CP leaves ONLINE: during this unit +invocation's orderly stop (profile_stop's intent file, holding the ID) no +notice goes out; without one, or with a wrong or symlinked intent, one does +(#389 review).""" +import importlib.machinery +import importlib.util +import os +from pathlib import Path +import tempfile +import unittest +from unittest.mock import patch + +loader = importlib.machinery.SourceFileLoader('modem_cp', 'lib/omamobile-modem-cp') +cp = importlib.util.module_from_spec(importlib.util.spec_from_loader('modem_cp', loader)) +loader.exec_module(cp) + +INVOCATION = '0123456789abcdef0123456789abcdef' +OTHER = 'fedcba9876543210fedcba9876543210' + + +class Done(Exception): + pass + + +class WatchStop(unittest.TestCase): + def run_watch(self, intent=None, symlink=False): + """ONLINE, then OFFLINE; returns the notices sent.""" + with tempfile.TemporaryDirectory() as directory: + run = Path(directory) / 'run' + run.mkdir() + if intent is not None: + target = run / f'intent-{INVOCATION}' + if symlink: + real = Path(directory) / 'elsewhere' + real.write_text(intent + '\n') + target.symlink_to(real) + else: + target.write_text(intent + '\n') + states = iter([cp.ONLINE, 0, 0]) + sleeps = [] + + def sleep(seconds): + sleeps.append(seconds) + if len(sleeps) == 3: + raise Done + + sent = [] + with patch.object(cp, 'RUN', run), \ + patch.dict(os.environ, {'INVOCATION_ID': INVOCATION}), \ + patch.object(cp.os, 'open', return_value=99), \ + patch.object(cp.fcntl, 'ioctl', side_effect=lambda fd, cmd: next(states)), \ + patch.object(cp, 'record_crash'), \ + patch.object(cp, 'notify', side_effect=lambda title, body: sent.append(title)), \ + patch.object(cp.time, 'sleep', side_effect=sleep): + with self.assertRaises(Done): + cp.watch() + return sent + + def test_stop_with_this_invocations_intent_sends_nothing(self): + self.assertEqual(self.run_watch(intent=INVOCATION), []) + + def test_without_intent_sends_once(self): + self.assertEqual(self.run_watch(), ['Cellular stopped']) + + def test_wrong_intent_sends_once(self): + self.assertEqual(self.run_watch(intent=OTHER), ['Cellular stopped']) + + def test_symlinked_intent_sends_once(self): + self.assertEqual(self.run_watch(intent=INVOCATION, symlink=True), ['Cellular stopped']) + + def test_no_invocation_id_is_no_intent(self): + with patch.dict(os.environ, {'INVOCATION_ID': ''}): + self.assertFalse(cp.stop_intended()) + + +if __name__ == '__main__': + unittest.main()