Gate the two-panel DT behind an opt-in build after live phone regression

This commit is contained in:
Luxferre committed 2026-11-10 14:53:47 +02:00
1 parent 31db372779
commit a7b1a75465
15 files changed
+2757 -265

No files matched your search

+22 -54
View File
@@ -1,19 +1,14 @@
#!/usr/bin/env python3
"""Build a 2720 Flip DTB with the external panel disabled (hardware rollback).
"""Rollback DTB for the 2720 Flip: the verified single-panel shipping layout.
The cover panel DT is shipped enabled, but gpio13 mux polarity / external
reset polarity still need a live sign-off. If the main panel or keypad
regresses, this script produces a DTB that keeps the verified internal panel
and disables only display@1, without touching the spi-mux or the DTS source.
After enabling the opt-in two-panel DT, this is the file to put back in
pmOS_boot (and in the standalone boot image via repack-beatles-bootimg.py)
if the main panel or keypad regresses. It is simply the shipping DTB compiled
from the tracked DTS, so no source file is ever modified.
./scripts/build-beatles-no-cover-dtb.py # writes images/...no-cover.dtb
./scripts/build-beatles-no-cover-dtb.py --check # validation only
./scripts/build-beatles-no-cover-dtb.py --install # also patches local images
--install builds a separate no-cover boot.img and replaces boot.img/DTB in
the local raw image's pmOS_boot; it never changes the tracked DTS/DTB. Run
check-rebuild.sh before rolling back: in the rollback state its pmOS_boot
check expects the shipping DTB and will report the deliberate mismatch.
./scripts/build-beatles-no-cover-dtb.py --install # also patch local images
"""
import argparse
import pathlib
@@ -22,78 +17,52 @@ import sys
import tempfile
BASE = pathlib.Path(__file__).resolve().parent.parent
DTS = BASE / "devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts"
SOURCE = BASE / "devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts"
OUTPUT = BASE / "images/qcom-msm8905-nokia-beatles-no-cover.dtb"
OPENING = '\t\t\t\tdisplay@1 {\n'
MARKER = 'nokia,beatles-gc9305-ext-panel'
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--check", action="store_true",
help="validate the transformation without writing images/")
help="validate the rollback DTB without writing images/")
parser.add_argument("--install", action="store_true",
help="also build a no-cover boot.img and patch the local raw image")
help="also build a rollback boot.img and patch the local raw image")
args = parser.parse_args()
source = DTS.read_text()
start = source.find(OPENING)
if start < 0:
sys.stderr.write("FAIL: display@1 is missing from the shipping DTS\n")
return 1
end = source.find("\n\t\t\t\t};\n", start)
if end < 0:
sys.stderr.write("FAIL: display@1 node is not terminated\n")
return 1
block = source[start:end]
if MARKER not in block or 'status = "disabled";' in block:
sys.stderr.write("FAIL: unexpected display@1 node contents\n")
return 1
patched = (source[:start] + OPENING +
'\t\t\t\t\tstatus = "disabled";\n' +
source[start + len(OPENING):])
with tempfile.TemporaryDirectory(prefix="bananarchy-no-cover-") as tmp:
root = pathlib.Path(tmp)
dts = root / "no-cover.dts"
dtb = root / "no-cover.dtb"
dec = root / "no-cover-decomp.dts"
dts.write_text(patched)
for cmd in (["dtc", "-I", "dts", "-O", "dtb", "-o", str(dtb), str(dts)],
dec = root / "no-cover.dts"
for cmd in (["dtc", "-I", "dts", "-O", "dtb", "-o", str(dtb), str(SOURCE)],
["dtc", "-I", "dtb", "-O", "dts", "-o", str(dec), str(dtb)]):
proc = subprocess.run(cmd, capture_output=True, text=True)
if proc.returncode:
sys.stderr.write("FAIL: %s\n%s" % (" ".join(cmd), proc.stderr))
return 1
text = dec.read_text(encoding="utf-8", errors="replace")
ext_start = text.find("display@1 {")
ext = text[ext_start:text.find("\n\t\t\t\t};", ext_start) + 10] \
if ext_start >= 0 else ""
if 'status = "disabled";' not in ext or MARKER not in ext:
sys.stderr.write("FAIL: rollback DTB did not disable the external panel\n")
return 1
for token in ('qcom,msm-id = <0x14b 0x00>;',
'qcom,board-id = <0x1000b 0x100>;',
'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;',
'reg = <0x80000000 0x20000000>;',
'dc-gpios = <0x27 0x6e 0x00>;',
'spi-max-frequency = <0x17d7840>;'):
for token in ('display@0 {', 'spidev@1 {', 'status = "okay";',
'qcom,msm-id = <0x14b 0x00>;',
'reg = <0x80000000 0x20000000>;'):
if token not in text:
sys.stderr.write("FAIL: rollback DTB lost %s\n" % token)
return 1
if 'compatible = "spi-mux"' in text or 'display@1 {' in text:
sys.stderr.write("FAIL: rollback DTB still contains the cover mux\n")
return 1
if args.check:
print("[ok] no-cover DTB transformation validated (%d bytes)" %
print("[ok] single-panel rollback DTB validated (%d bytes)" %
dtb.stat().st_size)
return 0
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
OUTPUT.write_bytes(dtb.read_bytes())
print("wrote %s" % OUTPUT.relative_to(BASE))
no_cover_boot = BASE / "images/boot-bananarchy-nokia-beatles-no-cover.img"
rollback_boot = BASE / "images/boot-bananarchy-nokia-beatles-no-cover.img"
shipping_boot = BASE / "images/boot-bananarchy-nokia-beatles.img"
raw = BASE / "images/bananarchy-nokia-beatles.img"
repack = ["python3", str(BASE / "scripts/repack-beatles-bootimg.py"),
"--boot-image", str(shipping_boot), "--dtb", str(OUTPUT),
"--output", str(no_cover_boot)]
"--output", str(rollback_boot)]
sync = ["python3", str(BASE / "scripts/sync-beatles-bootfs.py"),
"--raw-image", str(raw), "--boot-image", str(no_cover_boot),
"--raw-image", str(raw), "--boot-image", str(rollback_boot),
"--dtb", str(OUTPUT)]
if not args.install:
print("install with: %s" % " ".join(repack))
@@ -106,8 +75,7 @@ def main():
(" ".join(cmd), proc.stdout, proc.stderr))
return 1
print(proc.stdout.strip())
print("rollback installed into %s; restore the shipping DTB/boot.img with "
"sync-beatles-bootfs.py (no overrides) to undo." % raw.name)
print("rollback installed into %s" % raw.name)
return 0