Port Nokia 800 Tough (nokia-coconut), fix microSD detection, and stage upcoming a1120 (cocojamboo) build
- Migrate nokia-tough to canonical nokia-coconut while keeping CLI aliases, add layered bootloader/lk2nd/nokia-coconut.patch, bootfs/bootimg validators, and offline scripts/inspect-stock-msm8905-dump.py - Complete nokia-coconut Stage 2 hardware bring-up: wire 6-column 22-key keypad (gpio0, gpio3, gpio7, gpio99, gpio6, gpio1), gpio98 KEY_POWER, and pon@800:resin KEY_DOWN (0x6c); split leds-msm8905-torch into GPIO_13 white:torch (dedicated top-edge flashlight) and GPIO_32 camera:flash (rear camera flash for camera.so and bananarchy-photo) - Restore sdhci@7864000 non-removable across all six DTS/DTB targets, remove unwired gpio38 cd-gpios/sdc2-cd-* states, and harden sxmo_sdcard.sh under flock - Register upcoming build a1120 (cocojamboo) in scripts/version.sh, scripts/check-rebuild.sh, CHANGELOG.md, AGENTS.md, README.md, and MANUAL.md with verified hashes across nokia-argon, nokia-beatles, and nokia-coconut
This commit is contained in:
1 parent
fc5c4282f5
commit
ab53423e33
60 files changed
+2669
-453
No files matched your search
@@ -26,9 +26,9 @@ case "$DEVICE" in
|
||||
DTB_FILE="qcom-msm8905-nokia-beatles.dtb"
|
||||
LID_PROFILE="flip"
|
||||
;;
|
||||
nokia-tough|nokia-coconut|tough|coconut)
|
||||
DEVICE="nokia-tough"
|
||||
DEVICE_DIR="nokia-tough"
|
||||
nokia-coconut|nokia-tough|coconut|tough)
|
||||
DEVICE="nokia-coconut"
|
||||
DEVICE_DIR="nokia-coconut"
|
||||
DEVICEINFO_FILE="deviceinfo"
|
||||
DTB_FILE="qcom-msm8905-nokia-coconut.dtb"
|
||||
LID_PROFILE="none"
|
||||
@@ -49,7 +49,7 @@ case "$DEVICE" in
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unsupported device '$DEVICE'." >&2
|
||||
echo "Supported devices: nokia-argon, nokia-beatles, nokia-tough, nokia-sparkler, nokia-leo" >&2
|
||||
echo "Supported devices: nokia-argon, nokia-beatles, nokia-coconut, nokia-sparkler, nokia-leo" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -122,7 +122,8 @@ rm -f "$TARGET_ROOTFS/usr/bin/bantam" "$TARGET_ROOTFS/usr/local/bin/bantam" "$TA
|
||||
cp -af "$BASE_DIR/overlay/rootfs/." "$TARGET_ROOTFS/"
|
||||
rm -f "$TARGET_ROOTFS/usr/bin/bananarchy-lid.py" \
|
||||
"$TARGET_ROOTFS/usr/bin/bananarchy-cover-idle.py" \
|
||||
"$TARGET_ROOTFS/usr/bin/bananarchy-volume-keys.py"
|
||||
"$TARGET_ROOTFS/usr/bin/bananarchy-volume-keys.py" \
|
||||
"$TARGET_ROOTFS/usr/lib/kernel-cmdline.d/50-device-nokia-tough.conf"
|
||||
for daemon in bananarchy-lid bananarchy-cover-idle bananarchy-volume-keys \
|
||||
bananarchy-dsds bananarchy-modemmonitor bananarchy-soundmonitor \
|
||||
bananarchy-notifmonitor bananarchy-run-aligned \
|
||||
|
||||
@@ -22,8 +22,20 @@ for arg in "$@"; do
|
||||
--check|-c)
|
||||
CHECK_ONLY=1
|
||||
;;
|
||||
nokia-argon|nokia-beatles|nokia-tough|nokia-sparkler|nokia-leo)
|
||||
TARGET_DEVICE="$arg"
|
||||
nokia-argon|argon)
|
||||
TARGET_DEVICE="nokia-argon"
|
||||
;;
|
||||
nokia-beatles|beatles)
|
||||
TARGET_DEVICE="nokia-beatles"
|
||||
;;
|
||||
nokia-coconut|nokia-tough|coconut|tough)
|
||||
TARGET_DEVICE="nokia-coconut"
|
||||
;;
|
||||
nokia-sparkler|sparkler)
|
||||
TARGET_DEVICE="nokia-sparkler"
|
||||
;;
|
||||
nokia-leo|leo)
|
||||
TARGET_DEVICE="nokia-leo"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${ROOTFS_DIR_SET:-}" ]; then
|
||||
|
||||
@@ -305,7 +305,7 @@ EOF
|
||||
for dts in \
|
||||
/bananarchy/devices/nokia-argon/qcom-msm8905-nokia-argon.dts \
|
||||
/bananarchy/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts \
|
||||
/bananarchy/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts \
|
||||
/bananarchy/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts \
|
||||
/bananarchy/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts \
|
||||
/bananarchy/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts; do
|
||||
dtb="${dts%.dts}.dtb"
|
||||
|
||||
Executable
+160
@@ -0,0 +1,160 @@
|
||||
#!/bin/sh
|
||||
# Build the nokia-coconut lk2nd boot images from upstream source.
|
||||
#
|
||||
# ./scripts/build-lk2nd-coconut.sh build normal + diagnostic + display
|
||||
# ./scripts/build-lk2nd-coconut.sh --check validate the shipped images only
|
||||
# ./scripts/build-lk2nd-coconut.sh --only normal build just one variant
|
||||
# ./scripts/build-lk2nd-coconut.sh --force-panel-init append lk2nd.force-panel-init to
|
||||
# the normal image cmdline
|
||||
# WITH_DISPLAY=1 ./scripts/build-lk2nd-coconut.sh enable the SPI display during boot
|
||||
#
|
||||
# Overrides: BANANARCHY_LK2ND_SRC (existing upstream checkout),
|
||||
# BANANARCHY_LK2ND_BUILD_DIR (scratch), JOBS (make -j).
|
||||
set -eu
|
||||
|
||||
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||
UPSTREAM=https://github.com/msm8916-mainline/lk2nd.git
|
||||
COMMIT=cf45aefd22d744b2bf9b39455afae697ce430063
|
||||
BASE_PATCH="$BASE_DIR/bootloader/lk2nd/nokia-beatles.patch"
|
||||
PATCH="$BASE_DIR/bootloader/lk2nd/nokia-coconut.patch"
|
||||
NORMAL_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-coconut.img"
|
||||
DIAG_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-coconut-diagnostic.img"
|
||||
DISPLAY_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-coconut-display.img"
|
||||
DOCKER_IMAGE=bananarchy-lk2nd-build:local
|
||||
BUILD_DIR=${BANANARCHY_LK2ND_BUILD_DIR:-"$BASE_DIR/.lk2nd-build"}
|
||||
|
||||
CHECK_ONLY=0
|
||||
ONLY=all
|
||||
FORCE_PANEL_INIT=0
|
||||
WITH_DISPLAY=${WITH_DISPLAY:-0}
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check) CHECK_ONLY=1 ;;
|
||||
--only) shift; ONLY=${1:-all} ;;
|
||||
--force-panel-init) FORCE_PANEL_INIT=1 ;;
|
||||
--with-display) WITH_DISPLAY=1 ;;
|
||||
*) echo "[!] unknown option: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
CMD_BASE="lk2nd lk2nd.compatible=nokia,coconut"
|
||||
if [ "$WITH_DISPLAY" != 1 ]; then
|
||||
CMD_BASE="$CMD_BASE lk2nd.no-display"
|
||||
fi
|
||||
if [ "$FORCE_PANEL_INIT" = 1 ]; then
|
||||
CMD_BASE="$CMD_BASE lk2nd.force-panel-init"
|
||||
fi
|
||||
CMD_DIAG="lk2nd lk2nd.compatible=nokia,coconut lk2nd.no-display"
|
||||
CMD_DISPLAY="lk2nd lk2nd.compatible=nokia,coconut lk2nd.display=on"
|
||||
|
||||
check_images() {
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
|
||||
--image "$NORMAL_IMAGE" --base-patch "$BASE_PATCH" --patch "$PATCH" \
|
||||
--expect-fastboot 0
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
|
||||
--image "$DIAG_IMAGE" --base-patch "$BASE_PATCH" --patch "$PATCH" \
|
||||
--expect-fastboot 1
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
|
||||
--image "$DISPLAY_IMAGE" --base-patch "$BASE_PATCH" --patch "$PATCH" \
|
||||
--expect-fastboot 0 --expect-display 1
|
||||
}
|
||||
|
||||
if [ "$CHECK_ONLY" = 1 ]; then
|
||||
check_images
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for tool in git docker python3; do
|
||||
if ! command -v "$tool" >/dev/null 2>&1; then
|
||||
echo "[!] $tool is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
if [ ! -f "$BASE_PATCH" ] || [ ! -f "$PATCH" ]; then
|
||||
echo "[!] missing lk2nd patch files ($BASE_PATCH / $PATCH)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${BANANARCHY_LK2ND_SRC:-}" ]; then
|
||||
SRC=$BANANARCHY_LK2ND_SRC
|
||||
else
|
||||
SRC="$BUILD_DIR/src-coconut"
|
||||
LOCAL_CACHE="$BUILD_DIR/src"
|
||||
mkdir -p "$BUILD_DIR"
|
||||
head=$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)
|
||||
if [ "$head" != "$COMMIT" ]; then
|
||||
if [ -d "$LOCAL_CACHE/.git" ] && \
|
||||
[ "$(git -C "$LOCAL_CACHE" rev-parse HEAD 2>/dev/null || true)" = "$COMMIT" ]; then
|
||||
echo "[*] seeding coconut lk2nd tree from cached $COMMIT"
|
||||
rm -rf "$SRC"
|
||||
cp -a "$LOCAL_CACHE" "$SRC"
|
||||
else
|
||||
if [ ! -d "$SRC/.git" ]; then
|
||||
git init -q "$SRC"
|
||||
git -C "$SRC" remote add origin "$UPSTREAM"
|
||||
fi
|
||||
echo "[*] fetching upstream lk2nd at $COMMIT"
|
||||
git -C "$SRC" fetch --depth 1 origin "$COMMIT"
|
||||
git -C "$SRC" checkout -f -q FETCH_HEAD
|
||||
fi
|
||||
fi
|
||||
git -C "$SRC" checkout -q --detach "$COMMIT"
|
||||
git -C "$SRC" reset --hard -q "$COMMIT"
|
||||
git -C "$SRC" clean -fdq
|
||||
fi
|
||||
|
||||
head=$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)
|
||||
if [ "$head" != "$COMMIT" ]; then
|
||||
echo "[!] $SRC is at ${head:-unknown}, expected $COMMIT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in "$BASE_PATCH" "$PATCH"; do
|
||||
name=$(basename "$p")
|
||||
if git -C "$SRC" apply --check --reverse "$p" 2>/dev/null; then
|
||||
echo "[*] $name already applied"
|
||||
else
|
||||
echo "[*] applying $name"
|
||||
git -C "$SRC" apply --check "$p"
|
||||
git -C "$SRC" apply "$p"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! docker image inspect "$DOCKER_IMAGE" >/dev/null 2>&1; then
|
||||
echo "[*] building the arm-none-eabi toolchain image"
|
||||
docker build -t "$DOCKER_IMAGE" "$BASE_DIR/bootloader/lk2nd"
|
||||
fi
|
||||
|
||||
build_variant() {
|
||||
label=$1
|
||||
version=$2
|
||||
extra=$3
|
||||
cmdline=$4
|
||||
out=$5
|
||||
echo "[*] building lk2nd-msm8909 ($label)"
|
||||
# shellcheck disable=SC2086
|
||||
docker run --rm --user "$(id -u):$(id -g)" \
|
||||
-v "$SRC:/src" -w /src "$DOCKER_IMAGE" \
|
||||
make TOOLCHAIN_PREFIX=arm-none-eabi- \
|
||||
LK2ND_VERSION="$version" \
|
||||
MKBOOTIMG_CMDLINE="$cmdline" \
|
||||
$extra -j"${JOBS:-4}" lk2nd-msm8909
|
||||
mkdir -p "$(dirname "$out")"
|
||||
cp "$SRC/build-lk2nd-msm8909/lk2nd.img" "$out"
|
||||
echo "[*] wrote $out"
|
||||
sha256sum "$out"
|
||||
}
|
||||
|
||||
if [ "$ONLY" = all ] || [ "$ONLY" = normal ]; then
|
||||
build_variant normal bananarchy-coconut-a1114-r1 "" "$CMD_BASE" "$NORMAL_IMAGE"
|
||||
fi
|
||||
if [ "$ONLY" = all ] || [ "$ONLY" = diagnostic ]; then
|
||||
build_variant diagnostic bananarchy-coconut-a1114-diag-r1 \
|
||||
"DEBUG=2 LK2ND_FORCE_FASTBOOT=1" "$CMD_DIAG" "$DIAG_IMAGE"
|
||||
fi
|
||||
if [ "$ONLY" = all ] || [ "$ONLY" = display ]; then
|
||||
build_variant display bananarchy-coconut-a1114-display-r1 "" "$CMD_DISPLAY" "$DISPLAY_IMAGE"
|
||||
fi
|
||||
|
||||
check_images
|
||||
@@ -7,6 +7,7 @@ cleanly when the image has not been built yet, so check-rebuild.sh stays useful
|
||||
in a fresh clone.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
@@ -26,6 +27,15 @@ STOCK_BOARD_ID = struct.pack(">2I", 0x1000b, 0x100)
|
||||
STOCK_PMIC_ID = struct.pack(">4I", 0x1000d, 0, 0, 0)
|
||||
MEMORY_512M = struct.pack(">2I", 0x80000000, 0x20000000)
|
||||
|
||||
DEVICE_MODELS = {
|
||||
"nokia-beatles": "Nokia 2720 Flip",
|
||||
"nokia-coconut": "Nokia 800 Tough",
|
||||
}
|
||||
DEVICE_SHORT = {
|
||||
"nokia-beatles": "2720",
|
||||
"nokia-coconut": "800 Tough",
|
||||
}
|
||||
|
||||
|
||||
def align(value, page):
|
||||
return (value + page - 1) // page * page
|
||||
@@ -79,11 +89,33 @@ def parse_fdt(data):
|
||||
return nodes, totalsize
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Validate MSM8905 lk2nd-chained mainline boot.img"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--device",
|
||||
choices=tuple(DEVICE_MODELS.keys()),
|
||||
default="nokia-beatles",
|
||||
help="Target device to validate (default: nokia-beatles)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--image",
|
||||
default="",
|
||||
help="Explicit path to boot-bananarchy-<device>.img",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
device = args.device
|
||||
short_name = DEVICE_SHORT[device]
|
||||
expected_model = DEVICE_MODELS[device]
|
||||
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
boot = os.path.join(base, "images", "boot-bananarchy-nokia-beatles.img")
|
||||
boot = args.image or os.path.join(base, "images", "boot-bananarchy-%s.img" % device)
|
||||
if not os.path.isfile(boot):
|
||||
print("[skip] 2720 boot image not built yet")
|
||||
print("[skip] %s boot image not built yet" % short_name)
|
||||
return 0
|
||||
data = open(boot, "rb").read()
|
||||
problems = []
|
||||
@@ -106,7 +138,7 @@ def main():
|
||||
if flag in cmdline_parts:
|
||||
problems.append("cmdline still has kernel debug flag %s" % flag)
|
||||
if kernel_addr != 0x80008000 or ramdisk_addr != 0x81000000 or tags_addr != 0x80000100:
|
||||
problems.append("boot header load addresses do not match the stock 2720")
|
||||
problems.append("boot header load addresses do not match the stock %s" % short_name)
|
||||
kernel_off = page
|
||||
dtb_rel = struct.unpack_from("<I", data, kernel_off + DTB_OFFSET_FIELD)[0]
|
||||
dtb_abs = kernel_off + dtb_rel
|
||||
@@ -121,13 +153,13 @@ def main():
|
||||
problems.append("appended DTB is truncated")
|
||||
root = nodes.get("/", {})
|
||||
model = root.get("model", b"").rstrip(b"\0").decode("utf-8", "replace")
|
||||
if model != "Nokia 2720 Flip":
|
||||
problems.append("appended DTB model is %r" % model)
|
||||
if model != expected_model:
|
||||
problems.append("appended DTB model is %r (expected %r)" % (model, expected_model))
|
||||
for prop, expected in (("qcom,msm-id", STOCK_MSM_ID),
|
||||
("qcom,board-id", STOCK_BOARD_ID),
|
||||
("qcom,pmic-id", STOCK_PMIC_ID)):
|
||||
if root.get(prop) != expected:
|
||||
problems.append("%s does not match the stock 2720 QRD SKUB value" % prop)
|
||||
problems.append("%s does not match the stock %s QRD SKUB value" % (prop, short_name))
|
||||
mem = None
|
||||
for path, props in nodes.items():
|
||||
if props.get("device_type") == b"memory\0":
|
||||
@@ -143,7 +175,7 @@ def main():
|
||||
for problem in problems:
|
||||
print("FAIL: %s" % problem)
|
||||
return 1
|
||||
print("[ok] 2720 boot image: exact stock IDs, 512 MiB memory fallback, appended DTB pointer")
|
||||
print("[ok] %s boot image: exact stock IDs, 512 MiB memory fallback, appended DTB pointer" % short_name)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Executable
+429
@@ -0,0 +1,429 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate the source-built nokia-coconut lk2nd boot image.
|
||||
|
||||
Checks (all offline, pure Python):
|
||||
* Android boot.img header, cmdline and SEANDROIDENFORCE trailer.
|
||||
* QCDT v2 exact MSM8905 QRD SKUB entry (0x14b / 0x1000b / 0x100 / 0) and
|
||||
QRD fallback entry (0x14b / 0xb / 0x100) sharing one DTB.
|
||||
* Every unique QCDT DTB has /cpus/cpu@2 and /cpus/cpu@3 with a 4-byte
|
||||
device_type (the 2019 HMD partial-goods ASSERT fix).
|
||||
* /lk2nd/nokia-coconut node: model, compatible, match-panel, dtb-files,
|
||||
and panel init nodes (with GC9305 v2 init stream).
|
||||
* Base and coconut patch layers plus shared spi-panel-init.h stay in sync.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
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 = 0x14b
|
||||
STOCK_VARIANT_ID = 0x1000b
|
||||
STOCK_SUBTYPE = 0x100
|
||||
STOCK_SOC_REV = 0
|
||||
FALLBACK_VARIANT_ID = 0xb
|
||||
BOARD_ID = [FALLBACK_VARIANT_ID, STOCK_SUBTYPE,
|
||||
STOCK_VARIANT_ID, STOCK_SUBTYPE]
|
||||
|
||||
PANEL_NAMES = (
|
||||
"qcom,mdss_spi_gc9305_qvga_cmd",
|
||||
"qcom,mdss_spi_gc9305_v2_qvga_cmd",
|
||||
"qcom,mdss_spi_gc9305_3rd_qvga_cmd",
|
||||
"qcom,mdss_spi_st7789_qvga_cmd",
|
||||
"qcom,mdss_spi_gc9306_qvga_cmd",
|
||||
)
|
||||
INIT_PANEL = PANEL_NAMES[1]
|
||||
EXPECTED_CMDS = 10
|
||||
|
||||
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_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, problems):
|
||||
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 0x14b/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/cat-b35", "/lk2nd/nokia-argon",
|
||||
"/lk2nd/nokia-beatles", "/lk2nd/nokia-coconut"):
|
||||
if needed not in subnodes:
|
||||
problems.append(prefix + "missing %s (device node lost)" % needed)
|
||||
|
||||
node = "/lk2nd/nokia-coconut"
|
||||
if node not in nodes:
|
||||
problems.append(prefix + "missing /lk2nd/nokia-coconut")
|
||||
return None
|
||||
props = nodes[node]
|
||||
if prop_str(nodes, node, "model") != "Nokia 800 Tough":
|
||||
problems.append(prefix + "wrong model %r" % prop_str(nodes, node, "model"))
|
||||
if prop_str(nodes, node, "compatible") != "nokia,coconut":
|
||||
problems.append(prefix + "wrong compatible %r" %
|
||||
prop_str(nodes, node, "compatible"))
|
||||
if "lk2nd,match-panel" not in props:
|
||||
problems.append(prefix + "coconut node lost lk2nd,match-panel")
|
||||
if prop_str(nodes, node, "lk2nd,dtb-files") != "msm8905-nokia-coconut":
|
||||
problems.append(prefix + "wrong lk2nd,dtb-files %r" %
|
||||
prop_str(nodes, node, "lk2nd,dtb-files"))
|
||||
|
||||
stream = None
|
||||
for name in PANEL_NAMES:
|
||||
panel = node + "/panel/" + name
|
||||
if panel not in nodes:
|
||||
problems.append(prefix + "missing panel node %s" % name)
|
||||
continue
|
||||
if name == INIT_PANEL:
|
||||
if "lk2nd,panel-init" not in nodes[panel]:
|
||||
problems.append(prefix + "panel %s has no lk2nd,panel-init" % name)
|
||||
else:
|
||||
stream = nodes[panel]["lk2nd,panel-init"]
|
||||
check_stream(name, stream, problems)
|
||||
elif "lk2nd,panel-init" in nodes[panel]:
|
||||
problems.append(prefix + "panel %s must stay compact (no init stream)" % name)
|
||||
return stream
|
||||
|
||||
|
||||
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 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-coconut.img"))
|
||||
ap.add_argument("--base-patch",
|
||||
default=os.path.join(base, "bootloader", "lk2nd", "nokia-beatles.patch"))
|
||||
ap.add_argument("--patch",
|
||||
default=os.path.join(base, "bootloader", "lk2nd", "nokia-coconut.patch"))
|
||||
ap.add_argument("--emit-streams-header", default=None,
|
||||
help="write the panel init stream as a C array for the host unit test")
|
||||
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)
|
||||
if len(data) > 512 * 1024:
|
||||
problems.append("lk2nd image %d bytes exceeds the 512 KiB lk2nd partition" % len(data))
|
||||
|
||||
cmdline = data[64:576].split(b"\0")[0].decode("utf-8", "replace")
|
||||
cmd_parts = cmdline.split(" ")
|
||||
if cmd_parts[:2] != ["lk2nd", "lk2nd.compatible=nokia,coconut"] 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"nokia,coconut"):
|
||||
if marker not in data:
|
||||
problems.append("binary is missing %r" % marker.decode("ascii", "replace"))
|
||||
if b"beatles low-bit reboot cookie" not in data:
|
||||
problems.append("binary is missing low-bit reboot cookie")
|
||||
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))
|
||||
entries = {}
|
||||
num_entries = 0
|
||||
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 (platform_id == STOCK_PLATFORM_ID and soc_rev == STOCK_SOC_REV and
|
||||
subtype == STOCK_SUBTYPE and
|
||||
variant_id in (STOCK_VARIANT_ID, FALLBACK_VARIANT_ID)):
|
||||
entries[variant_id] = (dtb_off, dtb_size, i)
|
||||
for variant, label in ((STOCK_VARIANT_ID, "exact MSM8905 QRD SKUB"),
|
||||
(FALLBACK_VARIANT_ID, "QRD fallback")):
|
||||
if variant not in entries:
|
||||
problems.append("QCDT has no %s entry" % label)
|
||||
if len(entries) == 2:
|
||||
exact, fallback = entries[STOCK_VARIANT_ID], entries[FALLBACK_VARIANT_ID]
|
||||
if exact[:2] != fallback[:2]:
|
||||
problems.append("the two MSM8905 QRD SKUB entries must share one DTB")
|
||||
|
||||
seen_offsets = {}
|
||||
for i in range(num_entries):
|
||||
off = qcdt_off + 12 + 24 * i
|
||||
_, _, _, _, dtb_off, dtb_size = struct.unpack_from("<6I", data, off)
|
||||
if dtb_off and dtb_size:
|
||||
seen_offsets.setdefault(dtb_off, dtb_size)
|
||||
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")))
|
||||
|
||||
stream = None
|
||||
if STOCK_VARIANT_ID in entries:
|
||||
dtb_off, dtb_size, _ = entries[STOCK_VARIANT_ID]
|
||||
dtb = data[qcdt_off + dtb_off:qcdt_off + dtb_off + dtb_size]
|
||||
if dtb[:4] != b"\xd0\x0d\xfe\xed":
|
||||
problems.append("coconut DTB is not an FDT")
|
||||
else:
|
||||
try:
|
||||
nodes, totalsize = fdt_nodes(dtb)
|
||||
if totalsize > dtb_size:
|
||||
problems.append("coconut DTB is truncated (%d > %d)" %
|
||||
(totalsize, dtb_size))
|
||||
stream = check_device_node(nodes, "coconut DTB", problems)
|
||||
except ValueError as exc:
|
||||
problems.append("coconut DTB: %s" % exc)
|
||||
|
||||
header_path = os.path.join(base, "bootloader", "lk2nd", "spi-panel-init.h")
|
||||
if not os.path.isfile(args.base_patch):
|
||||
problems.append("missing base patch %s" % args.base_patch)
|
||||
elif not os.path.isfile(args.patch):
|
||||
problems.append("missing coconut patch %s" % args.patch)
|
||||
elif not os.path.isfile(header_path):
|
||||
problems.append("missing %s" % header_path)
|
||||
else:
|
||||
base_text = open(args.base_patch, "r").read()
|
||||
patch_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 base patch")
|
||||
for needed in (
|
||||
"lk2nd/device/2nd/spi-display.c",
|
||||
"lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts",
|
||||
"lk2nd/device/dts/msm8909/nokia-coconut.dtsi",
|
||||
):
|
||||
if "diff --git a/%s b/%s" % (needed, needed) not in patch_text:
|
||||
problems.append("coconut patch is missing %s" % needed)
|
||||
if "nokia,coconut" not in patch_text or "lk2nd,panel-init" not in patch_text:
|
||||
problems.append("coconut patch is missing nokia,coconut or lk2nd,panel-init")
|
||||
|
||||
if problems:
|
||||
for problem in problems:
|
||||
print("FAIL: %s" % problem)
|
||||
return 1
|
||||
|
||||
print("[ok] source-built coconut lk2nd (%s): cmdline=%r, %d bytes, "
|
||||
"dt_size=%d, both 0x14b entries -> DTB@0x%x" %
|
||||
("diagnostic" if args.expect_fastboot else
|
||||
"display" if args.expect_display else "normal",
|
||||
cmdline, len(data), dt_size, entries[STOCK_VARIANT_ID][0]))
|
||||
print("[ok] all %d QCDT DTBs have /cpus/cpu@2 and cpu@3 (partial-goods fix)" %
|
||||
len(seen_offsets))
|
||||
print("[ok] coconut DTB carries /lk2nd/nokia-coconut with the GC9305 v2 panel init stream")
|
||||
print("[ok] patches/header in sync")
|
||||
|
||||
if args.emit_streams_header:
|
||||
out = ["/* generated by scripts/check-lk2nd-coconut.py */",
|
||||
"#ifndef PANEL_STREAMS_H", "#define PANEL_STREAMS_H", "",
|
||||
"static const unsigned char stream_v2[] = {"]
|
||||
for i in range(0, len(stream), 12):
|
||||
out.append(" " + ", ".join("0x%02x" % x for x in stream[i:i + 12]) + ",")
|
||||
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())
|
||||
+160
-18
@@ -30,7 +30,7 @@ if ! grep -qF 'set-bananarchy-hostname.sh' "$BASE_DIR/scripts/bootstrap-rootfs-c
|
||||
fi
|
||||
if [ -x "$HOSTNAME_HELPER" ]; then
|
||||
HOSTNAME_TMP="$(mktemp -d)"
|
||||
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler nokia-leo; do
|
||||
for dev in nokia-argon nokia-beatles nokia-coconut nokia-sparkler nokia-leo; do
|
||||
if ! "$HOSTNAME_HELPER" "$HOSTNAME_TMP" "$dev"; then
|
||||
fail "hostname helper failed for $dev"
|
||||
continue
|
||||
@@ -190,7 +190,7 @@ echo "[check] Device-specific EDL Firehose loaders..."
|
||||
if ! grep -q '^DEVICE_LOADERS = {' "$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py is missing the device-to-loader map"
|
||||
fi
|
||||
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler nokia-leo; do
|
||||
for dev in nokia-argon nokia-beatles nokia-coconut nokia-sparkler nokia-leo; do
|
||||
if ! grep -q "\"$dev\":" "$BASE_DIR/flash-edl.py"; then
|
||||
fail "DEVICE_LOADERS is missing $dev"
|
||||
fi
|
||||
@@ -202,7 +202,7 @@ for mbn in 8110.mbn 2720.mbn 2720v.mbn 800t.mbn 8k.mbn; do
|
||||
done
|
||||
for mapping in \
|
||||
'"nokia-beatles": "2720.mbn"' \
|
||||
'"nokia-tough": "800t.mbn"' \
|
||||
'"nokia-coconut": "800t.mbn"' \
|
||||
'"nokia-sparkler": "8k.mbn"' \
|
||||
'"nokia-leo": "8k.mbn"' \
|
||||
'"us": "2720v.mbn"'; do
|
||||
@@ -245,8 +245,8 @@ fi
|
||||
if ! grep -q 'return "lk2nd"' "$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py no longer defaults to the lk2nd boot.img"
|
||||
fi
|
||||
if ! grep -q 'if method == "lk2nd" and device == "nokia-beatles":' "$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py no longer writes lk2nd to both slots on the 2720"
|
||||
if ! grep -q 'if method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:' "$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py no longer writes lk2nd to both slots on 2720/800 Tough"
|
||||
fi
|
||||
for variant in normal diagnostic display; do
|
||||
case "$variant" in
|
||||
@@ -285,13 +285,50 @@ if ! grep -qF 'target_names = ("boot", "recovery", "lk2nd")' \
|
||||
fail "flash-edl.py no longer refreshes the separate lk2nd partition"
|
||||
fi
|
||||
for f in bootloader/lk2nd/nokia-beatles.patch \
|
||||
bootloader/lk2nd/nokia-coconut.patch \
|
||||
bootloader/lk2nd/README.md \
|
||||
bootloader/lk2nd/spi-panel-init.h \
|
||||
bootloader/lk2nd/Dockerfile \
|
||||
scripts/build-lk2nd-beatles.sh \
|
||||
scripts/test-lk2nd-beatles-port.py; do
|
||||
scripts/test-lk2nd-beatles-port.py \
|
||||
scripts/build-lk2nd-coconut.sh \
|
||||
scripts/check-lk2nd-coconut.py \
|
||||
scripts/test-lk2nd-coconut-port.py \
|
||||
scripts/inspect-stock-msm8905-dump.py; do
|
||||
if [ ! -f "$BASE_DIR/$f" ]; then
|
||||
fail "missing nokia-beatles lk2nd port file: $f"
|
||||
fail "missing lk2nd port / inspection file: $f"
|
||||
fi
|
||||
done
|
||||
if ! grep -qF 'COCONUT_LK2ND_IMAGE = "images/boot-lk2nd-nokia-coconut-display.img"' \
|
||||
"$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py no longer references the display-enabled coconut lk2nd image"
|
||||
fi
|
||||
for variant in normal diagnostic display; do
|
||||
case "$variant" in
|
||||
normal)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-coconut.img"
|
||||
opts="--expect-fastboot 0"
|
||||
label="source-built nokia-coconut lk2nd"
|
||||
;;
|
||||
diagnostic)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-coconut-diagnostic.img"
|
||||
opts="--expect-fastboot 1"
|
||||
label="nokia-coconut forced-fastboot diagnostic image"
|
||||
;;
|
||||
display)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-coconut-display.img"
|
||||
opts="--expect-fastboot 0 --expect-display 1"
|
||||
label="nokia-coconut display lk2nd image with Fastboot reboot cookie"
|
||||
;;
|
||||
esac
|
||||
if [ ! -f "$image" ]; then
|
||||
echo "[skip] local build output ${image#"$BASE_DIR/"} is absent; prepare-release.sh will rebuild it"
|
||||
continue
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
if ! python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
|
||||
--image "$image" $opts; then
|
||||
fail "$label validation failed"
|
||||
fi
|
||||
done
|
||||
if [ -f "$BASE_DIR/scripts/make-beatles-lk2nd-bootimg.py" ]; then
|
||||
@@ -397,10 +434,13 @@ fi
|
||||
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"753c186db1fa5e7d58f3252ad344004bcb0d6fb26eb810ae9427d572cd7d94ca images/bananarchy-nokia-argon.img" \
|
||||
"12eb7e589a40c3935fcf283f3771b1e7e65d04b08b6d632c23b0f290304dd673 images/bananarchy-nokia-beatles.img" \
|
||||
"d6b82239f80038c1bd916c36d4c674dc1e36996b3d52c65efdd545ff320a08d8 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
"8444544b0395c5bdef2f76b87721a99c326a868465d8236e85ff5572e7634cc0 images/bananarchy-nokia-argon.img" \
|
||||
"7749caec22f5803112d21d24f032c09162bc7e6a239beabddb903272ebbd79c8 images/bananarchy-nokia-beatles.img" \
|
||||
"cc58d92e6a54eab77f355a148cbc0b424d2da64e65353e3163a9cfc1eba37235 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img" \
|
||||
"19d17f31b970099dc6c212da58efdf8a99249aaa43e65ebeb6e2b904d0c5809d images/bananarchy-nokia-coconut.img" \
|
||||
"2ff959ec89916adc02296adb948788bf8180009cd26454643e9f59334f09ad08 images/boot-bananarchy-nokia-coconut.img" \
|
||||
"e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a images/boot-lk2nd-nokia-coconut-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
path="$BASE_DIR/$2"
|
||||
@@ -737,6 +777,38 @@ else
|
||||
echo "[skip] local build output images/bananarchy-nokia-beatles.img is absent; prepare-release.sh will rebuild it"
|
||||
fi
|
||||
|
||||
echo "[check] 800 Tough (nokia-coconut) appended DTB..."
|
||||
COCONUT_DTS="$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts"
|
||||
if ! grep -qF 'qcom,msm-id = <0x14b 0x00>;' "$COCONUT_DTS"; then
|
||||
fail "nokia-coconut DTS lost the stock MSM8905 msm-id"
|
||||
fi
|
||||
if ! grep -qF 'qcom,board-id = <0x1000b 0x100>;' "$COCONUT_DTS"; then
|
||||
fail "nokia-coconut DTS lost the exact stock QRD SKUB board-id"
|
||||
fi
|
||||
if ! grep -qF 'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;' "$COCONUT_DTS"; then
|
||||
fail "nokia-coconut DTS lost the stock pmic-id"
|
||||
fi
|
||||
if ! grep -qF 'reg = <0x80000000 0x20000000>;' "$COCONUT_DTS"; then
|
||||
fail "nokia-coconut DTS lost the 512 MiB memory fallback"
|
||||
fi
|
||||
if grep -q 'switch-lid-' "$COCONUT_DTS"; then
|
||||
fail "nokia-coconut DTS still carries phantom slider lid-switch nodes"
|
||||
fi
|
||||
if [ -f "$BASE_DIR/images/boot-bananarchy-nokia-coconut.img" ]; then
|
||||
if ! python3 "$BASE_DIR/scripts/check-beatles-bootimg.py" --device nokia-coconut; then
|
||||
fail "800 Tough boot image validation failed"
|
||||
fi
|
||||
else
|
||||
echo "[skip] local build output images/boot-bananarchy-nokia-coconut.img is absent; prepare-release.sh will rebuild it"
|
||||
fi
|
||||
if [ -f "$BASE_DIR/images/bananarchy-nokia-coconut.img" ]; then
|
||||
if ! python3 "$BASE_DIR/scripts/sync-beatles-bootfs.py" --check --device nokia-coconut --raw-image "$BASE_DIR/images/bananarchy-nokia-coconut.img"; then
|
||||
fail "800 Tough raw image pmOS_boot filesystem is damaged or stale"
|
||||
fi
|
||||
else
|
||||
echo "[skip] local build output images/bananarchy-nokia-coconut.img is absent; prepare-release.sh will rebuild it"
|
||||
fi
|
||||
|
||||
echo "[check] Release hygiene..."
|
||||
KCONFIG="$BASE_DIR/patches/kernel/config-bananarchy-msm8909.armv7"
|
||||
for cfg in "$KCONFIG" \
|
||||
@@ -884,7 +956,7 @@ elif ! grep -qxF '.bantam.cfg' "$BASE_DIR/.gitignore"; then
|
||||
fi
|
||||
|
||||
echo "[check] Device initramfs module lists..."
|
||||
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler; do
|
||||
for dev in nokia-argon nokia-beatles nokia-coconut nokia-sparkler; do
|
||||
if [ ! -f "$BASE_DIR/devices/$dev/modules-initfs" ]; then
|
||||
fail "missing devices/$dev/modules-initfs"
|
||||
fi
|
||||
@@ -1323,7 +1395,7 @@ for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
|
||||
if ! grep -qF 'qcom,msm8909-bimc' "$dts" || \
|
||||
@@ -1410,7 +1482,7 @@ for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
|
||||
if [ "$(grep -c 'clock-latency-ns' "$dts" 2>/dev/null || echo 0)" -ne 8 ]; then
|
||||
@@ -1421,7 +1493,7 @@ for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts"; do
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts"; do
|
||||
if ! grep -A 3 'dai-link-multimedia3 {' "$dts" | grep -qF 'status = "disabled";'; then
|
||||
fail "${dts#"$BASE_DIR/"} must keep dai-link-multimedia3 disabled"
|
||||
fi
|
||||
@@ -1447,7 +1519,7 @@ for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
|
||||
if ! grep -qF 'compatible = "qcom,mpm";' "$dts" || \
|
||||
@@ -1550,7 +1622,7 @@ fi
|
||||
echo "[check] Version helper..."
|
||||
# Pin the release under test so the check does not break when the wall clock
|
||||
# rolls past the release date (version.sh otherwise derives it from today).
|
||||
for pair in "a1114 carbonara" "a1111 lennon"; do
|
||||
for pair in "a1120 cocojamboo" "a1114 carbonara" "a1111 lennon"; do
|
||||
set -- $pair
|
||||
want_ver=$1
|
||||
want_codename=$2
|
||||
@@ -2075,7 +2147,7 @@ for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
|
||||
if [ "$(grep -c 'regulator-allow-set-load;' "$dts" 2>/dev/null || echo 0)" -lt 3 ]; then
|
||||
@@ -2098,6 +2170,76 @@ elif ! "$BASE_DIR/scripts/test-standby-power-policy.py" >/dev/null 2>&1; then
|
||||
fail "host standby power policy test failed"
|
||||
fi
|
||||
|
||||
echo "[check] microSD sdhci@7864000 non-removable and zero-polling invariants..."
|
||||
for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
|
||||
if grep -qF 'cd-gpios' "$dts" || grep -qF 'sdc2-cd-' "$dts" || grep -qF 'broken-cd' "$dts"; then
|
||||
fail "${dts#"$BASE_DIR/"} still uses cd-gpios, sdc2-cd-*, or broken-cd on microSD"
|
||||
fi
|
||||
if [ "$(grep -c 'non-removable;' "$dts" 2>/dev/null || echo 0)" -lt 2 ]; then
|
||||
fail "${dts#"$BASE_DIR/"} is missing non-removable; on sdhci@7864000"
|
||||
fi
|
||||
done
|
||||
if command -v dtc >/dev/null 2>&1; then
|
||||
for dtb in "$BASE_DIR"/prebuilt/kernel-6.12.1-msm8916/dtbs/*.dtb; do
|
||||
[ -f "$dtb" ] || continue
|
||||
dec_dts="$(dtc -q -I dtb -O dts "$dtb" 2>/dev/null || true)"
|
||||
if [ -z "$dec_dts" ]; then
|
||||
fail "failed to decompile ${dtb#"$BASE_DIR/"}"
|
||||
elif printf "%s\n" "$dec_dts" | grep -qE 'cd-gpios|broken-cd'; then
|
||||
fail "${dtb#"$BASE_DIR/"} still contains cd-gpios or broken-cd"
|
||||
elif [ "$(printf "%s\n" "$dec_dts" | grep -c 'non-removable;' || echo 0)" -lt 2 ]; then
|
||||
fail "${dtb#"$BASE_DIR/"} is missing non-removable; on sdhci@7864000"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "[check] Nokia 800 Tough (nokia-coconut) 4x6 keypad DTS/DTB & dual LED invariants..."
|
||||
COCONUT_DTS="$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts"
|
||||
if ! grep -qF '"gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1"' "$COCONUT_DTS" || \
|
||||
grep -qF '"gpio52", "gpio56"' "$COCONUT_DTS" || \
|
||||
! grep -qF '0x3030067' "$COCONUT_DTS" || \
|
||||
! grep -qF '0x304006c' "$COCONUT_DTS" || \
|
||||
! grep -qF '0x105000e' "$COCONUT_DTS" || \
|
||||
! grep -qF '0x500d4' "$COCONUT_DTS"; then
|
||||
fail "devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts is missing the 6-column 22-key keypad layout"
|
||||
fi
|
||||
if ! awk '/key-end \{/,/\};/ { if ($0 ~ /linux,code = <0x74>;/) found=1 } END { exit(found ? 0 : 1) }' \
|
||||
"$COCONUT_DTS"; then
|
||||
fail "devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts key-end (gpio98) must map to KEY_POWER (0x74)"
|
||||
fi
|
||||
if ! awk '/resin \{/,/\};/ { if ($0 ~ /linux,code = <0x6c>;/) found=1 } END { exit(found ? 0 : 1) }' \
|
||||
"$COCONUT_DTS"; then
|
||||
fail "devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts pm8941_resin must map to KEY_DOWN (0x6c)"
|
||||
fi
|
||||
COCONUT_DTB="$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb"
|
||||
if command -v dtc >/dev/null 2>&1 && [ -f "$COCONUT_DTB" ]; then
|
||||
dec_coco="$(dtc -q -I dtb -O dts "$COCONUT_DTB" 2>/dev/null || true)"
|
||||
if ! printf "%s\n" "$dec_coco" | grep -qF '"gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1"' || \
|
||||
printf "%s\n" "$dec_coco" | grep -qF '"gpio52", "gpio56"' || \
|
||||
! printf "%s\n" "$dec_coco" | grep -qF '0x3030067' || \
|
||||
! printf "%s\n" "$dec_coco" | grep -qF '0x304006c' || \
|
||||
! printf "%s\n" "$dec_coco" | grep -qF '0x105000e' || \
|
||||
! printf "%s\n" "$dec_coco" | \
|
||||
awk '/key-end \{/,/\};/ { if ($0 ~ /linux,code = <0x74>;/) found=1 } END { exit(found ? 0 : 1) }' || \
|
||||
! printf "%s\n" "$dec_coco" | \
|
||||
awk '/resin \{/,/\};/ { if ($0 ~ /linux,code = <0x6c>;/) found=1 } END { exit(found ? 0 : 1) }'
|
||||
then
|
||||
fail "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb drifted from the 4x6 keypad layout"
|
||||
fi
|
||||
fi
|
||||
if ! grep -qF 'of_machine_is_compatible("nokia,coconut")' "$TORCH_SRC" || \
|
||||
! grep -qF '.name = "camera:flash"' "$TORCH_SRC" || \
|
||||
! grep -qF '/sys/class/leds/camera:flash/brightness' "$BASE_DIR/src/dwm-plugins/camera_plugin.cpp" || \
|
||||
! grep -qF '/sys/class/leds/camera:flash/brightness' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-photo"; then
|
||||
fail "nokia-coconut dual LED separation (GPIO_13 white:torch vs GPIO_32 camera:flash) is incomplete"
|
||||
fi
|
||||
|
||||
if [ "$FAILURES" -ne 0 ]; then
|
||||
echo "[check] $FAILURES check(s) failed."
|
||||
exit 1
|
||||
|
||||
Executable
+712
@@ -0,0 +1,712 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Inspect stock Qualcomm MSM8905/MSM8909 boot/recovery/QCDT/DTB/aboot dumps.
|
||||
|
||||
Extracts board IDs, memory nodes, SPI panel streams/GPIOs, keypad maps,
|
||||
flashlight/camera/audio/BMS nodes, and aboot strings offline for device porting.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
|
||||
BOOT_MAGIC = b"ANDROID!"
|
||||
QCDT_MAGIC = b"QCDT"
|
||||
FDT_MAGIC = 0xd00dfeed
|
||||
DTB_OFFSET_FIELD = 0x2c
|
||||
|
||||
FDT_BEGIN_NODE = 1
|
||||
FDT_END_NODE = 2
|
||||
FDT_PROP = 3
|
||||
FDT_NOP = 4
|
||||
FDT_END = 9
|
||||
|
||||
|
||||
def align_up(value, alignment):
|
||||
return (value + alignment - 1) // alignment * alignment
|
||||
|
||||
|
||||
def decode_cstr(raw):
|
||||
return raw.split(b"\0", 1)[0].decode("utf-8", "replace")
|
||||
|
||||
|
||||
def decode_strlist(raw):
|
||||
if not raw:
|
||||
return []
|
||||
parts = raw.rstrip(b"\0").split(b"\0")
|
||||
return [p.decode("utf-8", "replace") for p in parts if p]
|
||||
|
||||
|
||||
def decode_u32_list(raw):
|
||||
count = len(raw) // 4
|
||||
if count <= 0:
|
||||
return []
|
||||
return list(struct.unpack_from(">%dI" % count, raw, 0))
|
||||
|
||||
|
||||
def hex_preview(raw, limit=24):
|
||||
if not raw:
|
||||
return ""
|
||||
head = raw[:limit].hex(" ")
|
||||
if len(raw) > limit:
|
||||
return "%s ... (%d bytes)" % (head, len(raw))
|
||||
return "%s (%d bytes)" % (head, len(raw))
|
||||
|
||||
|
||||
def parse_fdt(data, offset=0):
|
||||
"""Parse a flattened device tree blob starting at offset."""
|
||||
if offset + 40 > len(data):
|
||||
raise ValueError("truncated FDT header")
|
||||
vals = struct.unpack_from(">10I", data, offset)
|
||||
magic, totalsize, off_struct, off_strings, _, version = vals[:6]
|
||||
size_strings, size_struct = vals[8], vals[9]
|
||||
if magic != FDT_MAGIC:
|
||||
raise ValueError("bad FDT magic %#x" % magic)
|
||||
if version not in (16, 17):
|
||||
raise ValueError("unsupported FDT version %d" % version)
|
||||
if totalsize < 40 or offset + totalsize > len(data):
|
||||
raise ValueError("FDT totalsize %d out of bounds" % totalsize)
|
||||
|
||||
blob = data[offset:offset + totalsize]
|
||||
strings = blob[off_strings:off_strings + size_strings]
|
||||
nodes = {}
|
||||
node_order = []
|
||||
stack = []
|
||||
pos = off_struct
|
||||
end_struct = off_struct + size_struct
|
||||
|
||||
while pos + 4 <= end_struct:
|
||||
token = struct.unpack_from(">I", blob, pos)[0]
|
||||
pos += 4
|
||||
if token == FDT_BEGIN_NODE:
|
||||
nul = blob.find(b"\0", pos)
|
||||
if nul < 0:
|
||||
raise ValueError("unterminated FDT node name")
|
||||
name = blob[pos:nul].decode("utf-8", "replace")
|
||||
pos = align_up(nul + 1, 4)
|
||||
stack.append(name)
|
||||
path = "/" + "/".join(p for p in stack if p)
|
||||
if path not in nodes:
|
||||
nodes[path] = {}
|
||||
node_order.append(path)
|
||||
elif token == FDT_END_NODE:
|
||||
if stack:
|
||||
stack.pop()
|
||||
elif token == FDT_PROP:
|
||||
if pos + 8 > end_struct:
|
||||
raise ValueError("truncated FDT_PROP")
|
||||
plen, nameoff = struct.unpack_from(">2I", blob, pos)
|
||||
pos += 8
|
||||
if pos + plen > end_struct:
|
||||
raise ValueError("FDT_PROP value out of bounds")
|
||||
pvalue = blob[pos:pos + plen]
|
||||
pos = align_up(pos + plen, 4)
|
||||
sname_end = strings.find(b"\0", nameoff)
|
||||
if sname_end < 0:
|
||||
sname = strings[nameoff:].decode("utf-8", "replace")
|
||||
else:
|
||||
sname = strings[nameoff:sname_end].decode("utf-8", "replace")
|
||||
path = "/" + "/".join(p for p in stack if p)
|
||||
nodes.setdefault(path, {})[sname] = pvalue
|
||||
elif token == FDT_NOP:
|
||||
continue
|
||||
elif token == FDT_END:
|
||||
break
|
||||
else:
|
||||
raise ValueError("unknown FDT token %#x at %#x" % (token, pos - 4))
|
||||
|
||||
return {
|
||||
"totalsize": totalsize,
|
||||
"nodes": nodes,
|
||||
"order": node_order,
|
||||
}
|
||||
|
||||
|
||||
def scan_fdt_blobs(data):
|
||||
"""Find valid FDT blobs inside data by scanning 4-byte aligned offsets."""
|
||||
found = []
|
||||
magic_bytes = struct.pack(">I", FDT_MAGIC)
|
||||
pos = 0
|
||||
while pos < len(data):
|
||||
hit = data.find(magic_bytes, pos)
|
||||
if hit < 0:
|
||||
break
|
||||
if hit % 4 == 0 and hit + 40 <= len(data):
|
||||
try:
|
||||
parsed = parse_fdt(data, hit)
|
||||
found.append((hit, parsed))
|
||||
pos = hit + align_up(parsed["totalsize"], 4)
|
||||
continue
|
||||
except ValueError:
|
||||
pass
|
||||
pos = hit + 4
|
||||
return found
|
||||
|
||||
|
||||
def parse_qcdt(data):
|
||||
"""Parse a Qualcomm QCDT v1/v2/v3 table."""
|
||||
if len(data) < 12 or data[:4] != QCDT_MAGIC:
|
||||
return None
|
||||
version, count = struct.unpack_from("<2I", data, 4)
|
||||
if version == 1:
|
||||
entry_size = 20
|
||||
# chipset, platform, rev, offset, size
|
||||
elif version == 2:
|
||||
entry_size = 24
|
||||
# chipset, platform, rev, pmic, offset, size
|
||||
elif version == 3:
|
||||
entry_size = 40
|
||||
# chipset, platform, variant_subtype, rev, pmic0..3, offset, size
|
||||
else:
|
||||
raise ValueError("unsupported QCDT version %d" % version)
|
||||
|
||||
entries = []
|
||||
pos = 12
|
||||
for idx in range(count):
|
||||
if pos + entry_size > len(data):
|
||||
raise ValueError("truncated QCDT entry %d" % idx)
|
||||
words = struct.unpack_from("<%dI" % (entry_size // 4), data, pos)
|
||||
pos += entry_size
|
||||
if version == 1:
|
||||
chipset, platform, rev, dt_off, dt_size = words
|
||||
pmics = []
|
||||
subtype = 0
|
||||
elif version == 2:
|
||||
chipset, platform, rev, pmic, dt_off, dt_size = words
|
||||
pmics = [pmic]
|
||||
subtype = 0
|
||||
else:
|
||||
chipset, platform, subtype, rev = words[:4]
|
||||
pmics = list(words[4:8])
|
||||
dt_off, dt_size = words[8:10]
|
||||
entry = {
|
||||
"index": idx,
|
||||
"chipset": chipset,
|
||||
"platform": platform,
|
||||
"subtype": subtype,
|
||||
"rev": rev,
|
||||
"pmic": pmics,
|
||||
"offset": dt_off,
|
||||
"size": dt_size,
|
||||
"fdt": None,
|
||||
}
|
||||
if dt_off + dt_size <= len(data) and dt_size >= 40:
|
||||
try:
|
||||
entry["fdt"] = summarize_fdt(parse_fdt(data, dt_off), label="qcdt[%d]" % idx)
|
||||
except ValueError as exc:
|
||||
entry["fdt_error"] = str(exc)
|
||||
entries.append(entry)
|
||||
|
||||
return {
|
||||
"version": version,
|
||||
"count": count,
|
||||
"entries": entries,
|
||||
}
|
||||
|
||||
|
||||
def _collect_gpio_props(props):
|
||||
hits = {}
|
||||
for key, val in props.items():
|
||||
if "gpio" in key or key in ("pwms", "qcom,channel-id", "reg"):
|
||||
u32 = decode_u32_list(val)
|
||||
if u32:
|
||||
hits[key] = [hex(x) for x in u32]
|
||||
elif val:
|
||||
hits[key] = hex_preview(val, 16)
|
||||
return hits
|
||||
|
||||
|
||||
def summarize_fdt(parsed, label="dtb"):
|
||||
"""Extract MSM8905 porting-relevant hardware metadata from parsed FDT."""
|
||||
nodes = parsed["nodes"]
|
||||
order = parsed["order"]
|
||||
root = nodes.get("/", {})
|
||||
|
||||
summary = {
|
||||
"label": label,
|
||||
"totalsize": parsed["totalsize"],
|
||||
"node_count": len(order),
|
||||
"model": decode_cstr(root.get("model", b"")),
|
||||
"compatible": decode_strlist(root.get("compatible", b"")),
|
||||
"qcom_msm_id": [hex(x) for x in decode_u32_list(root.get("qcom,msm-id", b""))],
|
||||
"qcom_board_id": [hex(x) for x in decode_u32_list(root.get("qcom,board-id", b""))],
|
||||
"qcom_pmic_id": [hex(x) for x in decode_u32_list(root.get("qcom,pmic-id", b""))],
|
||||
"memory_reg": [],
|
||||
"panels": [],
|
||||
"keypads": [],
|
||||
"leds": [],
|
||||
"battery": [],
|
||||
"audio_pa": [],
|
||||
"cameras": [],
|
||||
}
|
||||
|
||||
for path in order:
|
||||
props = nodes[path]
|
||||
low_path = path.lower()
|
||||
compats = decode_strlist(props.get("compatible", b""))
|
||||
compat_str = " ".join(compats).lower()
|
||||
|
||||
if props.get("device_type") == b"memory\0" or path.startswith("/memory"):
|
||||
regs = decode_u32_list(props.get("reg", b""))
|
||||
if regs:
|
||||
summary["memory_reg"].append({
|
||||
"path": path,
|
||||
"reg": [hex(x) for x in regs],
|
||||
})
|
||||
|
||||
is_panel = (
|
||||
any(k in props for k in (
|
||||
"qcom,mdss-spi-on-command",
|
||||
"qcom,mdss-dsi-on-command",
|
||||
"qcom,panel-spi-client",
|
||||
"lk2nd,panel-init",
|
||||
"init-sequence",
|
||||
))
|
||||
or any(tag in low_path or tag in compat_str for tag in (
|
||||
"gc93", "ili9", "st77", "nt35", "mdss_spi", "spi_panel", "mipi-dbi",
|
||||
))
|
||||
)
|
||||
if is_panel:
|
||||
panel_info = {
|
||||
"path": path,
|
||||
"compatible": compats,
|
||||
"spi_max_frequency": decode_u32_list(props.get("spi-max-frequency", b"")),
|
||||
"gpios": _collect_gpio_props(props),
|
||||
"init_cmds": {},
|
||||
}
|
||||
for cmd_prop in (
|
||||
"qcom,mdss-spi-on-command",
|
||||
"qcom,mdss-spi-off-command",
|
||||
"qcom,mdss-dsi-on-command",
|
||||
"lk2nd,panel-init",
|
||||
"init-sequence",
|
||||
):
|
||||
if cmd_prop in props:
|
||||
panel_info["init_cmds"][cmd_prop] = hex_preview(props[cmd_prop], 32)
|
||||
summary["panels"].append(panel_info)
|
||||
|
||||
is_gpio_key_child = (
|
||||
"/gpio_keys/" in low_path
|
||||
or "/gpio-keys/" in low_path
|
||||
or ("linux,code" in props and "gpios" in props)
|
||||
)
|
||||
if "gpio-keys" in compat_str or is_gpio_key_child:
|
||||
summary["keypads"].append({
|
||||
"type": "gpio-keys",
|
||||
"path": path,
|
||||
"label": decode_cstr(props.get("label", b"")),
|
||||
"linux_code": [hex(x) for x in decode_u32_list(props.get("linux,code", b""))],
|
||||
"gpios": [hex(x) for x in decode_u32_list(props.get("gpios", b""))],
|
||||
"debounce": decode_u32_list(props.get("debounce-interval", b"")),
|
||||
})
|
||||
elif "linux,keymap" in props or "keypad" in compat_str or "pm8909_kp" in low_path:
|
||||
keymap = decode_u32_list(props.get("linux,keymap", b""))
|
||||
decoded_keys = []
|
||||
for val in keymap[:48]:
|
||||
row = (val >> 24) & 0xff
|
||||
col = (val >> 16) & 0xff
|
||||
code = val & 0xffff
|
||||
decoded_keys.append("r%dc%d=%#x" % (row, col, code))
|
||||
summary["keypads"].append({
|
||||
"type": "matrix-keypad",
|
||||
"path": path,
|
||||
"compatible": compats,
|
||||
"rows": decode_u32_list(props.get("keypad,num-rows", b"")),
|
||||
"cols": decode_u32_list(props.get("keypad,num-columns", b"")),
|
||||
"keymap_count": len(keymap),
|
||||
"keymap_sample": decoded_keys,
|
||||
})
|
||||
|
||||
is_led = (
|
||||
not is_gpio_key_child
|
||||
and "gpio-keys" not in compat_str
|
||||
and any(tag in low_path or tag in compat_str for tag in (
|
||||
"led", "torch", "flash", "backlight",
|
||||
))
|
||||
and any(k in props for k in (
|
||||
"gpios", "pwms", "qcom,channel-id", "qcom,led-name", "linux,default-trigger",
|
||||
"compatible",
|
||||
))
|
||||
)
|
||||
if is_led:
|
||||
summary["leds"].append({
|
||||
"path": path,
|
||||
"compatible": compats,
|
||||
"label": decode_cstr(props.get("label", props.get("qcom,led-name", b""))),
|
||||
"trigger": decode_cstr(props.get("linux,default-trigger", b"")),
|
||||
"props": _collect_gpio_props(props),
|
||||
})
|
||||
|
||||
is_batt = (
|
||||
any(k in props for k in (
|
||||
"qcom,batt-type", "qcom,fcc-mah", "qcom,nom-batt-capacity-mah",
|
||||
"qcom,max-voltage-uv", "qcom,pc-temp-ocv-lut",
|
||||
))
|
||||
or "batterydata" in low_path
|
||||
or "bms" in low_path
|
||||
)
|
||||
if is_batt:
|
||||
batt_entry = {
|
||||
"path": path,
|
||||
"compatible": compats,
|
||||
"batt_type": decode_cstr(props.get("qcom,batt-type", b"")),
|
||||
"fcc_mah": decode_u32_list(props.get("qcom,fcc-mah", b"")),
|
||||
"nom_mah": decode_u32_list(props.get("qcom,nom-batt-capacity-mah", b"")),
|
||||
"max_uv": decode_u32_list(props.get("qcom,max-voltage-uv", b"")),
|
||||
}
|
||||
if "qcom,pc-temp-ocv-lut" in props:
|
||||
batt_entry["pc_temp_ocv_lut_bytes"] = len(props["qcom,pc-temp-ocv-lut"])
|
||||
summary["battery"].append(batt_entry)
|
||||
|
||||
has_pa = any(
|
||||
tag in key or tag in low_path or tag in compat_str
|
||||
for key in props
|
||||
for tag in ("spk-amp", "spk-pa", "pa-en", "tfa98", "aw87", "spk_pa")
|
||||
)
|
||||
if has_pa or any(k in props for k in ("qcom,ext-spk-amp-gpio", "ext-spk-amp-gpio")):
|
||||
summary["audio_pa"].append({
|
||||
"path": path,
|
||||
"compatible": compats,
|
||||
"gpios": _collect_gpio_props(props),
|
||||
})
|
||||
|
||||
is_cam = (
|
||||
"qcom,camera" in compat_str
|
||||
or "qcom,eeprom" in compat_str
|
||||
or "qcom,actuator" in compat_str
|
||||
or ("qcom,cam-power-seq-type" in props)
|
||||
or any(tag in low_path for tag in ("/qcom,cam-sensor", "/camera@", "/sensor@"))
|
||||
)
|
||||
if is_cam:
|
||||
summary["cameras"].append({
|
||||
"path": path,
|
||||
"compatible": compats,
|
||||
"label": decode_cstr(props.get("qcom,sensor-name", props.get("qcom,eeprom-name", b""))),
|
||||
"props": _collect_gpio_props(props),
|
||||
"clocks": decode_strlist(props.get("clock-names", b"")),
|
||||
"supplies": [k for k in props if k.endswith("-supply")],
|
||||
})
|
||||
|
||||
return summary
|
||||
|
||||
|
||||
def inspect_android_boot(data):
|
||||
"""Inspect an ANDROID! boot or recovery image."""
|
||||
if len(data) < 608 or data[:8] != BOOT_MAGIC:
|
||||
raise ValueError("not an ANDROID! boot image")
|
||||
fields = struct.unpack_from("<8s9I", data, 0)
|
||||
(
|
||||
_,
|
||||
kernel_size,
|
||||
kernel_addr,
|
||||
ramdisk_size,
|
||||
ramdisk_addr,
|
||||
second_size,
|
||||
second_addr,
|
||||
tags_addr,
|
||||
page_size,
|
||||
dt_size,
|
||||
) = fields
|
||||
cmdline = decode_cstr(data[64:576])
|
||||
|
||||
kernel_off = page_size
|
||||
ramdisk_off = kernel_off + align_up(kernel_size, page_size)
|
||||
second_off = ramdisk_off + align_up(ramdisk_size, page_size)
|
||||
dt_off = second_off + align_up(second_size, page_size)
|
||||
|
||||
result = {
|
||||
"kind": "android-boot",
|
||||
"header": {
|
||||
"kernel_size": kernel_size,
|
||||
"kernel_addr": hex(kernel_addr),
|
||||
"ramdisk_size": ramdisk_size,
|
||||
"ramdisk_addr": hex(ramdisk_addr),
|
||||
"second_size": second_size,
|
||||
"second_addr": hex(second_addr),
|
||||
"tags_addr": hex(tags_addr),
|
||||
"page_size": page_size,
|
||||
"dt_size": dt_size,
|
||||
"cmdline": cmdline,
|
||||
"kernel_offset_0x2c": None,
|
||||
},
|
||||
"qcdt": [],
|
||||
"appended_dtbs": [],
|
||||
}
|
||||
|
||||
if kernel_size >= DTB_OFFSET_FIELD + 4 and kernel_off + kernel_size <= len(data):
|
||||
kernel = data[kernel_off:kernel_off + kernel_size]
|
||||
rel_0x2c = struct.unpack_from("<I", kernel, DTB_OFFSET_FIELD)[0]
|
||||
result["header"]["kernel_offset_0x2c"] = hex(rel_0x2c)
|
||||
for hit, parsed in scan_fdt_blobs(kernel):
|
||||
tag = "appended-0x2c" if hit == rel_0x2c else ("appended@%#x" % hit)
|
||||
result["appended_dtbs"].append(summarize_fdt(parsed, label=tag))
|
||||
|
||||
for section_name, off, sz in (
|
||||
("second", second_off, second_size),
|
||||
("dt", dt_off, dt_size),
|
||||
):
|
||||
if sz >= 12 and off + sz <= len(data):
|
||||
chunk = data[off:off + sz]
|
||||
if chunk[:4] == QCDT_MAGIC:
|
||||
qcdt = parse_qcdt(chunk)
|
||||
qcdt["source"] = section_name
|
||||
result["qcdt"].append(qcdt)
|
||||
else:
|
||||
for hit, parsed in scan_fdt_blobs(chunk):
|
||||
result["appended_dtbs"].append(
|
||||
summarize_fdt(parsed, label="%s@%#x" % (section_name, hit))
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def inspect_aboot_strings(data):
|
||||
"""Extract relevant display, fastboot, and lock strings from stock aboot."""
|
||||
pattern = re.compile(rb"[ -~]{5,}")
|
||||
keywords = (
|
||||
"gc93", "ili9", "st77", "panel", "spi", "blsp", "gpio",
|
||||
"coconut", "beatles", "tough", "qrd", "skub", "oem ",
|
||||
"rpmb", "devinfo", "unlock", "tamper", "fih", "nokia",
|
||||
)
|
||||
seen = []
|
||||
seen_set = set()
|
||||
for match in pattern.finditer(data):
|
||||
text = match.group(0).decode("ascii", "replace")
|
||||
low = text.lower()
|
||||
if any(kw in low for kw in keywords):
|
||||
if text not in seen_set:
|
||||
seen_set.add(text)
|
||||
seen.append(text)
|
||||
if len(seen) >= 120:
|
||||
break
|
||||
return seen
|
||||
|
||||
|
||||
def inspect_path(path):
|
||||
data = open(path, "rb").read()
|
||||
if data[:8] == BOOT_MAGIC:
|
||||
return inspect_android_boot(data)
|
||||
if data[:4] == QCDT_MAGIC:
|
||||
return {"kind": "qcdt", "qcdt": [parse_qcdt(data)], "appended_dtbs": []}
|
||||
if len(data) >= 40 and struct.unpack_from(">I", data, 0)[0] == FDT_MAGIC:
|
||||
return {
|
||||
"kind": "dtb",
|
||||
"qcdt": [],
|
||||
"appended_dtbs": [summarize_fdt(parse_fdt(data, 0), label=os.path.basename(path))],
|
||||
}
|
||||
dtbs = [summarize_fdt(p, label="scan@%#x" % off) for off, p in scan_fdt_blobs(data)]
|
||||
if dtbs:
|
||||
return {"kind": "dtb-scan", "qcdt": [], "appended_dtbs": dtbs}
|
||||
raise ValueError("%s: unknown image format (expected ANDROID!, QCDT, or FDT)" % path)
|
||||
|
||||
|
||||
def _fdt_pack_node(name, props, children, string_table, string_offsets):
|
||||
def str_off(s):
|
||||
if s not in string_offsets:
|
||||
string_offsets[s] = len(string_table)
|
||||
string_table.extend(s.encode("ascii") + b"\0")
|
||||
return string_offsets[s]
|
||||
|
||||
out = bytearray()
|
||||
out.extend(struct.pack(">I", FDT_BEGIN_NODE))
|
||||
raw_name = name.encode("ascii") + b"\0"
|
||||
out.extend(raw_name)
|
||||
out.extend(b"\0" * (align_up(len(raw_name), 4) - len(raw_name)))
|
||||
for key, val in props.items():
|
||||
out.extend(struct.pack(">3I", FDT_PROP, len(val), str_off(key)))
|
||||
out.extend(val)
|
||||
out.extend(b"\0" * (align_up(len(val), 4) - len(val)))
|
||||
for cname, cprops, cchildren in children:
|
||||
out.extend(_fdt_pack_node(cname, cprops, cchildren, string_table, string_offsets))
|
||||
out.extend(struct.pack(">I", FDT_END_NODE))
|
||||
return out
|
||||
|
||||
|
||||
def _build_test_fdt():
|
||||
string_table = bytearray()
|
||||
string_offsets = {}
|
||||
root_props = {
|
||||
"model": b"Nokia 800 Tough\0",
|
||||
"compatible": b"nokia,coconut\0qcom,msm8909\0",
|
||||
"qcom,msm-id": struct.pack(">2I", 0x14b, 0),
|
||||
"qcom,board-id": struct.pack(">2I", 0x1000b, 0x100),
|
||||
"qcom,pmic-id": struct.pack(">4I", 0x1000d, 0, 0, 0),
|
||||
}
|
||||
children = [
|
||||
("memory@80000000", {
|
||||
"device_type": b"memory\0",
|
||||
"reg": struct.pack(">2I", 0x80000000, 0x20000000),
|
||||
}, []),
|
||||
("panel@0", {
|
||||
"compatible": b"qcom,mdss_spi_gc9305_v2_qvga_cmd\0",
|
||||
"spi-max-frequency": struct.pack(">I", 25000000),
|
||||
"dc-gpios": struct.pack(">3I", 1, 110, 0),
|
||||
"qcom,mdss-spi-on-command": b"\x35\x01\x15\x00\x36\x01\x00",
|
||||
}, []),
|
||||
("gpio_keys", {"compatible": b"gpio-keys\0"}, [
|
||||
("flashlight", {
|
||||
"label": b"flashlight\0",
|
||||
"gpios": struct.pack(">3I", 1, 90, 1),
|
||||
"linux,code": struct.pack(">I", 0xf2),
|
||||
}, []),
|
||||
]),
|
||||
("leds", {}, [
|
||||
("torch-flash", {
|
||||
"compatible": b"gpio-leds\0",
|
||||
"label": b"torch-flash\0",
|
||||
"gpios": struct.pack(">3I", 2, 5, 0),
|
||||
}, []),
|
||||
]),
|
||||
]
|
||||
struct_body = _fdt_pack_node("", root_props, children, string_table, string_offsets)
|
||||
struct_body.extend(struct.pack(">I", FDT_END))
|
||||
off_struct = 40
|
||||
off_strings = off_struct + len(struct_body)
|
||||
totalsize = off_strings + len(string_table)
|
||||
header = struct.pack(
|
||||
">10I", FDT_MAGIC, totalsize, off_struct, off_strings,
|
||||
off_struct, 17, 16, 0, len(string_table), len(struct_body),
|
||||
)
|
||||
return header + bytes(struct_body) + bytes(string_table)
|
||||
|
||||
|
||||
def run_self_test():
|
||||
dtb = _build_test_fdt()
|
||||
# Build synthetic QCDT v2
|
||||
qcdt_hdr = struct.pack("<2I", 2, 1)
|
||||
qcdt_entry = struct.pack("<6I", 0x14b, 0x1000b, 0x100, 0x1000d, 12 + 24, len(dtb))
|
||||
qcdt = QCDT_MAGIC + qcdt_hdr + qcdt_entry + dtb
|
||||
|
||||
# Build synthetic ANDROID! boot.img with appended DTB + QCDT in second
|
||||
page = 2048
|
||||
kernel_hdr = bytearray(0x40)
|
||||
struct.pack_into("<I", kernel_hdr, DTB_OFFSET_FIELD, len(kernel_hdr))
|
||||
kernel = bytes(kernel_hdr) + dtb
|
||||
ramdisk = b"RDISK"
|
||||
boot_hdr = bytearray(page)
|
||||
struct.pack_into(
|
||||
"<8s9I", boot_hdr, 0, BOOT_MAGIC,
|
||||
len(kernel), 0x80008000,
|
||||
len(ramdisk), 0x81000000,
|
||||
len(qcdt), 0x80f00000,
|
||||
0x80000100, page, 0,
|
||||
)
|
||||
cmdline = b"console=ttyMSM0,115200,n8\0"
|
||||
boot_hdr[64:64 + len(cmdline)] = cmdline
|
||||
def pad(b):
|
||||
rem = len(b) % page
|
||||
return b + (b"\0" * (page - rem) if rem else b"")
|
||||
img = bytes(boot_hdr) + pad(kernel) + pad(ramdisk) + pad(qcdt)
|
||||
|
||||
res = inspect_android_boot(img)
|
||||
assert res["header"]["kernel_offset_0x2c"] == "0x40", res
|
||||
assert len(res["appended_dtbs"]) == 1, res
|
||||
app = res["appended_dtbs"][0]
|
||||
assert app["model"] == "Nokia 800 Tough", app
|
||||
assert app["qcom_msm_id"] == ["0x14b", "0x0"], app
|
||||
assert app["memory_reg"][0]["reg"] == ["0x80000000", "0x20000000"], app
|
||||
assert app["panels"][0]["spi_max_frequency"] == [25000000], app
|
||||
assert len(app["leds"]) == 1, app
|
||||
assert len(res["qcdt"]) == 1 and res["qcdt"][0]["count"] == 1, res
|
||||
q0 = res["qcdt"][0]["entries"][0]
|
||||
assert q0["chipset"] == 0x14b and q0["fdt"]["model"] == "Nokia 800 Tough", q0
|
||||
print("[ok] inspect-stock-msm8905-dump.py self-test passed")
|
||||
return 0
|
||||
|
||||
|
||||
def print_fdt_summary(s):
|
||||
print(" [%s] %d bytes, %d nodes" % (s["label"], s["totalsize"], s["node_count"]))
|
||||
print(" model : %s" % (s["model"] or "(none)"))
|
||||
print(" compatible : %s" % (", ".join(s["compatible"]) or "(none)"))
|
||||
print(" qcom,msm-id : %s" % (" ".join(s["qcom_msm_id"]) or "(none)"))
|
||||
print(" qcom,board-id: %s" % (" ".join(s["qcom_board_id"]) or "(none)"))
|
||||
print(" qcom,pmic-id: %s" % (" ".join(s["qcom_pmic_id"]) or "(none)"))
|
||||
for mem in s["memory_reg"]:
|
||||
print(" memory : %s -> %s" % (mem["path"], " ".join(mem["reg"])))
|
||||
for p in s["panels"]:
|
||||
print(" panel : %s (%s) freq=%s gpios=%s" % (
|
||||
p["path"], ",".join(p["compatible"]), p["spi_max_frequency"], p["gpios"]))
|
||||
for cname, preview in p["init_cmds"].items():
|
||||
print(" %s: %s" % (cname, preview))
|
||||
for k in s["keypads"]:
|
||||
if k["type"] == "gpio-keys":
|
||||
if k["linux_code"] or k["gpios"]:
|
||||
print(" gpio-key : %s label=%r code=%s gpios=%s" % (
|
||||
k["path"], k["label"], k["linux_code"], k["gpios"]))
|
||||
else:
|
||||
print(" matrix-kp : %s rows=%s cols=%s count=%d sample=%s" % (
|
||||
k["path"], k["rows"], k["cols"], k["keymap_count"], k["keymap_sample"][:12]))
|
||||
for led in s["leds"]:
|
||||
print(" led/flash : %s label=%r compat=%s trigger=%r props=%s" % (
|
||||
led["path"], led["label"], led["compatible"], led["trigger"], led["props"]))
|
||||
for b in s["battery"]:
|
||||
print(" battery/bms : %s type=%r fcc=%s nom=%s max_uv=%s" % (
|
||||
b["path"], b["batt_type"], b["fcc_mah"], b["nom_mah"], b["max_uv"]))
|
||||
for pa in s["audio_pa"]:
|
||||
print(" audio-pa : %s compat=%s gpios=%s" % (
|
||||
pa["path"], pa["compatible"], pa["gpios"]))
|
||||
for cam in s["cameras"]:
|
||||
print(" camera : %s label=%r compat=%s supplies=%s" % (
|
||||
cam["path"], cam["label"], cam["compatible"], cam["supplies"]))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Inspect stock MSM8905/MSM8909 boot, recovery, QCDT, DTB, or aboot dumps"
|
||||
)
|
||||
parser.add_argument("images", nargs="*", help="Paths to boot.img, recovery.img, QCDT, or .dtb files")
|
||||
parser.add_argument("--aboot", default="", help="Optional aboot image to extract panel/fastboot strings")
|
||||
parser.add_argument("--json", action="store_true", help="Emit JSON output")
|
||||
parser.add_argument("--self-test", action="store_true", help="Run built-in synthetic image self-tests")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.self_test:
|
||||
return run_self_test()
|
||||
|
||||
if not args.images and not args.aboot:
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
report = {"images": {}, "aboot_strings": []}
|
||||
for path in args.images:
|
||||
report["images"][path] = inspect_path(path)
|
||||
if args.aboot:
|
||||
report["aboot_strings"] = inspect_aboot_strings(open(args.aboot, "rb").read())
|
||||
|
||||
if args.json:
|
||||
print(json.dumps(report, indent=2))
|
||||
return 0
|
||||
|
||||
for path, info in report["images"].items():
|
||||
print("=== %s (%s) ===" % (path, info["kind"]))
|
||||
hdr = info.get("header")
|
||||
if hdr:
|
||||
print(" page=%d kernel=%d (%s) ramdisk=%d (%s) second=%d dt=%d tags=%s" % (
|
||||
hdr["page_size"], hdr["kernel_size"], hdr["kernel_addr"],
|
||||
hdr["ramdisk_size"], hdr["ramdisk_addr"], hdr["second_size"],
|
||||
hdr["dt_size"], hdr["tags_addr"]))
|
||||
print(" cmdline : %s" % hdr["cmdline"])
|
||||
print(" kernel+0x2c : %s" % hdr["kernel_offset_0x2c"])
|
||||
for dtb_sum in info["appended_dtbs"]:
|
||||
print_fdt_summary(dtb_sum)
|
||||
for qcdt in info["qcdt"]:
|
||||
print(" QCDT v%d (%d entries, source=%s):" % (
|
||||
qcdt["version"], qcdt["count"], qcdt.get("source", "file")))
|
||||
for ent in qcdt["entries"]:
|
||||
print(" [%d] chipset=%#x platform=%#x subtype=%#x rev=%#x pmic=%s off=%#x size=%d" % (
|
||||
ent["index"], ent["chipset"], ent["platform"], ent["subtype"],
|
||||
ent["rev"], [hex(x) for x in ent["pmic"]], ent["offset"], ent["size"]))
|
||||
if ent.get("fdt"):
|
||||
print_fdt_summary(ent["fdt"])
|
||||
|
||||
if report["aboot_strings"]:
|
||||
print("=== aboot strings (%s) ===" % args.aboot)
|
||||
for line in report["aboot_strings"]:
|
||||
print(" %s" % line)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -17,8 +17,8 @@ case "$DEVICE" in
|
||||
nokia-beatles|beatles)
|
||||
DEVICE="nokia-beatles"
|
||||
;;
|
||||
nokia-tough|nokia-coconut|tough|coconut)
|
||||
DEVICE="nokia-tough"
|
||||
nokia-coconut|nokia-tough|coconut|tough)
|
||||
DEVICE="nokia-coconut"
|
||||
;;
|
||||
nokia-sparkler|sparkler)
|
||||
DEVICE="nokia-sparkler"
|
||||
@@ -28,7 +28,7 @@ case "$DEVICE" in
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unsupported device '$DEVICE'." >&2
|
||||
echo "Supported devices: nokia-argon, nokia-beatles, nokia-tough, nokia-sparkler, nokia-leo" >&2
|
||||
echo "Supported devices: nokia-argon, nokia-beatles, nokia-coconut, nokia-sparkler, nokia-leo" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -119,7 +119,7 @@ def validate_cmdline(conf, allow_debug=False):
|
||||
|
||||
|
||||
def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
|
||||
files=None):
|
||||
files=None, dtb_name="qcom-msm8905-nokia-beatles.dtb"):
|
||||
files = files if files is not None else BOOT_FS_FILES
|
||||
raw = open(raw_path, "rb").read(1024 * 1024 + 4096)
|
||||
offset, size = mbr_first_partition(raw)
|
||||
@@ -139,8 +139,8 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
|
||||
dst.write(chunk)
|
||||
left -= len(chunk)
|
||||
conf = cat(fs, "/extlinux/extlinux.conf").decode("utf-8", "replace")
|
||||
if "fdt /qcom-msm8905-nokia-beatles.dtb" not in conf:
|
||||
raise ValueError("extlinux.conf does not name the beatles DTB")
|
||||
if ("fdt /%s" % dtb_name) not in conf:
|
||||
raise ValueError("extlinux.conf does not name %s" % dtb_name)
|
||||
validate_cmdline(conf, allow_debug)
|
||||
for name, expected in files.items():
|
||||
got = sha(cat(fs, "/" + name))
|
||||
@@ -149,7 +149,7 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
|
||||
raise ValueError("/%s in boot fs is stale (%s != %s)" % (name, got[:12], want[:12]))
|
||||
if verbose:
|
||||
print("[ok] pmOS_boot at %#x (%d bytes): ext2 intact, extlinux.conf, "
|
||||
"boot.img and beatles DTB all current" % (offset, size))
|
||||
"boot.img and %s all current" % (offset, size, dtb_name))
|
||||
return offset, size, fs
|
||||
finally:
|
||||
if fs and os.path.exists(fs):
|
||||
@@ -158,7 +158,9 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--raw-image", default=str(BASE_DIR / "images" / "bananarchy-nokia-beatles.img"))
|
||||
parser.add_argument("--device", choices=["nokia-beatles", "nokia-coconut"],
|
||||
default="nokia-beatles")
|
||||
parser.add_argument("--raw-image", default="")
|
||||
parser.add_argument("--source-boot-fs", default="",
|
||||
help="Pristine ext2 boot-fs image to seed from when the "
|
||||
"raw image's superblock is destroyed")
|
||||
@@ -168,32 +170,37 @@ def main():
|
||||
parser.add_argument("--allow-debug", action="store_true",
|
||||
help="With --check, accept a diagnostic cmdline")
|
||||
parser.add_argument("--check", action="store_true")
|
||||
parser.add_argument("--dtb", default=str(BOOT_FS_FILES["qcom-msm8905-nokia-beatles.dtb"]),
|
||||
parser.add_argument("--dtb", default="",
|
||||
help="Override the DTB written to/checked in pmOS_boot")
|
||||
parser.add_argument("--boot-image", default=str(BOOT_FS_FILES["boot.img"]),
|
||||
parser.add_argument("--boot-image", default="",
|
||||
help="Override the boot.img written to/checked in pmOS_boot")
|
||||
args = parser.parse_args()
|
||||
|
||||
dtb = Path(args.dtb)
|
||||
boot_img = Path(args.boot_image)
|
||||
boot_files = dict(BOOT_FS_FILES)
|
||||
boot_files["qcom-msm8905-nokia-beatles.dtb"] = dtb
|
||||
boot_files["boot.img"] = boot_img
|
||||
for path in (args.raw_image, str(dtb), str(boot_img)):
|
||||
dtb_name = "qcom-msm8905-%s.dtb" % args.device
|
||||
raw_image = args.raw_image or str(BASE_DIR / "images" / ("bananarchy-%s.img" % args.device))
|
||||
dtb = Path(args.dtb) if args.dtb else (BASE_DIR / "devices" / args.device / dtb_name)
|
||||
boot_img = Path(args.boot_image) if args.boot_image else (
|
||||
BASE_DIR / "images" / ("boot-bananarchy-%s.img" % args.device)
|
||||
)
|
||||
boot_files = {
|
||||
"boot.img": boot_img,
|
||||
dtb_name: dtb,
|
||||
}
|
||||
for path in (raw_image, str(dtb), str(boot_img)):
|
||||
if not os.path.isfile(path):
|
||||
print("FAIL: missing %s" % path)
|
||||
return 1
|
||||
|
||||
if args.check:
|
||||
try:
|
||||
check(args.raw_image, dtb, boot_img, allow_debug=args.allow_debug,
|
||||
files=boot_files)
|
||||
check(raw_image, dtb, boot_img, allow_debug=args.allow_debug,
|
||||
files=boot_files, dtb_name=dtb_name)
|
||||
return 0
|
||||
except ValueError as exc:
|
||||
print("FAIL: %s" % exc)
|
||||
return 1
|
||||
|
||||
raw = open(args.raw_image, "rb").read(1024 * 1024 + 4096)
|
||||
raw = open(raw_image, "rb").read(1024 * 1024 + 4096)
|
||||
offset, size = mbr_first_partition(raw)
|
||||
with tempfile.NamedTemporaryFile(suffix=".img", delete=False) as handle:
|
||||
fs = handle.name
|
||||
@@ -206,7 +213,7 @@ def main():
|
||||
break
|
||||
dst.write(chunk)
|
||||
else:
|
||||
with open(args.raw_image, "rb") as src, open(fs, "wb") as dst:
|
||||
with open(raw_image, "rb") as src, open(fs, "wb") as dst:
|
||||
src.seek(offset)
|
||||
left = size
|
||||
while left > 0:
|
||||
@@ -245,7 +252,7 @@ def main():
|
||||
if conf_tmp:
|
||||
os.unlink(conf_tmp)
|
||||
|
||||
with open(args.raw_image, "r+b") as dst, open(fs, "rb") as src:
|
||||
with open(raw_image, "r+b") as dst, open(fs, "rb") as src:
|
||||
dst.seek(offset)
|
||||
while True:
|
||||
chunk = src.read(1 << 20)
|
||||
@@ -261,7 +268,7 @@ def main():
|
||||
os.unlink(fs)
|
||||
|
||||
try:
|
||||
check(args.raw_image, dtb, boot_img, files=boot_files)
|
||||
check(raw_image, dtb, boot_img, files=boot_files, dtb_name=dtb_name)
|
||||
except ValueError as exc:
|
||||
print("FAIL: %s" % exc)
|
||||
return 1
|
||||
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host tests for the source-built nokia-coconut lk2nd port.
|
||||
|
||||
Runs the image validator, compiles the shared C panel-init walker against the
|
||||
byte stream extracted from the built QCDT DTB, and verifies repository wiring.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
PINNED = "cf45aefd22d744b2bf9b39455afae697ce430063"
|
||||
|
||||
|
||||
def run(cmd, **kwargs):
|
||||
return subprocess.run(cmd, cwd=BASE, capture_output=True, text=True, **kwargs)
|
||||
|
||||
|
||||
def check(condition, message):
|
||||
if not condition:
|
||||
print("FAIL: %s" % message)
|
||||
return False
|
||||
print("[ok] %s" % message)
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
ok = True
|
||||
validator = os.path.join(BASE, "scripts", "check-lk2nd-coconut.py")
|
||||
build = os.path.join(BASE, "scripts", "build-lk2nd-coconut.sh")
|
||||
base_patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-beatles.patch")
|
||||
patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-coconut.patch")
|
||||
header = os.path.join(BASE, "bootloader", "lk2nd", "spi-panel-init.h")
|
||||
test_c = os.path.join(BASE, "bootloader", "lk2nd", "test_spi_panel_init.c")
|
||||
|
||||
variants = (
|
||||
("images/boot-lk2nd-nokia-coconut.img", 0, 0),
|
||||
("images/boot-lk2nd-nokia-coconut-diagnostic.img", 1, 0),
|
||||
("images/boot-lk2nd-nokia-coconut-display.img", 0, 1),
|
||||
)
|
||||
for image, fastboot, display in variants:
|
||||
ok &= check(os.path.isfile(os.path.join(BASE, image)), "%s exists" % image)
|
||||
if not os.path.isfile(os.path.join(BASE, image)):
|
||||
continue
|
||||
cmd = [sys.executable, validator, "--image", image,
|
||||
"--expect-fastboot", str(fastboot),
|
||||
"--expect-display", str(display)]
|
||||
r = subprocess.run(cmd, cwd=BASE, capture_output=True, text=True)
|
||||
for line in r.stdout.strip().split("\n"):
|
||||
if line:
|
||||
print(line)
|
||||
ok &= check(r.returncode == 0,
|
||||
"%s passes structural validation" % os.path.basename(image))
|
||||
if r.returncode != 0:
|
||||
print(r.stderr.strip())
|
||||
|
||||
for path, label in ((build, "build-lk2nd-coconut.sh"),
|
||||
(base_patch, "nokia-beatles.patch"),
|
||||
(patch, "nokia-coconut.patch"),
|
||||
(header, "spi-panel-init.h"),
|
||||
(test_c, "test_spi_panel_init.c"),
|
||||
(os.path.join(BASE, "bootloader", "lk2nd", "Dockerfile"),
|
||||
"toolchain Dockerfile")):
|
||||
ok &= check(os.path.isfile(path), "%s exists" % label)
|
||||
|
||||
script = open(build).read()
|
||||
ok &= check(PINNED in script, "build script pins upstream commit %s" % PINNED)
|
||||
ok &= check("LK2ND_FORCE_FASTBOOT=1" in script and "lk2nd.no-display" in script,
|
||||
"build script can produce the forced-fastboot no-display diagnostic image")
|
||||
ok &= check("lk2nd.display=on" in script and "--expect-display" in script,
|
||||
"build script can produce and validate the SPI display image")
|
||||
ok &= check("nokia-beatles.patch" in script and "nokia-coconut.patch" in script,
|
||||
"build script layers nokia-coconut.patch on top of nokia-beatles.patch")
|
||||
ok &= check("lk2nd.compatible=nokia,coconut" in script,
|
||||
"build script sets coconut compatible cmdline")
|
||||
|
||||
patch_text = open(patch).read()
|
||||
ok &= check("nokia-coconut.dtsi" in patch_text and
|
||||
"msm8905-qrd-skub.dts" in patch_text and
|
||||
"lk2nd,panel-init" in patch_text and
|
||||
"nokia,coconut" in patch_text,
|
||||
"coconut patch adds device node, panel streams and SPI matching")
|
||||
ok &= check("find_panel_init_in_dev" in patch_text,
|
||||
"coconut patch prefers active compatible panel stream first")
|
||||
|
||||
flasher = open(os.path.join(BASE, "flash-edl.py")).read()
|
||||
ok &= check("images/boot-lk2nd-nokia-coconut-display.img" in flasher,
|
||||
"flasher references the display-enabled coconut lk2nd image")
|
||||
ok &= check('"nokia-coconut": COCONUT_LK2ND_IMAGE' in flasher,
|
||||
"flasher maps nokia-coconut to its source-built lk2nd image")
|
||||
|
||||
preflight = open(os.path.join(BASE, "scripts", "check-rebuild.sh")).read()
|
||||
ok &= check("check-lk2nd-coconut.py" in preflight,
|
||||
"check-rebuild.sh validates the coconut lk2nd images")
|
||||
|
||||
coconut_dts = open(os.path.join(
|
||||
BASE, "devices", "nokia-coconut", "qcom-msm8905-nokia-coconut.dts"
|
||||
)).read()
|
||||
ok &= check(
|
||||
'"gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1"' in coconut_dts and
|
||||
'"gpio52", "gpio56"' not in coconut_dts,
|
||||
"coconut DTS wires stock 6-column keypad GPIOs (gpio0, gpio3, gpio7, gpio99, gpio6, gpio1)"
|
||||
)
|
||||
ok &= check(
|
||||
"0x3030067" in coconut_dts and "0x304006c" in coconut_dts and
|
||||
"0x105000e" in coconut_dts and "0x500d4" in coconut_dts and
|
||||
"linux,code = <0x74>;" in coconut_dts,
|
||||
"coconut DTS includes 22-key 4x6 keymap and end/power key"
|
||||
)
|
||||
resin_block = coconut_dts.split("resin {", 1)[1].split("};", 1)[0]
|
||||
ok &= check(
|
||||
"linux,code = <0x6c>;" in resin_block and "linux,code = <0x72>;" not in resin_block,
|
||||
"coconut DTS maps pm8941_resin to KEY_DOWN (0x6c), not KEY_VOLUMEDOWN"
|
||||
)
|
||||
|
||||
gcc = shutil.which("gcc") or shutil.which("cc")
|
||||
norm_img = os.path.join(BASE, "images", "boot-lk2nd-nokia-coconut.img")
|
||||
if gcc and os.path.isfile(norm_img):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
streams = os.path.join(tmp, "panel_streams.h")
|
||||
r = subprocess.run([sys.executable, validator,
|
||||
"--image", "images/boot-lk2nd-nokia-coconut.img",
|
||||
"--emit-streams-header", streams],
|
||||
cwd=BASE, capture_output=True, text=True)
|
||||
ok &= check(r.returncode == 0, "panel init stream extracted from coconut QCDT DTB")
|
||||
if r.returncode == 0:
|
||||
binary = os.path.join(tmp, "test_spi_panel_init")
|
||||
r = run([gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
|
||||
"-I", tmp, "-I", os.path.join(BASE, "bootloader", "lk2nd"),
|
||||
"-o", binary, test_c])
|
||||
ok &= check(r.returncode == 0,
|
||||
"host C unit test compiles against the shared parser header")
|
||||
if r.returncode == 0:
|
||||
r = run([binary])
|
||||
ok &= check(r.returncode == 0,
|
||||
"host C unit test accepts the coconut GC9305 v2 init stream")
|
||||
elif not gcc:
|
||||
print("[skip] no host C compiler; C unit test skipped")
|
||||
|
||||
print("[%s] nokia-coconut lk2nd port tests" % ("ok" if ok else "FAIL"))
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -16,6 +16,7 @@ YEAR_LETTER="$(printf "\\$(printf '%03o' $(( 97 + LETTER_IDX )))")"
|
||||
VERSION="${BANANARCHY_VERSION:-${YEAR_LETTER}${MONTH}${DAY}}"
|
||||
|
||||
case "$VERSION" in
|
||||
a1120) DEFAULT_CODENAME=cocojamboo ;;
|
||||
a1114) DEFAULT_CODENAME=carbonara ;;
|
||||
a1111) DEFAULT_CODENAME=lennon ;;
|
||||
a1108) DEFAULT_CODENAME=dejavu ;;
|
||||
|
||||
Reference in new issue
Block a user