Skip to content

omamobile-modem 0.1.10: the modem profile starts once per boot - #163

Merged
derekross merged 8 commits into
derekross:mainfrom
W4HO-ham:modem-once-per-boot
Oct 31, 2026
Merged

derekross merged 8 commits into
derekross:mainfrom
W4HO-ham:modem-once-per-boot

Conversation

@W4HO-ham

@W4HO-ham W4HO-ham commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The follow-up from #154: the gotcha becomes a guard on every phone. After the profile has stopped, starting it again in the same boot reset the palmtop (a watchdog reset with nothing in pstore), so the profile refuses a second start in the same boot.

Where the marker goes down: at the CP power-on, not at the first start. modem check refuses a second start before the start script writes anything, and the marker itself is created at the power-on step, so a stage that only ran rfsd doesn't count as a start and doesn't block the next one. The create is atomic (( set -C; : > "$mark" )), so two starts launched at the same moment can't both get through.

#148 has merged and this is rebased onto it, so only the two 0.1.10 commits remain (the version conflict is resolved to 0.1.10). The 0.1.8 commit is no longer on the branch.

Tested on the 9a tonight: the modem reaches ONLINE, the marker lands at the power-on, and a second start in the same boot is refused by modem check before anything runs. omamobile-vendor-chroot modem check prints the refusal (read-only) while the modem is up, and "preconditions met" after a reboot.

…rary and the CP state it waits for

On the 9a gps.cfg sets GlueLayer_IsUseCustomGnssLib, and gnssd dlopen()s libcustomgnss.so, which waits for ONLINE at /sys/bus/platform/devices/cpif/modem_state and then opens RIL's GPS channel through libsitril-gps and libsitril-client. The extractor left all three out, since nothing links them, and the chroot's /sys had only the device path, not its bus link. Neither fixes Kepler's engine-start fault yet.
On the palmtop (Pixel 9a) every open and close of umts_boot0 woke the CP's PCIe link for about 100 ms. The watcher opened the file for each 0.5 s poll, so it woke the link about 120 times a minute. It now holds one file open for the whole watch and polls every 5 s, which cuts the link-ups to about 5 a minute. Whether the status ioctl on the held file wakes the link too is being measured. The watcher was one source of link cycling, and the hang seen while gnssd reloaded Kepler is still open: it happened with this watcher in place too. A crash still shows within seconds.

The interval, OMAMOBILE_MODEM_WATCH_SECONDS, is read inside watch() and checked against 0.2-60 s, with the default used otherwise, so a bad value can't break the other subcommands, power-off at the profile's stop included. The package test covers it.
…s at 0.5 s

Measured on the palmtop with the modem ONLINE: the profile's held-file watcher made 0 link-ups in a minute, and a second held-file watcher at 0.5 s added 0 in its minute. So it is the open and close of umts_boot0 that wakes the CP's PCIe link, not the status ioctl, and the default goes back to 0.5 s with the file held open; crash timing on the other phones stays as it was.
After the profile has stopped, starting it again in the same boot reset the palmtop (Pixel 9a) silently, a watchdog reset with nothing in pstore, and on the 6 Pro an in-place restart left the CP in BOOTING. The start script's own marker only covers a bring-up that never reached ONLINE. The profile now writes a marker under /run at its first start and refuses a second start in the same boot with a message that says to reboot; nothing removes the marker. The test runs the guard twice.
@derekross

Copy link
Copy Markdown
Owner

Thanks for turning the gotcha into a guard; a reboot really is the only recovery we know works. Since it's still a draft behind #148, here are two things worth fixing before it comes out of draft. Both come from where the marker is checked and written, not from the idea.

  1. A refused start turns the modem off for the next boot as well. omamobile-modem-start writes /var/lib/omamobile/modem-bringup-started and then execs omamobile-vendor-chroot modem start. Only the watcher removes that file, at ONLINE. The new check is the first line of profile_start, before the watcher starts. So a second systemctl start omamobile-modem rewrites the persistent marker, then dies on the once-per-boot check. The user reboots as the message says, and the start script skips the modem because "the last bring-up never reached ONLINE". The check has to refuse before the start script writes its marker. One way: test for the /run marker in profile_check (the start script runs modem check before it writes anything), and write the marker in profile_start.

  2. It also refuses the staged start that the runbooks use. The marker is written before [[ $MODEM_STAGE == rfsd ]] && return, so an rfsd-only start counts as the boot's one start. The Pixel 7 Pro's MODEM-PLAN M3.4.4 runs the profile with OMAMOBILE_MODEM_STAGE=rfsd, then M3.4.5 starts omamobile-modem in the same boot, and raven's steps 5 and 6 do the same. With this change the second step would be refused, and through point 1 it would also skip the modem at the next boot. The hazard you describe is a second CP power-on, so I'd write the marker just before cbd runs, after the rfsd-stage return. Please also add a test for the order: an rfsd-stage start followed by a full one is allowed, and a refused start leaves the persistent marker as it was.

Once #148 has merged and you've rebased (its modem files are identical to the copy you stacked on, so the rebase only drops those commits), the version will be 0.1.10 if nothing else has taken it. As with #148, this changes the shared profile the Pixel 7 Pro runs, so I'll start the modem on my phone once before it merges, and try a second start to see the refusal.

… the CP power-on

The once-per-boot guard ran first in profile_start, after the start script had already written its persistent marker, so a refused second start made the next boot skip the modem too. It also counted an rfsd-only staged start as the boot's one start, which the runbooks' rfsd-then-full sequence needs. The check now runs from profile_check (the start script runs modem check before it writes anything) and from profile_start, and the marker is written just before cbd runs, after the rfsd-stage return. The tests cover the staged start, the refusal from the check, and the persistent marker staying as it was.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Both points are in, at 9b1bcb0.

  1. The refusal now comes from the check. modem_once_per_boot is split into modem_once_check and modem_once_mark. profile_check runs the check first, so modem check, which the start script runs before it writes /var/lib/omamobile/modem-bringup-started, refuses a second start and the persistent marker stays as it was; the next boot still starts the modem. profile_start runs the check as well, for a start that skips the script.
  2. The marker is written in profile_start just before cbd runs, after the MODEM_STAGE == rfsd return. An rfsd-only staged start writes nothing, so cheetah's M3.4.4 then M3.4.5 and raven's steps 5 and 6 are one CP power-on.

Tests (packages/omamobile-modem/test/all): the staged sequence (check, rfsd stage writes no marker, full start marks, the next check is refused), the order in the source (the check first in profile_check, the mark between the rfsd return and the cbd line, the start script's check before its marker write), and a refused check stopping before anything is written. tools/pr-check passes.

Still stacked on #148 (open), so this stays a draft; once #148 merges I'll rebase so only this commit remains, at 0.1.10 if it's still free.

# Conflicts:
#	packages/omamobile-modem/version
@derekross

Copy link
Copy Markdown
Owner

Thanks for the quick turnaround. Both points from my last comment are in at 9b1bcb0, and I checked them against the code. The check is the first thing profile_check runs, and the start script runs modem check before it writes its latch, so a refused start no longer makes the next boot skip the modem. The marker is now written after the rfsd-stage return, just before cbd, so the staged rfsd-then-full sequence from cheetah's and raven's runbooks still works. The package test passes for me, also from the package directory on its own, and the gate is clean.

What's left is ordering and paperwork:

  1. Once omamobile-modem 0.1.9: watch the CP state on one open file #148 merges, please rebase so only your two 0.1.10 commits remain (the version file conflicts otherwise).
  2. When I squash, I'll write the message myself. The first 0.1.10 commit says the marker is written at the first start, which the second commit changed, and the branch still carries the 0.1.8 commit main already has.
  3. Could you update the PR description the same way: the marker goes down at the CP power-on, and an rfsd-only stage doesn't count?

Two small optional ideas. The marker could be created atomically (( set -C; : > "$mark" )), so two starts launched at the same moment can't both get through. And it's worth a line in the README that modem check now refuses once the modem is up, since we've used it as a health check after installs.

If you get a minute with the modem up on the 9a, omamobile-vendor-chroot modem check should print the refusal (it's read-only), and after the next reboot it should say "preconditions met". That's a safe proof on your phone. On my side, since this changes the profile every phone runs, I'll start the modem on my Pixel 7 Pro once, try a second start to see the refusal, and check that the next boot brings the modem up normally, before I merge.

Two starts launched at the same moment could both pass the check before either wrote the marker; the mark is now created with set -C, so the second fails there.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Description updated as you describe (the marker at the CP power-on, an rfsd-only stage doesn't count, and that modem check now refuses once the modem is up). The atomic create is in at bb5132d (set -C, the second of two simultaneous starts fails there), tests pass. The package has no README to carry the modem check note, so it lives in the description and the profile's comment. I'll rebase once #148 is in, and run the read-only modem check proof on the palmtop the next time its modem is up.

W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Oct 30, 2026
…t, and runs on real packages

The slot-B precondition and a one-hang cap head the runbook, citing the AGENTS line that is on main. Every stop of the modem unit by hand becomes an attended reboot, since a profile stop hard-reset the palmtop once and the power-off path is unqualified; SIM-11's checksum compare moves to after the reboot. SIM-1 now requires a real install of omamobile-modem (0.1.10 once derekross#148 and derekross#163 merge) with pacman -Qkk clean and the profile's sha256 recorded, and omamobile-modem-sit 0.3.4, since 0.3.3's state reads cycle the CP link. The start script the runbook relies on is committed under device/tegu/bringup. Smaller: no calls to the palmtop during the test and what to do if a release isn't confirmed, the cluster watchdog reset named for a hang, test -d for the CPIF check, the unit copy marked temporary, the Linux poweroff question answered, the network no longer named.
@derekross

Copy link
Copy Markdown
Owner

Thanks for the atomic create. It's right: the second of two starts stops before cbd, and the profile takes rfsd down with it. Once #148 has merged, I can move this onto main myself if you like, by cherry-picking your three 0.1.10 commits (0e4df8d, 9b1bcb0, bb5132d). I tried it here: no conflicts, the version lands at 0.1.10, and the package is identical to your branch. Then I'll start the modem on my 7 Pro, try a second start to see the refusal, and check that the next boot brings it up normally, before merging. Your read-only modem check on the 9a would be a nice extra proof, but it isn't needed for the merge.

# Conflicts:
#	packages/omamobile-modem/version
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Merged main after #148 landed: 0.1.10 now sits on 0.1.9's held-file watcher, with the once-per-boot marker and the noclobber create on top. pr-check and the package test pass; nothing else changed.

@derekross
derekross marked this pull request as ready for review October 31, 2026 03:24
@derekross
derekross merged commit 3471da7 into derekross:main Oct 31, 2026
2 checks passed
@derekross

Copy link
Copy Markdown
Owner

Tested on my 7 Pro tonight, from a build identical to your branch: the modem reached ONLINE in about 9 s, the marker was in /run/omamobile-modem/profile-started, and a second start in the same boot was refused ("the modem profile already started this boot (at 22:20:29); reboot before starting it again") while the running modem stayed active. Thanks for merging main in yourself; that made the cherry-pick unnecessary. Merged!

Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 1, 2026
…blocklist

Unplugging the cable and plugging it back in leaves a Pixel 8 Pro off the
USB link until it is rebooted: the MAX77759's Type-C side opens its USB2
data switch (TCPC 0x25, vendor register 0x93) on unplug, and with no Type-C
driver nothing closes it again, only the bootloader does at the next boot.
The README said so ("a replug may need a reboot"); on a Pixel 8 Pro the
kernel log shows nothing at all at the unplug, and the switch reads 0x00
after it and 0x09 once the rescue has written it back.

Add omamobile-usb-rescue, the Pixel 7 Pro's service on husky's bus
(10cb0000.i2c, hsi2c_11): while VBUS is valid (CHG_DETAILS_00.CHGIN_DTLS
== 3) it writes 0x09 to 0x25:0x93 when the switch is not 0x09, and it
stands aside once a Type-C driver owns the chip. It writes that one
register only, and logs every change of the switch, VBUS and the UDC
state to the journal. Without the bus (the base DT disables it) it says
so and exits, so the unit is inert until the bring-up overlay enables
hsi2c_11 (kernel derekross#163). Depends on i2c-tools.

Also add the MAX77759 blocklist the Pixel 7 Pro has, plus max77759_charger:
binding the PMIC creates its charger, GPIO and NVMEM cells, and the
charger driver programs the charge limits from the battery node, so
those and tcpci_maxim must not load before their bring-up steps.
Blacklist only, so a manual modprobe still works; the fuel gauge and the
MFD core still autoload. The test's "modprobe.d only sets options" rule
now has this one file as its exception, checked for what it contains.

Tested on a Pixel 8 Pro (7.3.0-rc6, slot B): unplug at 11:37:08 (switch
0x00, VBUS 0), replug at 11:37:26 (VBUS 1), the service wrote 0x09 and
the desktop had the link back at 11:37:28, no reboot; the same on a wall
charger. test/all passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 1, 2026
…ator

Three overlays for the MAX77759 steps of the battery plan, none default,
listed through DTB_OVERLAYS like the other devices':

- battery-clk-test: CMU_PERIC1 and its sysreg, USI11 and the bus still off
  (step M2b);
- battery-i2c-test: also USI11 and hsi2c_11, the bus of the gauge, PMIC,
  charger registers and Type-C controller (M3). They need kernel derekross#163;
- gauge-model: Google's ModelGauge m5 model for the pack, as
  maxim,fg-model and maxim,fg-params on the fuel gauge (M4c).

Without a model the gauge stays in its power-on state (Status 0x0002,
Config 0x2354) and reports a battery temperature stuck at exactly 22.0 C:
the same gauge on a Pixel 7 does the same without its model and reads
33.1 C with it (kernel derekross#171). With default-a1-0k (what Google's driver
falls back to for an unknown pack) loaded through this overlay the driver
logs "battery model loaded (DesignCap 0x994, TaskPeriod 0x2d00)", the
power-on bit clears, and the temperature reads 34.4 C and moves. The pack
(ATL, COS or LSN) is not known yet, so the percentage may be a few points
off; the charge voltage comes from the device tree, not the model.

tools/gen-gauge-overlay.py writes the overlay from Google's stock husky
node, so no number is typed by hand: each stock u32 table cell becomes
two u16 words, the stock parameter bytes become big-endian u16 words in
the order of struct max77759_fg_params. The shipped gauge-model.dtso is
its output for default-a1-0k.

tests/device-overlays compiles all three with dtc -@ (48 overlays ok).
Booted on a Pixel 8 Pro (7.3.0-rc6, slot B): all three, in order.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 1, 2026
The tool's recovery text had the Pixel 7 Pro's buttons: on the 8 Pro the
forced restart is Power + Volume Up for 15 to 30 s, then Power + Volume
Down for fastboot, and the known-good set is "your known-good image set".
Both the recovery text and wd-drill's start message now warn that every
reset spends one of slot B's three boot tries. The phone half refuses a
board that is not google,zuma-husky.

The notes get a boot-count rule in the safety section, a clause on which
kernel was booted against derekross#163 and derekross#175 as they stand, the hand writes
marked as research, the stock tables' source, the 2 mAh per unit fix, the
overlay list, and the matrix cells qualified as a test kernel. gen-gauge-
overlay.py gets its SPDX header.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Lef <me@lefteros.com>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…ross#163)

A second start of the modem profile in a boot where the CP was already powered is refused: the check runs first in profile_check, and a marker in /run/omamobile-modem is created atomically (noclobber) at the CP power-on, after the rfsd stage, so the staged rfsd-then-full sequence still works and a refused start doesn't write the persistent latch that would skip the next boot. A second start in the same boot reset the 9a and left raven's CP in BOOTING.

Tested on the Pixel 7 Pro (2026-10-30): the modem reached ONLINE in about 9 s, and a second start in the same boot was refused with "the modem profile already started this boot …; reboot before starting it again" while the running modem stayed active.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants