Gate the two-panel DT behind an opt-in build after live phone regression
This commit is contained in:
1 parent
31db372779
commit
a7b1a75465
15 files changed
+2757
-265
No files matched your search
Executable
+109
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the opt-in 2720 Flip two-panel DTB (external GC9305 on /dev/fb1).
|
||||
|
||||
The shipping DTB keeps the verified single-panel layout. A live test showed
|
||||
that registering the external panel makes the main panel go dark, so this DT
|
||||
is deliberately opt-in until gpio13 mux polarity and the gpio21/gpio23 DC/
|
||||
reset routing are probed on hardware.
|
||||
|
||||
./scripts/build-beatles-cover-panel.py # writes images/...cover.dtb
|
||||
./scripts/build-beatles-cover-panel.py --check # validation only
|
||||
./scripts/build-beatles-cover-panel.py --install # also patch local images
|
||||
|
||||
--install builds a separate cover boot.img and replaces boot.img/DTB in the
|
||||
local raw image's pmOS_boot; it never changes the tracked DTS/DTB.
|
||||
"""
|
||||
import argparse
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
BASE = pathlib.Path(__file__).resolve().parent.parent
|
||||
SOURCE = BASE / "devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts"
|
||||
OUTPUT = BASE / "images/qcom-msm8905-nokia-beatles-cover.dtb"
|
||||
|
||||
|
||||
def validate(text):
|
||||
checks = (
|
||||
'compatible = "spi-mux";',
|
||||
'compatible = "gpio-mux";',
|
||||
'nokia,beatles-gc9305-ext-panel',
|
||||
'display@1 {',
|
||||
'dc-gpios = <0x27 0x15 0x00>;',
|
||||
'reset-gpios = <0x27 0x17 0x00>;',
|
||||
'spi-max-frequency = <0x17d7840>;',
|
||||
'status = "disabled";',
|
||||
'qcom,msm-id = <0x14b 0x00>;',
|
||||
'qcom,board-id = <0x1000b 0x100>;',
|
||||
'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;',
|
||||
'reg = <0x80000000 0x20000000>;',
|
||||
)
|
||||
for token in checks:
|
||||
if token not in text:
|
||||
return "opt-in DTB lost %s" % token
|
||||
if 'pins = "gpio13";' not in text or \
|
||||
'pins = "gpio21", "gpio23", "gpio13";' in text:
|
||||
return "gpio13 is not isolated from the external panel pinctrl group"
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--check", action="store_true",
|
||||
help="validate the opt-in DT without writing images/")
|
||||
parser.add_argument("--install", action="store_true",
|
||||
help="also build a cover boot.img and patch the local raw image")
|
||||
args = parser.parse_args()
|
||||
if not SOURCE.is_file():
|
||||
sys.stderr.write("FAIL: missing %s\n" % SOURCE.relative_to(BASE))
|
||||
return 1
|
||||
with tempfile.TemporaryDirectory(prefix="bananarchy-cover-dtb-") as tmp:
|
||||
root = pathlib.Path(tmp)
|
||||
dtb = root / "cover.dtb"
|
||||
dec = root / "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")
|
||||
problem = validate(text)
|
||||
if problem:
|
||||
sys.stderr.write("FAIL: %s\n" % problem)
|
||||
return 1
|
||||
if args.check:
|
||||
print("[ok] opt-in two-panel 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))
|
||||
cover_boot = BASE / "images/boot-bananarchy-nokia-beatles-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(cover_boot)]
|
||||
sync = ["python3", str(BASE / "scripts/sync-beatles-bootfs.py"),
|
||||
"--raw-image", str(raw), "--boot-image", str(cover_boot),
|
||||
"--dtb", str(OUTPUT)]
|
||||
if not args.install:
|
||||
print("install with: %s" % " ".join(repack))
|
||||
print("then: %s" % " ".join(sync))
|
||||
print("WARNING: verify the main panel before using this DT as a default.")
|
||||
return 0
|
||||
for cmd in (repack, sync):
|
||||
proc = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if proc.returncode:
|
||||
sys.stderr.write("FAIL: %s\n%s%s" %
|
||||
(" ".join(cmd), proc.stdout, proc.stderr))
|
||||
return 1
|
||||
print(proc.stdout.strip())
|
||||
print("opt-in DT installed into %s; update the pinned image hash in "
|
||||
"check-rebuild.sh if this image is kept." % raw.name)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
+38
-17
@@ -369,8 +369,8 @@ fi
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08 images/bananarchy-nokia-argon.img" \
|
||||
"185ae4fcd8aa4bb65ff03711e50c68a1af073ff13402ddd053e65b65f11b6460 images/bananarchy-nokia-beatles.img" \
|
||||
"9862c9f7c22988537737e5a1d0d07952200bc5aecc9577107fca775ef8c9514b images/boot-bananarchy-nokia-beatles.img" \
|
||||
"30c470600d1187f463cd76319e96ecf0ed0af55858b2ae8244e588340a641942 images/bananarchy-nokia-beatles.img" \
|
||||
"2b5c61aba307dbbda61f3b19a2ad5770f9854f41cba4e2c97e24efb7e20879f3 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
@@ -634,14 +634,13 @@ for token in 'qcom,msm-id = <0x14b 0x00>;' \
|
||||
fail "the shipping beatles DTB lost a stock Qualcomm ID ($token)"
|
||||
fi
|
||||
done
|
||||
if ! grep -qF 'compatible = "spi-mux"' "$COVER_DTS" || \
|
||||
! grep -qF 'compatible = "gpio-mux"' "$COVER_DTS" || \
|
||||
! grep -qF 'nokia,beatles-gc9305-ext-panel' "$COVER_DTS" || \
|
||||
! grep -qF 'display@1 {' "$COVER_DTS"; then
|
||||
fail "the shipping beatles DTB lost the external panel (/dev/fb1) wiring"
|
||||
if grep -qF 'compatible = "spi-mux"' "$COVER_DTS" || \
|
||||
grep -qF 'compatible = "gpio-mux"' "$COVER_DTS" || \
|
||||
grep -qF 'display@1 {' "$COVER_DTS"; then
|
||||
fail "the shipping beatles DTB applies the hardware-gated cover overlay"
|
||||
fi
|
||||
if ! grep -A6 'spidev@1 {' "$COVER_DTS" | grep -qF 'status = "disabled"'; then
|
||||
fail "spidev@1 must stay disabled while spi-mux owns chip select 1"
|
||||
if ! grep -A4 'spidev@1 {' "$COVER_DTS" | grep -qF 'status = "okay"'; then
|
||||
fail "the shipping beatles DTB lost the spidev@1 diagnostic fallback"
|
||||
fi
|
||||
for f in "$BASE_DIR/overlay/rootfs/usr/share/mkinitfs/files/00-nokia-argon-display.files" \
|
||||
"$BASE_DIR/devices/nokia-beatles/00-nokia-beatles-display.files"; do
|
||||
@@ -1320,12 +1319,19 @@ if command -v gcc >/dev/null 2>&1 && \
|
||||
fail "host cover display behaviour test failed"
|
||||
fi
|
||||
|
||||
echo "[check] 2720 Flip external panel (/dev/fb1)..."
|
||||
if [ ! -x "$BASE_DIR/scripts/test-cover-dt.py" ]; then
|
||||
fail "missing host DT validation scripts/test-cover-dt.py"
|
||||
elif command -v dtc >/dev/null 2>&1 && \
|
||||
! "$BASE_DIR/scripts/test-cover-dt.py" >/dev/null 2>&1; then
|
||||
fail "host 2720 Flip /dev/fb1 DT validation failed"
|
||||
echo "[check] 2720 Flip external panel (opt-in DT)..."
|
||||
if [ ! -f "$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" ] || \
|
||||
[ ! -x "$BASE_DIR/scripts/build-beatles-cover-panel.py" ] || \
|
||||
[ ! -x "$BASE_DIR/scripts/test-cover-dt.py" ]; then
|
||||
fail "missing the opt-in cover DT source or its host validation tools"
|
||||
fi
|
||||
if command -v dtc >/dev/null 2>&1; then
|
||||
if ! "$BASE_DIR/scripts/build-beatles-cover-panel.py" --check >/dev/null 2>&1; then
|
||||
fail "opt-in two-panel DTB validation failed"
|
||||
fi
|
||||
if ! "$BASE_DIR/scripts/test-cover-dt.py" >/dev/null 2>&1; then
|
||||
fail "host 2720 Flip DT wiring validation failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[check] Cover panel diagnostics..."
|
||||
@@ -1343,12 +1349,27 @@ if ! grep -qF 'bananarchy-cover-diagnose.sh' \
|
||||
fail "apply-bananarchy-overlay.sh no longer installs the cover diagnostics"
|
||||
fi
|
||||
|
||||
echo "[check] 2720 Flip cover rollback..."
|
||||
echo "[check] 2720 Flip initramfs mux modules..."
|
||||
MODULES_INITFS="$BASE_DIR/devices/nokia-beatles/modules-initfs"
|
||||
for mod in mux-core mux-gpio spi-mux panel-mipi-dbi; do
|
||||
if ! grep -qxF "$mod" "$MODULES_INITFS"; then
|
||||
fail "devices/nokia-beatles/modules-initfs no longer loads $mod in the initramfs"
|
||||
fi
|
||||
done
|
||||
for ko in "$BASE_DIR/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/mux/mux-core.ko.zst" \
|
||||
"$BASE_DIR/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/mux/mux-gpio.ko.zst" \
|
||||
"$BASE_DIR/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/spi/spi-mux.ko.zst"; do
|
||||
if [ ! -f "$ko" ]; then
|
||||
fail "${ko#"$BASE_DIR/"} is missing from the overlay module tree"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "[check] 2720 Flip single-panel rollback..."
|
||||
if [ ! -x "$BASE_DIR/scripts/build-beatles-no-cover-dtb.py" ]; then
|
||||
fail "missing rollback builder scripts/build-beatles-no-cover-dtb.py"
|
||||
elif command -v dtc >/dev/null 2>&1 && \
|
||||
! "$BASE_DIR/scripts/build-beatles-no-cover-dtb.py" --check >/dev/null 2>&1; then
|
||||
fail "the no-cover DTB rollback transformation failed validation"
|
||||
fail "the single-panel rollback DTB failed validation"
|
||||
fi
|
||||
if ! grep -qF 'parser.add_argument("--dtb"' \
|
||||
"$BASE_DIR/scripts/sync-beatles-bootfs.py" || \
|
||||
|
||||
+102
-91
@@ -1,9 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host validation for the 2720 Flip external panel (/dev/fb1) DT wiring.
|
||||
"""Host validation for the 2720 Flip external panel DT wiring.
|
||||
|
||||
Checks the shipping DTB (not just its DTS source), the firmware/initramfs
|
||||
lists and the Xorg/ module configuration so the second panel cannot silently
|
||||
disappear or regress the verified main-panel path.
|
||||
The shipping DTB must stay on the verified single-panel layout: a live test
|
||||
showed that registering the external panel darkens the main panel. The
|
||||
two-panel wiring is therefore an opt-in source, validated here in detail so
|
||||
it is ready for the gpio13/reset/DC hardware sign-off. Also checks the
|
||||
firmware/initramfs lists, mux modules and Xorg pin shared by both layouts.
|
||||
"""
|
||||
import hashlib
|
||||
import pathlib
|
||||
@@ -15,6 +17,7 @@ import tempfile
|
||||
BASE = pathlib.Path(__file__).resolve().parent.parent
|
||||
DTS = BASE / "devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts"
|
||||
DTB = BASE / "devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb"
|
||||
OPTIN_DTS = BASE / "devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts"
|
||||
DTB_COPIES = (
|
||||
BASE / "overlay/rootfs/boot/qcom-msm8905-nokia-beatles.dtb",
|
||||
BASE / "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb",
|
||||
@@ -29,36 +32,15 @@ XORG = BASE / "overlay/rootfs/etc/X11/xorg.conf.d/10-bananarchy-msm8909.conf"
|
||||
KCONFIG = BASE / "patches/kernel/config-bananarchy-msm8909.armv7"
|
||||
MODULES_LOAD = BASE / "overlay/rootfs/etc/modules-load.d/bananarchy-hardware.conf"
|
||||
LOCAL_START = BASE / "overlay/rootfs/etc/local.d/10-bananarchy-hardware.start"
|
||||
|
||||
|
||||
BOOT_IMAGE = BASE / "images/boot-bananarchy-nokia-beatles.img"
|
||||
|
||||
|
||||
def fail(message):
|
||||
sys.stderr.write("FAIL: %s\n" % message)
|
||||
return 1
|
||||
|
||||
|
||||
def appended_dtb_matches(dtb_bytes):
|
||||
"""The standalone boot.img must carry the same DTB as devices/."""
|
||||
if not BOOT_IMAGE.is_file():
|
||||
return True, "skipped (local build output absent)"
|
||||
data = BOOT_IMAGE.read_bytes()
|
||||
if data[:8] != b"ANDROID!":
|
||||
return False, "boot image has no Android header"
|
||||
page = struct.unpack_from("<I", data, 36)[0] # page_size
|
||||
kernel_size = struct.unpack_from("<I", data, 8)[0]
|
||||
dtb_rel = struct.unpack_from("<I", data, page + 0x2c)[0]
|
||||
dtb_abs = page + dtb_rel
|
||||
if not 0 < dtb_rel < kernel_size or data[dtb_abs:dtb_abs + 4] != b"\xd0\x0d\xfe\xed":
|
||||
return False, "kernel+0x2c does not point at an FDT"
|
||||
embedded = data[dtb_abs:page + kernel_size]
|
||||
if embedded[:len(dtb_bytes)] != dtb_bytes:
|
||||
return False, "appended DTB is stale"
|
||||
return True, "ok"
|
||||
|
||||
|
||||
def node(text, opening):
|
||||
"""Return the text of a DT node from its opening line to its matching brace."""
|
||||
start = text.find(opening)
|
||||
if start < 0:
|
||||
return ""
|
||||
@@ -73,9 +55,35 @@ def node(text, opening):
|
||||
return ""
|
||||
|
||||
|
||||
def appended_dtb_matches(dtb_bytes):
|
||||
if not BOOT_IMAGE.is_file():
|
||||
return True, "skipped (local build output absent)"
|
||||
data = BOOT_IMAGE.read_bytes()
|
||||
if data[:8] != b"ANDROID!":
|
||||
return False, "boot image has no Android header"
|
||||
page = struct.unpack_from("<I", data, 36)[0]
|
||||
kernel_size = struct.unpack_from("<I", data, 8)[0]
|
||||
dtb_rel = struct.unpack_from("<I", data, page + 0x2c)[0]
|
||||
dtb_abs = page + dtb_rel
|
||||
if not 0 < dtb_rel < kernel_size or data[dtb_abs:dtb_abs + 4] != b"\xd0\x0d\xfe\xed":
|
||||
return False, "kernel+0x2c does not point at an FDT"
|
||||
embedded = data[dtb_abs:page + kernel_size]
|
||||
if embedded[:len(dtb_bytes)] != dtb_bytes:
|
||||
return False, "appended DTB is stale"
|
||||
return True, "ok"
|
||||
|
||||
|
||||
def decompile(dtb, target):
|
||||
proc = subprocess.run(["dtc", "-I", "dtb", "-O", "dts", "-o", str(target),
|
||||
str(dtb)], capture_output=True, text=True)
|
||||
if proc.returncode:
|
||||
return None
|
||||
return target.read_text(encoding="utf-8", errors="replace")
|
||||
|
||||
|
||||
def main():
|
||||
for path in (DTS, DTB, FIRMWARE, XORG, KCONFIG, MODULES_LOAD, LOCAL_START,
|
||||
*DTB_COPIES, *INITRAMFS_LISTS):
|
||||
for path in (DTS, DTB, OPTIN_DTS, FIRMWARE, XORG, KCONFIG, MODULES_LOAD,
|
||||
LOCAL_START, *DTB_COPIES, *INITRAMFS_LISTS):
|
||||
if not path.is_file():
|
||||
return fail("missing %s" % path.relative_to(BASE))
|
||||
with tempfile.TemporaryDirectory(prefix="bananarchy-cover-dt-") as tmp:
|
||||
@@ -88,7 +96,7 @@ def main():
|
||||
return fail("shipping DTS does not compile: %s" % build.stderr.strip())
|
||||
if built.read_bytes() != DTB.read_bytes():
|
||||
return fail("the shipping DTB is stale; recompile it from the DTS")
|
||||
print("[ok] DTB matches the shipping DTS")
|
||||
print("[ok] shipping DTB matches the shipping DTS")
|
||||
for copy in DTB_COPIES:
|
||||
if hashlib.sha256(copy.read_bytes()).digest() != \
|
||||
hashlib.sha256(DTB.read_bytes()).digest():
|
||||
@@ -98,83 +106,86 @@ def main():
|
||||
if not ok:
|
||||
return fail("2720 boot image: %s" % detail)
|
||||
print("[ok] standalone boot.img appended DTB: %s" % detail)
|
||||
decompile = subprocess.run(["dtc", "-I", "dtb", "-O", "dts", "-o", str(dec),
|
||||
str(DTB)], capture_output=True, text=True)
|
||||
if decompile.returncode:
|
||||
|
||||
text = decompile(DTB, dec)
|
||||
if text is None:
|
||||
return fail("cannot decompile the shipping DTB")
|
||||
text = dec.read_text(encoding="utf-8", errors="replace")
|
||||
for token in ('qcom,msm-id = <0x14b 0x00>;',
|
||||
'qcom,board-id = <0x1000b 0x100>;',
|
||||
'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;',
|
||||
'reg = <0x80000000 0x20000000>;'):
|
||||
if token not in text:
|
||||
return fail("shipping DTB lost %s" % token)
|
||||
if 'compatible = "spi-mux"' in text or 'display@1 {' in text:
|
||||
return fail("shipping DTB must keep the verified single-panel layout")
|
||||
if 'status = "okay";' not in node(text, "spidev@1 {"):
|
||||
return fail("shipping DTB lost the spidev@1 diagnostic fallback")
|
||||
print("[ok] shipping DTB keeps the verified single-panel layout")
|
||||
|
||||
# Stock boot identifiers and memory fallback must survive the DT change.
|
||||
for token in ('qcom,msm-id = <0x14b 0x00>;',
|
||||
'qcom,board-id = <0x1000b 0x100>;',
|
||||
'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;',
|
||||
'reg = <0x80000000 0x20000000>;'):
|
||||
if token not in text:
|
||||
return fail("shipping DTB lost %s" % token)
|
||||
print("[ok] stock Qualcomm IDs and 512 MiB memory fallback preserved")
|
||||
optin = root / "optin.dtb"
|
||||
optin_dec = root / "optin.dts"
|
||||
build = subprocess.run(["dtc", "-I", "dts", "-O", "dtb", "-o", str(optin),
|
||||
str(OPTIN_DTS)], capture_output=True, text=True)
|
||||
if build.returncode:
|
||||
return fail("opt-in cover DTS does not compile: %s" % build.stderr.strip())
|
||||
opt = decompile(optin, optin_dec)
|
||||
if opt is None:
|
||||
return fail("cannot decompile the opt-in cover DTB")
|
||||
mux = node(opt, "spi-mux@0 {")
|
||||
internal = node(mux, "display@0 {")
|
||||
external = node(mux, "display@1 {")
|
||||
if 'compatible = "spi-mux";' not in mux or \
|
||||
'compatible = "gpio-mux";' not in node(opt, "spi-panel-mux {") or \
|
||||
not internal or not external:
|
||||
return fail("opt-in DT lost the two-panel spi-mux wiring")
|
||||
if 'nokia,beatles-gc9305-panel' not in internal or \
|
||||
"spi-max-frequency = <0x17d7840>;" not in internal or \
|
||||
"dc-gpios = <0x27 0x6e 0x00>;" not in internal:
|
||||
return fail("opt-in DT changed the verified main panel path")
|
||||
if 'nokia,beatles-gc9305-ext-panel' not in external or \
|
||||
"spi-max-frequency = <0x17d7840>;" not in external or \
|
||||
"dc-gpios = <0x27 0x15 0x00>;" not in external or \
|
||||
"reset-gpios = <0x27 0x17 0x00>;" not in external or \
|
||||
"write-only;" not in external or "vactive = <0xf0>;" not in external:
|
||||
return fail("opt-in external panel node lost its 8-bit/240x240 wiring")
|
||||
cover_pins = node(opt, "cover-panel-gpios-default-state {")
|
||||
mux_pins = node(opt, "cover-mux-gpio-default-state {")
|
||||
if "gpio13" in cover_pins or 'pins = "gpio21", "gpio23";' not in cover_pins:
|
||||
return fail("opt-in external panel pinctrl still steals gpio13")
|
||||
if 'pins = "gpio13";' not in mux_pins or "bias-pull-down;" not in mux_pins:
|
||||
return fail("opt-in gpio13 has no dedicated pull-down pinctrl state")
|
||||
if 'status = "disabled";' not in node(opt, "spidev@1 {"):
|
||||
return fail("opt-in spidev@1 still owns chip select 1")
|
||||
print("[ok] opt-in two-panel DT validated (hardware sign-off still required)")
|
||||
|
||||
mux = node(text, "spi-mux@0 {")
|
||||
if not mux or 'compatible = "spi-mux";' not in mux or \
|
||||
"mux-controls = <0x96>;" not in mux or \
|
||||
"spi-max-frequency = <0x17d7840>;" not in mux:
|
||||
return fail("spi-mux node is missing or has the wrong clock/control")
|
||||
internal = node(mux, "display@0 {")
|
||||
external = node(mux, "display@1 {")
|
||||
if not internal or not external:
|
||||
return fail("both panels must be children of spi-mux@0")
|
||||
if 'compatible = "nokia,beatles-gc9305-panel"' not in internal or \
|
||||
"spi-max-frequency = <0x17d7840>;" not in internal or \
|
||||
"dc-gpios = <0x27 0x6e 0x00>;" not in internal or \
|
||||
"pinctrl-0 = <0x6e>;" not in internal:
|
||||
return fail("the verified main panel path changed")
|
||||
if 'compatible = "nokia,beatles-gc9305-ext-panel"' not in external or \
|
||||
"panel-mipi-dbi-spi" not in external or \
|
||||
"spi-max-frequency = <0x17d7840>;" not in external or \
|
||||
"dc-gpios = <0x27 0x15 0x00>;" not in external or \
|
||||
"reset-gpios = <0x27 0x17 0x00>;" not in external or \
|
||||
"write-only;" not in external or \
|
||||
"vactive = <0xf0>;" not in external:
|
||||
return fail("external panel node is missing its 8-bit/240x240 wiring")
|
||||
print("[ok] two 25 MHz panel-mipi-dbi-spi displays behind spi-mux")
|
||||
|
||||
gpio_mux = node(text, "spi-panel-mux {")
|
||||
if 'compatible = "gpio-mux";' not in gpio_mux or \
|
||||
"mux-gpios = <0x27 0x0d 0x00>;" not in gpio_mux or \
|
||||
"idle-state = <0x00>;" not in gpio_mux or \
|
||||
"pinctrl-0 = <0x93>;" not in gpio_mux:
|
||||
return fail("gpio13 mux controller is missing its idle/internal state")
|
||||
cover_pins = node(text, "cover-panel-gpios-default-state {")
|
||||
mux_pins = node(text, "cover-mux-gpio-default-state {")
|
||||
if "gpio13" in cover_pins or 'pins = "gpio21", "gpio23";' not in cover_pins:
|
||||
return fail("the external panel pinctrl state still steals gpio13")
|
||||
if 'pins = "gpio13";' not in mux_pins or "bias-pull-down;" not in mux_pins:
|
||||
return fail("gpio13 has no dedicated pull-down pinctrl state")
|
||||
print("[ok] gpio13 mux select is isolated from the external panel pinctrl")
|
||||
|
||||
spidev = node(text, "spidev@1 {")
|
||||
if 'status = "disabled";' not in spidev:
|
||||
return fail("spidev@1 still owns chip select 1")
|
||||
if 'Option "kmsdev" "/dev/dri/card0"' not in XORG.read_text():
|
||||
return fail("Xorg no longer pins the internal DRM card")
|
||||
print("[ok] spidev disabled and Xorg keeps card0")
|
||||
|
||||
return fail("Xorg no longer pins the main DRM card")
|
||||
if not FIRMWARE.read_bytes().startswith(b"MIPI DBI"):
|
||||
return fail("external panel firmware is not a MIPI DBI command stream")
|
||||
for lst in INITRAMFS_LISTS:
|
||||
if FW_LIST not in lst.read_text().splitlines():
|
||||
return fail("%s does not ship the cover firmware in the initramfs" %
|
||||
lst.relative_to(BASE))
|
||||
kconfig = KCONFIG.read_text().splitlines()
|
||||
for opt in ("CONFIG_MULTIPLEXER=m", "CONFIG_MUX_GPIO=m", "CONFIG_SPI_MUX=m"):
|
||||
if opt not in kconfig:
|
||||
return fail("kernel config lost %s" % opt)
|
||||
kernel_config = KCONFIG.read_text().splitlines()
|
||||
for opt_name in ("CONFIG_MULTIPLEXER=m", "CONFIG_MUX_GPIO=m", "CONFIG_SPI_MUX=m"):
|
||||
if opt_name not in kernel_config:
|
||||
return fail("kernel config lost %s" % opt_name)
|
||||
initfs_modules = (BASE / "devices/nokia-beatles/modules-initfs").read_text().splitlines()
|
||||
for mod in ("mux-core", "mux-gpio", "spi-mux", "panel-mipi-dbi"):
|
||||
if mod not in initfs_modules:
|
||||
return fail("devices/nokia-beatles/modules-initfs lost %s" % mod)
|
||||
for ko in ("overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/mux/mux-core.ko.zst",
|
||||
"overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/mux/mux-gpio.ko.zst",
|
||||
"overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/spi/spi-mux.ko.zst"):
|
||||
if not (BASE / ko).is_file():
|
||||
return fail("missing initramfs module artifact %s" % ko)
|
||||
for script in (MODULES_LOAD, LOCAL_START):
|
||||
body = script.read_text()
|
||||
for mod in ("mux-core", "mux-gpio", "spi-mux"):
|
||||
if mod not in body:
|
||||
return fail("%s no longer loads %s" % (script.name, mod))
|
||||
print("[ok] initramfs firmware and mux modules are provisioned")
|
||||
print("2720 Flip /dev/fb1 DT wiring: all checks passed")
|
||||
print("[ok] Xorg pin, initramfs firmware and mux modules are provisioned")
|
||||
print("2720 Flip DT wiring: all checks passed")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user