- Remove LK2ND_VERSION from lk2nd/device/menu/menu.c (display_fastboot_menu and display_default_image_on_screen) in bootloader/lk2nd/nokia-beatles.patch so the BANANARCHY LINUX boot splash renders intact and boot/Fastboot-recovery screens carry no OS version tag.
- Replace -a1109-r3 / -a1114-r1 / -a1120-r1 suffixes in scripts/build-lk2nd-{beatles,coconut,sparkler}.sh with OS-version-neutral bananarchy-<target>{,-diag,-display} tags and enforce this in scripts/check-lk2nd-{beatles,coconut,sparkler}.py and scripts/check-rebuild.sh.
- Rebuild all 9 lk2nd images and refresh the a1120 (cocojamboo) display lk2nd and archive SHA-256 hashes in scripts/check-rebuild.sh, CHANGELOG.md, bootloader/lk2nd/README.md, and AGENTS.md.
481 lines
19 KiB
Python
Executable File
481 lines
19 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Validate the source-built nokia-sparkler lk2nd boot image.
|
|
|
|
Checks (all offline, pure Python):
|
|
* Android boot.img header, cmdline, and SEANDROIDENFORCE trailer.
|
|
* QCDT v2 exact MSM8909 MTP entry (0xf5 / 0x8 / 0x100 / 0).
|
|
* Every unique QCDT DTB has /cpus/cpu@2 and /cpus/cpu@3 with a 4-byte
|
|
device_type (the partial-goods ASSERT fix).
|
|
* /lk2nd/nokia-sparkler node: model, compatible, match-cmdline, dtb-files,
|
|
menu-key-strings, gpio-keys/volume-up, and all four panel init streams
|
|
(GC9307 HLT 15-command and ST7789VX2 CTC 11-command variants).
|
|
* Base (beatles), coconut, and sparkler patch layers plus shared
|
|
spi-panel-init.h stay in sync.
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import re
|
|
import struct
|
|
import sys
|
|
|
|
BOOT_MAGIC = b"ANDROID!"
|
|
QCDT_MAGIC = b"QCDT"
|
|
FDT_MAGIC = 0xd00dfeed
|
|
FDT_BEGIN_NODE = 1
|
|
FDT_END_NODE = 2
|
|
FDT_PROP = 3
|
|
FDT_NOP = 4
|
|
FDT_END = 9
|
|
|
|
STOCK_PLATFORM_ID = 0xf5
|
|
STOCK_VARIANT_ID = 0x8
|
|
STOCK_SUBTYPE = 0x100
|
|
STOCK_SOC_REV = 0
|
|
BOARD_ID = [STOCK_VARIANT_ID, STOCK_SUBTYPE]
|
|
|
|
EXPECTED_MENU_KEYS = ["* and # keys", "Top power key"]
|
|
KEY_VOLUMEUP_CODE = 0x115
|
|
|
|
GC9307_PANELS = (
|
|
"qcom,mdss_spi_gc9307_hlt_28_qvga_cmd",
|
|
"qcom,mdss_spi_gc9307_hlt_28_qvga_spi_cmd",
|
|
)
|
|
ST7789VX2_PANELS = (
|
|
"qcom,mdss_spi_st7789vx2_ctc_28_qvga_cmd",
|
|
"qcom,mdss_spi_st7789vx2_ctc_28_qvga_spi_cmd",
|
|
)
|
|
PANEL_SPECS = (
|
|
(GC9307_PANELS[0], 15, 58, "GC9307 HLT"),
|
|
(GC9307_PANELS[1], 15, 58, "GC9307 HLT SPI"),
|
|
(ST7789VX2_PANELS[0], 11, 44, "ST7789VX2 CTC"),
|
|
(ST7789VX2_PANELS[1], 11, 44, "ST7789VX2 CTC SPI"),
|
|
)
|
|
|
|
RGB565 = bytes([0x3a, 0x05])
|
|
COLUMN_WINDOW = bytes([0x2a, 0x00, 0x00, 0x00, 0xef])
|
|
ROW_WINDOW = bytes([0x2b, 0x00, 0x00, 0x01, 0x3f])
|
|
|
|
|
|
def align(value, page):
|
|
return (value + page - 1) // page * page
|
|
|
|
|
|
def fdt_nodes(data):
|
|
vals = struct.unpack_from(">10I", data, 0)
|
|
magic, totalsize, off_struct, off_strings, _, version = vals[:6]
|
|
size_strings, size_struct = vals[8], vals[9]
|
|
if magic != FDT_MAGIC or version not in (16, 17):
|
|
raise ValueError("invalid FDT header")
|
|
strings = data[off_strings:off_strings + size_strings]
|
|
nodes = {}
|
|
stack = []
|
|
pos = off_struct
|
|
while True:
|
|
token = struct.unpack_from(">I", data, pos)[0]
|
|
pos += 4
|
|
if token == FDT_BEGIN_NODE:
|
|
end = data.index(b"\0", pos)
|
|
name = data[pos:end].decode("utf-8", "replace")
|
|
pos = (end + 4) & ~3
|
|
if not stack:
|
|
path = "/"
|
|
elif stack[-1] == "/":
|
|
path = "/" + name
|
|
else:
|
|
path = stack[-1] + "/" + name
|
|
stack.append(path)
|
|
nodes[path] = {}
|
|
elif token == FDT_END_NODE:
|
|
stack.pop()
|
|
if not stack:
|
|
break
|
|
elif token == FDT_PROP:
|
|
length, nameoff = struct.unpack_from(">II", data, pos)
|
|
pos += 8
|
|
value = data[pos:pos + length]
|
|
pos = (pos + length + 3) & ~3
|
|
end = strings.index(b"\0", nameoff)
|
|
prop = strings[nameoff:end].decode("utf-8", "replace")
|
|
nodes[stack[-1]][prop] = value
|
|
elif token == FDT_NOP:
|
|
continue
|
|
elif token == FDT_END:
|
|
break
|
|
else:
|
|
raise ValueError("bad FDT token 0x%x" % token)
|
|
return nodes, totalsize
|
|
|
|
|
|
def prop_str(nodes, path, prop):
|
|
return nodes.get(path, {}).get(prop, b"").rstrip(b"\0").decode("utf-8", "replace")
|
|
|
|
|
|
def prop_strlist(nodes, path, prop):
|
|
raw = nodes.get(path, {}).get(prop, b"")
|
|
if not raw:
|
|
return []
|
|
return [s.decode("utf-8", "replace") for s in raw.rstrip(b"\0").split(b"\0")]
|
|
|
|
|
|
def prop_cells(nodes, path, prop):
|
|
raw = nodes.get(path, {}).get(prop, b"")
|
|
return list(struct.unpack(">%dI" % (len(raw) // 4), raw[:len(raw) // 4 * 4]))
|
|
|
|
|
|
def parse_stream(raw):
|
|
"""Return (commands, total_delay) or raise ValueError."""
|
|
off = 0
|
|
commands = []
|
|
total_delay = 0
|
|
while off + 2 <= len(raw):
|
|
wait, dlen = raw[off], raw[off + 1]
|
|
off += 2
|
|
if not dlen or off + dlen > len(raw):
|
|
raise ValueError("malformed command at byte %d" % (off - 2))
|
|
payload = raw[off:off + dlen]
|
|
off += dlen
|
|
commands.append((wait, payload))
|
|
total_delay += wait
|
|
if off != len(raw):
|
|
raise ValueError("trailing garbage at byte %d" % off)
|
|
return commands, total_delay
|
|
|
|
|
|
def check_stream(name, raw, expected_cmds, expected_bytes, problems):
|
|
if len(raw) != expected_bytes:
|
|
problems.append("%s panel init has %d bytes, expected %d" %
|
|
(name, len(raw), expected_bytes))
|
|
try:
|
|
commands, total_delay = parse_stream(raw)
|
|
except ValueError as exc:
|
|
problems.append("%s panel init stream: %s" % (name, exc))
|
|
return None
|
|
if len(commands) != expected_cmds:
|
|
problems.append("%s panel init has %d commands, expected %d" %
|
|
(name, len(commands), expected_cmds))
|
|
if total_delay != 120:
|
|
problems.append("%s panel init waits %d ms total, expected 120" %
|
|
(name, total_delay))
|
|
payloads = [payload for _, payload in commands]
|
|
for label, want in (("RGB565 COLMOD", RGB565),
|
|
("240 column window", COLUMN_WINDOW),
|
|
("320 row window", ROW_WINDOW)):
|
|
if want not in payloads:
|
|
problems.append("%s panel init is missing the %s command" % (name, label))
|
|
if b"\x11" not in payloads:
|
|
problems.append("%s panel init is missing sleep-out (0x11)" % name)
|
|
if b"\x29" not in payloads:
|
|
problems.append("%s panel init is missing display-on (0x29)" % name)
|
|
if not payloads or payloads[-1] != b"\x2c":
|
|
problems.append("%s panel init does not end with RAMWR (0x2c)" % name)
|
|
return commands
|
|
|
|
|
|
def check_device_node(nodes, label, problems):
|
|
prefix = "%s: " % label
|
|
if prop_cells(nodes, "/", "qcom,msm-id")[:2] != [STOCK_PLATFORM_ID, 0]:
|
|
problems.append(prefix + "qcom,msm-id is not the stock 0xf5/0")
|
|
board = prop_cells(nodes, "/", "qcom,board-id")
|
|
if board != BOARD_ID:
|
|
problems.append(prefix + "qcom,board-id is %r, expected %r" % (board, BOARD_ID))
|
|
if "/chosen" not in nodes:
|
|
problems.append(prefix + "missing /chosen")
|
|
if not any(props.get("device_type") == b"memory\0" for props in nodes.values()):
|
|
problems.append(prefix + "missing /memory node")
|
|
|
|
subnodes = sorted(p for p in nodes if p.startswith("/lk2nd/") and
|
|
p.count("/") == 2)
|
|
for needed in ("/lk2nd/nokia-leo", "/lk2nd/nokia-sparkler"):
|
|
if needed not in subnodes:
|
|
problems.append(prefix + "missing %s" % needed)
|
|
|
|
node = "/lk2nd/nokia-sparkler"
|
|
if node not in nodes:
|
|
problems.append(prefix + "missing /lk2nd/nokia-sparkler")
|
|
return None
|
|
props = nodes[node]
|
|
if prop_str(nodes, node, "model") != "Nokia 8000 4G":
|
|
problems.append(prefix + "wrong model %r" % prop_str(nodes, node, "model"))
|
|
if prop_str(nodes, node, "compatible") != "nokia,sparkler":
|
|
problems.append(prefix + "wrong compatible %r" %
|
|
prop_str(nodes, node, "compatible"))
|
|
if prop_str(nodes, node, "lk2nd,match-cmdline") != "* androidboot.hw.name=sparkler *":
|
|
problems.append(prefix + "wrong lk2nd,match-cmdline %r" %
|
|
prop_str(nodes, node, "lk2nd,match-cmdline"))
|
|
if "lk2nd,match-panel" in props:
|
|
problems.append(prefix + "sparkler node must not require lk2nd,match-panel")
|
|
if prop_str(nodes, node, "lk2nd,dtb-files") != "msm8909-nokia-sparkler":
|
|
problems.append(prefix + "wrong lk2nd,dtb-files %r" %
|
|
prop_str(nodes, node, "lk2nd,dtb-files"))
|
|
if prop_strlist(nodes, node, "lk2nd,menu-key-strings") != EXPECTED_MENU_KEYS:
|
|
problems.append(prefix + "wrong lk2nd,menu-key-strings %r" %
|
|
prop_strlist(nodes, node, "lk2nd,menu-key-strings"))
|
|
|
|
keys_node = node + "/gpio-keys"
|
|
vol_up_node = keys_node + "/volume-up"
|
|
if keys_node not in nodes or prop_str(nodes, keys_node, "compatible") != "gpio-keys":
|
|
problems.append(prefix + "missing /lk2nd/nokia-sparkler/gpio-keys")
|
|
elif vol_up_node not in nodes:
|
|
problems.append(prefix + "missing /lk2nd/nokia-sparkler/gpio-keys/volume-up")
|
|
else:
|
|
if prop_cells(nodes, vol_up_node, "lk2nd,code") != [KEY_VOLUMEUP_CODE]:
|
|
problems.append(prefix + "volume-up lk2nd,code is %r, expected [%d]" %
|
|
(prop_cells(nodes, vol_up_node, "lk2nd,code"),
|
|
KEY_VOLUMEUP_CODE))
|
|
gpios = prop_cells(nodes, vol_up_node, "gpios")
|
|
if len(gpios) != 3 or gpios[1] != 90:
|
|
problems.append(prefix + "volume-up gpios %r must target gpio 90" % (gpios,))
|
|
|
|
streams = {}
|
|
for name, expected_cmds, expected_bytes, desc in PANEL_SPECS:
|
|
panel = node + "/panel/" + name
|
|
if panel not in nodes:
|
|
problems.append(prefix + "missing %s panel node %s" % (desc, name))
|
|
continue
|
|
if "lk2nd,panel-init" not in nodes[panel]:
|
|
problems.append(prefix + "panel %s has no lk2nd,panel-init" % name)
|
|
else:
|
|
raw = nodes[panel]["lk2nd,panel-init"]
|
|
streams[name] = raw
|
|
check_stream(name, raw, expected_cmds, expected_bytes, problems)
|
|
return streams
|
|
|
|
|
|
def extract_patch_file(patch_text, path):
|
|
"""Return the added-file body for a 'new file' diff section."""
|
|
marker = "diff --git a/%s b/%s\n" % (path, path)
|
|
start = patch_text.find(marker)
|
|
if start < 0:
|
|
return None
|
|
lines = patch_text[start:].split("\n")
|
|
out = []
|
|
started = False
|
|
for line in lines[1:]:
|
|
if line.startswith("@@"):
|
|
started = True
|
|
continue
|
|
if not started:
|
|
continue
|
|
if line.startswith("diff --git "):
|
|
break
|
|
if line.startswith("+"):
|
|
out.append(line[1:])
|
|
return "\n".join(out) + "\n"
|
|
|
|
|
|
def format_c_array(name, raw):
|
|
lines = ["static const unsigned char %s[] = {" % name]
|
|
for i in range(0, len(raw), 12):
|
|
lines.append(" " + ", ".join("0x%02x" % x for x in raw[i:i + 12]) + ",")
|
|
lines.append("};")
|
|
return lines
|
|
|
|
|
|
def main():
|
|
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
ap = argparse.ArgumentParser(description=__doc__)
|
|
ap.add_argument("--image", default=os.path.join(base, "images", "boot-lk2nd-nokia-sparkler.img"))
|
|
ap.add_argument("--beatles-patch", default=os.path.join(base, "bootloader", "lk2nd", "nokia-beatles.patch"))
|
|
ap.add_argument("--coconut-patch", default=os.path.join(base, "bootloader", "lk2nd", "nokia-coconut.patch"))
|
|
ap.add_argument("--patch", default=os.path.join(base, "bootloader", "lk2nd", "nokia-sparkler.patch"))
|
|
ap.add_argument("--emit-streams-header", default=None,
|
|
help="write the GC9307 and ST7789VX2 panel init streams as C arrays")
|
|
ap.add_argument("--expect-fastboot", type=int, choices=(0, 1), default=0,
|
|
help="require (1) or forbid (0) the forced-fastboot diagnostic build")
|
|
ap.add_argument("--expect-display", type=int, choices=(0, 1), default=0,
|
|
help="require (1) or forbid (0) the boot-time SPI display build")
|
|
args = ap.parse_args()
|
|
|
|
problems = []
|
|
if not os.path.isfile(args.image):
|
|
print("FAIL: missing %s" % args.image)
|
|
return 1
|
|
data = open(args.image, "rb").read()
|
|
if data[:8] != BOOT_MAGIC:
|
|
print("FAIL: %s is not an Android boot image" % args.image)
|
|
return 1
|
|
hdr = struct.unpack_from("<8s10I", data, 0)
|
|
kernel_size, kernel_addr, ramdisk_size, _ = hdr[1:5]
|
|
second_size, _, _, page = hdr[5:9]
|
|
dt_size = hdr[9]
|
|
if page != 2048:
|
|
problems.append("page size is %d, expected 2048" % page)
|
|
if kernel_addr != 0x80008000:
|
|
problems.append("kernel load address %#x is not the stock 0x80008000" % kernel_addr)
|
|
if dt_size == 0 or dt_size % page != 0:
|
|
problems.append("dt_size %d is not a page-multiple QCDT image" % dt_size)
|
|
cmdline = data[64:576].split(b"\0")[0].decode("utf-8", "replace")
|
|
cmd_parts = cmdline.split(" ")
|
|
if cmd_parts[:2] != ["lk2nd", "lk2nd.compatible=nokia,sparkler"] or \
|
|
any(p not in ("lk2nd.force-panel-init", "lk2nd.no-display",
|
|
"lk2nd.display=on") for p in cmd_parts[2:]):
|
|
problems.append("cmdline is %r" % cmdline)
|
|
no_display = "lk2nd.no-display" in cmd_parts[2:]
|
|
display_on = "lk2nd.display=on" in cmd_parts[2:]
|
|
if args.expect_fastboot and not no_display:
|
|
problems.append("diagnostic image must carry lk2nd.no-display")
|
|
if args.expect_display and not display_on:
|
|
problems.append("display image must carry lk2nd.display=on")
|
|
if args.expect_display and no_display:
|
|
problems.append("display image must not carry lk2nd.no-display")
|
|
if not args.expect_display and display_on:
|
|
problems.append("non-display image must not carry lk2nd.display=on")
|
|
forced_fastboot = b"Fastboot mode was forced with compile-time flag." in data
|
|
if forced_fastboot != bool(args.expect_fastboot):
|
|
problems.append("fastboot diagnostic marker is %s, expected %s" %
|
|
(forced_fastboot, bool(args.expect_fastboot)))
|
|
for marker in (b"lk2nd.no-display", b"lk2nd.display=on",
|
|
b"oem scan-boot", b"oem display-init", b"oem display-test",
|
|
b"oem scan-dtb", b"QUP output FIFO timeout",
|
|
b"SPI panel %s: keeping aboot continuous splash",
|
|
b"SPI display ready",
|
|
b"scan-only: final kernel cmdline/DTB ready",
|
|
b"No valid pstore console",
|
|
b"SPI panel fallback from QCDT: %s",
|
|
b"offset is not block-aligned",
|
|
b"aligned read exceeds partition",
|
|
b"beatles low-bit reboot cookie"):
|
|
if marker not in data:
|
|
problems.append("binary is missing %r" % marker.decode("ascii", "replace"))
|
|
want_ver = (b"bananarchy-sparkler-diag\x00" if args.expect_fastboot else
|
|
b"bananarchy-sparkler-display\x00" if args.expect_display else
|
|
b"bananarchy-sparkler\x00")
|
|
if want_ver not in data:
|
|
problems.append("binary is missing version-neutral tag %r" %
|
|
want_ver.rstrip(b"\x00").decode("ascii"))
|
|
if re.search(rb"bananarchy-sparkler-[a-z][0-9]{4}", data):
|
|
problems.append("binary embeds an OS release version tag in LK2ND_VERSION")
|
|
if not data.endswith(b"SEANDROIDENFORCE"):
|
|
problems.append("missing SEANDROIDENFORCE trailer")
|
|
|
|
qcdt_off = (page + align(kernel_size, page) + align(ramdisk_size, page) +
|
|
align(second_size, page))
|
|
sparkler_entry = None
|
|
seen_offsets = {}
|
|
if data[qcdt_off:qcdt_off + 4] != QCDT_MAGIC:
|
|
problems.append("no QCDT table at offset %d" % qcdt_off)
|
|
else:
|
|
_, version, num_entries = struct.unpack_from("<4sII", data, qcdt_off)
|
|
if version != 2:
|
|
problems.append("QCDT version is %d, expected 2" % version)
|
|
for i in range(num_entries):
|
|
off = qcdt_off + 12 + 24 * i
|
|
platform_id, variant_id, subtype, soc_rev, dtb_off, dtb_size = \
|
|
struct.unpack_from("<6I", data, off)
|
|
if dtb_off and dtb_size:
|
|
seen_offsets.setdefault(dtb_off, dtb_size)
|
|
if (platform_id == STOCK_PLATFORM_ID and variant_id == STOCK_VARIANT_ID and
|
|
subtype == STOCK_SUBTYPE and soc_rev == STOCK_SOC_REV):
|
|
sparkler_entry = (dtb_off, dtb_size, i)
|
|
if not sparkler_entry:
|
|
problems.append("QCDT has no MSM8909 MTP entry (0xf5/0x8/0x100/0)")
|
|
|
|
for dtb_off, dtb_size in seen_offsets.items():
|
|
dtb = data[qcdt_off + dtb_off:qcdt_off + dtb_off + dtb_size]
|
|
if dtb[:4] != b"\xd0\x0d\xfe\xed":
|
|
continue
|
|
try:
|
|
nodes, _ = fdt_nodes(dtb)
|
|
except ValueError:
|
|
continue
|
|
if "/cpus" not in nodes:
|
|
problems.append("QCDT DTB@0x%x lacks /cpus (aboot partial-goods ASSERT)" %
|
|
dtb_off)
|
|
continue
|
|
for cpu in ("cpu@2", "cpu@3"):
|
|
path = "/cpus/" + cpu
|
|
if path not in nodes:
|
|
problems.append("QCDT DTB@0x%x lacks %s" % (dtb_off, path))
|
|
elif nodes[path].get("device_type") != b"cpu\0":
|
|
problems.append("QCDT DTB@0x%x %s device_type is %r, expected b'cpu\\0'" %
|
|
(dtb_off, path, nodes[path].get("device_type")))
|
|
|
|
streams = {}
|
|
if sparkler_entry:
|
|
dtb_off, dtb_size, _ = sparkler_entry
|
|
dtb = data[qcdt_off + dtb_off:qcdt_off + dtb_off + dtb_size]
|
|
if dtb[:4] != b"\xd0\x0d\xfe\xed":
|
|
problems.append("8000 4G DTB is not an FDT")
|
|
else:
|
|
try:
|
|
nodes, totalsize = fdt_nodes(dtb)
|
|
if totalsize > dtb_size:
|
|
problems.append("8000 4G DTB is truncated (%d > %d)" %
|
|
(totalsize, dtb_size))
|
|
streams = check_device_node(nodes, "8000 4G DTB", problems) or {}
|
|
except ValueError as exc:
|
|
problems.append("8000 4G DTB: %s" % exc)
|
|
|
|
header_path = os.path.join(base, "bootloader", "lk2nd", "spi-panel-init.h")
|
|
if not os.path.isfile(args.beatles_patch):
|
|
problems.append("missing base patch %s" % args.beatles_patch)
|
|
elif not os.path.isfile(args.coconut_patch):
|
|
problems.append("missing coconut patch %s" % args.coconut_patch)
|
|
elif not os.path.isfile(args.patch):
|
|
problems.append("missing sparkler patch %s" % args.patch)
|
|
elif not os.path.isfile(header_path):
|
|
problems.append("missing %s" % header_path)
|
|
else:
|
|
base_text = open(args.beatles_patch, "r").read()
|
|
coco_text = open(args.coconut_patch, "r").read()
|
|
spark_text = open(args.patch, "r").read()
|
|
want = open(header_path, "r").read()
|
|
got = extract_patch_file(base_text, "lk2nd/include/lk2nd/spi-panel-init.h")
|
|
if got != want:
|
|
problems.append("bootloader/lk2nd/spi-panel-init.h is out of sync with nokia-beatles.patch")
|
|
if "diff --git a/lk2nd/device/menu/menu.c b/lk2nd/device/menu/menu.c" not in base_text:
|
|
problems.append("base patch must strip LK2ND_VERSION from boot/recovery screens")
|
|
if "diff --git a/lk2nd/device/dts/msm8909/nokia-coconut.dtsi" not in coco_text:
|
|
problems.append("nokia-coconut.patch is missing nokia-coconut.dtsi")
|
|
for needed in (
|
|
"lk2nd/device/2nd/spi-display.c",
|
|
"lk2nd/device/dts/msm8909/msm8909-mtp.dts",
|
|
"lk2nd/device/dts/msm8909/nokia-sparkler.dtsi",
|
|
):
|
|
if "diff --git a/%s b/%s" % (needed, needed) not in spark_text:
|
|
problems.append("sparkler patch is missing %s" % needed)
|
|
for token in ('"nokia,sparkler"', '#include "nokia-sparkler.dtsi"',
|
|
"qcom,mdss_spi_gc9307_hlt_28_qvga_cmd",
|
|
"qcom,mdss_spi_st7789vx2_ctc_28_qvga_cmd",
|
|
"* and # keys", "Top power key", "KEY_VOLUMEUP"):
|
|
if token not in spark_text:
|
|
problems.append("sparkler patch is missing %s" % token)
|
|
|
|
if problems:
|
|
for problem in problems:
|
|
print("FAIL: %s" % problem)
|
|
return 1
|
|
|
|
print("[ok] source-built sparkler lk2nd (%s): cmdline=%r, %d bytes, "
|
|
"dt_size=%d, 0xf5/0x8/0x100 -> DTB@0x%x" %
|
|
("diagnostic" if args.expect_fastboot else
|
|
"display" if args.expect_display else "normal",
|
|
cmdline, len(data), dt_size, sparkler_entry[0]))
|
|
print("[ok] all %d QCDT DTBs have /cpus/cpu@2 and cpu@3 (partial-goods fix)" %
|
|
len(seen_offsets))
|
|
print("[ok] 8000 4G DTB carries /lk2nd/nokia-sparkler with GC9307 + ST7789VX2 init streams and gpio90 KEY_VOLUMEUP")
|
|
print("[ok] patch layers and header in sync")
|
|
|
|
if args.emit_streams_header:
|
|
gc = streams.get(GC9307_PANELS[0], b"")
|
|
st = streams.get(ST7789VX2_PANELS[0], b"")
|
|
out = [
|
|
"/* generated by scripts/check-lk2nd-sparkler.py */",
|
|
"#ifndef PANEL_STREAMS_SPARKLER_H",
|
|
"#define PANEL_STREAMS_SPARKLER_H",
|
|
"",
|
|
]
|
|
out += format_c_array("stream_gc9307", gc)
|
|
out.append("")
|
|
out += format_c_array("stream_st7789vx2", st)
|
|
out += ["", "#endif"]
|
|
with open(args.emit_streams_header, "w") as fh:
|
|
fh.write("\n".join(out) + "\n")
|
|
print("[ok] wrote %s" % args.emit_streams_header)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|