From d90a1347fafdf69d485dca0ec38c7c67d537382f Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Thu, 29 Oct 2026 09:13:33 +0100 Subject: [PATCH 01/32] dodge: descriptor, NOTES, BRINGUP and chainload helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Device-only first cut for OnePlus 13 (dodge). Omarchy on slot B with UFS_RW="boot_b userdata", shared initramfs/init, BOOT_METHOD=qcom-abl. BRINGUP records how this phone was installed (firmware A→B for ARB, GPT bit 54 by hand); the inactive-slot installer and firmware-match helper are deferred. Includes the reboot wrapper the package test compares. Signed-off-by: Martin Lund Assisted-by: Grok Bot --- device/dodge/BRINGUP-M1.md | 81 ++++++++++++++ device/dodge/NOTES.md | 86 +++++++++++++++ device/dodge/chainload/README.md | 12 ++ device/dodge/chainload/init | 39 +++++++ device/dodge/chainload/probe-init | 58 ++++++++++ device/dodge/chainload/stage2-dtb.py | 159 +++++++++++++++++++++++++++ device/dodge/device.conf | 26 +++++ device/dodge/initramfs/reboot-to.c | 56 ++++++++++ device/dodge/reboot | 10 ++ 9 files changed, 527 insertions(+) create mode 100644 device/dodge/BRINGUP-M1.md create mode 100644 device/dodge/NOTES.md create mode 100644 device/dodge/chainload/README.md create mode 100644 device/dodge/chainload/init create mode 100644 device/dodge/chainload/probe-init create mode 100755 device/dodge/chainload/stage2-dtb.py create mode 100644 device/dodge/device.conf create mode 100644 device/dodge/initramfs/reboot-to.c create mode 100755 device/dodge/reboot diff --git a/device/dodge/BRINGUP-M1.md b/device/dodge/BRINGUP-M1.md new file mode 100644 index 000000000..8a41bffb8 --- /dev/null +++ b/device/dodge/BRINGUP-M1.md @@ -0,0 +1,81 @@ + +# OnePlus 13 (dodge): first light and install record + +Status (2026-10-28): boots native Arch / Omarchy on SM8750 from slot B's +`boot` partition. Companion kernel under review: +[linux-omarchy-mobile #115](https://github.com/derekross/linux-omarchy-mobile/pull/115). +This document is the CONTRIBUTING §5 / §6 first-light **record** of how this +phone was installed. It is not a procedure for other owners: the guarded +inactive-slot installer and firmware-match helper are deferred to a later PR. + +## 1. Sources + +- **Kernel base:** `omamobile` on + [derekross/linux-omarchy-mobile](https://github.com/derekross/linux-omarchy-mobile). +- **Board series:** subsystem-split commits on `dodge/pr-kernel-v1` + ([#115](https://github.com/derekross/linux-omarchy-mobile/pull/115)). Config + profile: `gpu2` (`CONFIG_QCOM_IPA=m`, MSM DRM). +- **Device tree:** `arch/arm64/boot/dts/qcom/sm8750-oneplus-dodge.dts` + (`compatible = "oneplus,dodge", …`). +- **Userspace:** `device/dodge/` and `packages/omamobile-device-dodge` in this + repository. Shared `initramfs/init` (storage guard + allowlist); no + dodge-forked init. + +## 2. Descriptor + +[device.conf](device.conf): `BOOT_METHOD=qcom-abl`, `BOOT_IMAGES=boot`, +`UFS_RW="boot_b userdata"`, `OMAMOBILE_SLOT=b`, `COMPATIBLE="oneplus,dodge"`, +`FASTBOOT_PRODUCT=sun`. Omarchy runs on slot B; stock stays on slot A. Day-2 +kernel updates rewrite `boot_b` only. + +## 3. How this phone was installed (record) + +On 2026-10-28, from private branch `oneplus13-dodge`, OxygenOS family +CPH2653 16.0.10: + +1. **Firmware match (ARB).** OxygenOS anti-rollback means booting a slot whose + `xbl_config` / firmware is below the fuse floor can hard-brick. Before + activating slot B, every A/B firmware pair was hashed; **27 differed**. + A byte-exact A→B copy of abl/aop/…/xbl/modem/… was done with sha256 + read-back. Left untouched: vbmeta, qweslicstore, oplusstanvbk, + modemst/fsg/fsc/persist/EFS/oplusdycnvbk/RPMB. A later helper RAM-boot + reported RESULT=MATCH with no writes. +2. **Flash.** Omarchy `boot_b` and Arch on `userdata`; stock OTA `boot.img` + left on `boot_a` only (not booted). `--set-active=b`, reboot. +3. **Boot-success (GPT bit 54).** Qualcomm ABL keeps the slot-successful flag + in GPT attribute bit 54 of `boot_` (primary + backup, both CRCs). + Without it, ABL burns a retry each boot, marks the slot unbootable, and + falls back to slot A (stock over Omarchy userdata). On this phone the bit + was set by hand after the first clean boot — LUN/sectors/bit/CRCs, + before-after, and the rollback (`fastboot --set-active=a` only after a + userdata wipe plan) are recorded under + [NOTES](NOTES.md#2026-10-28-matrix-evidence). A oneshot service is not + shipped in this PR; see the PR discussion for the Pixel-shaped alternative. + +`version-bootloader` is empty on this ABL, so a Pixel-style BL string check +cannot substitute for the firmware match. + +## 4. Modem (opt-in) and off-phone backups + +Units under [modem/](modem/) stay inert unless +`/etc/omamobile/modem-probe.enable` exists. With the flag, each boot restores a +named good EFS *copy* under `/var/lib/omamobile/efs-good/` (read-only `dd` of +the phone's own partitions; never `-P` on the live partitions; never committed +to git). See [modem/README.md](modem/README.md). + +Per CONTRIBUTING §3.3, before any modem session this phone also keeps +**off-phone**, read-only backups of `modemst1`, `modemst2`, `fsg`, `fsc`, +`persist`, and the oplus NV partitions, with a `SHA256SUMS` checked before +each session. Those backups are never in git. + +## 5. Phone-smoke evidence (2026-10-28 slot-B move) + +| Gate | Evidence | Result | +| --- | --- | --- | +| Firmware-match | sha256 of every `*_a`/`*_b` pair: **27 differed**. Byte-exact A→B copy (read-back verified). Left untouched: vbmeta, qweslicstore, oplusstanvbk, modemst/fsg/fsc/persist/EFS/oplusdycnvbk/RPMB | pass | +| Inactive-slot boot | Omarchy `boot_b` set active; stock OTA `boot.img` on `boot_a` only | pass | +| `version-bootloader` | empty on this ABL | noted | +| Boot-success | GPT bit 54 set by hand on `boot_b` after first clean boot | pass | + +A `tools/phone-smoke` report from one boot of the build this PR describes is a +follow-up (needs a phone boot of this curated tip). diff --git a/device/dodge/NOTES.md b/device/dodge/NOTES.md new file mode 100644 index 000000000..cc25d59fe --- /dev/null +++ b/device/dodge/NOTES.md @@ -0,0 +1,86 @@ + +# OnePlus 13 (dodge) + +Status (2026-10-28): native Arch Linux ARM / Omarchy Mobile on Qualcomm SM8750 +(`7.3.0-rc6-dodge-gpu2` lineage). Display, GPU (Adreno 830), touch, Wi-Fi, +Bluetooth pairing, speakers/mics, sensors (autorotate), USB gadget networking +and SSH work on the phone. Modem (MPSS + IPA + ModemManager + NetworkManager +cellular) works behind an opt-in flag with a per-phone EFS restore (see +[modem/README.md](modem/README.md)); no modem blobs or EFS snapshots are in +this repository. Fingerprint, cameras and NFC are not started. + +Kernel series: [linux-omarchy-mobile #115](https://github.com/derekross/linux-omarchy-mobile/pull/115) +(`dodge/pr-kernel-v1`; subsystem-split; gpu2 + IPA). Device tree: +`arch/arm64/boot/dts/qcom/sm8750-oneplus-dodge.dts`. Userspace: this tree's +`device/dodge/` and `packages/omamobile-device-dodge`. + +Descriptor: `BOOT_METHOD=qcom-abl`, `OMAMOBILE_SLOT=b`, +`UFS_RW="boot_b userdata"`. Omarchy runs on slot B; stock stays on slot A. +Day-2 kernel updates rewrite `boot_b`. The guarded inactive-slot installer +and firmware-match helper are deferred to a later PR; how this phone was +installed (firmware A→B copy for ARB, GPT bit-54 mark) is a record in +[BRINGUP-M1.md](BRINGUP-M1.md), not a procedure for others. Never flash xbl, +abl, vbmeta or modem from an image. + +## Feature matrix (phone-verified) + +| Block | Status | Notes | +| --- | --- | --- | +| Boot | testing | Omarchy on `boot_b` (2026-10-28); stock `boot_a` kept; GPT bit 54 marked by hand (kernel in review, [#115](https://github.com/derekross/linux-omarchy-mobile/pull/115)) | +| Storage | testing | UFS; guard allowlists `boot_b` and `userdata` (shared `initramfs/init`) | +| Display | testing | Samsung panel through msm/dpu; brightness and DPMS; warm-boot drop fixed (QTB read) | +| GPU | testing | Adreno 830 (gpu2); glmark2 / Freedreno on the phone; Vulkan untested | +| Touch | testing | Synaptics over SPI | +| Buttons | testing | Power and volume | +| USB net | partial | CDC NCM gadget + ACM console; SSH. Gap: gadget stuck after cable replug until reboot | +| Wi-Fi | testing | WCN7860 (peach) / ath12k; autoconnect and 5 GHz | +| Bluetooth | partial | WCN7860; pairing verified; A2DP untested (no headset yet) | +| Battery | partial | gauge reads; charging path not fully claimed | +| Speakers/mics | testing | AW882xx + UCM2 + PipeWire; speaker, earpiece and built-in mics; headset plug untested | +| Sensors | testing | SSC via hexagonrpc / libssc; accel, proximity, compass; autorotate | +| Modem | testing | MPSS + IPA + MM + NM; LTE registration and data; EFS restore every boot; opt-in flag; calls/SMS untested | +| Suspend | WIP | screen-off idle works; s2idle not yet the default | +| Fingerprint | no | | +| Cameras | no | | +| NFC | no | | +| Charging / Haptics / Torch / GNSS | no | | +| AoC | - | Tensor-only block | + +## 2026-10-28: matrix evidence + +Phone-verified summary for [docs/DEVICES.md](../../docs/DEVICES.md). Companion +kernel in review as +[linux-omarchy-mobile #115](https://github.com/derekross/linux-omarchy-mobile/pull/115). +Full narrative for the slot-B move is in [BRINGUP-M1.md](BRINGUP-M1.md) §5. + +| Block | What was run on the phone | Status word | +| --- | --- | --- | +| Boot / storage | Firmware A→B match (27 pairs, sha256 read-back); Omarchy on `boot_b`; GPT bit 54 marked by hand; stock OTA `boot` kept on `boot_a` | testing | +| Display | msm/dpu panel up; brightness and DPMS; warm-boot drop closed (QTB read on MDSS enable; Martin verified cold start and idle/wake 2026-10-24) | testing | +| GPU | Adreno 830 via Freedreno on gpu2; Hyprland and glmark2 on the phone; Vulkan (turnip) not run | testing | +| Touch / buttons | `touchpanel` input; power and volume keys | testing | +| USB net | CDC NCM + ACM + SSH. Known gap: after a cable replug the UDC can stay stuck until a reboot | partial | +| Wi-Fi | WCN7860 / ath12k; autoconnect, DHCP, 5 GHz | testing | +| Bluetooth | hci0 up; pairing with another phone verified; A2DP / headset audio not tested | partial | +| Battery | fuel-gauge capacity reads; charging path not claimed | partial | +| Speakers/mics | Speaker and earpiece heard; built-in mic record+playback hands-on; USB-C headset plug untested | testing | +| Sensors | Accelerometer, proximity, compass through SSC; autorotate on by default after install | testing | +| Modem | With `/etc/omamobile/modem-probe.enable` and IPA (gpu2): LTE registration and data; EFS restore every boot; calls and SMS untested. Flag is opt-in in the package | testing | +| Suspend | Screen-off idle with GDSC off; `systemctl suspend` / s2idle not the default | WIP | + +## Provenance + +- Board DTS and driver enablement authored for Omarchy Mobile from public + mainline SM8750 support, OnePlus 13 DT fragments, and bring-up on this phone. +- Audio codec unmute and panel sequence: see kernel commit messages and + `Assisted-by` / `Signed-off-by` trailers. +- Missing upstream sign-offs from earlier community fragments (index986 / + ROCKNIX / Teguh) are listed in the kernel PR description for the maintainer. + +## What is not in this tree + +Lab notebooks (`dev-docs/`), DIAG trials, out-of-tree splash/fastrpc experiments, +EFS snapshots, modem firmware blobs, and AGENTS/PLAN files stay on the private +bring-up branch. The modem units document how to take **read-only** `dd` +copies of the phone's own EFS partitions onto the device; those copies are +never committed. diff --git a/device/dodge/chainload/README.md b/device/dodge/chainload/README.md new file mode 100644 index 000000000..6de970aa1 --- /dev/null +++ b/device/dodge/chainload/README.md @@ -0,0 +1,12 @@ + +# dodge chainload (optional) + +Helpers used during early bring-up to load a stage-2 DTB and continue into the +Arch root without flashing. Day-to-day kernel updates rewrite `boot_b` from +a built `boot.img`; keep these scripts only if you are iterating a one-shot +`fastboot boot` image. + +- `init` / `probe-init`: small initramfs entry points for chain experiments. +- `stage2-dtb.py`: packs or swaps a board DTB into a boot image for trials. + +Nothing here is required by `packages/omamobile-device-dodge`. diff --git a/device/dodge/chainload/init b/device/dodge/chainload/init new file mode 100644 index 000000000..dcd992a7d --- /dev/null +++ b/device/dodge/chainload/init @@ -0,0 +1,39 @@ +#!/omamobile/busybox sh +# SPDX-License-Identifier: MIT +# Stage 1 of the dodge kexec chain-loader (device/dodge/PLAN.md §5.3). +# +# Runs on our kernel and ABL's stock DTB, from the kernel's built-in +# initramfs, started by CONFIG_CMDLINE_FORCE rdinit=/omamobile/init. +# Everything lives under /omamobile so the ramdisks ABL unpacks over +# the built-in one (vendor_boot, Magisk's init_boot) cannot replace it. +# +# kexec_load (kexec-tools -c -l --dtb) starts stage 2: our kernel, our +# DTB, our initramfs. -c matters: kexec-tools 2.0.32 tries kexec_file_load +# first, which ignores --dtb on arm64 and hands stage 2 the running FDT, +# stock's. Every boot before 2026-10-16 ran stage 2 on stock's DTB. +# Each failure holds for its own time, so the time OxygenOS comes back +# says which step failed: +# kexec -l fails -> hold 230 s, then reset +# kexec -e returns -> hold 200 s, then reset +# Keep both away from stage 2's own fallbacks. PID 1 never exits. +B=/omamobile/busybox +$B mount -t proc proc /proc +CMDLINE=$($B cat /omamobile/cmdline) +# dodge_vbif (built into the dodge kernel, DIAG for the warm-boot display +# drop): hand stage 1's VBIF snapshots (early_initcall and just before +# kexec) to stage 2 on its command line. Skipped when the kernel lacks it. +if $B mount -t sysfs sysfs /sys 2>/dev/null && [ -d /sys/module/dodge_vbif ]; then + V=/sys/module/dodge_vbif/parameters + echo 1 > $V/snap + CMDLINE="$CMDLINE dodge_vbif.s1e=$($B cat $V/early) dodge_vbif.s1k=$($B cat $V/last)" +fi +KEXEC="/omamobile/lib/ld-musl-aarch64.so.1 --library-path /omamobile/lib /omamobile/kexec" +if $KEXEC -c -l /omamobile/Image --dtb=/omamobile/dodge.dtb \ + --initrd=/omamobile/initrd --command-line="$CMDLINE"; then + $KEXEC -e + $B sleep 200 +else + $B sleep 230 +fi +echo b > /proc/sysrq-trigger +while :; do $B sleep 60; done diff --git a/device/dodge/chainload/probe-init b/device/dodge/chainload/probe-init new file mode 100644 index 000000000..02842cdfc --- /dev/null +++ b/device/dodge/chainload/probe-init @@ -0,0 +1,58 @@ +#!/bin/busybox sh +# SPDX-License-Identifier: MIT +# Timing-coded probe for stage 2 of the dodge chain-loader. No USB, no +# log: the time until OxygenOS returns carries up to five yes/no facts. +# +# /probe-paths has one test per line, bit 0 first: +# a path or glob the bit is set if it exists +# eq:PATH=VALUE the bit is set if the file reads VALUE +# kmsg:TEXT the bit is set if the kernel log contains TEXT +# deferred:NAME the bit is set if NAME is in devices_deferred +# v = sum of bit_i << i. After a 40 s settle the init holds 10 + 8*v s, +# then resets. adb lands near 72 + 8*v s after Booting OKAY (stage 2 and +# OxygenOS take about 22 s together; the 60 s hold came back at 82 s). +# If the reset request is ignored, a panic at 320 s resets (panic=10). +# +# The cpio must carry /proc, /sys and /dev: without them every write to +# /proc/sysrq-trigger fails and PID 1 sleeps forever (2026-10-15 probes). +# PID 1 never exits. +B=/bin/busybox +$B mount -t proc proc /proc +$B mount -t sysfs sysfs /sys +$B mount -t devtmpfs devtmpfs /dev +$B mount -t debugfs debugfs /sys/kernel/debug +echo 1 > /proc/sys/kernel/sysrq +( $B sleep 320; echo c > /proc/sysrq-trigger ) & +$B sleep 40 +v=0 +i=0 +while read -r t; do + case $t in ''|'#'*) continue ;; esac + case $t in + eq:*) + t=${t#eq:} + [ "$($B cat "${t%%=*}" 2>/dev/null)" = "${t#*=}" ] && v=$((v | (1 << i))) + ;; + kmsg:*) + $B dmesg | $B grep -F "${t#kmsg:}" >/dev/null && v=$((v | (1 << i))) + ;; + deferred:*) + if $B grep -F "${t#deferred:}" /sys/kernel/debug/devices_deferred >/dev/null 2>&1; then + v=$((v | (1 << i))) + fi + ;; + *) + for f in $t; do + [ -e "$f" ] && v=$((v | (1 << i))) + break + done + ;; + esac + i=$((i + 1)) +done < /probe-paths +echo "omamobile-probe v=$v" > /dev/kmsg +$B sleep $((10 + 8 * v)) +echo b > /proc/sysrq-trigger +$B sleep 5 +echo c > /proc/sysrq-trigger +while :; do $B sleep 60; done diff --git a/device/dodge/chainload/stage2-dtb.py b/device/dodge/chainload/stage2-dtb.py new file mode 100755 index 000000000..8d89f5e6b --- /dev/null +++ b/device/dodge/chainload/stage2-dtb.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Make the stage 2 DTB for the dodge kexec chain-loader. + +Usage: stage2-dtb.py [ramoops] [splash] [fb] [peripheral] [hs] [rscpd] + +ABL fills the `memory` node at boot and kexec does not, so its reg is +taken from the phone's live FDT (/sys/firmware/fdt from a rooted +capture, kept outside git). The upstream DTS carries another phone's +map. `memory@a0000000` keeps size 0. + +ramoops add a ramoops node at OxygenOS's ramoops address and layout +splash reserve ABL's splash buffer with an identity map on mdss +fb add a simple-framebuffer over ABL's splash buffer, reusing + splash's reservation if set. Works on our DTB with splash +ramoops was booted on 2026-10-15, also on stock's DTB, so it has not +really been tried either. +peripheral dr_mode = "peripheral" and no usb-role-switch on the dwc3 + node. The role otherwise comes from pmic_glink, which this + initramfs does not load. Not needed: otg works on our DTB. +hs peripheral, and drop the usb3-phy so dwc3 does not wait + on the combo PHY. Also drops the dwc3 iommus entry, which + blocks its DMA under ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT. +rscpd drop power-domains from the apps RSC, so RPMh does not wait + on PSCI's cpuidle genpd, which does not bind after kexec. +""" +import re +import subprocess +import sys + + +def dts(path): + return subprocess.run(["dtc", "-q", "-I", "dtb", "-O", "dts", path], + capture_output=True, text=True, check=True).stdout + + +def node_span(s, header): + i = s.index(header) + depth = 0 + for k in range(i, len(s)): + if s[k] == "{": + depth += 1 + elif s[k] == "}": + depth -= 1 + if depth == 0: + return i, k + raise ValueError(header) + + +def insert_in(s, header, text): + _, j = node_span(s, header) + line = s.rindex("\n", 0, j) + return s[:line] + text.rstrip("\n") + s[line:] + + +built, live, out, *opts = sys.argv[1:] +ours, theirs = dts(built), dts(live) + +i, j = node_span(theirs, "\n\tmemory {") +live_reg = re.search(r"reg = <[^>]*>;", theirs[i:j]).group(0) +i, j = node_span(ours, "\n\tmemory {") +block = ours[i:j] +ours = ours[:i] + block.replace(re.search(r"reg = <[^>]*>;", block).group(0), live_reg) + ours[j:] + +if "ramoops" in opts: + ours = insert_in(ours, "reserved-memory {", """ + ramoops@880000000 { + compatible = "ramoops"; + reg = <0x08 0x80000000 0x00 0x240000>; + record-size = <0x00>; + console-size = <0x40000>; + ftrace-size = <0x00>; + pmsg-size = <0x200000>; + ecc-size = <0x00>; + no-map; + }; +""") + +def force_peripheral(s): + if s.count('dr_mode = "otg";') != 1 or s.count("usb-role-switch;") != 1: + raise SystemExit("expected exactly one otg dr_mode and one usb-role-switch") + s = s.replace('dr_mode = "otg";', 'dr_mode = "peripheral";', 1) + return re.sub(r"\n[ \t]*usb-role-switch;\n", "\n", s, count=1) + + +if "peripheral" in opts or "hs" in opts: + ours = force_peripheral(ours) + +if "hs" in opts: + m = re.search( + r'phys = <(0x[0-9a-fA-F]+)[^>]*>;\n(\s*)phy-names = "usb2-phy", "usb3-phy";', + ours) + if not m: + raise SystemExit("expected usb2-phy and usb3-phy on one phys entry") + ours = (ours[:m.start()] + + f'phys = <{m.group(1)}>;\n{m.group(2)}phy-names = "usb2-phy";' + + ours[m.end():]) + # The dwc3 node is the only one with this SID. Dropping it avoids + # waiting on apps_smmu after kexec. + if 'iommus = <0x23 0x40 0x00>;' not in ours: + raise SystemExit("expected the dwc3 iommus entry") + ours = ours.replace('\n\t\t\t\tiommus = <0x23 0x40 0x00>;\n', '\n', 1) + +if "splash" in opts: + # SID 0x800 is mdss. ABL leaves it scanning 0xfc800000. The identity + # map is what arm-smmu installs from iommu-addresses. + if "qcom,sm8750-mdss" not in ours: + raise SystemExit("no mdss node") + ours = ours.replace( + "display-subsystem@ae00000 {", + "mdss: display-subsystem@ae00000 {", + 1) + ours = ours.replace( + 'compatible = "qcom,sm8750-mdss";', + 'compatible = "qcom,sm8750-mdss";\n\t\t\tmemory-region = <&cont_splash_mem>;', + 1) + ours = insert_in(ours, "reserved-memory {", """ + cont_splash_mem: splash@fc800000 { + reg = <0x00 0xfc800000 0x00 0x2b00000>; + no-map; + iommu-addresses = <&mdss 0x00 0xfc800000 0x00 0x2b00000>; + }; +""") + +# The apps RSC's only supplier is PSCI's power-domain-system genpd. After +# kexec the PSCI cpuidle domain does not bind, so fw_devlink holds the RSC +# (and RPMh clocks, GCC, regulators, everything after) unprobed. Without +# power-domains rpmh-rsc uses its CPU PM notifier instead +if "rscpd" in opts: + i, j = node_span(ours, "\n\t\trsc@16500000 {") + # Three tabs: the RSC's own property, not a child's. + m = re.search(r"\n\t\t\tpower-domains = <0x[0-9a-f]+>;", ours[i:j]) + if not m: + raise SystemExit("expected power-domains on the apps RSC") + ours = ours[:i + m.start()] + ours[i + m.end():] + +if "fb" in opts: + # splash already reserves this region and asks for the identity map. + # A second node at the same address is a broken DTB. + if "splash" not in opts: + ours = insert_in(ours, "reserved-memory {", """ + splash@fc800000 { + reg = <0x00 0xfc800000 0x00 0x2b00000>; + no-map; + }; +""") + ours = insert_in(ours, "\n\tchosen {", """ + framebuffer@fc800000 { + compatible = "simple-framebuffer"; + reg = <0x00 0xfc800000 0x00 0x1167000>; + width = <1440>; + height = <3168>; + stride = <5760>; + format = "a8r8g8b8"; + }; +""") + +subprocess.run(["dtc", "-q", "-I", "dts", "-O", "dtb", "-o", out, "-"], + input=ours, text=True, check=True) diff --git a/device/dodge/device.conf b/device/dodge/device.conf new file mode 100644 index 000000000..fb0d8353b --- /dev/null +++ b/device/dodge/device.conf @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: MIT +# Device descriptor: OnePlus 13 (dodge). Format rules: device/cheetah/device.conf. +# +# Omarchy runs on slot B; stock stays on slot A. Day-2 kernel updates write +# boot_b. This PR ships the device files only: the inactive-slot installer and +# firmware-match helper are deferred. How this phone was installed (including +# the firmware copy already done and the GPT bit-54 mark) is a record in +# BRINGUP-M1.md, not a procedure for others. FASTBOOT_PRODUCT=sun is ABL +# getvar product. Never flash xbl/abl/vbmeta/modem from an image. + +CODENAME=dodge +FASTBOOT_PRODUCT=sun +NAME="OnePlus 13" +SOC=sm8750 +COMPATIBLE="oneplus,dodge" +PACKAGE=omamobile-device-dodge +BOOT_METHOD=qcom-abl + +DTB=qcom/sm8750-oneplus-dodge.dtb +INITRAMFS_INIT=initramfs/init +PANEL_SIZE=1440x3168 + +BOOT_IMAGES=boot +UFS_RW="boot_b userdata" +OMAMOBILE_SLOT=b +CMDLINE="clk_ignore_unused pd_ignore_unused panic=10 console=tty0" diff --git a/device/dodge/initramfs/reboot-to.c b/device/dodge/initramfs/reboot-to.c new file mode 100644 index 000000000..f663f18e4 --- /dev/null +++ b/device/dodge/initramfs/reboot-to.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +// reboot-to: reboot with a reason ABL reads from the PMIC SDAM. +// "reboot-to bootloader" is LINUX_REBOOT_CMD_RESTART2. Busybox reboot +// cannot pass a reason. Same call as +// packages/omamobile-device-cheetah/src/reboot-to.c, built without a +// libc so the ramdisk pack needs no aarch64 sysroot. +// +// aarch64 Linux entry: sp points at argc, then the argv pointers. + +#define __NR_sync 81 +#define __NR_reboot 142 +#define __NR_exit_group 94 + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 + +static long scall(long n, long a, long b, long c, long d) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + register long x2 __asm__("x2") = c; + register long x3 __asm__("x3") = d; + + __asm__ volatile("svc #0" + : "+r"(x0) + : "r"(x1), "r"(x2), "r"(x3), "r"(x8) + : "memory"); + return x0; +} + +/* A C _start has a prologue, so sp there is no longer the entry stack. + Linux put argc at [sp] and argv just after it. */ +__attribute__((naked)) void _start(void) +{ + __asm__ volatile( + "ldr x0, [sp]\n" + "add x1, sp, #8\n" + "b go\n"); +} + +void go(long argc, char **argv) +{ + const char *reason = "bootloader"; + + if (argc > 1 && argv[1] && argv[1][0]) + reason = argv[1]; + + scall(__NR_sync, 0, 0, 0, 0); + scall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, + LINUX_REBOOT_CMD_RESTART2, (long)reason); + scall(__NR_exit_group, 1, 0, 0, 0); + for (;;) + ; +} diff --git a/device/dodge/reboot b/device/dodge/reboot new file mode 100755 index 000000000..1e4792e88 --- /dev/null +++ b/device/dodge/reboot @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# reboot bootloader on this phone is LINUX_REBOOT_CMD_RESTART2 with the +# string "bootloader". systemd's reboot bootloader is the EFI firmware +# path and does not pass that string, so ABL starts the normal boot. +# This file is ahead of /usr/bin/reboot on PATH. +if [ "${1-}" = bootloader ]; then + exec /usr/local/bin/reboot-to bootloader +fi +exec /usr/bin/systemctl reboot "$@" From 1a4c2cd550dfc1cd94a7ecefdadc8f03aa670f95 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Thu, 29 Oct 2026 09:13:33 +0100 Subject: [PATCH 02/32] dodge: omamobile-device-dodge package USB gadget networking, SSH, mirrorlist and reboot-to, with the package test that cmp's reboot and reboot-to.c against device/dodge/. Signed-off-by: Martin Lund Assisted-by: Grok Bot --- .../10-omamobile-usb.conf | 4 ++ .../20-usb-gadget.network | 18 ++++++ packages/omamobile-device-dodge/LICENSE | 21 +++++++ packages/omamobile-device-dodge/PKGBUILD | 43 ++++++++++++++ .../omamobile-mirrorlist | 3 + packages/omamobile-device-dodge/reboot | 10 ++++ packages/omamobile-device-dodge/reboot-to.c | 56 +++++++++++++++++++ .../sshd-omamobile.conf | 3 + packages/omamobile-device-dodge/sshd.sysusers | 4 ++ packages/omamobile-device-dodge/test/all | 9 +++ packages/omamobile-device-dodge/version | 1 + 11 files changed, 172 insertions(+) create mode 100644 packages/omamobile-device-dodge/10-omamobile-usb.conf create mode 100644 packages/omamobile-device-dodge/20-usb-gadget.network create mode 100644 packages/omamobile-device-dodge/LICENSE create mode 100644 packages/omamobile-device-dodge/PKGBUILD create mode 100644 packages/omamobile-device-dodge/omamobile-mirrorlist create mode 100755 packages/omamobile-device-dodge/reboot create mode 100644 packages/omamobile-device-dodge/reboot-to.c create mode 100644 packages/omamobile-device-dodge/sshd-omamobile.conf create mode 100644 packages/omamobile-device-dodge/sshd.sysusers create mode 100755 packages/omamobile-device-dodge/test/all create mode 100644 packages/omamobile-device-dodge/version diff --git a/packages/omamobile-device-dodge/10-omamobile-usb.conf b/packages/omamobile-device-dodge/10-omamobile-usb.conf new file mode 100644 index 000000000..e1297f94a --- /dev/null +++ b/packages/omamobile-device-dodge/10-omamobile-usb.conf @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MIT +# usb0 is configured by systemd-networkd. NetworkManager leaves it alone. +[keyfile] +unmanaged-devices=interface-name:usb0 diff --git a/packages/omamobile-device-dodge/20-usb-gadget.network b/packages/omamobile-device-dodge/20-usb-gadget.network new file mode 100644 index 000000000..d5c120b1d --- /dev/null +++ b/packages/omamobile-device-dodge/20-usb-gadget.network @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: MIT +# The initramfs brings up the CDC NCM gadget. This gives usb0 an address +# after switch_root. The laptop is 172.16.42.2. +# +# The laptop does not forward traffic, so its default route must lose to +# Wi-Fi's (NetworkManager uses metric 600 for wlan). Metric 900 keeps a +# fallback via the laptop without stealing the default route. +[Match] +Name=usb0 + +[Network] +Address=172.16.42.1/24 +DNS=1.1.1.1 +ConfigureWithoutCarrier=yes + +[Route] +Gateway=172.16.42.2 +Metric=900 diff --git a/packages/omamobile-device-dodge/LICENSE b/packages/omamobile-device-dodge/LICENSE new file mode 100644 index 000000000..aecd59624 --- /dev/null +++ b/packages/omamobile-device-dodge/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Derek Ross + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/omamobile-device-dodge/PKGBUILD b/packages/omamobile-device-dodge/PKGBUILD new file mode 100644 index 000000000..ffd7c803d --- /dev/null +++ b/packages/omamobile-device-dodge/PKGBUILD @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: MIT +# Maintainer: Martin Lund +pkgname=omamobile-device-dodge +pkgver=$(cat "${startdir:-.}/version") +pkgrel=1 +pkgdesc="Omarchy Mobile support for the OnePlus 13 (dodge): reboot-to-fastboot and USB networking" +arch=(aarch64) +url="https://github.com/derekross/omarchy-mobile" +license=(MIT) +depends=(bash systemd) + +build() { + # Same syscall as device/dodge/initramfs/reboot-to.c. No libc. + gcc -nostdlib -static -ffreestanding -fno-stack-protector \ + -fno-asynchronous-unwind-tables -Oz \ + -o "$srcdir/reboot-to" "$startdir/reboot-to.c" +} + +package() { + install -Dm755 "$srcdir/reboot-to" "$pkgdir/usr/local/bin/reboot-to" + install -Dm755 "$startdir/reboot" "$pkgdir/usr/local/bin/reboot" + install -Dm644 "$startdir/20-usb-gadget.network" \ + "$pkgdir/usr/lib/systemd/network/20-usb-gadget.network" + install -Dm644 "$startdir/10-omamobile-usb.conf" \ + "$pkgdir/usr/lib/NetworkManager/conf.d/10-omamobile-usb.conf" + install -Dm644 "$startdir/sshd-omamobile.conf" \ + "$pkgdir/etc/ssh/sshd_config.d/omamobile.conf" + install -Dm644 "$startdir/sshd.sysusers" \ + "$pkgdir/usr/lib/sysusers.d/sshd.conf" + # The console prompt has no keyboard on this phone, and it is + # Before=sysinit, so it holds the boot ahead of sshd. + install -d "$pkgdir/etc/systemd/system" + ln -s /dev/null "$pkgdir/etc/systemd/system/systemd-firstboot.service" + install -Dm644 "$startdir/omamobile-mirrorlist" \ + "$pkgdir/etc/pacman.d/omamobile-mirrorlist" + install -Dm644 "$startdir/LICENSE" \ + "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + # Enable sshd and networkd. Nothing else starts. + local wants="$pkgdir/usr/lib/systemd/system/multi-user.target.wants" + install -d "$wants" + ln -s ../systemd-networkd.service "$wants/systemd-networkd.service" + ln -s ../sshd.service "$wants/sshd.service" +} diff --git a/packages/omamobile-device-dodge/omamobile-mirrorlist b/packages/omamobile-device-dodge/omamobile-mirrorlist new file mode 100644 index 000000000..0db302c4c --- /dev/null +++ b/packages/omamobile-device-dodge/omamobile-mirrorlist @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: MIT +# [omamobile] in pacman.conf. The repository is on the phone. +Server = file:///var/lib/omamobile/repo/$arch diff --git a/packages/omamobile-device-dodge/reboot b/packages/omamobile-device-dodge/reboot new file mode 100755 index 000000000..1e4792e88 --- /dev/null +++ b/packages/omamobile-device-dodge/reboot @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# reboot bootloader on this phone is LINUX_REBOOT_CMD_RESTART2 with the +# string "bootloader". systemd's reboot bootloader is the EFI firmware +# path and does not pass that string, so ABL starts the normal boot. +# This file is ahead of /usr/bin/reboot on PATH. +if [ "${1-}" = bootloader ]; then + exec /usr/local/bin/reboot-to bootloader +fi +exec /usr/bin/systemctl reboot "$@" diff --git a/packages/omamobile-device-dodge/reboot-to.c b/packages/omamobile-device-dodge/reboot-to.c new file mode 100644 index 000000000..f663f18e4 --- /dev/null +++ b/packages/omamobile-device-dodge/reboot-to.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +// reboot-to: reboot with a reason ABL reads from the PMIC SDAM. +// "reboot-to bootloader" is LINUX_REBOOT_CMD_RESTART2. Busybox reboot +// cannot pass a reason. Same call as +// packages/omamobile-device-cheetah/src/reboot-to.c, built without a +// libc so the ramdisk pack needs no aarch64 sysroot. +// +// aarch64 Linux entry: sp points at argc, then the argv pointers. + +#define __NR_sync 81 +#define __NR_reboot 142 +#define __NR_exit_group 94 + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 + +static long scall(long n, long a, long b, long c, long d) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + register long x2 __asm__("x2") = c; + register long x3 __asm__("x3") = d; + + __asm__ volatile("svc #0" + : "+r"(x0) + : "r"(x1), "r"(x2), "r"(x3), "r"(x8) + : "memory"); + return x0; +} + +/* A C _start has a prologue, so sp there is no longer the entry stack. + Linux put argc at [sp] and argv just after it. */ +__attribute__((naked)) void _start(void) +{ + __asm__ volatile( + "ldr x0, [sp]\n" + "add x1, sp, #8\n" + "b go\n"); +} + +void go(long argc, char **argv) +{ + const char *reason = "bootloader"; + + if (argc > 1 && argv[1] && argv[1][0]) + reason = argv[1]; + + scall(__NR_sync, 0, 0, 0, 0); + scall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, + LINUX_REBOOT_CMD_RESTART2, (long)reason); + scall(__NR_exit_group, 1, 0, 0, 0); + for (;;) + ; +} diff --git a/packages/omamobile-device-dodge/sshd-omamobile.conf b/packages/omamobile-device-dodge/sshd-omamobile.conf new file mode 100644 index 000000000..dfc8cb6d5 --- /dev/null +++ b/packages/omamobile-device-dodge/sshd-omamobile.conf @@ -0,0 +1,3 @@ +PermitRootLogin prohibit-password +PasswordAuthentication no +KbdInteractiveAuthentication no diff --git a/packages/omamobile-device-dodge/sshd.sysusers b/packages/omamobile-device-dodge/sshd.sysusers new file mode 100644 index 000000000..530dccf47 --- /dev/null +++ b/packages/omamobile-device-dodge/sshd.sysusers @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MIT +# openssh 10.6p1-2 does not ship this. Without the user, sshd-session +# exits and a locked root never gets as far as the authorized key. +u sshd - "Privilege separation user" /usr/share/empty.sshd diff --git a/packages/omamobile-device-dodge/test/all b/packages/omamobile-device-dodge/test/all new file mode 100755 index 000000000..ee536547c --- /dev/null +++ b/packages/omamobile-device-dodge/test/all @@ -0,0 +1,9 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +set -eu +cd "$(dirname "$0")/.." +cmp reboot-to.c ../../device/dodge/initramfs/reboot-to.c +cmp reboot ../../device/dodge/reboot +sh -n reboot +echo ok wrapper +echo ok sources diff --git a/packages/omamobile-device-dodge/version b/packages/omamobile-device-dodge/version new file mode 100644 index 000000000..559ca4df6 --- /dev/null +++ b/packages/omamobile-device-dodge/version @@ -0,0 +1 @@ +20261021.1 From fe27b7578bb41e2facbc5b8fe42edca1428f4b6e Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Thu, 29 Oct 2026 09:13:33 +0100 Subject: [PATCH 03/32] dodge: audio, Wi-Fi, Bluetooth, sensors, modem, desktop and display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phone-verified userspace for the subsystems that work on dodge. Modem units stay inert without /etc/omamobile/modem-probe.enable; README covers CONTRIBUTING §3.3 off-phone backups with SHA256SUMS. No firmware, EFS or calibration blobs. Signed-off-by: Martin Lund Assisted-by: Grok Bot --- device/dodge/audio/OnePlus-dodge.m4 | 47 +++ .../dodge/audio/omamobile-dodge-audio.service | 23 ++ .../dodge/audio/ucm2/OnePlus/dodge/HiFi.conf | 215 +++++++++++ .../ucm2/OnePlus/dodge/OnePlus-dodge.conf | 13 + .../wireplumber/60-dodge-speaker-volume.conf | 24 ++ device/dodge/bluetooth/install | 42 +++ device/dodge/bluetooth/omamobile-bt | 88 +++++ device/dodge/bluetooth/omamobile-bt.service | 19 + device/dodge/desktop/install | 13 + device/dodge/desktop/login-sddm | 101 ++++++ .../dodge/desktop/omamobile-hyprland.service | 28 ++ device/dodge/desktop/setup-stock | 131 +++++++ device/dodge/desktop/setup-ui | 69 ++++ device/dodge/desktop/shell.toml | 19 + device/dodge/display/display-try | 29 ++ device/dodge/display/install | 23 ++ device/dodge/display/omamobile-display-msm | 74 ++++ .../display/omamobile-display-msm.service | 19 + .../selfheal/omamobile-display-selfheal | 41 +++ .../omamobile-display-selfheal.service | 15 + device/dodge/idle/install | 23 ++ device/dodge/idle/omamobile-idle-off.service | 19 + .../dodge/idle/omamobile-idle-off/shell.qml | 47 +++ .../modem/78-omamobile-mm-fake-net.rules | 8 + .../dodge/modem/ModemManager-omamobile.conf | 7 + device/dodge/modem/README.md | 73 ++++ device/dodge/modem/adsp-battery.sh | 52 +++ device/dodge/modem/install | 26 ++ .../modem/omamobile-cellular.nmconnection | 27 ++ .../dodge/modem/omamobile-mm-netport.service | 17 + device/dodge/modem/omamobile-modem | 131 +++++++ .../dodge/modem/omamobile-modem-efs.service | 21 ++ .../modem/omamobile-modem-online.service | 20 ++ device/dodge/modem/omamobile-modem.service | 17 + .../modem/omamobile-rmtfs-rw-copies.conf | 11 + device/dodge/modem/omamobile-rmtfs.service | 18 + .../dodge/modem/omamobile-tqftpserv.service | 13 + device/dodge/sensors/81-omamobile-ssc.rules | 5 + device/dodge/sensors/README.md | 49 +++ .../hexagonrpc-da7a374-omamobile.patch | 101 ++++++ .../sensors/iio-sensor-proxy-omamobile.conf | 3 + device/dodge/sensors/install | 25 ++ .../dodge/sensors/libssc-4e4c6c8-no-gir.patch | 13 + device/dodge/sensors/lp-extents.py | 18 + device/dodge/sensors/omamobile-autorotate | 336 ++++++++++++++++++ .../dodge/sensors/omamobile-sensors.service | 15 + device/dodge/sensors/prepare-root | 31 ++ device/dodge/timesync/dodge-timesync.service | 10 + device/dodge/timesync/dodge-timesync.timer | 11 + device/dodge/wifi/install | 54 +++ device/dodge/wifi/omamobile-wifi-ath12k | 96 +++++ .../dodge/wifi/omamobile-wifi-ath12k.service | 17 + device/dodge/wifi/omamobile-wifi-pcie | 12 + device/dodge/wifi/omamobile-wifi-pcie.service | 13 + 54 files changed, 2372 insertions(+) create mode 100644 device/dodge/audio/OnePlus-dodge.m4 create mode 100644 device/dodge/audio/omamobile-dodge-audio.service create mode 100644 device/dodge/audio/ucm2/OnePlus/dodge/HiFi.conf create mode 100644 device/dodge/audio/ucm2/OnePlus/dodge/OnePlus-dodge.conf create mode 100644 device/dodge/audio/wireplumber/60-dodge-speaker-volume.conf create mode 100755 device/dodge/bluetooth/install create mode 100755 device/dodge/bluetooth/omamobile-bt create mode 100644 device/dodge/bluetooth/omamobile-bt.service create mode 100755 device/dodge/desktop/install create mode 100755 device/dodge/desktop/login-sddm create mode 100644 device/dodge/desktop/omamobile-hyprland.service create mode 100755 device/dodge/desktop/setup-stock create mode 100755 device/dodge/desktop/setup-ui create mode 100644 device/dodge/desktop/shell.toml create mode 100755 device/dodge/display/display-try create mode 100755 device/dodge/display/install create mode 100755 device/dodge/display/omamobile-display-msm create mode 100644 device/dodge/display/omamobile-display-msm.service create mode 100755 device/dodge/display/selfheal/omamobile-display-selfheal create mode 100644 device/dodge/display/selfheal/omamobile-display-selfheal.service create mode 100755 device/dodge/idle/install create mode 100644 device/dodge/idle/omamobile-idle-off.service create mode 100644 device/dodge/idle/omamobile-idle-off/shell.qml create mode 100644 device/dodge/modem/78-omamobile-mm-fake-net.rules create mode 100644 device/dodge/modem/ModemManager-omamobile.conf create mode 100644 device/dodge/modem/README.md create mode 100644 device/dodge/modem/adsp-battery.sh create mode 100755 device/dodge/modem/install create mode 100644 device/dodge/modem/omamobile-cellular.nmconnection create mode 100644 device/dodge/modem/omamobile-mm-netport.service create mode 100755 device/dodge/modem/omamobile-modem create mode 100644 device/dodge/modem/omamobile-modem-efs.service create mode 100644 device/dodge/modem/omamobile-modem-online.service create mode 100644 device/dodge/modem/omamobile-modem.service create mode 100644 device/dodge/modem/omamobile-rmtfs-rw-copies.conf create mode 100644 device/dodge/modem/omamobile-rmtfs.service create mode 100644 device/dodge/modem/omamobile-tqftpserv.service create mode 100644 device/dodge/sensors/81-omamobile-ssc.rules create mode 100644 device/dodge/sensors/README.md create mode 100644 device/dodge/sensors/hexagonrpc-da7a374-omamobile.patch create mode 100644 device/dodge/sensors/iio-sensor-proxy-omamobile.conf create mode 100755 device/dodge/sensors/install create mode 100644 device/dodge/sensors/libssc-4e4c6c8-no-gir.patch create mode 100644 device/dodge/sensors/lp-extents.py create mode 100755 device/dodge/sensors/omamobile-autorotate create mode 100644 device/dodge/sensors/omamobile-sensors.service create mode 100755 device/dodge/sensors/prepare-root create mode 100644 device/dodge/timesync/dodge-timesync.service create mode 100644 device/dodge/timesync/dodge-timesync.timer create mode 100755 device/dodge/wifi/install create mode 100755 device/dodge/wifi/omamobile-wifi-ath12k create mode 100644 device/dodge/wifi/omamobile-wifi-ath12k.service create mode 100755 device/dodge/wifi/omamobile-wifi-pcie create mode 100644 device/dodge/wifi/omamobile-wifi-pcie.service diff --git a/device/dodge/audio/OnePlus-dodge.m4 b/device/dodge/audio/OnePlus-dodge.m4 new file mode 100644 index 000000000..107f663ab --- /dev/null +++ b/device/dodge/audio/OnePlus-dodge.m4 @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: BSD-3-Clause +# AudioReach topology for the OnePlus 13 (dodge, SM8750). +# Derived from linux-msm/audioreach-topology SM8550-HDK.m4 and +# Google-SC7180-WSA-Speakers-SEC-I2S-VA-DMIC-WCD-TX3.m4 (Copyright, Linaro Ltd, 2023). +# Speakers: two smart amplifiers on Secondary MI2S (TLMM i2s1), playback on SD1. +# Headset: WCD939x HPH over RX codec DMA 0 (USB-C analog), fed from MultiMedia1. +# Microphones: WCD939x ADCs over SoundWire TX into TX codec DMA 3, captured on MultiMedia3. +# Build: m4 -I OnePlus-dodge.m4 > OnePlus-dodge.conf +# alsatplg -c OnePlus-dodge.conf -o OnePlus-dodge-tplg.bin +# Install on the phone as /lib/firmware/qcom/sm8750/OnePlus-dodge-tplg.bin +include(`audioreach/audioreach.m4') +include(`audioreach/stream-subgraph.m4') +include(`audioreach/device-subgraph.m4') +include(`util/route.m4') +include(`util/mixer.m4') +include(`audioreach/tokens.m4') +dnl Playback MultiMedia1 +STREAM_SG_PCM_ADD(audioreach/subgraph-stream-vol-playback.m4, FRONTEND_DAI_MULTIMEDIA1, + `S16_LE', 48000, 48000, 2, 2, + 0x00004001, 0x00004001, 0x00006001, `110000') +dnl Capture MultiMedia3 +STREAM_SG_PCM_ADD(audioreach/subgraph-stream-capture.m4, FRONTEND_DAI_MULTIMEDIA3, + `S16_LE', 48000, 48000, 1, 2, + 0x00004003, 0x00004003, 0x00006020, `110000') +dnl Secondary MI2S Playback (speaker amplifiers). The amplifiers listen on +dnl i2s1 data1 (gpio124), the DSP's SD1: on SD0 they never left the noise gate. +DEVICE_SG_ADD(audioreach/subgraph-device-i2s-playback.m4, `Secondary', SECONDARY_MI2S_RX, + `S16_LE', 48000, 48000, 2, 2, + LPAIF_INTF_TYPE_LPAIF, I2S_INTF_TYPE_SECONDARY, SD_LINE_IDX_I2S_SD1, DATA_FORMAT_FIXED_POINT, + 0x00004005, 0x00004005, 0x00006050, `SECONDARY_MI2S_RX') +dnl WCD RX Playback (USB-C analog headset) +DEVICE_SG_ADD(audioreach/subgraph-device-codec-dma-playback.m4, `RX_CODEC_DMA_RX_0', RX_CODEC_DMA_RX_0, + `S16_LE', 48000, 48000, 2, 2, + LPAIF_INTF_TYPE_RXTX, CODEC_INTF_IDX_RX0, 0, DATA_FORMAT_FIXED_POINT, + 0x00004007, 0x00004007, 0x00006070) +dnl WCD TX Capture (built-in and headset microphones) +DEVICE_SG_ADD(audioreach/subgraph-device-codec-dma-capture.m4, `TX_CODEC_DMA_TX_3', TX_CODEC_DMA_TX_3, + `S16_LE', 48000, 48000, 1, 2, + LPAIF_INTF_TYPE_RXTX, CODEC_INTF_IDX_TX3, 0, DATA_FORMAT_FIXED_POINT, + 0x00004009, 0x00004009, 0x00006090) +dnl +STREAM_DEVICE_PLAYBACK_MIXER(SECONDARY_MI2S_RX, ``SECONDARY_MI2S_RX'', ``MultiMedia1'') +STREAM_DEVICE_PLAYBACK_ROUTE(SECONDARY_MI2S_RX, ``SECONDARY_MI2S_RX Audio Mixer'', ``MultiMedia1, stream0.logger1'') +STREAM_DEVICE_PLAYBACK_MIXER(RX_CODEC_DMA_RX_0, ``RX_CODEC_DMA_RX_0'', ``MultiMedia1'') +STREAM_DEVICE_PLAYBACK_ROUTE(RX_CODEC_DMA_RX_0, ``RX_CODEC_DMA_RX_0 Audio Mixer'', ``MultiMedia1, stream0.logger1'') +STREAM_DEVICE_CAPTURE_MIXER(FRONTEND_DAI_MULTIMEDIA3, ``TX_CODEC_DMA_TX_3'') +STREAM_DEVICE_CAPTURE_ROUTE(FRONTEND_DAI_MULTIMEDIA3, ``MultiMedia3 Mixer'', ``TX_CODEC_DMA_TX_3, device120.logger1'') diff --git a/device/dodge/audio/omamobile-dodge-audio.service b/device/dodge/audio/omamobile-dodge-audio.service new file mode 100644 index 000000000..520f9c9fd --- /dev/null +++ b/device/dodge/audio/omamobile-dodge-audio.service @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: MIT +# dodge speaker audio at boot: FastRPC audio PD, q6apm, the amplifiers and +# the DT sound card, then the MultiMedia1 -> speakers route. Installed by +# hand to /etc/systemd/system with the script in /usr/local/lib/omamobile (see +# device/dodge/NOTES.md). The amplifiers are set to the driver cap (703 = +# attenuation 320, about -30 dB); the driver default of 700 is inaudible. +[Unit] +Description=dodge speaker audio bring-up +Requires=omamobile-adsp-battery.service +After=omamobile-adsp-battery.service systemd-udev-settle.service systemd-modules-load.service +ConditionPathExists=/usr/local/lib/omamobile/audio-bringup.sh + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/lib/omamobile/audio-bringup.sh +ExecStartPost=/usr/bin/amixer -q -c OnePlusdodge cset name="SECONDARY_MI2S_RX Audio Mixer MultiMedia1" 1 +ExecStartPost=/usr/bin/amixer -q -c OnePlusdodge cset name="Left Amp Volume" 703 +ExecStartPost=/usr/bin/amixer -q -c OnePlusdodge cset name="Right Amp Volume" 703 +TimeoutStartSec=180 + +[Install] +WantedBy=multi-user.target diff --git a/device/dodge/audio/ucm2/OnePlus/dodge/HiFi.conf b/device/dodge/audio/ucm2/OnePlus/dodge/HiFi.conf new file mode 100644 index 000000000..96bd2843e --- /dev/null +++ b/device/dodge/audio/ucm2/OnePlus/dodge/HiFi.conf @@ -0,0 +1,215 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Speaker or USB-C headphones on MultiMedia1, and the built-in mics. +# One back end at a time (hw_params fails with both mixers on), and +# never none: a front end with no back end cannot be opened (EINVAL). +# So the speaker route is the default and Headphones swaps it out. Amplifier gain stays at the driver default; the driver +# caps it (attenuation floor) until speaker protection and calibration exist. + +SectionVerb { + EnableSequence [ + cset "name='RX_CODEC_DMA_RX_0 Audio Mixer MultiMedia1' 0" + cset "name='SECONDARY_MI2S_RX Audio Mixer MultiMedia1' 1" + cset "name='MultiMedia3 Mixer TX_CODEC_DMA_TX_3' 1" + ] + + Value { + TQ "HiFi" + } +} + +SectionDevice."Speaker" { + Comment "Speaker playback" + + # Amp Volume 703 is the driver's cap, attenuation 320 (about -30 dB). + # This is the level heard at 11:39. The driver default, 323 + # (attenuation 700, about -66 dB), is inaudible. + EnableSequence [ + cset "name='Left Amp Volume' 703" + cset "name='Right Amp Volume' 703" + cset "name='SECONDARY_MI2S_RX Audio Mixer MultiMedia1' 1" + ] + + DisableSequence [ + ] + + Value { + PlaybackChannels 2 + PlaybackPriority 100 + PlaybackPCM "hw:${CardId},0" + } +} + +# Built-in microphones: AMIC1 (WCD939x ADC1, SoundWire TX channel 0) and +# AMIC5 (ADC4, channel 3), both on MIC BIAS1, into TX decimators 0 and 1. +SectionDevice."Mic" { + Comment "Internal microphones" + + EnableSequence [ + cset "name='MultiMedia3 Mixer TX_CODEC_DMA_TX_3' 1" + cset "name='ADC1_MIXER Switch' 1" + cset "name='ADC1 MUX' CH1_AMIC1" + cset "name='ADC1 Switch' 1" + cset "name='ADC1 Volume' 10" + cset "name='TX0 MODE' ADC_ULP" + cset "name='ADC4_MIXER Switch' 1" + cset "name='ADC4 MUX' CH4_AMIC5" + cset "name='ADC4 Switch' 1" + cset "name='ADC4 Volume' 10" + cset "name='TX3 MODE' ADC_ULP" + cset "name='TX DEC0 MUX' SWR_MIC" + cset "name='TX SMIC MUX0' SWR_MIC0" + cset "name='TX_DEC0 Volume' 100" + cset "name='TX_AIF1_CAP Mixer DEC0' 1" + cset "name='TX DEC1 MUX' SWR_MIC" + cset "name='TX SMIC MUX1' SWR_MIC3" + cset "name='TX_DEC1 Volume' 100" + cset "name='TX_AIF1_CAP Mixer DEC1' 1" + ] + + DisableSequence [ + cset "name='TX_AIF1_CAP Mixer DEC0' 0" + cset "name='TX_AIF1_CAP Mixer DEC1' 0" + cset "name='ADC1 Switch' 0" + cset "name='ADC4 Switch' 0" + cset "name='ADC1_MIXER Switch' 0" + cset "name='ADC4_MIXER Switch' 0" + ] + + Value { + CapturePriority 100 + CapturePCM "hw:${CardId},2" + CaptureChannels 2 + } +} + + +# USB-C analog headphones: WCD939x HPH behind RX codec DMA 0. Plug +# detection comes from the Type-C stack (audio accessory mode). +SectionDevice."Headset" { + Comment "Headset microphone" + + # USB-C analog headset: AMIC2 (MIC BIAS2) through the WCD939x USBSS, + # ADC2 on TX SWR_MIC1, DEC0, one channel on hw:CARD,2. The path is + # verified live with nothing plugged in (noise floor about -65 dBFS, + # EIO with ADC2 off). The jack and MBHC still need the plug test. + ConflictingDevice [ + "Mic" + ] + + EnableSequence [ + cset "name='MultiMedia3 Mixer TX_CODEC_DMA_TX_3' 1" + cset "name='ADC2_MIXER Switch' 1" + # Select AMIC2 twice (disable, then AMIC2). A single write after + # the Mic device sometimes leaves ADC2 silent until the mux moves. + cset "name='ADC2 MUX' CH2_AMIC_DISABLE" + cset "name='ADC2 MUX' CH2_AMIC2" + cset "name='ADC2 Switch' 1" + cset "name='ADC2 Volume' 10" + cset "name='TX1 MODE' ADC_LP" + cset "name='MBHC Switch' 1" + cset "name='TX_AIF1_CAP Mixer DEC1' 0" + cset "name='TX DEC0 MUX' SWR_MIC" + cset "name='TX SMIC MUX0' SWR_MIC1" + cset "name='TX_DEC0 Volume' 84" + cset "name='TX_AIF1_CAP Mixer DEC0' 1" + ] + + DisableSequence [ + cset "name='TX_AIF1_CAP Mixer DEC0' 0" + cset "name='MBHC Switch' 0" + cset "name='ADC2 Switch' 0" + cset "name='ADC2_MIXER Switch' 0" + cset "name='ADC2 MUX' CH2_AMIC_DISABLE" + cset "name='TX SMIC MUX0' SWR_MIC0" + ] + + Value { + CapturePriority 300 + CapturePCM "hw:${CardId},2" + CaptureChannels 1 + CaptureMixerElem "ADC2" + JackControl "Mic Jack" + } +} + +SectionDevice."Headphones" { + Comment "Headphones playback" + + ConflictingDevice [ + "Speaker" + ] + + EnableSequence [ + cset "name='RX_HPH PWR Mode' LOHIFI" + cset "name='RX_MACRO RX0 MUX' AIF1_PB" + cset "name='RX_MACRO RX1 MUX' AIF1_PB" + cset "name='RX INT0_1 MIX1 INP0' RX0" + cset "name='RX INT1_1 MIX1 INP0' RX1" + cset "name='RX INT0 DEM MUX' CLSH_DSM_OUT" + cset "name='RX INT1 DEM MUX' CLSH_DSM_OUT" + cset "name='HPHL_RDAC Switch' 1" + cset "name='HPHR_RDAC Switch' 1" + cset "name='HPHL_COMP Switch' 1" + cset "name='HPHR_COMP Switch' 1" + cset "name='HPHL Switch' 1" + cset "name='HPHR Switch' 1" + cset "name='CLSH Switch' 1" + cset "name='RX HPH Mode' CLS_H_LOHIFI" + cset "name='HPHL Volume' 20" + cset "name='HPHR Volume' 20" + cset "name='SECONDARY_MI2S_RX Audio Mixer MultiMedia1' 0" + cset "name='RX_CODEC_DMA_RX_0 Audio Mixer MultiMedia1' 1" + ] + + DisableSequence [ + cset "name='RX_CODEC_DMA_RX_0 Audio Mixer MultiMedia1' 0" + cset "name='HPHL Switch' 0" + cset "name='HPHR Switch' 0" + cset "name='HPHL_RDAC Switch' 0" + cset "name='HPHR_RDAC Switch' 0" + cset "name='HPHL_COMP Switch' 0" + cset "name='HPHR_COMP Switch' 0" + cset "name='CLSH Switch' 0" + cset "name='RX_MACRO RX0 MUX' ZERO" + cset "name='RX_MACRO RX1 MUX' ZERO" + cset "name='RX INT0_1 MIX1 INP0' ZERO" + cset "name='RX INT1_1 MIX1 INP0' ZERO" + cset "name='SECONDARY_MI2S_RX Audio Mixer MultiMedia1' 1" + ] + + Value { + PlaybackChannels 2 + PlaybackPriority 200 + PlaybackPCM "hw:${CardId},0" + JackControl "Headphone Jack" + } +} + +# Earpiece: the top (left) speaker in the stock Receiver profile, with the +# bottom amplifier muted. A profile change made while playing takes +# effect when the next stream is set up (hw_params). +SectionDevice."Earpiece" { + Comment "Earpiece playback" + + ConflictingDevice [ + "Speaker" + "Headphones" + ] + + EnableSequence [ + cset "name='Right Amp Volume' 0" + cset "name='Left Amp Volume' 703" + cset "name='Left Amp Profile' Receiver" + ] + + DisableSequence [ + cset "name='Right Amp Volume' 703" + cset "name='Left Amp Profile' Speaker" + ] + + Value { + PlaybackChannels 2 + PlaybackPriority 50 + PlaybackPCM "hw:${CardId},0" + } +} diff --git a/device/dodge/audio/ucm2/OnePlus/dodge/OnePlus-dodge.conf b/device/dodge/audio/ucm2/OnePlus/dodge/OnePlus-dodge.conf new file mode 100644 index 000000000..760d52099 --- /dev/null +++ b/device/dodge/audio/ucm2/OnePlus/dodge/OnePlus-dodge.conf @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# OnePlus 13 (dodge): two Awinic speaker amplifiers on SECONDARY_MI2S_RX. +# Install as /usr/share/alsa/ucm2/OnePlus/dodge/ and link +# /usr/share/alsa/ucm2/conf.d/sm8750/OnePlus-dodge.conf to this file. +# Speakers, built-in microphones, USB-C headset and headset mic (plug untested) and earpiece. +Syntax 4 + +SectionUseCase."HiFi" { + File "/OnePlus/dodge/HiFi.conf" + Comment "HiFi quality Music." +} + +Include.card-init.File "/lib/card-init.conf" diff --git a/device/dodge/audio/wireplumber/60-dodge-speaker-volume.conf b/device/dodge/audio/wireplumber/60-dodge-speaker-volume.conf new file mode 100644 index 000000000..5929a5d43 --- /dev/null +++ b/device/dodge/audio/wireplumber/60-dodge-speaker-volume.conf @@ -0,0 +1,24 @@ +## dodge: default route volume for the built-in card. +## WirePlumber's global default is 0.064 linear (0.40 on the cubic scale wpctl +## shows), which with the amplifiers at their -30 dB cap is too quiet. +## 0.614 linear is 0.85 cubic, about -4 dB. The amplifier driver still enforces +## the hardware cap (attenuation >= 320). This applies only while no route +## volume is saved; a user change is remembered as usual. +## Install to /etc/wireplumber/wireplumber.conf.d/. + +monitor.alsa.rules = [ + { + matches = [ + { + device.name = "alsa_card.platform-sound" + } + ] + actions = { + update-props = { + device.routes.default-sink-volume = 0.614 + # Without this the sources would fall back to the sink value above. + device.routes.default-source-volume = 1.0 + } + } + } +] diff --git a/device/dodge/bluetooth/install b/device/dodge/bluetooth/install new file mode 100755 index 000000000..948fa0e72 --- /dev/null +++ b/device/dodge/bluetooth/install @@ -0,0 +1,42 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Install the dodge Bluetooth bring-up on the phone. Run as root, from +# this directory (copied to the phone), or with the directory as $1. +# Idempotent. +# +# Installs omamobile-bt (script and unit), enables it and BlueZ's +# bluetooth.service. It does not start them. +# +# It also copies the WCN7860 Bluetooth firmware from the phone's own +# bluetooth_a partition (read-only loop mount of a copy) to +# /lib/firmware/qca: gngbtfw20.mbn (rampatch) and gngbtnv20.* (NVM). +# Nothing is shipped or committed. Existing files are left alone. The +# kernel modules in /usr/local/lib/omamobile/bt are installed separately. +set -eu +SRC=${1:-$(dirname "$0")} +FW=/lib/firmware/qca + +log() { echo "dodge-bt-install: $*"; } + +[ "$(id -u)" = 0 ] || { log "run as root"; exit 1; } + +install -D -m 755 "$SRC/omamobile-bt" /usr/local/sbin/omamobile-bt +install -D -m 644 "$SRC/omamobile-bt.service" /etc/systemd/system/omamobile-bt.service +systemctl daemon-reload +systemctl enable omamobile-bt.service bluetooth.service + +if [ -s "$FW/gngbtfw20.mbn" ] && [ -s "$FW/gngbtnv20.bin" ]; then + log "firmware already in $FW" +else + part=$(readlink -f /dev/disk/by-partlabel/bluetooth_a) + [ -b "$part" ] || { log "no bluetooth_a partition"; exit 1; } + tmp=$(mktemp -d) + trap 'umount "$tmp/m" 2>/dev/null; rm -rf "$tmp"' EXIT + mkdir "$tmp/m" + dd if="$part" of="$tmp/bt.img" bs=1M status=none + mount -o ro,loop "$tmp/bt.img" "$tmp/m" + mkdir -p "$FW" + cp -n "$tmp/m/image/gngbtfw20.mbn" "$tmp/m/image"/gngbtnv20.* "$FW/" + log "copied $(ls "$FW" | grep -c '^gngbt') gngbt* files to $FW" +fi +log "done; the next boot brings up hci0" diff --git a/device/dodge/bluetooth/omamobile-bt b/device/dodge/bluetooth/omamobile-bt new file mode 100755 index 000000000..1068c467d --- /dev/null +++ b/device/dodge/bluetooth/omamobile-bt @@ -0,0 +1,88 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Bring up Bluetooth on the WCN7860 (peach) once per boot: load the +# Bluetooth stack and hci_uart from /usr/local/lib/omamobile/bt (no +# /lib/modules tree here, so nothing autoloads), wait for hci0, and +# give it a public address so it leaves the "unconfigured" state. +# +# hci_qca powers the chip through the WCN7850 power sequencer that +# omamobile-wifi-pcie loads, downloads qca/gngbtfw20.mbn and +# qca/gngbtnv20.bin (from the phone's own bluetooth_a partition, not +# shipped here), and then waits for an address. +# +# The real BD address lives in the persist partition, which we never +# read. Instead this uses a random address generated once on this phone +# and kept in /var/lib/omamobile/bt-public-addr (mode 600, never +# committed). The first octet is 0x02 (locally administered). +set -u +D=/usr/local/lib/omamobile/bt +W=/usr/local/lib/omamobile +STAMP=/run/omamobile-bt.tried +ADDR=/var/lib/omamobile/bt-public-addr + +log() { echo "omamobile-bt: $*"; } + +if [ -e "$STAMP" ]; then + log "already tried this boot ($STAMP)" + exit 0 +fi +: > "$STAMP" + +load() { + [ -e "/sys/module/$1" ] && return 0 + for f in "$D/$1.ko" "$W/$1.ko"; do + [ -f "$f" ] && { insmod "$f" && return 0; } + done + [ -e "/sys/module/$1" ] +} + +# kpp is a module on 7.3 and built in on 6.16 (no file there). +[ -f "$D/kpp.ko" ] && { load kpp || log "kpp failed to load"; } +for m in rfkill ecc ecdh_generic bluetooth btqca btbcm hci_uart; do + load "$m" || { log "$m failed to load"; exit 1; } +done + +# hci0 is registered before hci_qca has downloaded the firmware (about +# 1.5 s), so its sysfs node is not the signal. Wait until mgmt reports +# it either as a configured controller or as unconfigured with a +# missing public address. +state= +i=0 +while [ $i -lt 60 ]; do + if btmgmt info 2>/dev/null | grep -q '^hci0:.*Primary controller'; then + state=configured + break + fi + if btmgmt -i 0 config 2>/dev/null | + grep -q 'missing options:.*public-address'; then + state=needs-address + break + fi + sleep 0.5 + i=$((i + 1)) +done +case $state in +configured) + log "hci0 configured" + exit 0 ;; +needs-address) ;; +*) + log "hci0 did not finish setup in 30 s" + exit 1 ;; +esac + +if [ ! -s "$ADDR" ]; then + mkdir -p "${ADDR%/*}" + (umask 077 + od -An -N5 -tx1 /dev/urandom | + awk '{ printf "02:%s:%s:%s:%s:%s\n", $1, $2, $3, $4, $5 }' | + tr a-f A-F > "$ADDR") + log "generated a new public address in $ADDR" +fi +chmod 600 "$ADDR" +if btmgmt -i 0 public-addr "$(cat "$ADDR")" >/dev/null 2>&1; then + log "hci0 public address set from $ADDR" +else + log "setting the public address failed" + exit 1 +fi diff --git a/device/dodge/bluetooth/omamobile-bt.service b/device/dodge/bluetooth/omamobile-bt.service new file mode 100644 index 000000000..8b7af31dc --- /dev/null +++ b/device/dodge/bluetooth/omamobile-bt.service @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# Bluetooth on the WCN7860 (peach): stack, hci_uart and a public +# address, once per boot. After the Wi-Fi units, which load the power +# sequencer and rfkill. +[Unit] +Description=Bluetooth for the WCN7860 (peach), once per boot +After=omamobile-wifi-pcie.service omamobile-wifi-ath12k.service local-fs.target +Wants=omamobile-wifi-pcie.service +Before=bluetooth.service +ConditionPathExists=!/run/omamobile-bt.tried + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/sbin/omamobile-bt +TimeoutStartSec=90 + +[Install] +WantedBy=multi-user.target diff --git a/device/dodge/desktop/install b/device/dodge/desktop/install new file mode 100755 index 000000000..d4b615110 --- /dev/null +++ b/device/dodge/desktop/install @@ -0,0 +1,13 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Install the dodge desktop unit (Hyprland on tty1) on the phone. Run as +# root, from this directory (copied to the phone), or with it as $1. +# Idempotent. Enables the unit; does not restart a running desktop. +set -eu +SRC=${1:-$(dirname "$0")} +log() { echo "dodge-desktop-install: $*"; } +[ "$(id -u)" = 0 ] || { log "run as root"; exit 1; } +install -D -m 644 "$SRC/omamobile-hyprland.service" /etc/systemd/system/omamobile-hyprland.service +systemctl daemon-reload +systemctl enable omamobile-hyprland.service +log "done; takes effect on the next start of the desktop" diff --git a/device/dodge/desktop/login-sddm b/device/dodge/desktop/login-sddm new file mode 100755 index 000000000..1873fd13b --- /dev/null +++ b/device/dodge/desktop/login-sddm @@ -0,0 +1,101 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# dodge-login-sddm: start the desktop the stock Omarchy Mobile way, SDDM +# autologin into Omarchy's session (omamobile-firstboot's s_login), instead of +# dodge's omamobile-hyprland.service (uwsm on tty1 under PAM "login"). The +# lock (lock-on-start, setup-stock) then asks for the PIN, as on stock. +# Run as root: +# +# login-sddm [USER] stage SDDM autologin for the next boot +# login-sddm --revert [USER] back to omamobile-hyprland.service on tty1 +# login-sddm --status show which path the next boot takes +# +# Never starts, stops or restarts sddm, getty or the running desktop: the +# change takes effect at the next boot. Idempotent. +# +# What it changes (all undone by --revert): +# - /etc/sddm.conf.d/autologin.conf and /var/lib/sddm/state.conf, as +# firstboot writes them (Session=omarchy.desktop: uwsm + Hyprland). +# - sddm.service drop-in: after the msm panel and touch units, as +# omamobile-hyprland.service was (they order Before= that unit only). +# - (removed) /etc/xdg/uwsm/env.d/50-dodge-software-gl: formerly LIBGL_ALWAYS_SOFTWARE=1 for +# the session, which omamobile-hyprland.service set. Hyprland renders on +# the GPU either way (aquamarine/GBM ignores it); apps keep llvmpipe GL, so +# the login switch changes one thing only. Dropping it is a separate step. +# - omamobile-hyprland.service disabled (not stopped), sddm.service enabled, +# default target graphical.target (sddm is PartOf graphical.target; dodge +# booted to multi-user.target, which is why the enabled sddm never ran). +# sddm.service Conflicts=getty@tty1.service, so the two never share the seat. +set -euo pipefail +mode=apply +case ${1:-} in --revert) mode=revert; shift ;; --status) mode=status; shift ;; esac +U=${1:-ml} +st=/var/lib/dodge-login-sddm +conf=/etc/sddm.conf.d/autologin.conf +state=/var/lib/sddm/state.conf +dropin=/etc/systemd/system/sddm.service.d/50-dodge.conf +uenv=/etc/xdg/uwsm/env.d/50-dodge-software-gl +[[ $(id -u) == 0 ]] || { echo "run as root" >&2; exit 1; } + +if [[ $mode == status ]]; then + echo "default target: $(systemctl get-default)" + echo "sddm.service: $(systemctl is-enabled sddm.service 2>&1)" + echo "omamobile-hyprland: $(systemctl is-enabled omamobile-hyprland.service 2>&1)" + echo "autologin.conf: $([[ -f $conf ]] && tr '\n' ' ' < "$conf" || echo none)" + exit 0 +fi + +if [[ $mode == revert ]]; then + [[ -d $st ]] || { echo "nothing staged by login-sddm ($st missing)" >&2; exit 1; } + [[ -f $st/created-autologin ]] && rm -f "$conf" + [[ -f $st/state.conf ]] && cp -p "$st/state.conf" "$state" + [[ -f $st/created-state ]] && rm -f "$state" + rm -f "$dropin" "$uenv" + rmdir "${dropin%/*}" "${uenv%/*}" "/etc/xdg/uwsm" 2>/dev/null || true + systemctl daemon-reload + [[ -f $st/sddm-was-disabled ]] && systemctl disable sddm.service + systemctl enable omamobile-hyprland.service + systemctl set-default "$(cat "$st/default.target")" + rm -rf "$st" + echo "reverted: next boot starts the desktop with omamobile-hyprland.service on tty1" + exit 0 +fi + +id "$U" >/dev/null +command -v sddm >/dev/null || { echo "sddm is not installed" >&2; exit 1; } +session="" +for d in /usr/local/share/wayland-sessions /usr/share/wayland-sessions; do + [[ -f $d/omarchy.desktop ]] && { session=omarchy; break; } +done +[[ -n $session ]] || { echo "Omarchy's session (omarchy.desktop) is not installed" >&2; exit 1; } +[[ -f /etc/pam.d/sddm-autologin ]] || { echo "/etc/pam.d/sddm-autologin missing" >&2; exit 1; } + +# What was there before, once (a second run must keep the first state) +if [[ ! -d $st ]]; then + install -d -m 700 "$st" + systemctl get-default > "$st/default.target" + [[ -f $conf ]] || touch "$st/created-autologin" + if [[ -f $state ]]; then cp -p "$state" "$st/state.conf"; else touch "$st/created-state"; fi + systemctl is-enabled --quiet sddm.service || touch "$st/sddm-was-disabled" +fi + +# omamobile-firstboot s_login, as is +mkdir -p /etc/sddm.conf.d /var/lib/sddm +printf '[Autologin]\nUser=%s\nSession=%s.desktop\n' "$U" "$session" > "$conf" +printf '[Last]\nSession=%s.desktop\nUser=%s\n' "$session" "$U" > "$state" +chown -R sddm:sddm /var/lib/sddm 2>/dev/null || true + +install -d "${dropin%/*}" +cat > "$dropin" <<'UNIT' +# dodge (login-sddm): the panel and touch first, as omamobile-hyprland.service had +[Unit] +After=omamobile-display-msm.service omamobile-touch.service +UNIT +# GPU works on 7.3 gpu1 (2026-10-25): no software-GL override any more. +# Remove the one older runs of this script wrote. +rm -f "$uenv" +systemctl daemon-reload +systemctl disable omamobile-hyprland.service +systemctl enable sddm.service +systemctl set-default graphical.target +echo "staged: the next boot autologins $U with SDDM ($session.desktop); revert with: $0 --revert $U" diff --git a/device/dodge/desktop/omamobile-hyprland.service b/device/dodge/desktop/omamobile-hyprland.service new file mode 100644 index 000000000..da47089e3 --- /dev/null +++ b/device/dodge/desktop/omamobile-hyprland.service @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: MIT +# The desktop: Hyprland (through uwsm) on tty1 as user ml, no display +# manager. Starts after omamobile-display-msm (the msm DSI panel) without +# requiring it, so it comes up on simpledrm if msm did not load. +# Rendering is software (llvmpipe) on either path. +[Unit] +Description=Hyprland desktop (msm DSI panel, simpledrm fallback) +After=systemd-user-sessions.service systemd-logind.service omamobile-display-msm.service +Conflicts=getty@tty1.service +OnFailure=getty@tty1.service + +[Service] +User=ml +Group=ml +PAMName=login +TTYPath=/dev/tty1 +TTYReset=yes +TTYVHangup=yes +StandardInput=tty +StandardOutput=journal +StandardError=journal +WorkingDirectory=/home/ml +Environment=LIBGL_ALWAYS_SOFTWARE=1 +ExecStart=/usr/bin/uwsm start -e -D Hyprland hyprland.desktop +Restart=no + +[Install] +WantedBy=multi-user.target diff --git a/device/dodge/desktop/setup-stock b/device/dodge/desktop/setup-stock new file mode 100755 index 000000000..1939f6974 --- /dev/null +++ b/device/dodge/desktop/setup-stock @@ -0,0 +1,131 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# dodge-setup-stock: the rest of the stock Omarchy Mobile setup on the +# OnePlus 13 (dodge), after setup-ui: lock screen with PIN pad, power and +# volume keys, on-screen keyboard (squeekboard), the phone window rules, +# menu entries, Chromium flags, screensaver branding. Run as root: +# +# setup-stock [USER] apply (USER defaults to ml) +# setup-stock --revert [USER] undo: no lock, no PIN, dodge idle screen-off +# +# The user part is the packaged omamobile-setup-user (omamobile-shell) as is, +# plus the tail of omamobile-firstboot's user step (credential type, the +# lock-keypad toggle; lock-on-start only once a PIN exists). The PIN is the +# account password (stock: omamobile-set-pin runs passwd); this script never +# sets or stores one. Set it as root with `passwd USER`, or later from the +# phone's menu (System > PIN). +# +# Kept dodge-specific, stock skipped (would break dodge): +# - ufw (firstboot allows ssh on usb0 only): root ssh over Wi-Fi must work. +# - sddm autologin: staged separately by login-sddm (it changes how the +# phone boots); until then omamobile-hyprland.service starts Hyprland. +# - `usermod -L root`: root ssh is key-only already (sshd 10-omamobile.conf). +# Replaced: dodge's omamobile-idle-off.service (screen off at 150 s, no lock) +# is disabled; the stock idle path runs instead (screensaver 150 s, lock +# 300 s, the lock blanks the panel 10 s later). `--revert` brings it back. +# Backups: ~USER/.local/state/dodge-setup-stock/, /var/lib/dodge-setup-stock/. +# Omarchy's default keyring (step 1b) is kept on --revert: it may hold +# Chromium's cookie key and other secrets by then. Remove it by hand if needed +# (~USER/.local/share/keyrings/Default_keyring.keyring and default). +set -euo pipefail +revert=0 +[[ ${1:-} == --revert ]] && { revert=1; shift; } +U=${1:-ml} +[[ $(id -u) == 0 ]] || { echo "run as root" >&2; exit 1; } +id "$U" >/dev/null +H=$(getent passwd "$U" | cut -d: -f6) +uid=$(id -u "$U") +bk=$H/.local/state/dodge-setup-stock +rbk=/var/lib/dodge-setup-stock +files=(.config/hypr/autostart.lua .config/hypr/looknfeel.lua .config/omarchy/shell.json + .config/omarchy/extensions/omarchy-menu.jsonc .config/chromium-flags.conf + .config/omarchy/branding/screensaver.txt .config/foot/screensaver.ini) +added_toggles=(lock-keypad lock-on-start lock-after-screensaver suspend-off credential-password) + +as_user() { + local sig + sig=$(ls -t "/run/user/$uid/hypr" 2>/dev/null | head -1 || true) + runuser -u "$U" -- env LANG=C.UTF-8 HOME="$H" USER="$U" LOGNAME="$U" PATH=/usr/share/omarchy/bin:/usr/local/bin:/usr/bin \ + XDG_RUNTIME_DIR="/run/user/$uid" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \ + WAYLAND_DISPLAY=wayland-1 HYPRLAND_INSTANCE_SIGNATURE="$sig" OMARCHY_PATH=/usr/share/omarchy "$@" +} +live() { # apply to a running session, if there is one + pgrep -u "$U" -x Hyprland >/dev/null || return 0 + as_user hyprctl reload >/dev/null || true + as_user bash -c "$1" /dev/null 2>&1 || true # daemons: keep no pipe open + as_user bash -c 'setsid omarchy-restart-shell' /dev/null 2>&1 & +} + +if ((revert)); then + [[ -f $bk/files.tgz ]] || { echo "no backup in $bk; nothing to revert" >&2; exit 1; } + # Removing the PAM file under a held lock would leave a lock nobody can open + # (the shell prints a locale WARN on stdout without LANG, hence grep -x). + if pgrep -u "$U" -x Hyprland >/dev/null && as_user omarchy-shell lock isLocked 2>/dev/null | grep -qx true; then + echo "the session is locked; unlock it first (or reboot), then revert" >&2; exit 1 + fi + as_user bash -s "$bk" "${files[@]}" <<'SH' +set -u; bk=$1; shift; cd ~ +for f in "$@"; do grep -qxF "$f" "$bk/files.list" || rm -f "$f"; done +tar -xzf "$bk/files.tgz" +t=~/.local/state/omarchy/toggles d=~/.local/state/omarchy/done +for x in lock-keypad lock-on-start lock-after-screensaver suspend-off credential-password screensaver-off; do + if grep -qxF "$x" "$bk/toggles.list"; then touch "$t/$x"; else rm -f "$t/$x"; fi +done +for m in "$d"/*; do grep -qxF "$(basename "$m")" "$bk/done.list" || rm -f "$m"; done +[[ -f $bk/credential ]] || rm -f ~/.config/omamobile/credential +gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false 2>/dev/null || true +SH + # The PIN is the account password: put back what was there before (locked). + if [[ -f $rbk/shadow.$U ]]; then usermod -p "$(cat "$rbk/shadow.$U")" "$U"; else usermod -p '!' "$U"; fi + [[ -f $rbk/pam-created ]] && rm -f /etc/pam.d/omarchy-lock-password /etc/pam.d/omarchy-lock-fingerprint "$rbk/pam-created" + systemctl --global enable omamobile-idle-off.service 2>/dev/null || true + live 'pkill -u "$USER" -x squeekboard; omarchy-shell lock unlock >/dev/null 2>&1; systemctl --user start omamobile-idle-off.service' + echo "reverted: no lock, no PIN, dodge idle screen-off"; exit 0 +fi + +command -v omamobile-setup-user >/dev/null || { echo "omamobile-shell is not installed" >&2; exit 1; } +command -v squeekboard >/dev/null || { echo "squeekboard is not installed" >&2; exit 1; } +# Backups, once (a second run must not overwrite the pre-stock state). +install -d -m 700 "$rbk" +[[ -f $rbk/shadow.$U ]] || { getent shadow "$U" | cut -d: -f2 > "$rbk/shadow.$U"; chmod 600 "$rbk/shadow.$U"; } +if [[ ! -f $bk/files.tgz ]]; then + as_user bash -s "$bk" "${files[@]}" <<'SH' +set -eu; bk=$1; shift; mkdir -p "$bk"; cd ~ +: > "$bk/files.list"; for f in "$@"; do [[ -e $f ]] && echo "$f" >> "$bk/files.list"; done +tar -czf "$bk/files.tgz" -T "$bk/files.list" +ls ~/.local/state/omarchy/toggles > "$bk/toggles.list"; ls ~/.local/state/omarchy/done > "$bk/done.list" +[[ -f ~/.config/omamobile/credential ]] && cp ~/.config/omamobile/credential "$bk/credential" || true +SH +fi + +# 0. The lock's PAM service (Omarchy install/config/lockscreen-pam.sh, which +# omamobile-firstboot runs; dodge's rootfs never ran firstboot). Without it +# the lock refuses to engage ("missing-pam"). +[[ -f /etc/pam.d/omarchy-lock-password || -f $rbk/pam-created ]] || touch "$rbk/pam-created" +OMARCHY_INSTALL_USER=$U omarchy-apply-lock >/dev/null +# 1. Stock user setup, unchanged (idempotent via omarchy-done markers). +as_user omamobile-setup-user +# 1b. Omarchy's default keyring (install/user/default-keyring.sh, from +# omarchy-provision-user, which firstboot runs; dodge never did). Without it +# gnome-keyring raises an invisible "create keyring" prompt and Chromium +# (--password-store=gnome-libsecret) hangs every request with cookies. +# Idempotent: it only writes the files that are missing. +kr=$H/.local/share/keyrings/Default_keyring.keyring +had_kr=0; [[ -f $kr ]] && had_kr=1 +as_user bash -eu /usr/share/omarchy/install/user/default-keyring.sh +if ((!had_kr)) && pgrep -u "$U" -f gnome-keyring-daemon >/dev/null; then + echo "new default keyring: restart gnome-keyring-daemon (or log in again) to use it" +fi +# 2. omamobile-firstboot's user tail: PIN type, number pad, lock after start. +as_user bash -c 't=~/.local/state/omarchy/toggles; mkdir -p "$t" ~/.config/omamobile + [[ -f ~/.config/omamobile/credential ]] || echo pin > ~/.config/omamobile/credential + touch "$t/lock-keypad"; rm -f "$t/screensaver-off"' +if [[ $(passwd -S "$U" | awk '{print $2}') == P ]]; then + as_user touch "$H/.local/state/omarchy/toggles/lock-on-start" +else + echo "no PIN yet: set one with 'passwd $U' (digits for the number pad), then rerun to lock after start" +fi +# 3. Stock idle path instead of dodge's screen-off-without-lock. +systemctl --global disable omamobile-idle-off.service 2>/dev/null || true +live 'systemctl --user stop omamobile-idle-off.service; pgrep -u "$USER" -x squeekboard >/dev/null || setsid squeekboard >/dev/null 2>&1 &' +echo "done: stock lock, keys and keyboard; revert with: $0 --revert $U" diff --git a/device/dodge/desktop/setup-ui b/device/dodge/desktop/setup-ui new file mode 100755 index 000000000..a5773751a --- /dev/null +++ b/device/dodge/desktop/setup-ui @@ -0,0 +1,69 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# dodge-setup-ui: the stock Omarchy Mobile display setup for the OnePlus 13, +# plus the dodge overrides (shell.toml here). Run as the desktop user (not +# root), from this directory or with it as $1. Idempotent. +# +# It does the display part of omamobile-setup-user (omamobile-shell): the +# phone shell plugins, the phone bar profile and the scale-3 monitor, and +# records the same omarchy-done markers, so a later full omamobile-setup-user +# keeps them. The lock, power-key and keyboard steps are in setup-stock. +# Backups: ~/.config/omarchy/shell.json.pre-dodge-ui, +# ~/.config/hypr/monitors.lua.pre-dodge-ui. `--revert` puts them back. +# +# Sharp PNG app icons (workaround for Omarchy's shell, omarchy 4.0.4): its +# AppLibrary icon index keeps the FIRST file `find` lists per icon name, SVGs +# first, then PNGs in directory order. For PNG-only icons that is often +# hicolor/16x16 or 48x48 (chromium.png: 16x16), which the home grid scales to +# 52 px x scale 3 = 156 px: blurry. The index scans ~/.local/share/icons +# before /usr/share/icons, so we link the largest hicolor PNG (512 or 256) of +# every icon without an SVG there. Links listed in +# ~/.local/state/dodge-setup-ui/icon-links; `--revert` removes them. +set -euo pipefail +if [[ ${1:-} == --revert ]]; then SRC=$(cd "$(dirname "$0")" && pwd) +else SRC=$(cd "${1:-$(dirname "$0")}" && pwd); fi +[[ $(id -u) != 0 ]] || { echo "run as the desktop user" >&2; exit 1; } +share=/usr/share/omamobile/shell +cfg=~/.config/omarchy +mon=~/.config/hypr/monitors.lua +links=~/.local/state/dodge-setup-ui/icon-links + +if [[ ${1:-} == --revert ]]; then + [[ -f $cfg/shell.json.pre-dodge-ui ]] && cp "$cfg/shell.json.pre-dodge-ui" "$cfg/shell.json" + [[ -f $mon.pre-dodge-ui ]] && cp "$mon.pre-dodge-ui" "$mon" + rm -f "$cfg/shell.toml" + if [[ -f $links ]]; then + while read -r l; do [[ -L $l ]] && rm -f "$l"; done < "$links" + rm -f "$links" + fi + echo "reverted; restart with: hyprctl reload; omarchy-restart-shell"; exit 0 +fi + +[[ -d $share/plugins ]] || { echo "omamobile-shell is not installed" >&2; exit 1; } +[[ -f $cfg/shell.json.pre-dodge-ui ]] || cp "$cfg/shell.json" "$cfg/shell.json.pre-dodge-ui" +[[ -f $mon.pre-dodge-ui ]] || cp "$mon" "$mon.pre-dodge-ui" + +mkdir -p "$cfg/plugins" +for p in "$share"/plugins/omamobile.*; do ln -sfn "$p" "$cfg/plugins/$(basename "$p")"; done +cp "$share/profile/shell.json" "$cfg/shell.json" +sed -i 's/^local omarchy_monitor_scale = .*/local omarchy_monitor_scale = 3/' "$mon" +install -m 644 "$SRC/shell.toml" "$cfg/shell.toml" +# Large PNG icons first in the shell's icon index (see the top) +declare -A svg=() have=() +while read -r n; do svg[$n]=1; done < <(find ~/.icons ~/.local/share/icons /usr/local/share/icons /usr/share/icons \ + \( -path '*/apps/*' -o -path '*/devices/*' \) -name '*.svg' -printf '%f\n' 2>/dev/null | sed 's/\.svg$//' | sort -u) +mkdir -p "${links%/*}"; touch "$links" +for sz in 512x512 256x256; do + for f in /usr/share/icons/hicolor/$sz/apps/*.png; do + [[ -f $f ]] || continue + n=$(basename "$f" .png) + [[ -n ${svg[$n]:-} || -n ${have[$n]:-} ]] && continue + have[$n]=1 + l=~/.local/share/icons/hicolor/$sz/apps/$n.png + [[ -e $l ]] && continue + mkdir -p "${l%/*}"; ln -s "$f" "$l"; echo "$l" >> "$links" + done +done +omarchy-done mark omamobile-shell-profile +omarchy-done mark omamobile-monitor-scale +echo "done; apply with: hyprctl reload; omarchy-restart-shell" diff --git a/device/dodge/desktop/shell.toml b/device/dodge/desktop/shell.toml new file mode 100644 index 000000000..3676e356e --- /dev/null +++ b/device/dodge/desktop/shell.toml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# OnePlus 13 (dodge) overrides for the Omarchy shell, installed as +# ~/.config/omarchy/shell.toml (user keys win over the theme's shell.toml). +# Only what differs from the stock Omarchy Mobile phone profile. +# +# Panel: 1440x3168, 6.82 in, about 510 ppi (20.1 px/mm). At the stock phone +# scale 3 one logical px is about 0.15 mm. + +[bar] +# omamobile.bar is max(44, size-horizontal) tall: 44 is 6.6 mm here, 48 is +# 7.2 mm, inside a 7-9 mm touch target. +size-horizontal = 48 + +[spacing] +# The bar's left/right inset (stock 18 = 2.7 mm). 22 (3.3 mm) keeps the clock +# and battery icon clear of the rounded corners: the panel radius isn't +# published, but an arc of up to about 220 px leaves the icons' top edge +# inside this inset. +huge = 22 diff --git a/device/dodge/display/display-try b/device/dodge/display/display-try new file mode 100755 index 000000000..dc7555615 --- /dev/null +++ b/device/dodge/display/display-try @@ -0,0 +1,29 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Hand-test of the msm display path on dodge (run as root, once per boot). +# Arms a dead-man reboot first: a reboot always brings simpledrm back. +set -u +DM=${DM:-300} +H=/lib/modules/$(uname -r).held/kernel +[ -d "$H" ] || H=/lib/modules/$(uname -r)/kernel +P=/usr/local/lib/omamobile/display +systemd-run --quiet --unit=dm-display-$$ --on-active="$DM" systemctl reboot --force +echo "dead-man reboot in ${DM}s (unit dm-display-$$)" +[ "${DRMDBG:-0}" != 0 ] && echo "$DRMDBG" > /sys/module/drm/parameters/debug 2>/dev/null +for k in \ + $H/drivers/clk/qcom/dispcc-sm8750.ko \ + $H/drivers/video/backlight/backlight.ko \ + $H/drivers/gpu/drm/display/drm_display_helper.ko \ + $H/drivers/gpu/drm/display/drm_dp_aux_bus.ko \ + $H/drivers/gpu/drm/drm_exec.ko \ + $H/drivers/gpu/drm/scheduler/gpu-sched.ko \ + $H/drivers/soc/qcom/llcc-qcom.ko \ + $H/drivers/soc/qcom/ocmem.ko \ + $H/drivers/soc/qcom/mdt_loader.ko \ + $P/panel-aa569-p-3-a0019-dsc.ko \ + $( [ -f $P/msm.ko ] && echo $P/msm.ko || echo $H/drivers/gpu/drm/msm/msm.ko ) +do + n=$(basename "$k" .ko | tr - _) + if grep -q "^$n " /proc/modules; then echo "have $n"; continue; fi + insmod "$k" && echo "ok $n" || { echo "FAIL $n"; exit 1; } +done diff --git a/device/dodge/display/install b/device/dodge/display/install new file mode 100755 index 000000000..ef2eac1be --- /dev/null +++ b/device/dodge/display/install @@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Install the msm display load at boot on the phone. Run as root, from +# this directory (copied to the phone), or with the directory as $1. +# Idempotent. Installs omamobile-display-msm (script and unit) and +# display-try, and enables the unit; it does not start it (one load per +# boot, the next boot loads it). msm.ko and the panel module in +# /usr/local/lib/omamobile/display are installed separately. +# Off switch: touch /etc/omamobile/display-msm.disable +set -eu +SRC=${1:-$(dirname "$0")} +log() { echo "dodge-display-install: $*"; } +[ "$(id -u)" = 0 ] || { log "run as root"; exit 1; } +install -D -m 755 "$SRC/omamobile-display-msm" /usr/local/sbin/omamobile-display-msm +install -D -m 644 "$SRC/omamobile-display-msm.service" /etc/systemd/system/omamobile-display-msm.service +install -D -m 755 "$SRC/display-try" /usr/local/sbin/display-try +systemctl daemon-reload +systemctl enable omamobile-display-msm.service +for f in msm.ko panel-aa569-p-3-a0019-dsc.ko; do + [ -f "/usr/local/lib/omamobile/display/$f" ] || log "warning: /usr/local/lib/omamobile/display/$f missing" +done +[ -e /etc/omamobile/display-msm.disable ] && log "note: disabled by /etc/omamobile/display-msm.disable" +log "done; the next boot loads msm" diff --git a/device/dodge/display/omamobile-display-msm b/device/dodge/display/omamobile-display-msm new file mode 100755 index 000000000..9aa2f8dfd --- /dev/null +++ b/device/dodge/display/omamobile-display-msm @@ -0,0 +1,74 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Load the msm display path (dispcc, deps, AA569 panel, msm) once per +# boot, before Hyprland. Needs the kernel fix that keeps MDSS_GDSC on +# across runtime suspend, or the first screen off breaks the display. +# +# Off switch: touch /etc/omamobile/display-msm.disable (then reboot). +# Fallback: if msm has not bound a DSI connector within $WAIT seconds, +# it says so and exits 0; Hyprland starts anyway. As long as msm has not +# bound, simpledrm is untouched (msm only takes the framebuffer over +# once it binds). +set -u +WAIT=${WAIT:-20} +DISABLE=/etc/omamobile/display-msm.disable +STAMP=/run/omamobile-display-msm.tried +H=/lib/modules/$(uname -r).held/kernel +[ -d "$H" ] || H=/lib/modules/$(uname -r)/kernel +P=/usr/local/lib/omamobile/display + +log() { echo "omamobile-display-msm: $*"; echo "omamobile-display-msm: $*" > /dev/kmsg 2>/dev/null; } + +[ -e "$DISABLE" ] && { log "disabled by $DISABLE, staying on simpledrm"; exit 0; } +[ -e /sys/module/msm ] && { log "msm already loaded"; exit 0; } +[ -e "$STAMP" ] && { log "already tried this boot ($STAMP)"; exit 0; } +: > "$STAMP" + +# Load what modules.dep lists for $1 first, last entry first. With the +# 6.16 list below these are already loaded; a newer kernel's msm.ko +# needs more (7.3: drm_gpuvm, ubwc_config, cec). +load_deps() { + local d n dep=${H%/kernel}/modules.dep + [ -r "$dep" ] || return 0 + for d in $(sed -n "s#^[^:]*/$(basename "$1"):##p" "$dep" | head -1 | tr ' ' '\n' | tac); do + n=$(basename "$d" .ko | tr - _) + grep -q "^$n " /proc/modules && continue + insmod "${H%/kernel}/$d" || return 1 + done +} + +# dispcc first: msm-mdss otherwise fails -110 after the deferred-probe timeout. +for k in \ + $H/drivers/clk/qcom/dispcc-sm8750.ko \ + $H/drivers/video/backlight/backlight.ko \ + $H/drivers/gpu/drm/display/drm_display_helper.ko \ + $H/drivers/gpu/drm/display/drm_dp_aux_bus.ko \ + $H/drivers/gpu/drm/drm_exec.ko \ + $H/drivers/gpu/drm/scheduler/gpu-sched.ko \ + $H/drivers/soc/qcom/llcc-qcom.ko \ + $H/drivers/soc/qcom/ocmem.ko \ + $H/drivers/soc/qcom/mdt_loader.ko \ + $P/panel-aa569-p-3-a0019-dsc.ko \ + $( [ -f $P/msm.ko ] && echo $P/msm.ko || echo $H/drivers/gpu/drm/msm/msm.ko ) +do + n=$(basename "$k" .ko | tr - _) + grep -q "^$n " /proc/modules && continue + # Another kernel (via omamobile-kmod-overlay) may build this one in. + [ -f "$k" ] || ! grep -q "/$(basename "$k")\$" "${H%/kernel}/modules.builtin" 2>/dev/null || continue + load_deps "$k" || { log "a dependency of $n failed; staying on simpledrm"; exit 0; } + insmod "$k" || { log "insmod $n failed; staying on simpledrm"; exit 0; } +done + +i=0 +while [ $i -lt $((WAIT * 2)) ]; do + for c in /sys/class/drm/card*-DSI-1; do + if [ -r "$c/status" ] && [ "$(cat "$c/status")" = connected ]; then + log "msm bound: $(basename "$c") after $((i / 2)) s" + exit 0 + fi + done + sleep 0.5 + i=$((i + 1)) +done +log "msm did not bind a DSI connector within ${WAIT} s; Hyprland starts on whatever is there ($(ls /dev/dri 2>/dev/null | tr '\n' ' '))" +exit 0 diff --git a/device/dodge/display/omamobile-display-msm.service b/device/dodge/display/omamobile-display-msm.service new file mode 100644 index 000000000..315cde4fb --- /dev/null +++ b/device/dodge/display/omamobile-display-msm.service @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# msm display path, loaded once per boot before Hyprland. Never blocks +# the desktop: the script exits 0 on any failure, and Hyprland only +# orders after this unit (no Requires), so a timeout here still lets it +# start. +[Unit] +Description=msm display (DSI panel) for dodge, loaded once +After=local-fs.target systemd-modules-load.service +Before=omamobile-hyprland.service +ConditionPathExists=!/etc/omamobile/display-msm.disable + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/sbin/omamobile-display-msm +TimeoutStartSec=60 + +[Install] +WantedBy=multi-user.target diff --git a/device/dodge/display/selfheal/omamobile-display-selfheal b/device/dodge/display/selfheal/omamobile-display-selfheal new file mode 100755 index 000000000..4f51eda89 --- /dev/null +++ b/device/dodge/display/selfheal/omamobile-display-selfheal @@ -0,0 +1,41 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Display self-heal (dodge), OPT-IN. If the first msm panel init this boot +# failed with a DSI cmd DMA timeout (-110: the warm-boot display drop), the +# screen stays dark and the phone freezes ~6 min later. Reboot once so the +# next warm boot (usually good) brings the display back. +# +# Enable: touch /etc/omamobile/display-selfheal.enable +# systemctl enable omamobile-display-selfheal.service +# Loop guard: at most one self-heal reboot per $GAP seconds (marker mtime +# in /var/lib/omamobile). A good boot removes the marker. +set -u +MARK=/var/lib/omamobile/display-selfheal +GAP=${GAP:-600} +WAIT=${WAIT:-25} +log() { echo "omamobile-display-selfheal: $*"; echo "omamobile-display-selfheal: $*" > /dev/kmsg 2>/dev/null; } + +# give msm time to bind and send the first panel commands +i=0 +while [ $i -lt "$WAIT" ]; do + journalctl -k -b -q --no-pager | grep -q -e 'cmd dma tx failed' -e 'Failed to initialize panel' && break + [ -e /sys/class/drm/card1-DSI-1 ] || [ -e /sys/class/drm/card0-DSI-1 ] && [ $i -ge 10 ] && break + sleep 1; i=$((i + 1)) +done + +if ! journalctl -k -b -q --no-pager | grep -q -e 'ret=-110' -e 'Failed to initialize panel: -110'; then + [ -e "$MARK" ] && { rm -f "$MARK"; log "display OK, cleared marker"; } + exit 0 +fi + +mkdir -p "${MARK%/*}" +if [ -e "$MARK" ]; then + age=$(( $(date +%s) - $(stat -c %Y "$MARK") )) + if [ "$age" -lt "$GAP" ]; then + log "panel init -110 again, but already self-healed ${age}s ago; not rebooting" + exit 0 + fi +fi +: > "$MARK"; sync +log "first panel init failed with -110 (display dark); rebooting once" +systemctl reboot diff --git a/device/dodge/display/selfheal/omamobile-display-selfheal.service b/device/dodge/display/selfheal/omamobile-display-selfheal.service new file mode 100644 index 000000000..1cbd1a7cc --- /dev/null +++ b/device/dodge/display/selfheal/omamobile-display-selfheal.service @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: MIT +# OPT-IN: not enabled by default. Reboots once if msm's first panel init +# failed with -110 (see omamobile-display-selfheal). +[Unit] +Description=Reboot once if the msm panel init timed out (dodge display drop) +After=omamobile-display-msm.service +ConditionPathExists=/etc/omamobile/display-selfheal.enable + +[Service] +Type=oneshot +ExecStart=/usr/local/sbin/omamobile-display-selfheal +TimeoutStartSec=60 + +[Install] +WantedBy=multi-user.target diff --git a/device/dodge/idle/install b/device/dodge/idle/install new file mode 100755 index 000000000..b9d02d0bf --- /dev/null +++ b/device/dodge/idle/install @@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Install the dodge idle screen-off (no lock). Run as root, from this +# directory (copied to the phone), or with it as $1. Idempotent. +# - /usr/share/omamobile/idle-off/shell.qml and the user unit +# /etc/systemd/user/omamobile-idle-off.service, enabled globally. +# - Omarchy's screensaver is switched off for $IDLE_USER (its own toggle, +# omarchy-toggle-screensaver turns it back on): it ran llvmpipe at about +# 650 % CPU and never turned the screen off. +# Nothing touches the lock or PAM. Undo: systemctl --global disable +# omamobile-idle-off.service and remove the toggle file. +set -eu +SRC=${1:-$(dirname "$0")} +IDLE_USER=${IDLE_USER:-ml} +log() { echo "dodge-idle-install: $*"; } +[ "$(id -u)" = 0 ] || { log "run as root"; exit 1; } +install -D -m 644 "$SRC/omamobile-idle-off/shell.qml" /usr/share/omamobile/idle-off/shell.qml +install -D -m 644 "$SRC/omamobile-idle-off.service" /etc/systemd/user/omamobile-idle-off.service +systemctl --global enable omamobile-idle-off.service +home=$(getent passwd "$IDLE_USER" | cut -d: -f6) +runuser -u "$IDLE_USER" -- mkdir -p "$home/.local/state/omarchy/toggles" +runuser -u "$IDLE_USER" -- touch "$home/.local/state/omarchy/toggles/screensaver-off" +log "done; starts with the next graphical session (or: systemctl --user start omamobile-idle-off as $IDLE_USER)" diff --git a/device/dodge/idle/omamobile-idle-off.service b/device/dodge/idle/omamobile-idle-off.service new file mode 100644 index 000000000..3f4e8b4f2 --- /dev/null +++ b/device/dodge/idle/omamobile-idle-off.service @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# dodge: screen off after inactivity, no lock (user unit, see shell.qml). +# Timeout: OMAMOBILE_IDLE_OFF_SECONDS here or in a drop-in. Off switch: +# systemctl --user disable --now omamobile-idle-off.service +[Unit] +Description=Screen off after inactivity (dodge, no lock) +PartOf=graphical-session.target +After=graphical-session.target + +[Service] +Environment=OMAMOBILE_IDLE_OFF_SECONDS=150 +Environment=PATH=/usr/share/omarchy/bin:/usr/local/bin:/usr/bin +Environment=OMARCHY_PATH=/usr/share/omarchy +ExecStart=/usr/bin/quickshell -n -p /usr/share/omamobile/idle-off +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=graphical-session.target diff --git a/device/dodge/idle/omamobile-idle-off/shell.qml b/device/dodge/idle/omamobile-idle-off/shell.qml new file mode 100644 index 000000000..5a198d562 --- /dev/null +++ b/device/dodge/idle/omamobile-idle-off/shell.qml @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +// dodge: turn the screen off after inactivity, no lock (Martin's choice +// for now). A separate Quickshell instance next to omarchy-shell. After +// OMAMOBILE_IDLE_OFF_SECONDS (default 150) without input it runs +// `omarchy-brightness-display off` (DPMS off plus bl_power 4); the first +// input after that (touch, key) runs `omarchy-brightness-display on`. +// Honours idle inhibitors (video, `noidle` windows) and Omarchy's +// stay-awake toggle. +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Wayland + +ShellRoot { + id: root + readonly property int seconds: { + var v = parseInt(Quickshell.env("OMAMOBILE_IDLE_OFF_SECONDS") || "150") + return v > 0 ? v : 150 + } + property bool turnedOff: false + + function run(cmd) { + proc.command = ["bash", "-lc", cmd] + proc.running = true + } + + IdleMonitor { + id: monitor + timeout: root.seconds + respectInhibitors: true + onIsIdleChanged: { + if (isIdle) { + console.log("omamobile-idle-off: idle " + root.seconds + " s, screen off") + root.turnedOff = true + root.run("[[ -f $HOME/.local/state/omarchy/indicators/stay-awake ]] && exit 0; omarchy-brightness-display off") + } else if (root.turnedOff) { + console.log("omamobile-idle-off: activity, screen on") + root.turnedOff = false + root.run("omarchy-brightness-display on") + } + } + } + + Process { id: proc } + + Component.onCompleted: console.log("omamobile-idle-off: ready, " + root.seconds + " s") +} diff --git a/device/dodge/modem/78-omamobile-mm-fake-net.rules b/device/dodge/modem/78-omamobile-mm-fake-net.rules new file mode 100644 index 000000000..da2dc8bdf --- /dev/null +++ b/device/dodge/modem/78-omamobile-mm-fake-net.rules @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MIT +# Experiment (2026-10-21): ModemManager refuses a QMI modem without a net port, +# and SM8750 has no IPA driver in 6.16 yet. Offer a tun device as the +# qcom-soc net port so MM creates the modem for control (registration, SIM, +# voice/SMS). Data through it cannot work. Remove once IPA exists. +ACTION!="add|change|move|bind", GOTO="omamobile_mm_fake_end" +SUBSYSTEM=="net", KERNEL=="rmnet_mm0", ENV{ID_MM_DEVICE_PROCESS}="1", ENV{ID_MM_QCOM_SOC}="1", ENV{ID_MM_PHYSDEV_UID}="qcom-soc", ENV{ID_MM_CANDIDATE}="1" +LABEL="omamobile_mm_fake_end" diff --git a/device/dodge/modem/ModemManager-omamobile.conf b/device/dodge/modem/ModemManager-omamobile.conf new file mode 100644 index 000000000..d641fe9af --- /dev/null +++ b/device/dodge/modem/ModemManager-omamobile.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT +# Drop-in: ModemManager runs only with the dodge modem flag, after the modem +# DSP, the SIM provisioning/online step and the stand-in net port are up. +[Unit] +ConditionPathExists=/etc/omamobile/modem-probe.enable +Wants=omamobile-modem.service omamobile-modem-online.service omamobile-mm-netport.service +After=omamobile-modem.service omamobile-modem-online.service omamobile-mm-netport.service diff --git a/device/dodge/modem/README.md b/device/dodge/modem/README.md new file mode 100644 index 000000000..537ec9b46 --- /dev/null +++ b/device/dodge/modem/README.md @@ -0,0 +1,73 @@ + +# dodge modem + +Everything here is inert unless `/etc/omamobile/modem-probe.enable` exists. +Default in the package: **off** (no `/etc/omamobile/modem-probe.enable`). +Owners who opt in need their own firmware under `/lib/firmware` and their +own EFS copies (never shipped). On a kernel without an enabled IPA DT node +`omamobile-modem-efs` exits without touching the copies, so rmtfs and the MPSS +are never started and a rollback stays safe even with the flag on. + +## Boot sequence (flag present) + +1. `adsp-battery.sh` loads `qcom_q6v5_pas`. The MPSS is probed; the CDSP may + fail its load without firmware (harmless). +2. `omamobile-modem-efs.service` runs before rmtfs when IPA is present. It + restores the named good EFS *copy set* from + `/var/lib/omamobile/efs-good/` (name in + `/etc/omamobile/modem-efs-good`). Good sets are never rotated. Optional + auto-snapshots under `/var/lib/omamobile/efs-snapshots/` stay on the phone. +3. `omamobile-rmtfs.service` loads `qcom_rmtfs_mem` and runs **only** + `rmtfs -r -o /var/lib/omamobile/modem-efs -v`: read-only copies of the EFS + partitions, with modem writes kept in RAM. Never `-P`. +4. `omamobile-tqftpserv.service` serves MCFG from `/lib/firmware`. +5. `omamobile-modem.service` starts the MPSS by name. Do **not** stop the + modem remoteproc (hard-reset risk on 7.3); the unit has no ExecStop. +6. `omamobile-modem-online.service` provisions SIM slot 1 if needed, goes + online, waits for registration. +7. ModemManager (drop-in `ModemManager-omamobile.conf`) and the NM profile + `omamobile-cellular.nmconnection` (APN `internet`, metric 700) bring up + data on `rmnet_ipa0` / `qmapmux0.0`. + +## EFS restore (no blobs in git) + +The modem needs the phone's own non-volatile calibration. This repository +ships **units and docs only** — never EFS snapshots, NV backups, or modem +firmware. + +On the phone, once, take read-only copies of the current slot's partitions +(`dd if=` only, mode 600) into `/var/lib/omamobile/modem-efs/` (and promote a +known-good set into `/var/lib/omamobile/efs-good/`): + +- `oplusstanvbk_` → `oem_stanvbk` +- `oplusdycnvbk` → `oem_dycnvbk` (per-unit; keep off any shared medium) + +A set the modem has written to for a few minutes can crash the next boot +(rtsar), so the good set is restored on every boot. Firmware for the MPSS +belongs under `/lib/firmware/qcom/sm8750/OnePlus/` from the owner's own +factory image (`tools/phone-provision` / extract scripts); it is not in git. + + +## Off-phone backups (CONTRIBUTING §3.3) + +Before any modem session, keep **off-phone**, read-only copies of: + +- `modemst1`, `modemst2` +- `fsg`, `fsc` +- `persist` +- oplus NV (`oplusstanvbk_`, `oplusdycnvbk`) + +Store them with a `SHA256SUMS` and re-check the hashes before each modem +session. Never commit those copies (or any EFS / modem firmware) to git. On +this phone the off-phone set lives outside the repository; the on-phone +`/var/lib/omamobile/efs-good/` set above is a separate, phone-local restore +path used when the opt-in flag is present. + +## Install + +Copy this directory to the phone and run `./install` as root. It expects +`rmtfs` and `tqftpserv` (linux-msm), the in-tree `rmtfs_mem` module for the +running kernel, and the firmware + EFS copies above. + +Turn on: `touch /etc/omamobile/modem-probe.enable`, then reboot. Turn off: +remove the flag and reboot. diff --git a/device/dodge/modem/adsp-battery.sh b/device/dodge/modem/adsp-battery.sh new file mode 100644 index 000000000..770c3d1a6 --- /dev/null +++ b/device/dodge/modem/adsp-battery.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Bring up the ADSP and the PMIC battery manager. Not required for boot. +# Installed as /usr/local/lib/omamobile/adsp-battery.sh (omamobile-adsp-battery.service). +# +# The PAS driver is loaded with only_adsp=1 by default, so the modem and the +# CDSP are not probed. Creating /etc/omamobile/modem-probe.enable loads it with +# only_adsp=0 instead: the MPSS is then probed (auto_boot is off, so it stays +# offline until started by hand) and the CDSP is probed too. Remove the file +# to go back. +set -u +HELD=/usr/lib/modules/6.16.0-gb3ee311dab85.held/kernel +LOCAL=/usr/local/lib/omamobile +load() { + local ko="$1" + shift || true + local base name + base=$(basename "$ko" .ko) + name=${base//-/_} + if awk -v m="$name" '$1==m {found=1} END{exit !found}' /proc/modules; then + return 0 + fi + insmod "$ko" "$@" +} +load "$HELD/net/qrtr/qrtr.ko" +load "$HELD/net/qrtr/qrtr-smd.ko" +load "$HELD/drivers/soc/qcom/qmi_helpers.ko" +load "$HELD/drivers/soc/qcom/qcom_pdr_msg.ko" +load "$HELD/drivers/soc/qcom/pdr_interface.ko" +load "$HELD/drivers/remoteproc/qcom_pil_info.ko" +load "$HELD/drivers/soc/qcom/mdt_loader.ko" +load "$HELD/drivers/rpmsg/qcom_glink_smem.ko" +load "$HELD/drivers/remoteproc/qcom_common.ko" +load "$HELD/drivers/remoteproc/qcom_sysmon.ko" +load "$HELD/drivers/remoteproc/qcom_q6v5.ko" +load "$LOCAL/qcom_pd_mapper.ko" +ONLY_ADSP=1 +[ -e /etc/omamobile/modem-probe.enable ] && ONLY_ADSP=0 +load "$LOCAL/qcom_q6v5_pas.ko" only_adsp=$ONLY_ADSP +adsp_state() { + local r + for r in /sys/class/remoteproc/remoteproc*; do + [ "$(cat "$r/name" 2>/dev/null)" = adsp ] && { cat "$r/state"; return; } + done +} +for _ in 1 2 3 4 5 6 7 8 9 10; do + state=$(adsp_state 2>/dev/null || true) + [ "$state" = running ] && break + sleep 0.5 +done +load "$HELD/drivers/soc/qcom/pmic_glink.ko" +load "$HELD/drivers/power/supply/qcom_battmgr.ko" diff --git a/device/dodge/modem/install b/device/dodge/modem/install new file mode 100755 index 000000000..39ee3e36a --- /dev/null +++ b/device/dodge/modem/install @@ -0,0 +1,26 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Run as root on the phone from device/dodge/modem. Installs the modem helper +# and units, the ModemManager drop-in and udev rule, and enables them. They do nothing unless +# /etc/omamobile/modem-probe.enable exists. Needs: /usr/local/bin/rmtfs and +# tqftpserv (built from linux-msm git), qcom_rmtfs_mem.ko, the EFS copies. +set -eu +cd "$(dirname "$0")" +for f in /usr/local/bin/rmtfs /usr/local/bin/tqftpserv /usr/local/lib/omamobile/modem/qcom_rmtfs_mem.ko; do + [ -e "$f" ] || { echo "missing $f" >&2; exit 1; } +done +install -Dm755 omamobile-modem /usr/local/lib/omamobile/modem/omamobile-modem +install -Dm755 adsp-battery.sh /usr/local/lib/omamobile/adsp-battery.sh +install -Dm644 78-omamobile-mm-fake-net.rules /etc/udev/rules.d/78-omamobile-mm-fake-net.rules +install -Dm600 omamobile-cellular.nmconnection /etc/NetworkManager/system-connections/omamobile-cellular.nmconnection +install -Dm644 ModemManager-omamobile.conf /etc/systemd/system/ModemManager.service.d/omamobile.conf +for u in omamobile-modem-efs omamobile-rmtfs omamobile-tqftpserv omamobile-modem omamobile-modem-online omamobile-mm-netport; do + install -Dm644 "$u.service" "/etc/systemd/system/$u.service" +done +systemctl daemon-reload +nmcli connection reload || true +udevadm control --reload +systemctl unmask ModemManager.service +systemctl enable omamobile-modem-efs.service omamobile-modem-online.service omamobile-rmtfs.service omamobile-tqftpserv.service omamobile-modem.service \ + omamobile-mm-netport.service ModemManager.service +echo "installed; active only with /etc/omamobile/modem-probe.enable" diff --git a/device/dodge/modem/omamobile-cellular.nmconnection b/device/dodge/modem/omamobile-cellular.nmconnection new file mode 100644 index 000000000..e1dff0a1a --- /dev/null +++ b/device/dodge/modem/omamobile-cellular.nmconnection @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: MIT +# Mobile data through NetworkManager + ModemManager. NM reads the bearer's +# IP config from MM (static on QMI) and applies address, routes, DNS and MTU +# on the qmapmux link (rmnet_ipa0 underneath on the IPA kernel). The APN is +# the generic "internet"; no SIM-specific value lives here. Wi-Fi stays +# preferred: lower autoconnect priority than Wi-Fi profiles (default 0) and +# route metric 700 against Wi-Fi's 600, so with both up the default route is +# Wi-Fi and cellular takes over only when Wi-Fi is gone. +# Inert without a ModemManager modem (modem flag /etc/omamobile/modem-probe.enable off). +[connection] +id=omamobile-cellular +type=gsm +autoconnect=true +autoconnect-priority=-10 +autoconnect-retries=0 + +[gsm] +apn=internet + +[ipv4] +method=auto +route-metric=700 + +[ipv6] +method=auto +addr-gen-mode=stable-privacy +route-metric=700 diff --git a/device/dodge/modem/omamobile-mm-netport.service b/device/dodge/modem/omamobile-mm-netport.service new file mode 100644 index 000000000..a4075d9ff --- /dev/null +++ b/device/dodge/modem/omamobile-mm-netport.service @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT +# ModemManager needs a net port for a QMI modem; SM8750 has no IPA driver yet. +# A tun device tagged by 78-omamobile-mm-fake-net.rules stands in, so MM can +# create the modem for control (SIM, registration, voice/SMS). No data. +[Unit] +Description=dodge stand-in net port for ModemManager (no IPA yet) +ConditionPathExists=/etc/omamobile/modem-probe.enable +Before=ModemManager.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/ip tuntap add mode tun name rmnet_mm0 +ExecStop=/usr/bin/ip tuntap del mode tun name rmnet_mm0 + +[Install] +WantedBy=multi-user.target diff --git a/device/dodge/modem/omamobile-modem b/device/dodge/modem/omamobile-modem new file mode 100755 index 000000000..56e16aa8f --- /dev/null +++ b/device/dodge/modem/omamobile-modem @@ -0,0 +1,131 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# omamobile-modem rmtfs-mem|start|stop|efs-prepare|snapshot