Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/omamobile-device-flame/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Derek Ross and Omarchy Mobile contributors

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.
11 changes: 11 additions & 0 deletions packages/omamobile-device-flame/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: MIT
pkgname=omamobile-device-flame
pkgver=$(cat "${startdir:-.}/version")
pkgrel=1
pkgdesc="Experimental guarded native-root support for Google Pixel 4 (flame)"
arch=(aarch64)
url="https://github.com/derekross/omarchy-mobile"
license=(MIT)
depends=(bash python systemd util-linux e2fsprogs 'omamobile-shell>=0.2.24' 'omamobile-firstboot>=0.1.3' foot xdg-terminal-exec udiskie)
check() { "$startdir/test/all"; }
package() { "$startdir/install" "$pkgdir"; }
29 changes: 29 additions & 0 deletions packages/omamobile-device-flame/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- SPDX-License-Identifier: MIT -->
# omamobile-device-flame

Experimental Pixel 4 native-root policy. Install only into the opt-in flame
root described in [the native runbook (review snapshot)](https://github.com/wirelessjoe/omarchy-mobile/blob/c6ce0c41f58a387f18e4f06a6de1a283698c9500/device/flame/native/README.md).
The runtime must be available before using the separate native boot/root
plumbing. This split itself installs no boot image or GPT writer.
The package enables the storage guard, hides protected partitions from desktop
disk tools, keeps the journal off USB, and selects the tested software-rendering
fallback for SDDM and user services. PID 1 feeds the 30-second watchdog; USB
networkd/DHCP stays separate from NetworkManager, and first-boot 0.1.3 adds
USB-only recovery/DHCP firewall rules. It does not mark a boot slot successful.

Foot, xdg-terminal-exec and udiskie are explicit dependencies so hand-built
roots cannot omit the terminal or disk helpers used by upstream Omarchy.
The existing AI Agent shortcut and chooser remain upstream's; no separate
Codex desktop app or agent selection is installed by this package.

`omamobile-flame-configure-user` seeds the tested 2.5 display scale. Its optional
`--chrome` switch merges the tested Wayland/software-rendering/0.6 scale flags
for an already installed Chrome browser. Other flags are preserved and prior
files are backed up under the owner's private state directory. It never
accepts a browser license or starts the browser. Chrome is not a dependency.
Normal mobile user setup calls `--chrome-if-installed` once for flame roots.

Wi-Fi's unit is shipped **disabled**. Before enabling it, supply the owner's
matching firmware and current verified private manifests/NV shadows and pass
the native Wi-Fi gates. No firmware, calibration, host keys or credentials
are in this package. Keep `ftm5_fw.ftb` absent before the first touch test.
70 changes: 70 additions & 0 deletions packages/omamobile-device-flame/bin/omamobile-flame-configure-user
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/python3
# SPDX-License-Identifier: MIT
"""Seed the measured flame scale; optionally fix an owner-installed Chrome."""
import argparse
from pathlib import Path
import os
import re
import shutil
import tempfile


def replace(home, path, content):
if path.exists() and path.read_text() == content:
return
backup = home / '.local/state/omamobile/flame-config-backups'
if path.exists():
backup.mkdir(parents=True, exist_ok=True, mode=0o700)
saved = backup / path.name
if not saved.exists():
shutil.copy2(path, saved)
saved.chmod(0o600)
path.parent.mkdir(parents=True, exist_ok=True)
fd, name = tempfile.mkstemp(prefix='.' + path.name, dir=path.parent)
try:
with os.fdopen(fd, 'w') as stream:
stream.write(content)
os.replace(name, path)
finally:
Path(name).unlink(missing_ok=True)


def configure(home, chrome=False):
monitors = home / '.config/hypr/monitors.lua'
if not monitors.exists():
raise RuntimeError('Run normal Omarchy Mobile user setup first')
original = monitors.read_text()
content, count = re.subn(r'^local omarchy_monitor_scale = .*$',
'local omarchy_monitor_scale = 2.5', original,
flags=re.MULTILINE)
if count != 1:
raise RuntimeError('Expected one Omarchy monitor-scale declaration')
replace(home, monitors, content)
if chrome:
flags = home / '.config/chrome-flags.conf'
lines = flags.read_text().splitlines() if flags.exists() else []
keys = ('--disable-gpu', '--ozone-platform', '--force-device-scale-factor')
kept = [line for line in lines if not any(
line.strip() == key or line.strip().startswith(key + '=') for key in keys)]
kept += ['--disable-gpu', '--ozone-platform=wayland',
'--force-device-scale-factor=0.6']
replace(home, flags, '\n'.join(kept) + '\n')


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--chrome', action='store_true', help='merge the tested Chrome flags')
parser.add_argument('--chrome-if-installed', action='store_true')
args = parser.parse_args()
if os.getuid() == 0:
parser.error('run as the desktop owner, not root')
if not Path('/usr/share/omamobile/flame-root').is_file():
parser.error('not a flame native root')
chrome = args.chrome or (args.chrome_if_installed and bool(
shutil.which('google-chrome-stable') or shutil.which('google-chrome')))
configure(Path.home(), chrome)
print('Flame display defaults configured' + ('; Chrome flags merged' if chrome else ''))


if __name__ == '__main__':
main()
16 changes: 16 additions & 0 deletions packages/omamobile-device-flame/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
destination=${1:?Usage: install ABSOLUTE_STAGING_DIRECTORY}
[[ $destination == /* && $destination != / ]] || exit 1
for file in bin/*; do install -Dm755 "$file" "$destination/usr/bin/${file##*/}"; done
for file in vendor/bin/*; do install -Dm755 "$file" "$destination/usr/bin/${file##*/}"; done
while IFS= read -r -d '' file; do
install -Dm644 "$file" "$destination/usr/lib/${file#vendor/lib/}"
done < <(find vendor/lib -type f -print0)
install -d "$destination/usr/lib/systemd/system/sysinit.target.wants"
ln -sfn ../flame-storage-guard.service "$destination/usr/lib/systemd/system/sysinit.target.wants/flame-storage-guard.service"
install -Dm644 version "$destination/usr/share/omamobile/device-flame/version"
install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-flame/LICENSE"
install -Dm644 /dev/null "$destination/usr/share/omamobile/flame-root"
54 changes: 54 additions & 0 deletions packages/omamobile-device-flame/test/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
set -euo pipefail
export PYTHONDONTWRITEBYTECODE=1
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
bash -n install
python3 -B test/storage-guard.py
sh -n vendor/bin/flame-storage-guard
bash -n vendor/bin/flame-wifi-start vendor/bin/flame-partition-links
./install "$scratch/root"
test -f "$scratch/root/usr/share/omamobile/flame-root"
test -L "$scratch/root/usr/lib/systemd/system/sysinit.target.wants/flame-storage-guard.service"
test ! -e "$scratch/root/usr/lib/systemd/system/multi-user.target.wants/flame-wifi.service"
test -f "$scratch/root/usr/lib/systemd/journald.conf.d/90-flame-standalone.conf"
grep -q '^ForwardToConsole=no$' "$scratch/root/usr/lib/systemd/journald.conf.d/90-flame-standalone.conf"
grep -qx 'RuntimeWatchdogSec=30s' "$scratch/root/usr/lib/systemd/system.conf.d/10-flame-watchdog.conf"
grep -qx 'RebootWatchdogSec=1min' "$scratch/root/usr/lib/systemd/system.conf.d/10-flame-watchdog.conf"
grep -qx 'Name=usb0' "$scratch/root/usr/lib/systemd/network/10-flame-usb.network"
grep -qx 'EmitRouter=no' "$scratch/root/usr/lib/systemd/network/10-flame-usb.network"
if grep -q '^Gateway=' "$scratch/root/usr/lib/systemd/network/10-flame-usb.network"; then
echo 'not ok - USB must not become the default gateway' >&2
exit 1
fi
python3 - <<'PY'
from pathlib import Path
import importlib.machinery,importlib.util,tempfile
path=Path('bin/omamobile-flame-configure-user')
loader=importlib.machinery.SourceFileLoader('flame_user',str(path))
spec=importlib.util.spec_from_loader(loader.name,loader)
module=importlib.util.module_from_spec(spec);loader.exec_module(module)
with tempfile.TemporaryDirectory() as folder:
home=Path(folder);monitor=home/'.config/hypr/monitors.lua'
monitor.parent.mkdir(parents=True);monitor.write_text('local omarchy_monitor_scale = 3\n-- owner setting\n')
chrome=home/'.config/chrome-flags.conf'
chrome.write_text('--force-device-scale-factor=0.83\n--ozone-platform=x11\n--lang=fr\n# owner comment\n')
module.configure(home,chrome=True)
assert monitor.read_text()=='local omarchy_monitor_scale = 2.5\n-- owner setting\n'
assert chrome.read_text()=='--lang=fr\n# owner comment\n--disable-gpu\n--ozone-platform=wayland\n--force-device-scale-factor=0.6\n'
backup=home/'.local/state/omamobile/flame-config-backups/chrome-flags.conf'
assert '--force-device-scale-factor=0.83' in backup.read_text()
before=chrome.read_bytes();saved=backup.read_bytes()
module.configure(home,chrome=True)
assert chrome.read_bytes()==before and backup.read_bytes()==saved
assert chrome.stat().st_mode & 0o777==0o600
# A manually maintained monitor layout must not be overwritten by guesswork.
monitor.write_text('-- custom layout\n')
try:module.configure(home,chrome=True)
except RuntimeError:pass
else:raise AssertionError('unknown monitor configuration accepted')
assert monitor.read_text()=='-- custom layout\n'
print('ok - flame package stages guard-only activation; user settings merge, backup and repeat safely')
PY
25 changes: 25 additions & 0 deletions packages/omamobile-device-flame/test/storage-guard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
from pathlib import Path
import tempfile,subprocess,os
source=(Path(__file__).resolve().parents[1]/'vendor/bin/flame-storage-guard').read_text()
body='UFS_RW="boot_b userdata"'+source.split('UFS_RW="boot_b userdata"',1)[1].split('\nwhile :; do',1)[0]
with tempfile.TemporaryDirectory() as d:
p=Path(d); sys=p/'sys';dev=p/'dev';bin=p/'bin'
for x in (sys,dev,bin):x.mkdir()
body=body.replace('/sys/class/block/',str(sys)+'/').replace('/dev/',str(dev)+'/').replace('[ -b ','[ -f ')
(p/'guard').write_text('say() { echo "$*" >&2; }\n'+body+'\nstorage_guard\n')
(bin/'blockdev').write_text('#!/bin/sh\n[ "$1" = --setro ] || exit 92\n[ "${MODE:-}" != fail ] || exit 1\n[ "${MODE:-}" != lie ] || exit 0\necho 1 > "$SYS/${2##*/}/ro"\n')
(bin/'blockdev').chmod(0o755)
def add(n,part='',ro='0'):
(sys/n).mkdir();(sys/n/'ro').write_text(ro+'\n');(sys/n/'uevent').write_text('PARTNAME='+part+'\n' if part else '');(dev/n).touch()
def run(mode=''):
return subprocess.run(['sh',str(p/'guard')],env=dict(os.environ,PATH=str(bin)+':'+os.environ['PATH'],SYS=str(sys),MODE=mode),capture_output=True)
for n,part in [('sda',''),('sda2','persist'),('sda6','boot_a'),('sda7','boot_b'),('sda15','userdata'),('sdb',''),('sde33','devinfo'),('sdf2','modemst1'),('sdf3','userdata')]:add(n,part)
assert run().returncode==0
assert not (dev/'sda').exists()
for n in ['sda2','sda6','sdb','sde33','sdf2','sdf3']:assert (sys/n/'ro').read_text().strip()=='1',n
for n in ['sda7','sda15']:assert (sys/n/'ro').read_text().strip()=='0',n
(sys/'sda7'/'ro').write_text('1\n');(dev/'sda').touch();assert run().returncode==0;assert not (dev/'sda').exists();assert (sys/'sda7'/'ro').read_text().strip()=='1'
add('sdg');assert run('fail').returncode!=0;assert run('lie').returncode!=0
print('Root guard: exact sda allowlist, all calibration protected, other-LUN userdata rejected, whole node removed, existing RO preserved, failure closed')
20 changes: 20 additions & 0 deletions packages/omamobile-device-flame/vendor/bin/flame-partition-links
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# UFS LUN discovery order can change across boots. Never persist /dev/sdX paths.
set -euo pipefail
test -f /usr/share/omamobile/flame-root
test ! -e /dev/sda
directory=/run/omamobile/flame-partitions
install -d -m 700 "$directory"
for part in persist modemst1 modemst2 fsg fsc modem_a modem_b devinfo; do
target=''
for candidate in /sys/class/block/sd*/uevent; do
if grep -Fx "PARTNAME=$part" "$candidate" >/dev/null; then
[[ -z $target ]] || { echo 'Ambiguous protected partition' >&2; exit 1; }
target=/dev/$(basename "$(dirname "$candidate")")
fi
done
[[ -n $target && -b $target ]] || { echo 'Protected partition absent' >&2; exit 1; }
[[ $(blockdev --getro "$target") == 1 ]] || { echo 'Protected partition is writable' >&2; exit 1; }
ln -sfn "$target" "$directory/$part"
done
38 changes: 38 additions & 0 deletions packages/omamobile-device-flame/vendor/bin/flame-storage-guard
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Development storage guard; never clear an existing read-only flag.
export PATH=/usr/bin:/bin
say() { echo "omamobile-flame-guard: $*" >/dev/kmsg; }
UFS_RW="boot_b userdata"
part_name() { sed -n 's/^PARTNAME=//p' "$1/uevent"; }
storage_guard() {
for s in /sys/class/block/sd*; do
[ -r "$s/ro" ] || continue
name=${s##*/}
if [ "$name" = sda ]; then
rm -f /dev/sda
continue
fi
[ -b "/dev/$name" ] || continue
part=$(part_name "$s")
case "$name" in
sda[0-9]*)
# A previously read-only device stays so; never use --setrw.
case " $UFS_RW " in *" $part "*) continue ;; esac ;;
esac
[ "$(cat "$s/ro")" = 1 ] && continue
if ! blockdev --setro "/dev/$name" || [ "$(cat "$s/ro")" != 1 ]; then
say "FAILED to protect /dev/$name"
return 1
fi
done
[ ! -e /dev/sda ]
}
while :; do
if ! storage_guard; then
say 'Storage protection failed; forcing recovery'
echo c >/proc/sysrq-trigger
exit 1
fi
sleep 0.2
done
103 changes: 103 additions & 0 deletions packages/omamobile-device-flame/vendor/bin/flame-wifi-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# Experimental flame radio startup. Owner firmware and NV stay off-repository.
set -euo pipefail

fail() { echo "flame Wi-Fi: $*" >&2; exit 1; }
test -f /usr/share/omamobile/flame-root || fail 'wrong root'
[[ $(tr -d '\0' </proc/device-tree/model) == 'Google Pixel 4' ]] || fail 'wrong model'
tr '\0' '\n' </proc/device-tree/compatible | \
grep -Ex 'google,(flame|floral-sm8150)' >/dev/null || fail 'wrong device'
systemctl is-active --quiet flame-storage-guard.service
test ! -e /dev/sda || fail 'whole-disk node exists'
blockdev --setro /dev/sda7
for node in /sys/class/block/sd*; do
case ${node##*/} in sda|sda15) continue;; esac
[[ $(cat "$node/ro") == 1 ]] || fail 'protected storage is writable'
done

/usr/bin/flame-partition-links
sha256sum --check --status /etc/omamobile/flame-calibration.sha256
sha256sum --check --status /etc/omamobile/flame-firmware.sha256
# Firmware API 2 wins over the factory API 1 board file, including compressed
# copies and files restored by a linux-firmware upgrade. Fail before MPSS starts.
[[ -z $(cat /sys/module/firmware_class/parameters/path) ]] || fail 'custom firmware search path'
for root in /usr/lib/firmware/updates/"$(uname -r)" /usr/lib/firmware/updates \
/usr/lib/firmware/"$(uname -r)" /usr/lib/firmware; do
for file in "$root"/ath10k/WCN3990/hw1.0/board-2.bin{,.xz,.zst}; do
[[ ! -e $file ]] || fail 'generic API 2 board data overrides factory board.bin'
done
done

# Verify each shadow against the currently protected partition, not merely an
# older shadow manifest. rmtfs receives RAM files and never the real NV nodes.
for pair in modemst1:modem_fs1 modemst2:modem_fs2 fsg:modem_fsg fsc:modem_fsc; do
part=${pair%%:*}; file=${pair#*:}; source_node=''
for candidate in /sys/class/block/sd*/uevent; do
if grep -Fx "PARTNAME=$part" "$candidate" >/dev/null; then
[[ -z $source_node ]] || fail 'ambiguous NV partition'
source_node=/dev/$(basename "$(dirname "$candidate")")
fi
done
[[ -n $source_node ]] || fail 'NV partition is absent'
[[ $(sha256sum "$source_node" | cut -d' ' -f1) == \
$(sha256sum "/var/lib/omamobile/flame/nv/$file" | cut -d' ' -f1) ]] || fail 'stale NV shadow'
done

wifi_ready() {
# systemd may rename wlan0 (wld0 on the tested native root).
for iface in /sys/class/net/*; do
[[ ! -d $iface/wireless ]] || return 0
done
return 1
}
wifi_ready && exit 0
state=/var/lib/omamobile/flame/wifi-starting
[[ ! -e $state ]] || fail 'previous startup did not complete; inspect logs before clearing marker'
install -d -m 700 /var/lib/omamobile/flame
touch "$state"
sync -f "$state"

for program in rmtfs tqftpserv; do test -x "/usr/local/sbin/$program"; done
install -d -m 700 /run/rmtfs
for file in modem_fs1 modem_fs2 modem_fsg modem_fsc; do
install -m 600 "/var/lib/omamobile/flame/nv/$file" "/run/rmtfs/$file"
done
modprobe qrtr_smd
modprobe qcom_q6v5_pas
test -c /dev/qcom_rmtfs_mem1
rm -f /dev/mem
# Refuse existing filesystem servers: their options and backing data are unknown.
! pgrep -x rmtfs >/dev/null || fail 'rmtfs already running'
! pgrep -x tqftpserv >/dev/null || fail 'tqftpserv already running'
install -d -m 700 /var/log/omamobile
/usr/local/sbin/tqftpserv >>/var/log/omamobile/flame-tqftp.log 2>&1 &
/usr/local/sbin/rmtfs -r -v -o /run/rmtfs >>/var/log/omamobile/flame-rmtfs.log 2>&1 &
sleep 1
pgrep -x tqftpserv >/dev/null
pgrep -x rmtfs >/dev/null
mpss=''
for candidate in /sys/class/remoteproc/remoteproc*; do
[[ -f $candidate/name ]] || continue
[[ $(cat "$candidate/name") == modem ]] || continue
[[ -z $mpss ]] || fail 'ambiguous modem processor'
mpss=$candidate
done
[[ -n $mpss ]] || fail 'MPSS is absent'
# Repeated resets after a WLAN firmware fault previously stalled UFS.
echo disabled >"$mpss/recovery"
[[ $(cat "$mpss/state") == offline ]] || fail 'MPSS is already started'
echo start >"$mpss/state"
[[ $(cat "$mpss/state") == running ]]
modprobe ath10k_snoc
modprobe qcom_pd_mapper
for _ in {1..45}; do
if wifi_ready; then
rm "$state"
sync -f /var/lib/omamobile/flame
echo 'WLAN ready; modem filesystem uses verified read-only RAM shadows'
exit 0
fi
sleep 1
done
fail 'no WLAN interface after firmware startup'
Loading