Enable the 2720 Flip external panel and rebuild its DTB
This commit is contained in:
1 parent
ec55fb1457
commit
7c52d616e7
13 files changed
+348
-65
No files matched your search
@@ -369,8 +369,8 @@ fi
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08 images/bananarchy-nokia-argon.img" \
|
||||
"cc22a0d99972866e205bb76af37498a327e87a10d81e8341300ca3547ca4890a images/bananarchy-nokia-beatles.img" \
|
||||
"2b5c61aba307dbbda61f3b19a2ad5770f9854f41cba4e2c97e24efb7e20879f3 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"185ae4fcd8aa4bb65ff03711e50c68a1af073ff13402ddd053e65b65f11b6460 images/bananarchy-nokia-beatles.img" \
|
||||
"9862c9f7c22988537737e5a1d0d07952200bc5aecc9577107fca775ef8c9514b images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
@@ -379,7 +379,7 @@ for pair in \
|
||||
echo "[skip] local build output $2 is absent; prepare-release.sh will rebuild it"
|
||||
continue
|
||||
elif [ "$(sha256sum "$path" | cut -d' ' -f1)" != "$want" ]; then
|
||||
fail "$2 no longer matches the physically verified known-good image"
|
||||
fail "$2 no longer matches the pinned release image"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -634,12 +634,24 @@ 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"; then
|
||||
fail "the shipping beatles DTB still applies the hardware-gated cover overlay"
|
||||
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"
|
||||
fi
|
||||
if ! grep -A4 'spidev@1 {' "$COVER_DTS" | grep -qF 'status = "okay"'; then
|
||||
fail "the shipping beatles DTB lost the spidev@1 diagnostic fallback"
|
||||
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"
|
||||
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
|
||||
if ! grep -qxF '/lib/firmware/nokia,beatles-gc9305-ext-panel.bin' "$f"; then
|
||||
fail "${f#"$BASE_DIR/"} no longer ships the cover firmware in the initramfs"
|
||||
fi
|
||||
done
|
||||
if ! grep -qF 'Option "kmsdev" "/dev/dri/card0"' \
|
||||
"$BASE_DIR/overlay/rootfs/etc/X11/xorg.conf.d/10-bananarchy-msm8909.conf"; then
|
||||
fail "Xorg no longer pins the main DRM card"
|
||||
fi
|
||||
rm -f "$COVER_DTBO" "$COVER_DTS" "$COVER_DTS_BUILD"
|
||||
for opt in CONFIG_MULTIPLEXER=m CONFIG_MUX_GPIO=m CONFIG_SPI_MUX=m; do
|
||||
@@ -1307,6 +1319,14 @@ 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"
|
||||
fi
|
||||
|
||||
if [ "$FAILURES" -ne 0 ]; then
|
||||
echo "[check] $FAILURES check(s) failed."
|
||||
exit 1
|
||||
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host validation for the 2720 Flip external panel (/dev/fb1) 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.
|
||||
"""
|
||||
import hashlib
|
||||
import pathlib
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
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"
|
||||
DTB_COPIES = (
|
||||
BASE / "overlay/rootfs/boot/qcom-msm8905-nokia-beatles.dtb",
|
||||
BASE / "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb",
|
||||
)
|
||||
FIRMWARE = BASE / "overlay/rootfs/lib/firmware/nokia,beatles-gc9305-ext-panel.bin"
|
||||
FW_LIST = "/lib/firmware/nokia,beatles-gc9305-ext-panel.bin"
|
||||
INITRAMFS_LISTS = (
|
||||
BASE / "overlay/rootfs/usr/share/mkinitfs/files/00-nokia-argon-display.files",
|
||||
BASE / "devices/nokia-beatles/00-nokia-beatles-display.files",
|
||||
)
|
||||
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 ""
|
||||
depth = 0
|
||||
for pos in range(start, len(text)):
|
||||
if text[pos] == "{":
|
||||
depth += 1
|
||||
elif text[pos] == "}":
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
return text[start:pos + 1]
|
||||
return ""
|
||||
|
||||
|
||||
def main():
|
||||
for path in (DTS, DTB, 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:
|
||||
root = pathlib.Path(tmp)
|
||||
built = root / "built.dtb"
|
||||
dec = root / "decompiled.dts"
|
||||
build = subprocess.run(["dtc", "-I", "dts", "-O", "dtb", "-o", str(built),
|
||||
str(DTS)], capture_output=True, text=True)
|
||||
if build.returncode:
|
||||
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")
|
||||
for copy in DTB_COPIES:
|
||||
if hashlib.sha256(copy.read_bytes()).digest() != \
|
||||
hashlib.sha256(DTB.read_bytes()).digest():
|
||||
return fail("%s drifted from devices/" % copy.relative_to(BASE))
|
||||
print("[ok] overlay/prebuilt DTB copies are in sync")
|
||||
ok, detail = appended_dtb_matches(DTB.read_bytes())
|
||||
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:
|
||||
return fail("cannot decompile the shipping DTB")
|
||||
text = dec.read_text(encoding="utf-8", errors="replace")
|
||||
|
||||
# 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")
|
||||
|
||||
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")
|
||||
|
||||
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)
|
||||
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")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user