Bring up nokia-sparkler SMP/cpufreq/lk2nd/cam/haptics, fix timer and EDL USB timeout
- Add 0013 early-SCM 4-core SMP + cpufreq kernel patch and clock-frequency DT nodes - Complete nokia-sparkler lk2nd port, boot/X11 session startup, 180-deg cached camera, and 157 Hz haptic audio - Replace root-only timer backend with permissionless sxmo_timer.sh and keypad/hook cancellation - Fix EDL Firehose rawmode ACK, USB active-config preservation, *+# hint, and 30 s default USB timeout - Sync a1120 (cocojamboo) prebuilts, docs, tests, and verified checksums in check-rebuild.sh
This commit is contained in:
1 parent
ab53423e33
commit
d7992904bf
56 files changed
+31850
-28281
No files matched your search
@@ -193,7 +193,9 @@ EOF
|
||||
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/dwm-plugin
|
||||
|
||||
$CC $OPT_CFLAGS -std=c99 -D_DEFAULT_SOURCE -Wall -Wextra \
|
||||
$(pkgconf --cflags alsa) \
|
||||
/bananarchy/src/dwm-plugins/sxmo_vibrate.c \
|
||||
$(pkgconf --libs alsa) -lm \
|
||||
-o /bananarchy/prebuilt/sxmo-x11/usr/bin/sxmo_vibrate
|
||||
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/sxmo_vibrate
|
||||
|
||||
|
||||
@@ -104,6 +104,10 @@ EOF
|
||||
echo "[2k/5] Applying MSM8909 72h standby Wi-Fi, WCD analog, panel, LDO, and BMS patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch
|
||||
fi
|
||||
if ! grep -q "early_virt" drivers/firmware/qcom/qcom_scm-smc.c 2>/dev/null; then
|
||||
echo "[2l/5] Applying MSM8909 early-SCM SMP boot address and cpufreq patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0013-msm8909-early-scm-smp-cpufreq.patch
|
||||
fi
|
||||
if [ ! -f include/config/auto.conf ] || \
|
||||
! grep -q "CONFIG_NETFILTER_XT_MATCH_OWNER=m" .config 2>/dev/null || \
|
||||
! grep -q "CONFIG_INTERCONNECT_QCOM_MSM8909=y" .config 2>/dev/null || \
|
||||
@@ -150,6 +154,8 @@ EOF
|
||||
patch -p1 < /bananarchy/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch
|
||||
echo "[2k/5] Applying MSM8909 72h standby Wi-Fi, WCD analog, panel, LDO, and BMS patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch
|
||||
echo "[2l/5] Applying MSM8909 early-SCM SMP boot address and cpufreq patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0013-msm8909-early-scm-smp-cpufreq.patch
|
||||
|
||||
echo "[3/5] Preparing kernel configuration and Module.symvers..."
|
||||
cp /bananarchy/patches/kernel/config-bananarchy-msm8909.armv7 .config
|
||||
|
||||
Executable
+164
@@ -0,0 +1,164 @@
|
||||
#!/bin/sh
|
||||
# Build the nokia-sparkler (Nokia 8000 4G) lk2nd boot images from upstream source.
|
||||
#
|
||||
# ./scripts/build-lk2nd-sparkler.sh build normal + diagnostic + display
|
||||
# ./scripts/build-lk2nd-sparkler.sh --check validate the built images only
|
||||
# ./scripts/build-lk2nd-sparkler.sh --only normal build just one variant
|
||||
# ./scripts/build-lk2nd-sparkler.sh --force-panel-init append lk2nd.force-panel-init to
|
||||
# the normal image cmdline
|
||||
# WITH_DISPLAY=1 ./scripts/build-lk2nd-sparkler.sh enable the SPI display during boot
|
||||
#
|
||||
# Applies nokia-beatles.patch, nokia-coconut.patch, and nokia-sparkler.patch cleanly on top
|
||||
# of pinned upstream lk2nd.
|
||||
set -eu
|
||||
|
||||
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||
UPSTREAM=https://github.com/msm8916-mainline/lk2nd.git
|
||||
COMMIT=cf45aefd22d744b2bf9b39455afae697ce430063
|
||||
BEATLES_PATCH="$BASE_DIR/bootloader/lk2nd/nokia-beatles.patch"
|
||||
COCONUT_PATCH="$BASE_DIR/bootloader/lk2nd/nokia-coconut.patch"
|
||||
SPARKLER_PATCH="$BASE_DIR/bootloader/lk2nd/nokia-sparkler.patch"
|
||||
NORMAL_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-sparkler.img"
|
||||
DIAG_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-sparkler-diagnostic.img"
|
||||
DISPLAY_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-sparkler-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,sparkler"
|
||||
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,sparkler lk2nd.no-display"
|
||||
CMD_DISPLAY="lk2nd lk2nd.compatible=nokia,sparkler lk2nd.display=on"
|
||||
|
||||
check_images() {
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-sparkler.py" \
|
||||
--image "$NORMAL_IMAGE" --beatles-patch "$BEATLES_PATCH" \
|
||||
--coconut-patch "$COCONUT_PATCH" --patch "$SPARKLER_PATCH" \
|
||||
--expect-fastboot 0
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-sparkler.py" \
|
||||
--image "$DIAG_IMAGE" --beatles-patch "$BEATLES_PATCH" \
|
||||
--coconut-patch "$COCONUT_PATCH" --patch "$SPARKLER_PATCH" \
|
||||
--expect-fastboot 1
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-sparkler.py" \
|
||||
--image "$DISPLAY_IMAGE" --beatles-patch "$BEATLES_PATCH" \
|
||||
--coconut-patch "$COCONUT_PATCH" --patch "$SPARKLER_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
|
||||
for patch in "$BEATLES_PATCH" "$COCONUT_PATCH" "$SPARKLER_PATCH"; do
|
||||
if [ ! -f "$patch" ]; then
|
||||
echo "[!] missing $patch" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${BANANARCHY_LK2ND_SRC:-}" ]; then
|
||||
SRC=$BANANARCHY_LK2ND_SRC
|
||||
else
|
||||
SRC="$BUILD_DIR/src"
|
||||
mkdir -p "$BUILD_DIR"
|
||||
if [ ! -d "$SRC/.git" ]; then
|
||||
git init -q "$SRC"
|
||||
git -C "$SRC" remote add origin "$UPSTREAM"
|
||||
fi
|
||||
head=$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)
|
||||
if [ "$head" != "$COMMIT" ]; then
|
||||
echo "[*] fetching upstream lk2nd at $COMMIT"
|
||||
git -C "$SRC" fetch --depth 1 origin "$COMMIT"
|
||||
git -C "$SRC" checkout -q FETCH_HEAD
|
||||
fi
|
||||
git -C "$SRC" reset --hard -q HEAD
|
||||
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
|
||||
|
||||
apply_patch() {
|
||||
label=$1
|
||||
patch=$2
|
||||
if git -C "$SRC" apply --check --reverse "$patch" 2>/dev/null; then
|
||||
echo "[*] $label patch already applied"
|
||||
else
|
||||
echo "[*] applying $label patch"
|
||||
git -C "$SRC" apply --check "$patch"
|
||||
git -C "$SRC" apply "$patch"
|
||||
fi
|
||||
}
|
||||
|
||||
apply_patch "nokia-beatles" "$BEATLES_PATCH"
|
||||
apply_patch "nokia-coconut" "$COCONUT_PATCH"
|
||||
apply_patch "nokia-sparkler" "$SPARKLER_PATCH"
|
||||
# Keep the standalone header copy synchronized if built from a clean clone.
|
||||
cp "$BASE_DIR/bootloader/lk2nd/spi-panel-init.h" "$SRC/lk2nd/include/lk2nd/spi-panel-init.h"
|
||||
|
||||
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-sparkler-a1120-r1 "" "$CMD_BASE" "$NORMAL_IMAGE"
|
||||
fi
|
||||
if [ "$ONLY" = all ] || [ "$ONLY" = diagnostic ]; then
|
||||
build_variant diagnostic bananarchy-sparkler-a1120-diag-r1 \
|
||||
"DEBUG=2 LK2ND_FORCE_FASTBOOT=1" "$CMD_DIAG" "$DIAG_IMAGE"
|
||||
fi
|
||||
if [ "$ONLY" = all ] || [ "$ONLY" = display ]; then
|
||||
build_variant display bananarchy-sparkler-a1120-display-r1 "" "$CMD_DISPLAY" "$DISPLAY_IMAGE"
|
||||
fi
|
||||
|
||||
check_images
|
||||
@@ -27,14 +27,37 @@ 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",
|
||||
DEVICE_SPECS = {
|
||||
"nokia-beatles": {
|
||||
"model": "Nokia 2720 Flip",
|
||||
"short": "2720",
|
||||
"compatible": b"nokia,beatles",
|
||||
"msm_id": STOCK_MSM_ID,
|
||||
"board_id": STOCK_BOARD_ID,
|
||||
"pmic_id": STOCK_PMIC_ID,
|
||||
"addrs": (0x80008000, 0x81000000, 0x80000100),
|
||||
},
|
||||
"nokia-coconut": {
|
||||
"model": "Nokia 800 Tough",
|
||||
"short": "800 Tough",
|
||||
"compatible": b"nokia,coconut",
|
||||
"msm_id": STOCK_MSM_ID,
|
||||
"board_id": STOCK_BOARD_ID,
|
||||
"pmic_id": STOCK_PMIC_ID,
|
||||
"addrs": (0x80008000, 0x81000000, 0x80000100),
|
||||
},
|
||||
"nokia-sparkler": {
|
||||
"model": "Nokia 8000 4G",
|
||||
"short": "8000 4G",
|
||||
"compatible": b"nokia,sparkler",
|
||||
"msm_id": struct.pack(">2I", 0xf5, 0),
|
||||
"board_id": struct.pack(">2I", 0x8, 0x100),
|
||||
"pmic_id": STOCK_PMIC_ID,
|
||||
"addrs": (0x80008000, 0x82700000, 0x82500000),
|
||||
},
|
||||
}
|
||||
DEVICE_MODELS = {dev: spec["model"] for dev, spec in DEVICE_SPECS.items()}
|
||||
DEVICE_SHORT = {dev: spec["short"] for dev, spec in DEVICE_SPECS.items()}
|
||||
|
||||
|
||||
def align(value, page):
|
||||
@@ -110,8 +133,9 @@ def parse_args():
|
||||
def main():
|
||||
args = parse_args()
|
||||
device = args.device
|
||||
short_name = DEVICE_SHORT[device]
|
||||
expected_model = DEVICE_MODELS[device]
|
||||
spec = DEVICE_SPECS[device]
|
||||
short_name = spec["short"]
|
||||
expected_model = spec["model"]
|
||||
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
boot = args.image or os.path.join(base, "images", "boot-bananarchy-%s.img" % device)
|
||||
if not os.path.isfile(boot):
|
||||
@@ -137,7 +161,7 @@ def main():
|
||||
for flag in ("loglevel=8", "ignore_loglevel", "initcall_debug"):
|
||||
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:
|
||||
if (kernel_addr, ramdisk_addr, tags_addr) != spec["addrs"]:
|
||||
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]
|
||||
@@ -155,11 +179,14 @@ def main():
|
||||
model = root.get("model", b"").rstrip(b"\0").decode("utf-8", "replace")
|
||||
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)):
|
||||
compat_tokens = [c for c in root.get("compatible", b"").split(b"\0") if c]
|
||||
if spec["compatible"] not in compat_tokens:
|
||||
problems.append("appended DTB compatible %r lacks %r" % (compat_tokens, spec["compatible"]))
|
||||
for prop, expected in (("qcom,msm-id", spec["msm_id"]),
|
||||
("qcom,board-id", spec["board_id"]),
|
||||
("qcom,pmic-id", spec["pmic_id"])):
|
||||
if root.get(prop) != expected:
|
||||
problems.append("%s does not match the stock %s QRD SKUB value" % (prop, short_name))
|
||||
problems.append("%s does not match the expected %s value" % (prop, short_name))
|
||||
mem = None
|
||||
for path, props in nodes.items():
|
||||
if props.get("device_type") == b"memory\0":
|
||||
|
||||
Executable
+469
@@ -0,0 +1,469 @@
|
||||
#!/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 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"))
|
||||
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/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())
|
||||
+175
-15
@@ -179,12 +179,22 @@ for module in usb gpt sahara firehose utils; do
|
||||
fail "missing vendor/edl/Library/$module.py"
|
||||
fi
|
||||
done
|
||||
if [ ! -f "$BASE_DIR/vendor/edl/LICENSE" ]; then
|
||||
fail "missing vendor/edl/LICENSE"
|
||||
for f in vendor/edl/LICENSE scripts/test-edl-firehose-read.py; do
|
||||
if [ ! -f "$BASE_DIR/$f" ]; then
|
||||
fail "missing $f"
|
||||
fi
|
||||
done
|
||||
if ! python3 "$BASE_DIR/scripts/test-edl-firehose-read.py" >/dev/null 2>&1; then
|
||||
fail "Firehose rawmode read regression tests failed"
|
||||
fi
|
||||
if ! grep -q '^from Library\.sahara import qualcomm_sahara$' "$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py is missing the Sahara client import"
|
||||
fi
|
||||
if ! grep -qF 'DEFAULT_USB_TIMEOUT_MS = 30000' "$BASE_DIR/vendor/edl/Library/usb.py" || \
|
||||
! grep -qF 'DEFAULT_USB_IO_TIMEOUT_SEC = 30' "$BASE_DIR/flash-edl.py" || \
|
||||
! grep -qF '"--usb-timeout"' "$BASE_DIR/flash-edl.py"; then
|
||||
fail "EDL flasher USB transfer timeout defaults (30s) regressed"
|
||||
fi
|
||||
|
||||
echo "[check] Device-specific EDL Firehose loaders..."
|
||||
if ! grep -q '^DEVICE_LOADERS = {' "$BASE_DIR/flash-edl.py"; then
|
||||
@@ -286,6 +296,7 @@ if ! grep -qF 'target_names = ("boot", "recovery", "lk2nd")' \
|
||||
fi
|
||||
for f in bootloader/lk2nd/nokia-beatles.patch \
|
||||
bootloader/lk2nd/nokia-coconut.patch \
|
||||
bootloader/lk2nd/nokia-sparkler.patch \
|
||||
bootloader/lk2nd/README.md \
|
||||
bootloader/lk2nd/spi-panel-init.h \
|
||||
bootloader/lk2nd/Dockerfile \
|
||||
@@ -294,6 +305,10 @@ for f in bootloader/lk2nd/nokia-beatles.patch \
|
||||
scripts/build-lk2nd-coconut.sh \
|
||||
scripts/check-lk2nd-coconut.py \
|
||||
scripts/test-lk2nd-coconut-port.py \
|
||||
scripts/build-lk2nd-sparkler.sh \
|
||||
scripts/check-lk2nd-sparkler.py \
|
||||
scripts/test-lk2nd-sparkler-port.py \
|
||||
scripts/test-sparkler-port.py \
|
||||
scripts/inspect-stock-msm8905-dump.py; do
|
||||
if [ ! -f "$BASE_DIR/$f" ]; then
|
||||
fail "missing lk2nd port / inspection file: $f"
|
||||
@@ -303,6 +318,10 @@ if ! grep -qF 'COCONUT_LK2ND_IMAGE = "images/boot-lk2nd-nokia-coconut-display.im
|
||||
"$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py no longer references the display-enabled coconut lk2nd image"
|
||||
fi
|
||||
if ! grep -qF 'SPARKLER_LK2ND_IMAGE = "images/boot-lk2nd-nokia-sparkler-display.img"' \
|
||||
"$BASE_DIR/flash-edl.py"; then
|
||||
fail "flash-edl.py no longer references the display-enabled sparkler lk2nd image"
|
||||
fi
|
||||
for variant in normal diagnostic display; do
|
||||
case "$variant" in
|
||||
normal)
|
||||
@@ -331,6 +350,34 @@ for variant in normal diagnostic display; do
|
||||
fail "$label validation failed"
|
||||
fi
|
||||
done
|
||||
for variant in normal diagnostic display; do
|
||||
case "$variant" in
|
||||
normal)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-sparkler.img"
|
||||
opts="--expect-fastboot 0"
|
||||
label="source-built nokia-sparkler lk2nd"
|
||||
;;
|
||||
diagnostic)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-sparkler-diagnostic.img"
|
||||
opts="--expect-fastboot 1"
|
||||
label="nokia-sparkler forced-fastboot diagnostic image"
|
||||
;;
|
||||
display)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-sparkler-display.img"
|
||||
opts="--expect-fastboot 0 --expect-display 1"
|
||||
label="nokia-sparkler 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-sparkler.py" \
|
||||
--image "$image" $opts; then
|
||||
fail "$label validation failed"
|
||||
fi
|
||||
done
|
||||
if [ -f "$BASE_DIR/scripts/make-beatles-lk2nd-bootimg.py" ]; then
|
||||
fail "obsolete binary-patch lk2nd script is still present"
|
||||
fi
|
||||
@@ -434,13 +481,16 @@ fi
|
||||
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"8444544b0395c5bdef2f76b87721a99c326a868465d8236e85ff5572e7634cc0 images/bananarchy-nokia-argon.img" \
|
||||
"7749caec22f5803112d21d24f032c09162bc7e6a239beabddb903272ebbd79c8 images/bananarchy-nokia-beatles.img" \
|
||||
"cc58d92e6a54eab77f355a148cbc0b424d2da64e65353e3163a9cfc1eba37235 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"82f617e425fa9d33b1395c4e35639a6207e3c9d0aa376c7cedf35fddaccb5cc2 images/bananarchy-nokia-argon.img" \
|
||||
"cc40c682fcdacb6415c112494344826362de2f965e6238685462859de66d660e images/bananarchy-nokia-beatles.img" \
|
||||
"786e9a1f4e4ae92efc948393a1d8f04a9405840a214b6ef37914cf5821d7ed82 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
|
||||
"e82d64bd9f14b1fcca2c078e9fd43a4c4268b29ff688f268b32a939213be0545 images/bananarchy-nokia-coconut.img" \
|
||||
"55299e15abe5923fc525b4e54e81aa4791f0e61f8a070e84fe7497f75c62d7d7 images/boot-bananarchy-nokia-coconut.img" \
|
||||
"e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a images/boot-lk2nd-nokia-coconut-display.img" \
|
||||
"5dc17319742e4af95facc42681f0fe6fb2e80ddf30f421f3c54b9dbe04fefd3f images/bananarchy-nokia-sparkler.img" \
|
||||
"8205e2cb486d8ecc1e261a5c0b6f9ee7f70fd4eed2534d5bafc28ebc62d953d8 images/boot-bananarchy-nokia-sparkler.img" \
|
||||
"bc41c2ddd1079246a7e91a40222fcafb82b0b52965c8ee8081872767d006748f images/boot-lk2nd-nokia-sparkler-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
path="$BASE_DIR/$2"
|
||||
@@ -558,11 +608,13 @@ if ! grep -q 'msm8905-cam' "$BASE_DIR/overlay/rootfs/etc/local.d/10-bananarchy-h
|
||||
fail "the local.d hardware fallback no longer loads the camera driver"
|
||||
fi
|
||||
CAM_DRIVER="$BASE_DIR/src/msm8905-cam/msm8905-cam.c"
|
||||
if ! grep -qF 'cam->rotate_180 = of_machine_is_compatible("nokia,beatles");' \
|
||||
"$CAM_DRIVER" || \
|
||||
if ! grep -qF 'of_machine_is_compatible("nokia,beatles")' "$CAM_DRIVER" || \
|
||||
! grep -qF 'of_machine_is_compatible("nokia,sparkler")' "$CAM_DRIVER" || \
|
||||
! grep -qF 'of_machine_is_compatible("nokia,leo")' "$CAM_DRIVER" || \
|
||||
! grep -qF 'row_buf' "$CAM_DRIVER" || \
|
||||
! grep -qF 'msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb, cam->rotate_180);' \
|
||||
"$CAM_DRIVER"; then
|
||||
fail "the beatles-only 180-degree camera orientation correction is missing"
|
||||
fail "msm8905-cam orientation (beatles/sparkler/leo) or cached-row demosaic check failed"
|
||||
fi
|
||||
if [ ! -f "$BASE_DIR/scripts/busybox-sbin-applets.txt" ] || \
|
||||
! grep -qxF 'reboot' "$BASE_DIR/scripts/busybox-sbin-applets.txt"; then
|
||||
@@ -809,6 +861,40 @@ else
|
||||
echo "[skip] local build output images/bananarchy-nokia-coconut.img is absent; prepare-release.sh will rebuild it"
|
||||
fi
|
||||
|
||||
echo "[check] 8000 4G (nokia-sparkler) appended DTB..."
|
||||
SPARKLER_DTS="$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts"
|
||||
if ! grep -qF 'qcom,msm-id = <0xf5 0x00>;' "$SPARKLER_DTS"; then
|
||||
fail "nokia-sparkler DTS lost the stock MSM8909 msm-id"
|
||||
fi
|
||||
if ! grep -qF 'qcom,board-id = <0x08 0x100>;' "$SPARKLER_DTS"; then
|
||||
fail "nokia-sparkler DTS lost the stock MTP board-id"
|
||||
fi
|
||||
if ! grep -qF 'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;' "$SPARKLER_DTS"; then
|
||||
fail "nokia-sparkler DTS lost the stock pmic-id"
|
||||
fi
|
||||
if ! grep -qF 'reg = <0x80000000 0x20000000>;' "$SPARKLER_DTS"; then
|
||||
fail "nokia-sparkler DTS lost the 512 MiB memory fallback"
|
||||
fi
|
||||
for node in 'sound@7702000' 'vibrator@c000' 'audio-codec@f000'; do
|
||||
if ! grep -qF "$node" "$SPARKLER_DTS"; then
|
||||
fail "nokia-sparkler DTS is missing $node"
|
||||
fi
|
||||
done
|
||||
if [ -f "$BASE_DIR/images/boot-bananarchy-nokia-sparkler.img" ]; then
|
||||
if ! python3 "$BASE_DIR/scripts/check-beatles-bootimg.py" --device nokia-sparkler; then
|
||||
fail "8000 4G boot image validation failed"
|
||||
fi
|
||||
else
|
||||
echo "[skip] local build output images/boot-bananarchy-nokia-sparkler.img is absent; prepare-release.sh will rebuild it"
|
||||
fi
|
||||
if [ -f "$BASE_DIR/images/bananarchy-nokia-sparkler.img" ]; then
|
||||
if ! python3 "$BASE_DIR/scripts/sync-beatles-bootfs.py" --check --device nokia-sparkler --raw-image "$BASE_DIR/images/bananarchy-nokia-sparkler.img"; then
|
||||
fail "8000 4G raw image pmOS_boot filesystem is damaged or stale"
|
||||
fi
|
||||
else
|
||||
echo "[skip] local build output images/bananarchy-nokia-sparkler.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" \
|
||||
@@ -977,7 +1063,7 @@ fi
|
||||
if grep -qE '"\$\{?BASE_DIR\}?/prebuilt/kernel-6\.12\.1-msm8916/(leds|camera)/"\*\.ko\*' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
|
||||
fail "apply-bananarchy-overlay.sh still copies uncompressed .ko files via *.ko* wildcard"
|
||||
fi
|
||||
for dev_img in images/bananarchy-nokia-argon.img images/bananarchy-nokia-beatles.img; do
|
||||
for dev_img in images/bananarchy-nokia-argon.img images/bananarchy-nokia-beatles.img images/bananarchy-nokia-coconut.img images/bananarchy-nokia-sparkler.img; do
|
||||
if [ ! -f "$BASE_DIR/$dev_img" ]; then
|
||||
echo "[skip] local build output $dev_img is absent; skipping initramfs depmod check"
|
||||
continue
|
||||
@@ -1493,7 +1579,8 @@ 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"; do
|
||||
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
|
||||
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.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
|
||||
@@ -1507,13 +1594,16 @@ for q6cfg in \
|
||||
done
|
||||
if [ ! -f "$BASE_DIR/patches/kernel/0010-msm8909-rpm-lpm-bimc-wcd-ldo-uart.patch" ] || \
|
||||
! grep -qF '0010-msm8909-rpm-lpm-bimc-wcd-ldo-uart.patch' "$BASE_DIR/scripts/build-kernel-audio.sh" || \
|
||||
[ ! -f "$BASE_DIR/patches/kernel/0013-msm8909-early-scm-smp-cpufreq.patch" ] || \
|
||||
! grep -qF '0013-msm8909-early-scm-smp-cpufreq.patch' "$BASE_DIR/scripts/build-kernel-audio.sh" || \
|
||||
! grep -qxF 'CONFIG_QCOM_RPM_MASTER_STATS=y' "$BASE_DIR/patches/kernel/config-bananarchy-msm8909.armv7" || \
|
||||
! grep -qxF 'CONFIG_QCOM_RPM_MASTER_STATS=y' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/kernel-config" || \
|
||||
! grep -q ' qcom_mpm_enter_sleep$' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map" || \
|
||||
! grep -q ' spm_get_l2_device$' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map" || \
|
||||
! grep -q ' qcom_msm8909_gdsc_is_active$' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map" || \
|
||||
! grep -q ' qcom_iommu_resume$' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map"; then
|
||||
fail "deep-standby kernel patch 0010, RPM master stats config, or vMPM/L2-SAW/IOMMU symbols are missing"
|
||||
! grep -q ' qcom_iommu_resume$' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map" || \
|
||||
! grep -q ' qcom_scm_set_boot_addr_mc$' "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map"; then
|
||||
fail "deep-standby kernel patch 0010/0013, RPM master stats config, or vMPM/L2-SAW/IOMMU/early-SCM symbols are missing"
|
||||
fi
|
||||
for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
@@ -2240,6 +2330,76 @@ if ! grep -qF 'of_machine_is_compatible("nokia,coconut")' "$TORCH_SRC" || \
|
||||
fail "nokia-coconut dual LED separation (GPIO_13 white:torch vs GPIO_32 camera:flash) is incomplete"
|
||||
fi
|
||||
|
||||
echo "[check] Nokia 8000 4G (nokia-sparkler) keypad, audio, initfs, DRM & dual-GPIO torch invariants..."
|
||||
SPARKLER_DEVINFO="$BASE_DIR/devices/nokia-sparkler/deviceinfo"
|
||||
SPARKLER_INITFS="$BASE_DIR/devices/nokia-sparkler/modules-initfs"
|
||||
SPARKLER_DTB="$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb"
|
||||
TORCH_KO="$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko"
|
||||
if ! grep -qxF 'deviceinfo_drm="true"' "$SPARKLER_DEVINFO"; then
|
||||
fail "devices/nokia-sparkler/deviceinfo must set deviceinfo_drm=\"true\""
|
||||
fi
|
||||
if ! grep -qxF 'matrix_keypad' "$SPARKLER_INITFS" || \
|
||||
! grep -qxF 'matrix_keymap' "$SPARKLER_INITFS"; then
|
||||
fail "devices/nokia-sparkler/modules-initfs must include matrix_keypad and matrix_keymap"
|
||||
fi
|
||||
if ! grep -qF '0x500d4' "$SPARKLER_DTS" || \
|
||||
! grep -qF '0x100007f' "$SPARKLER_DTS" || \
|
||||
! grep -qF '0x205000e' "$SPARKLER_DTS" || \
|
||||
! grep -qF '0x301009e' "$SPARKLER_DTS" || \
|
||||
! grep -qF 'clock-frequency = <1094400000>;' "$SPARKLER_DTS" || \
|
||||
! awk '/vibrator@c000 \{/,/\};/ { if ($0 ~ /status = "disabled";/) found=1 } END { exit(found ? 0 : 1) }' "$SPARKLER_DTS" || \
|
||||
grep -qE '0x5008b|0x10002b8|0x20501be|0x30102b9' "$SPARKLER_DTS"; then
|
||||
fail "devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts drifted from Sxmo keypad, CPU clock, or haptic invariants"
|
||||
fi
|
||||
if command -v dtc >/dev/null 2>&1 && [ -f "$SPARKLER_DTB" ]; then
|
||||
dec_sparkler="$(dtc -q -I dtb -O dts "$SPARKLER_DTB" 2>/dev/null || true)"
|
||||
if ! printf "%s\n" "$dec_sparkler" | grep -qF 'qcom,msm-id = <0xf5 0x00>;' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF 'qcom,board-id = <0x08 0x100>;' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF 'reg = <0x80000000 0x20000000>;' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF 'sound@7702000' || \
|
||||
! printf "%s\n" "$dec_sparkler" | \
|
||||
awk '/vibrator@c000 \{/,/\};/ { if ($0 ~ /status = "disabled";/) found=1 } END { exit(found ? 0 : 1) }' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF 'audio-codec@f000' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF '0x500d4' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF '0x100007f' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF '0x205000e' || \
|
||||
! printf "%s\n" "$dec_sparkler" | grep -qF '0x301009e' || \
|
||||
printf "%s\n" "$dec_sparkler" | grep -qE '0x5008b|0x10002b8|0x20501be|0x30102b9'
|
||||
then
|
||||
fail "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb drifted from Sparkler DTS invariants"
|
||||
fi
|
||||
fi
|
||||
if ! grep -qF 'vibrate_haptic_audio' "$BASE_DIR/src/dwm-plugins/sxmo_vibrate.c" || \
|
||||
! grep -qF '157.0' "$BASE_DIR/src/dwm-plugins/sxmo_vibrate.c" || \
|
||||
! grep -qF 'nokia,sparkler' "$BASE_DIR/src/dwm-plugins/sxmo_vibrate.c"; then
|
||||
fail "sxmo_vibrate.c lost 157 Hz haptic audio support for nokia-sparkler"
|
||||
fi
|
||||
if ! grep -qF 'of_machine_is_compatible("nokia,sparkler")' "$TORCH_SRC" || \
|
||||
! grep -qF 'MSM8905_TLMM_GPIO31_PHYS' "$TORCH_SRC" || \
|
||||
{ [ -f "$TORCH_KO" ] && ! grep -qaF 'GPIO_32/GPIO_31 (BC847BS)' "$TORCH_KO"; }; then
|
||||
fail "nokia-sparkler dual-GPIO BC847BS torch support in leds-msm8905-torch is incomplete"
|
||||
fi
|
||||
|
||||
echo "[check] Universal keypad-friendly timer (sxmo_timer.sh, dmenu, hooks)..."
|
||||
TIMER_SH="$BASE_DIR/overlay/rootfs/usr/bin/sxmo_timer.sh"
|
||||
if [ ! -x "$TIMER_SH" ] || ! sh -n "$TIMER_SH" 2>/dev/null; then
|
||||
fail "overlay/rootfs/usr/bin/sxmo_timer.sh is missing, not executable, or has invalid syntax"
|
||||
fi
|
||||
if grep -qE 'boottime_alarm|pkill' "$TIMER_SH" || \
|
||||
! grep -qF '# title="$icon_clk Timer"' "$TIMER_SH" || \
|
||||
! grep -qF 'HUP INT TERM EXIT' "$TIMER_SH" || \
|
||||
! grep -qF 'stop_ringing()' "$TIMER_SH"; then
|
||||
fail "overlay/rootfs/usr/bin/sxmo_timer.sh failed permissionless/cancellation invariants"
|
||||
fi
|
||||
if ! grep -qF 'timer_menu_state' "$DMENU_SRC" || \
|
||||
! grep -qF '/usr/bin/sxmo_timer.sh stop_ringing' "$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_mute_ring.sh" || \
|
||||
! grep -qF '/usr/bin/sxmo_timer.sh stop_ringing' "$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_discard.sh"; then
|
||||
fail "dmenu or ring mute/discard hooks are missing timer stop integration"
|
||||
fi
|
||||
if ! python3 "$BASE_DIR/scripts/test-timer.py" >/dev/null 2>&1; then
|
||||
fail "scripts/test-timer.py failed"
|
||||
fi
|
||||
|
||||
if [ "$FAILURES" -ne 0 ]; then
|
||||
echo "[check] $FAILURES check(s) failed."
|
||||
exit 1
|
||||
|
||||
@@ -31,6 +31,11 @@ BOOT_FS_FILES = {
|
||||
"qcom-msm8905-nokia-beatles.dtb":
|
||||
BASE_DIR / "devices" / "nokia-beatles" / "qcom-msm8905-nokia-beatles.dtb",
|
||||
}
|
||||
DEVICE_DTB_NAMES = {
|
||||
"nokia-beatles": "qcom-msm8905-nokia-beatles.dtb",
|
||||
"nokia-coconut": "qcom-msm8905-nokia-coconut.dtb",
|
||||
"nokia-sparkler": "qcom-msm8909-nokia-sparkler.dtb",
|
||||
}
|
||||
DEBUG_PREFIX = "loglevel=8 ignore_loglevel initcall_debug panic=10"
|
||||
QUIET_PREFIX = "quiet splash"
|
||||
BOOT_CMD_FLAGS = "plymouth.ignore-serial-consoles plymouth.prefer-fbcon"
|
||||
@@ -158,7 +163,7 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--device", choices=["nokia-beatles", "nokia-coconut"],
|
||||
parser.add_argument("--device", choices=tuple(DEVICE_DTB_NAMES.keys()),
|
||||
default="nokia-beatles")
|
||||
parser.add_argument("--raw-image", default="")
|
||||
parser.add_argument("--source-boot-fs", default="",
|
||||
@@ -176,7 +181,7 @@ def main():
|
||||
help="Override the boot.img written to/checked in pmOS_boot")
|
||||
args = parser.parse_args()
|
||||
|
||||
dtb_name = "qcom-msm8905-%s.dtb" % args.device
|
||||
dtb_name = DEVICE_DTB_NAMES[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 (
|
||||
|
||||
Executable
+268
@@ -0,0 +1,268 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Offline tests for Firehose <read> handling across 8k/2720v and FIH loaders."""
|
||||
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.join(BASE_DIR, "vendor", "edl"))
|
||||
|
||||
import Library.firehose as firehose_mod # noqa: E402
|
||||
import Library.usb as usb_mod # noqa: E402
|
||||
from Library.firehose import qualcomm_firehose, xmlparser # noqa: E402
|
||||
from Library.gpt import gpt # noqa: E402
|
||||
from Library.usb import usb_class # noqa: E402
|
||||
|
||||
|
||||
def build_synthetic_gpt(sectors=32):
|
||||
"""Construct a 32-sector raw GPT image containing boot and userdata entries."""
|
||||
buf = bytearray(sectors * 512)
|
||||
# Protective MBR signature at LBA 0
|
||||
buf[510:512] = b"\x55\xaa"
|
||||
# GPT header at LBA 1 (revision 0x00010000 LE == 0x100 BE)
|
||||
header = struct.pack(
|
||||
"<8s4I4Q16sQ2I",
|
||||
b"EFI PART",
|
||||
0x00010000,
|
||||
92,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1023,
|
||||
34,
|
||||
1000,
|
||||
b"\x11" * 16,
|
||||
2,
|
||||
4,
|
||||
128,
|
||||
)
|
||||
buf[512:512 + len(header)] = header
|
||||
# Partition entries starting at LBA 2 (offset 1024)
|
||||
entries = [
|
||||
("boot", 34, 97),
|
||||
("userdata", 100, 999),
|
||||
]
|
||||
for idx, (name, first_lba, last_lba) in enumerate(entries):
|
||||
off = 1024 + idx * 128
|
||||
ptype = struct.pack("<I", 0xEBD0A0A2) + b"\x00" * 12
|
||||
puniq = bytes([idx + 1]) * 16
|
||||
pname = name.encode("utf-16-le").ljust(72, b"\x00")
|
||||
entry = struct.pack("<16s16s3Q72s", ptype, puniq, first_lba, last_lba, 0, pname)
|
||||
buf[off:off + 128] = entry
|
||||
return bytes(buf)
|
||||
|
||||
|
||||
class FakeCdc:
|
||||
def __init__(self, rx_packets):
|
||||
self.rx_packets = [bytearray(pkt) for pkt in rx_packets]
|
||||
self.tx_packets = []
|
||||
self.read_lengths = []
|
||||
|
||||
def write(self, data, pktsize=64, timeout=None):
|
||||
self.tx_packets.append((bytes(data) if not isinstance(data, str) else data.encode("utf-8"), pktsize))
|
||||
|
||||
def read(self, length=0x80000, timeout=None):
|
||||
self.read_lengths.append(length)
|
||||
if not self.rx_packets:
|
||||
return bytearray()
|
||||
pkt = self.rx_packets.pop(0)
|
||||
if len(pkt) <= length:
|
||||
return pkt
|
||||
out = pkt[:length]
|
||||
self.rx_packets.insert(0, pkt[length:])
|
||||
return out
|
||||
|
||||
|
||||
class TestEdlFirehoseRead(unittest.TestCase):
|
||||
def _make_fh(self, rx_packets, max_payload=1048576):
|
||||
cfg = qualcomm_firehose.cfg()
|
||||
cfg.MemoryName = "eMMC"
|
||||
cfg.SECTOR_SIZE_IN_BYTES = 512
|
||||
cfg.MaxPayloadSizeToTargetInBytes = max_payload
|
||||
cfg.MaxXMLSizeInBytes = 4096
|
||||
cdc = FakeCdc(rx_packets)
|
||||
return qualcomm_firehose(cdc, xmlparser(), cfg), cdc
|
||||
|
||||
def test_8k_rawmode_ack_gpt_parse(self):
|
||||
gpt_bytes = build_synthetic_gpt(32)
|
||||
rx = [
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><log value="start 0, num 32" /></data>',
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><response value="ACK" rawmode="true" /></data>\x00',
|
||||
gpt_bytes[:8192],
|
||||
gpt_bytes[8192:],
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><log value="Finished sector address 32" /></data>',
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><response value="ACK" rawmode="false" /></data>',
|
||||
]
|
||||
fh, cdc = self._make_fh(rx)
|
||||
with mock.patch.object(firehose_mod.time, "sleep"):
|
||||
got = fh.cmd_read_buffer(0, 0, 32, Display=False)
|
||||
self.assertEqual(bytes(got), gpt_bytes)
|
||||
table = gpt()
|
||||
self.assertTrue(table.parse(got, 512))
|
||||
self.assertEqual([e.name for e in table.partentries], ["boot", "userdata"])
|
||||
# Check raw reads never ask for more than remaining bytes (16 KiB here).
|
||||
self.assertEqual(cdc.read_lengths[0], 16384)
|
||||
self.assertEqual(cdc.read_lengths[1], 16384)
|
||||
self.assertEqual(cdc.read_lengths[2], 16384)
|
||||
self.assertEqual(cdc.read_lengths[3], 8192)
|
||||
|
||||
def test_fih_immediate_raw_gpt_parse(self):
|
||||
gpt_bytes = build_synthetic_gpt(32)
|
||||
rx = [
|
||||
gpt_bytes[:4096],
|
||||
gpt_bytes[4096:12288],
|
||||
gpt_bytes[12288:],
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><response value="ACK" rawmode="false" /></data>',
|
||||
]
|
||||
fh, cdc = self._make_fh(rx)
|
||||
with mock.patch.object(firehose_mod.time, "sleep"):
|
||||
got = fh.cmd_read_buffer(0, 0, 32, Display=False)
|
||||
self.assertEqual(bytes(got), gpt_bytes)
|
||||
table = gpt()
|
||||
self.assertTrue(table.parse(got, 512))
|
||||
self.assertEqual([e.name for e in table.partentries], ["boot", "userdata"])
|
||||
self.assertEqual(cdc.read_lengths[:3], [16384, 12288, 4096])
|
||||
|
||||
def test_single_sector_cmd_read_both_variants(self):
|
||||
sector = bytes([0xA5]) * 512
|
||||
for name, ack_pkts in (
|
||||
("8k", [b'<?xml version="1.0" encoding="UTF-8" ?><data><response value="ACK" rawmode="true" /></data>']),
|
||||
("fih", []),
|
||||
):
|
||||
with self.subTest(loader=name):
|
||||
rx = ack_pkts + [
|
||||
sector,
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><response value="ACK" rawmode="false" /></data>',
|
||||
]
|
||||
fh, cdc = self._make_fh(rx)
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
out = os.path.join(tmp, "sec.bin")
|
||||
with mock.patch.object(firehose_mod.time, "sleep"):
|
||||
res = fh.cmd_read(0, 7, 1, out, Display=False)
|
||||
self.assertTrue(res)
|
||||
self.assertNotEqual(res, "")
|
||||
with open(out, "rb") as handle:
|
||||
self.assertEqual(handle.read(), sector)
|
||||
self.assertEqual(cdc.read_lengths[0], 512)
|
||||
|
||||
def test_nak_before_raw_fails_cleanly(self):
|
||||
rx = [
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><log value="Invalid physical partition 9" /></data>',
|
||||
b'<?xml version="1.0" encoding="UTF-8" ?><data><response value="NAK" rawmode="false" /></data>',
|
||||
]
|
||||
fh, _ = self._make_fh(rx)
|
||||
got = fh.cmd_read_buffer(9, 0, 1, Display=False)
|
||||
self.assertEqual(got, "")
|
||||
|
||||
def test_usb_connect_preserves_active_configuration(self):
|
||||
fake_ep_out = object()
|
||||
fake_ep_in = object()
|
||||
|
||||
class FakeDevice:
|
||||
def __init__(self, initial_cfg, raise_on_get=False):
|
||||
self.initial_cfg = initial_cfg
|
||||
self.raise_on_get = raise_on_get
|
||||
self.set_configuration_calls = 0
|
||||
|
||||
def is_kernel_driver_active(self, _):
|
||||
return False
|
||||
|
||||
def get_active_configuration(self):
|
||||
if self.raise_on_get and self.set_configuration_calls == 0:
|
||||
raise usb_mod.usb.core.USBError("Entity not found")
|
||||
return self.initial_cfg if self.set_configuration_calls == 0 else "cfg1"
|
||||
|
||||
def set_configuration(self):
|
||||
self.set_configuration_calls += 1
|
||||
|
||||
with mock.patch.object(usb_mod.usb.util, "find_descriptor", side_effect=[
|
||||
"intf0", fake_ep_out, fake_ep_in,
|
||||
"intf0", fake_ep_out, fake_ep_in,
|
||||
"intf0", fake_ep_out, fake_ep_in,
|
||||
]), mock.patch.object(usb_mod.usb.util, "claim_interface"):
|
||||
dev_active = FakeDevice("cfg1")
|
||||
with mock.patch.object(usb_mod.usb.core, "find", return_value=dev_active):
|
||||
cdc = usb_class()
|
||||
self.assertTrue(cdc.connect())
|
||||
self.assertEqual(dev_active.set_configuration_calls, 0)
|
||||
|
||||
dev_none = FakeDevice(None)
|
||||
with mock.patch.object(usb_mod.usb.core, "find", return_value=dev_none):
|
||||
cdc = usb_class()
|
||||
self.assertTrue(cdc.connect())
|
||||
self.assertEqual(dev_none.set_configuration_calls, 1)
|
||||
|
||||
dev_err = FakeDevice("cfg1", raise_on_get=True)
|
||||
with mock.patch.object(usb_mod.usb.core, "find", return_value=dev_err):
|
||||
cdc = usb_class()
|
||||
self.assertTrue(cdc.connect())
|
||||
self.assertEqual(dev_err.set_configuration_calls, 1)
|
||||
|
||||
def test_usb_timeout_defaults_and_sahara_connect_probe(self):
|
||||
self.assertEqual(usb_mod.DEFAULT_USB_TIMEOUT_MS, 30000)
|
||||
|
||||
class TimeoutDevice:
|
||||
def __init__(self):
|
||||
self.default_timeout = 1000
|
||||
self.writes = []
|
||||
self.reads = []
|
||||
|
||||
def is_kernel_driver_active(self, _):
|
||||
return False
|
||||
|
||||
def get_active_configuration(self):
|
||||
return "cfg1"
|
||||
|
||||
def write(self, ep, payload, timeout=None):
|
||||
self.writes.append((ep, bytes(payload), timeout))
|
||||
|
||||
def read(self, ep, length, timeout=None):
|
||||
self.reads.append((ep, length, timeout))
|
||||
return b"ok"
|
||||
|
||||
dev = TimeoutDevice()
|
||||
with mock.patch.object(usb_mod.usb.core, "find", return_value=dev), \
|
||||
mock.patch.object(usb_mod.usb.util, "find_descriptor", side_effect=["intf0", "ep_out", "ep_in"]), \
|
||||
mock.patch.object(usb_mod.usb.util, "claim_interface"):
|
||||
cdc = usb_class()
|
||||
self.assertTrue(cdc.connect())
|
||||
self.assertEqual(dev.default_timeout, 30000)
|
||||
cdc.write(b"abc")
|
||||
cdc.read(64)
|
||||
cdc.read(64, timeout=2000)
|
||||
self.assertEqual(dev.writes[-1], ("ep_out", b"abc", 30000))
|
||||
self.assertEqual(dev.reads, [("ep_in", 64, 30000), ("ep_in", 64, 2000)])
|
||||
|
||||
class ProbeCdc:
|
||||
def __init__(self):
|
||||
self.read_calls = []
|
||||
self.write_calls = []
|
||||
|
||||
def read(self, length=0x80000, timeout=None):
|
||||
self.read_calls.append((length, timeout))
|
||||
if len(self.read_calls) == 1:
|
||||
raise TimeoutError("probe timed out")
|
||||
return bytearray(b'<?xml version="1.0" ?><data><response value="ACK" /></data>')
|
||||
|
||||
def write(self, data, pktsize=64, timeout=None):
|
||||
self.write_calls.append((data, pktsize, timeout))
|
||||
|
||||
from Library.sahara import qualcomm_sahara
|
||||
pcdc = ProbeCdc()
|
||||
sahara = qualcomm_sahara(pcdc)
|
||||
self.assertEqual(sahara.connect(), "Firehose")
|
||||
self.assertEqual(pcdc.read_calls[0][1], 2000)
|
||||
self.assertIsNone(pcdc.read_calls[1][1])
|
||||
|
||||
with open(os.path.join(BASE_DIR, "flash-edl.py"), "r", encoding="utf-8") as handle:
|
||||
flash_src = handle.read()
|
||||
self.assertIn("DEFAULT_USB_IO_TIMEOUT_SEC = 30", flash_src)
|
||||
self.assertIn('"--usb-timeout"', flash_src)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Executable
+233
@@ -0,0 +1,233 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host tests for the source-built nokia-sparkler lk2nd port.
|
||||
|
||||
Runs the image validator across all three build variants, compiles a host C
|
||||
panel-init walker test against the GC9307 HLT and ST7789VX2 CTC byte streams
|
||||
extracted from the QCDT DTB, checks repository wiring, and exercises negative
|
||||
validation checks on tampered binaries.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
PINNED = "cf45aefd22d744b2bf9b39455afae697ce430063"
|
||||
|
||||
HOST_TEST_C = r"""
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "spi-panel-init.h"
|
||||
#include "panel_streams_sparkler.h"
|
||||
|
||||
static unsigned char cmds[64];
|
||||
static unsigned char data[64][16];
|
||||
static unsigned int data_len[64];
|
||||
static unsigned int cmd_count, delay_total, delay_count;
|
||||
|
||||
static int rec_cmd(const unsigned char *cmd)
|
||||
{
|
||||
if(cmd_count < 64)
|
||||
cmds[cmd_count] = cmd[0];
|
||||
cmd_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rec_data(const unsigned char *buf, unsigned int len)
|
||||
{
|
||||
if(cmd_count > 0 && cmd_count <= 64 && len <= 16) {
|
||||
memcpy(data[cmd_count - 1], buf, len);
|
||||
data_len[cmd_count - 1] = len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rec_delay(unsigned int ms)
|
||||
{
|
||||
delay_total += ms;
|
||||
delay_count++;
|
||||
}
|
||||
|
||||
static const struct lk2nd_spi_panel_init_ops ops = {
|
||||
.write_cmd = rec_cmd,
|
||||
.write_data = rec_data,
|
||||
.delay = rec_delay,
|
||||
};
|
||||
|
||||
static void reset(void)
|
||||
{
|
||||
cmd_count = delay_total = delay_count = 0;
|
||||
memset(cmds, 0, sizeof(cmds));
|
||||
memset(data_len, 0, sizeof(data_len));
|
||||
}
|
||||
|
||||
#define CHECK(cond, msg) do { \
|
||||
if(!(cond)) { \
|
||||
printf("[fail] %s (line %d)\n", (msg), __LINE__); \
|
||||
return 1; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int has_cmd(const unsigned char *cmd, unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < cmd_count; i++) {
|
||||
if(cmds[i] != cmd[0])
|
||||
continue;
|
||||
if(len == 1)
|
||||
return 1;
|
||||
if(data_len[i] == len - 1 && memcmp(data[i], cmd + 1, len - 1) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int verify_stream(const char *label, const unsigned char *buf,
|
||||
unsigned int len, unsigned int expected_cmds)
|
||||
{
|
||||
static const unsigned char rgb565[] = {0x3a, 0x05};
|
||||
static const unsigned char window_x[] = {0x2a, 0x00, 0x00, 0x00, 0xef};
|
||||
static const unsigned char window_y[] = {0x2b, 0x00, 0x00, 0x01, 0x3f};
|
||||
static const unsigned char sleep_out[] = {0x11};
|
||||
static const unsigned char disp_on[] = {0x29};
|
||||
|
||||
reset();
|
||||
CHECK(lk2nd_spi_panel_init_run(buf, len, &ops) == 0, label);
|
||||
CHECK(cmd_count == expected_cmds, "unexpected command count");
|
||||
CHECK(delay_total == 120 && delay_count == 1, "expected 120 ms delay once");
|
||||
CHECK(has_cmd(rgb565, sizeof(rgb565)), "missing RGB565 0x3a 0x05");
|
||||
CHECK(has_cmd(window_x, sizeof(window_x)), "missing column window");
|
||||
CHECK(has_cmd(window_y, sizeof(window_y)), "missing row window");
|
||||
CHECK(has_cmd(sleep_out, sizeof(sleep_out)), "missing sleep-out 0x11");
|
||||
CHECK(has_cmd(disp_on, sizeof(disp_on)), "missing display-on 0x29");
|
||||
CHECK(cmds[cmd_count - 1] == 0x2c, "stream must end with RAMWR 0x2c");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
if(verify_stream("gc9307", stream_gc9307, sizeof(stream_gc9307), 15))
|
||||
return 1;
|
||||
if(verify_stream("st7789vx2", stream_st7789vx2, sizeof(stream_st7789vx2), 11))
|
||||
return 1;
|
||||
printf("[ok] verified sparkler GC9307 (15 cmds) and ST7789VX2 (11 cmds)\n");
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
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-sparkler.py")
|
||||
build = os.path.join(BASE, "scripts", "build-lk2nd-sparkler.sh")
|
||||
beatles_patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-beatles.patch")
|
||||
coconut_patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-coconut.patch")
|
||||
sparkler_patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-sparkler.patch")
|
||||
header = os.path.join(BASE, "bootloader", "lk2nd", "spi-panel-init.h")
|
||||
|
||||
variants = (
|
||||
("images/boot-lk2nd-nokia-sparkler.img", 0, 0),
|
||||
("images/boot-lk2nd-nokia-sparkler-diagnostic.img", 1, 0),
|
||||
("images/boot-lk2nd-nokia-sparkler-display.img", 0, 1),
|
||||
)
|
||||
for image, fastboot, display in variants:
|
||||
full = os.path.join(BASE, image)
|
||||
ok &= check(os.path.isfile(full), "%s exists" % image)
|
||||
if not os.path.isfile(full):
|
||||
continue
|
||||
r = run([sys.executable, validator, "--image", image,
|
||||
"--expect-fastboot", str(fastboot),
|
||||
"--expect-display", str(display)])
|
||||
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-sparkler.sh"),
|
||||
(beatles_patch, "nokia-beatles.patch"),
|
||||
(coconut_patch, "nokia-coconut.patch"),
|
||||
(sparkler_patch, "nokia-sparkler.patch"),
|
||||
(header, "spi-panel-init.h")):
|
||||
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 supports forced-fastboot no-display diagnostic image")
|
||||
ok &= check("lk2nd.compatible=nokia,sparkler" in script and
|
||||
"lk2nd.display=on" in script,
|
||||
"build script uses nokia,sparkler cmdline and display mode")
|
||||
|
||||
patch_text = open(sparkler_patch).read()
|
||||
for needed in ("lk2nd/device/2nd/spi-display.c",
|
||||
"lk2nd/device/dts/msm8909/msm8909-mtp.dts",
|
||||
"lk2nd/device/dts/msm8909/nokia-sparkler.dtsi",
|
||||
'"nokia,sparkler"',
|
||||
"qcom,mdss_spi_gc9307_hlt_28_qvga_cmd",
|
||||
"qcom,mdss_spi_st7789vx2_ctc_28_qvga_cmd",
|
||||
"KEY_VOLUMEUP"):
|
||||
ok &= check(needed in patch_text, "sparkler patch contains %s" % needed)
|
||||
|
||||
gcc = shutil.which("gcc") or shutil.which("cc")
|
||||
img_path = os.path.join(BASE, "images", "boot-lk2nd-nokia-sparkler-display.img")
|
||||
if gcc and os.path.isfile(img_path):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
streams = os.path.join(tmp, "panel_streams_sparkler.h")
|
||||
test_src = os.path.join(tmp, "test_sparkler_streams.c")
|
||||
r = run([sys.executable, validator,
|
||||
"--image", img_path,
|
||||
"--expect-display", "1",
|
||||
"--emit-streams-header", streams])
|
||||
ok &= check(r.returncode == 0, "panel init streams extracted from QCDT DTB")
|
||||
if r.returncode == 0:
|
||||
with open(test_src, "w") as fh:
|
||||
fh.write(HOST_TEST_C)
|
||||
binary = os.path.join(tmp, "test_sparkler_streams")
|
||||
r = run([gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
|
||||
"-I", tmp, "-I", os.path.join(BASE, "bootloader", "lk2nd"),
|
||||
"-o", binary, test_src])
|
||||
ok &= check(r.returncode == 0,
|
||||
"host C unit test compiles against spi-panel-init.h")
|
||||
if r.returncode == 0:
|
||||
r = run([binary])
|
||||
if r.stdout.strip():
|
||||
print(r.stdout.strip())
|
||||
ok &= check(r.returncode == 0,
|
||||
"host C unit test accepts GC9307 and ST7789VX2 streams")
|
||||
|
||||
tampered = os.path.join(tmp, "tampered.img")
|
||||
raw = bytearray(open(img_path, "rb").read())
|
||||
raw[-16:] = b"X" * 16
|
||||
with open(tampered, "wb") as fh:
|
||||
fh.write(raw)
|
||||
r = run([sys.executable, validator, "--image", tampered,
|
||||
"--expect-display", "1"])
|
||||
ok &= check(r.returncode != 0 and "SEANDROIDENFORCE" in r.stdout,
|
||||
"validator rejects tampered SEANDROIDENFORCE trailer")
|
||||
elif not gcc:
|
||||
print("[skip] no host C compiler; C unit test skipped")
|
||||
|
||||
print("[%s] nokia-sparkler lk2nd port tests" % ("ok" if ok else "FAIL"))
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+202
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Offline regression checks for Nokia 8000 4G (nokia-sparkler) bring-up."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def read_text(rel_path):
|
||||
with open(os.path.join(BASE_DIR, rel_path), "r", encoding="utf-8") as handle:
|
||||
return handle.read()
|
||||
|
||||
|
||||
class TestSparklerPort(unittest.TestCase):
|
||||
def test_deviceinfo_and_initfs(self):
|
||||
deviceinfo = read_text("devices/nokia-sparkler/deviceinfo")
|
||||
for expected in (
|
||||
'deviceinfo_codename="nokia-sparkler"',
|
||||
'deviceinfo_dtb="qcom-msm8909-nokia-sparkler"',
|
||||
'deviceinfo_drm="true"',
|
||||
'deviceinfo_flash_offset_base="0x80000000"',
|
||||
'deviceinfo_flash_offset_kernel="0x00008000"',
|
||||
'deviceinfo_flash_offset_ramdisk="0x02700000"',
|
||||
'deviceinfo_flash_offset_tags="0x02500000"',
|
||||
):
|
||||
self.assertIn(expected, deviceinfo)
|
||||
|
||||
initfs = read_text("devices/nokia-sparkler/modules-initfs").splitlines()
|
||||
for mod in ("pm8916-lbc", "pm8916-bms-vm", "panel-mipi-dbi", "matrix_keypad", "matrix_keymap"):
|
||||
self.assertIn(mod, initfs)
|
||||
|
||||
def _assert_dts_invariants(self, text):
|
||||
for expected in (
|
||||
'model = "Nokia 8000 4G";',
|
||||
'compatible = "nokia,sparkler", "qcom,msm8909";',
|
||||
'qcom,msm-id = <0xf5 0x00>;',
|
||||
'qcom,board-id = <0x08 0x100>;',
|
||||
'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;',
|
||||
'reg = <0x80000000 0x20000000>;',
|
||||
'sound@7702000',
|
||||
'audio-codec@f000',
|
||||
'audio-codec@771c000',
|
||||
'vibrator@c000',
|
||||
'apr {',
|
||||
'0x500d4',
|
||||
'0x100007f',
|
||||
'0x205000e',
|
||||
'0x301009e',
|
||||
):
|
||||
self.assertIn(expected, text)
|
||||
|
||||
for forbidden in ('0x5008b', '0x10002b8', '0x20501be', '0x30102b9', 'cd-gpios', 'broken-cd'):
|
||||
self.assertNotIn(forbidden, text)
|
||||
|
||||
mm3 = re.search(r'dai-link-multimedia3\s*\{[^}]*status\s*=\s*"disabled";', text, re.S)
|
||||
self.assertIsNotNone(mm3, "dai-link-multimedia3 must be disabled")
|
||||
vib = re.search(r'vibrator@c000\s*\{[^}]*status\s*=\s*"disabled";', text, re.S)
|
||||
self.assertIsNotNone(vib, "vibrator@c000 must be disabled on sparkler (157 Hz haptic audio)")
|
||||
star = re.search(r'key-star\s*\{[^}]*gpios\s*=\s*<0x27 0x5a 0x01>;[^}]*linux,code\s*=\s*<0x20a>;', text, re.S)
|
||||
self.assertIsNotNone(star, "key-star on gpio90 (0x5a) must map to KEY_NUMERIC_STAR (0x20a)")
|
||||
resin = re.search(r'resin\s*\{[^}]*compatible\s*=\s*"qcom,pm8941-resin";[^}]*linux,code\s*=\s*<0x20b>;', text, re.S)
|
||||
self.assertIsNotNone(resin, "pm8941_resin must map to KEY_NUMERIC_POUND (0x20b)")
|
||||
sdhci_ext = re.search(r'sdhci@7864000\s*\{[^}]*non-removable;', text, re.S)
|
||||
self.assertIsNotNone(sdhci_ext, "sdhci@7864000 must set non-removable;")
|
||||
|
||||
def test_dts_and_compiled_dtb_invariants(self):
|
||||
dts = read_text("devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts")
|
||||
self._assert_dts_invariants(dts)
|
||||
for cpu_idx in range(4):
|
||||
m = re.search(
|
||||
rf'cpu@{cpu_idx}\s*\{{[^}}]*clock-frequency\s*=\s*<1094400000>;',
|
||||
dts,
|
||||
re.S,
|
||||
)
|
||||
self.assertIsNotNone(m, f"cpu@{cpu_idx} must set clock-frequency = <1094400000>;")
|
||||
|
||||
dtc = shutil.which("dtc")
|
||||
if dtc is None:
|
||||
return
|
||||
for dtb_rel in (
|
||||
"devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dtb",
|
||||
"prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb",
|
||||
):
|
||||
dtb_path = os.path.join(BASE_DIR, dtb_rel)
|
||||
self.assertTrue(os.path.isfile(dtb_path), "missing compiled DTB: " + dtb_rel)
|
||||
with open(dtb_path, "rb") as handle:
|
||||
raw_dtb = handle.read()
|
||||
# 1094400000 Hz in big-endian u32 is 0x413b3800 ("A;8\0" in ASCII)
|
||||
self.assertGreaterEqual(raw_dtb.count(b"\x41\x3b\x38\x00"), 4, dtb_rel)
|
||||
dec = subprocess.check_output([dtc, "-q", "-I", "dtb", "-O", "dts", dtb_path], text=True)
|
||||
self._assert_dts_invariants(dec)
|
||||
|
||||
def test_smp_cpufreq_haptic_audio_and_camera_fixes(self):
|
||||
patch_0013 = read_text("patches/kernel/0013-msm8909-early-scm-smp-cpufreq.patch")
|
||||
for expected in (
|
||||
"early_virt",
|
||||
"qcom_scm_set_boot_addr_mc",
|
||||
"cpu_present(cpu)",
|
||||
"clock-frequency = <1094400000>;",
|
||||
):
|
||||
self.assertIn(expected, patch_0013)
|
||||
|
||||
build_k = read_text("scripts/build-kernel-audio.sh")
|
||||
self.assertIn("0013-msm8909-early-scm-smp-cpufreq.patch", build_k)
|
||||
|
||||
sysmap = read_text("prebuilt/kernel-6.12.1-msm8916/System.map")
|
||||
self.assertIn(" qcom_scm_set_boot_addr_mc\n", sysmap)
|
||||
|
||||
vib_c = read_text("src/dwm-plugins/sxmo_vibrate.c")
|
||||
for expected in ("is_haptic_audio_device", "vibrate_haptic_audio", "157.0", "nokia,sparkler"):
|
||||
self.assertIn(expected, vib_c)
|
||||
build_p = read_text("scripts/build-dwm-plugins.sh")
|
||||
self.assertIn("alsa", build_p)
|
||||
|
||||
cam_c = read_text("src/msm8905-cam/msm8905-cam.c")
|
||||
for expected in (
|
||||
'of_machine_is_compatible("nokia,sparkler")',
|
||||
"row_buf",
|
||||
"msm8905_cam_demosaic(cam->raw_dma_buf, dst_rgb, cam->rotate_180);",
|
||||
):
|
||||
self.assertIn(expected, cam_c)
|
||||
|
||||
def test_dual_gpio_torch_driver_and_module(self):
|
||||
torch_src = read_text("src/leds-msm8905-torch/leds-msm8905-torch.c")
|
||||
for expected in (
|
||||
'#define MSM8905_TLMM_GPIO31_PHYS 0x0101f000UL',
|
||||
'of_machine_is_compatible("nokia,sparkler")',
|
||||
'of_machine_is_compatible("nokia,leo")',
|
||||
'is_sparkler_dual_gpio_torch',
|
||||
'GPIO_32/GPIO_31 (BC847BS)',
|
||||
):
|
||||
self.assertIn(expected, torch_src)
|
||||
|
||||
ko_path = os.path.join(BASE_DIR, "prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko")
|
||||
ko_zst = ko_path + ".zst"
|
||||
self.assertTrue(os.path.isfile(ko_path), "missing leds-msm8905-torch.ko")
|
||||
self.assertTrue(os.path.isfile(ko_zst), "missing leds-msm8905-torch.ko.zst")
|
||||
with open(ko_path, "rb") as handle:
|
||||
raw_ko = handle.read()
|
||||
self.assertIn(b"GPIO_32/GPIO_31 (BC847BS)", raw_ko)
|
||||
|
||||
modinfo = shutil.which("modinfo")
|
||||
if modinfo is not None:
|
||||
out = subprocess.check_output([modinfo, "-F", "vermagic", ko_path], text=True).strip()
|
||||
self.assertEqual(out, "6.12.1-msm8916 SMP preempt mod_unload ARMv7 p2v8")
|
||||
deps = subprocess.check_output([modinfo, "-F", "depends", ko_path], text=True).strip()
|
||||
self.assertEqual(deps, "")
|
||||
|
||||
def test_flash_release_and_boot_validators_wired(self):
|
||||
flash_py = read_text("flash-edl.py")
|
||||
for expected in (
|
||||
'BOOT_IMAGE_DEVICES = ("nokia-beatles", "nokia-coconut", "nokia-sparkler")',
|
||||
'UNLOCK_DEFAULT_DEVICES = ("nokia-beatles", "nokia-coconut", "nokia-sparkler", "nokia-leo")',
|
||||
'EDL_STAR_HASH_DEVICES = ("nokia-sparkler", "nokia-leo")',
|
||||
'SPARKLER_LK2ND_IMAGE = "images/boot-lk2nd-nokia-sparkler-display.img"',
|
||||
'"nokia-sparkler": SPARKLER_LK2ND_IMAGE',
|
||||
):
|
||||
self.assertIn(expected, flash_py)
|
||||
|
||||
import importlib.util
|
||||
flash_spec = importlib.util.spec_from_file_location(
|
||||
"flash_edl",
|
||||
os.path.join(BASE_DIR, "flash-edl.py"),
|
||||
)
|
||||
flash_mod = importlib.util.module_from_spec(flash_spec)
|
||||
flash_spec.loader.exec_module(flash_mod)
|
||||
self.assertEqual(flash_mod.edl_button_combo_hint("nokia-sparkler"), "* + #")
|
||||
self.assertEqual(flash_mod.edl_button_combo_hint("nokia-leo"), "* + #")
|
||||
self.assertEqual(flash_mod.edl_button_combo_hint("nokia-argon"), "D-Pad Up + D-Pad Down")
|
||||
self.assertEqual(flash_mod.edl_button_combo_hint("nokia-beatles"), "D-Pad Up + D-Pad Down")
|
||||
self.assertEqual(flash_mod.edl_button_combo_hint("nokia-coconut"), "D-Pad Up + D-Pad Down")
|
||||
|
||||
manual_md = read_text("MANUAL.md")
|
||||
self.assertIn("`*` + `#`", manual_md)
|
||||
|
||||
prep_sh = read_text("prepare-release.sh")
|
||||
for expected in (
|
||||
'DISPLAY_IMAGE="images/boot-lk2nd-nokia-sparkler-display.img"',
|
||||
'BOOT_IMAGE="images/boot-bananarchy-nokia-sparkler.img"',
|
||||
'scripts/check-lk2nd-sparkler.py',
|
||||
'./scripts/build-lk2nd-sparkler.sh',
|
||||
):
|
||||
self.assertIn(expected, prep_sh)
|
||||
|
||||
sys.path.insert(0, os.path.join(BASE_DIR, "scripts"))
|
||||
import importlib
|
||||
bootimg_mod = importlib.import_module("check-beatles-bootimg")
|
||||
bootfs_mod = importlib.import_module("sync-beatles-bootfs")
|
||||
self.assertIn("nokia-sparkler", bootimg_mod.DEVICE_MODELS)
|
||||
self.assertEqual(bootimg_mod.DEVICE_MODELS["nokia-sparkler"], "Nokia 8000 4G")
|
||||
spec = bootimg_mod.DEVICE_SPECS["nokia-sparkler"]
|
||||
self.assertEqual(spec["addrs"], (0x80008000, 0x82700000, 0x82500000))
|
||||
self.assertEqual(bootfs_mod.DEVICE_DTB_NAMES["nokia-sparkler"], "qcom-msm8909-nokia-sparkler.dtb")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Executable
+291
@@ -0,0 +1,291 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Offline regression tests for sxmo_timer.sh, dmenu timer integration, and hooks."""
|
||||
|
||||
import os
|
||||
import pty
|
||||
import select
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
TIMER_SH = os.path.join(BASE_DIR, "overlay/rootfs/usr/bin/sxmo_timer.sh")
|
||||
|
||||
|
||||
def read_text(rel_path):
|
||||
with open(os.path.join(BASE_DIR, rel_path), "r", encoding="utf-8") as handle:
|
||||
return handle.read()
|
||||
|
||||
|
||||
class TestTimer(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.mkdtemp(prefix="bananarchy-timer-test-")
|
||||
self.bin_dir = os.path.join(self.tmp, "bin")
|
||||
self.rt_dir = os.path.join(self.tmp, "runtime")
|
||||
self.home_dir = os.path.join(self.tmp, "home")
|
||||
os.makedirs(self.bin_dir, exist_ok=True)
|
||||
os.makedirs(self.rt_dir, exist_ok=True)
|
||||
os.makedirs(os.path.join(self.home_dir, ".config", "sxmo"), exist_ok=True)
|
||||
self.ring_flag = os.path.join(self.tmp, "sxmo_timer_ringing")
|
||||
self.notify_log = os.path.join(self.tmp, "notify.log")
|
||||
self.vibrate_log = os.path.join(self.tmp, "vibrate.log")
|
||||
self.wake_log = os.path.join(self.tmp, "wake.log")
|
||||
|
||||
# Minimal sxmo_common.sh stub and mock helpers so BusyBox/POSIX ash behaves
|
||||
# identically offline without X11 or hardware access.
|
||||
self._write_exec(
|
||||
"sxmo_common.sh",
|
||||
"#!/bin/sh\n"
|
||||
"export XDG_RUNTIME_DIR=\"${XDG_RUNTIME_DIR:-/tmp}\"\n"
|
||||
"export XDG_CONFIG_HOME=\"${XDG_CONFIG_HOME:-$HOME/.config}\"\n",
|
||||
)
|
||||
self._write_exec(
|
||||
"sxmo_aligned_sleep",
|
||||
"#!/bin/sh\nsleep \"${1:-1}\"\n",
|
||||
)
|
||||
self._write_exec(
|
||||
"dunstify",
|
||||
f"#!/bin/sh\nprintf '%s\\n' \"$*\" >> '{self.notify_log}'\n",
|
||||
)
|
||||
self._write_exec(
|
||||
"notify-send",
|
||||
f"#!/bin/sh\nprintf '%s\\n' \"$*\" >> '{self.notify_log}'\n",
|
||||
)
|
||||
self._write_exec(
|
||||
"sxmo_vibrate",
|
||||
f"#!/bin/sh\nprintf '%s\\n' \"$*\" >> '{self.vibrate_log}'\nexit 0\n",
|
||||
)
|
||||
self._write_exec(
|
||||
"dunstctl",
|
||||
"#!/bin/sh\nexit 0\n",
|
||||
)
|
||||
self._write_exec(
|
||||
"killall",
|
||||
"#!/bin/sh\nexit 0\n",
|
||||
)
|
||||
|
||||
self.env = os.environ.copy()
|
||||
self.env.update({
|
||||
"PATH": f"{self.bin_dir}:{self.env.get('PATH', '')}",
|
||||
"HOME": self.home_dir,
|
||||
"XDG_CONFIG_HOME": os.path.join(self.home_dir, ".config"),
|
||||
"XDG_RUNTIME_DIR": self.rt_dir,
|
||||
"SXMO_TIMER_DIR": os.path.join(self.rt_dir, "sxmo_timers"),
|
||||
"SXMO_TIMER_RING_FLAG": self.ring_flag,
|
||||
"SXMO_TIMER_RING_SECS": "5",
|
||||
})
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
subprocess.run(
|
||||
[TIMER_SH, "stop"],
|
||||
env=self.env,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
timeout=5,
|
||||
check=False,
|
||||
)
|
||||
finally:
|
||||
shutil.rmtree(self.tmp, ignore_errors=True)
|
||||
|
||||
def _write_exec(self, name, content):
|
||||
path = os.path.join(self.bin_dir, name)
|
||||
with open(path, "w", encoding="utf-8") as handle:
|
||||
handle.write(content)
|
||||
os.chmod(path, 0o755)
|
||||
|
||||
def test_script_and_hooks_invariants(self):
|
||||
st_mode = os.stat(TIMER_SH).st_mode
|
||||
self.assertTrue(bool(st_mode & stat.S_IXUSR), "sxmo_timer.sh must be executable")
|
||||
subprocess.check_call(["sh", "-n", TIMER_SH])
|
||||
text = read_text("overlay/rootfs/usr/bin/sxmo_timer.sh")
|
||||
self.assertNotIn("boottime_alarm", text)
|
||||
self.assertNotIn("pkill", text)
|
||||
self.assertIn("HUP INT TERM EXIT", text)
|
||||
self.assertIn("stop_ringing()", text)
|
||||
|
||||
for rel in (
|
||||
"overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_mute_ring.sh",
|
||||
"overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_discard.sh",
|
||||
):
|
||||
hook_txt = read_text(rel)
|
||||
self.assertIn("/usr/bin/sxmo_timer.sh stop_ringing", hook_txt)
|
||||
|
||||
dmenu_c = read_text("src/sxmo-dmenu/dmenu.c")
|
||||
for expected in ("timer_menu_state(", "Stop Timer", "Cancel Timer", "/usr/bin/sxmo_timer.sh stop"):
|
||||
self.assertIn(expected, dmenu_c)
|
||||
|
||||
def test_countdown_no_permission_error_and_stop(self):
|
||||
proc = subprocess.Popen(
|
||||
[TIMER_SH, "timerrun", "10m"],
|
||||
env=self.env,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
try:
|
||||
timer_dir = self.env["SXMO_TIMER_DIR"]
|
||||
deadline = time.monotonic() + 3.0
|
||||
timer_files = []
|
||||
while time.monotonic() < deadline:
|
||||
if os.path.isdir(timer_dir):
|
||||
timer_files = [f for f in os.listdir(timer_dir) if f.endswith(".timer")]
|
||||
if timer_files:
|
||||
break
|
||||
time.sleep(0.05)
|
||||
self.assertTrue(timer_files, "expected active .timer state file during countdown")
|
||||
|
||||
st = subprocess.run(
|
||||
[TIMER_SH, "status"],
|
||||
env=self.env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
self.assertIn("running", st.stdout)
|
||||
self.assertIn("10m", st.stdout)
|
||||
|
||||
subprocess.run([TIMER_SH, "stop"], env=self.env, check=True)
|
||||
out, err = proc.communicate(timeout=4)
|
||||
self.assertEqual(err.strip(), "", f"unexpected stderr: {err!r}")
|
||||
self.assertIn("Timer: 10m", out)
|
||||
self.assertEqual([f for f in os.listdir(timer_dir) if f.endswith(".timer")], [])
|
||||
finally:
|
||||
if proc.poll() is None:
|
||||
proc.kill()
|
||||
proc.wait(timeout=3)
|
||||
for pipe in (proc.stdout, proc.stderr):
|
||||
if pipe is not None:
|
||||
pipe.close()
|
||||
|
||||
def test_expiry_ringing_and_stop_ringing(self):
|
||||
proc = subprocess.Popen(
|
||||
[TIMER_SH, "timerrun", "1s"],
|
||||
env=self.env,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
try:
|
||||
deadline = time.monotonic() + 4.0
|
||||
while time.monotonic() < deadline and not os.path.exists(self.ring_flag):
|
||||
time.sleep(0.05)
|
||||
self.assertTrue(os.path.exists(self.ring_flag), "ring flag must appear on expiry")
|
||||
|
||||
time.sleep(0.3)
|
||||
subprocess.run([TIMER_SH, "stop_ringing"], env=self.env, check=True)
|
||||
out, err = proc.communicate(timeout=4)
|
||||
self.assertEqual(err.strip(), "")
|
||||
self.assertIn("Done with 1s", out)
|
||||
self.assertFalse(os.path.exists(self.ring_flag), "ring flag must be cleaned on stop_ringing")
|
||||
self.assertTrue(os.path.exists(self.notify_log), "expected expiry notification")
|
||||
self.assertTrue(os.path.exists(self.vibrate_log), "expected expiry vibrate")
|
||||
finally:
|
||||
if proc.poll() is None:
|
||||
proc.kill()
|
||||
proc.wait(timeout=3)
|
||||
for pipe in (proc.stdout, proc.stderr):
|
||||
if pipe is not None:
|
||||
pipe.close()
|
||||
|
||||
def test_pty_keypress_cancels_countdown(self):
|
||||
master_fd, slave_fd = pty.openpty()
|
||||
proc = subprocess.Popen(
|
||||
[TIMER_SH, "timerrun", "10m"],
|
||||
env=self.env,
|
||||
stdin=slave_fd,
|
||||
stdout=slave_fd,
|
||||
stderr=subprocess.PIPE,
|
||||
close_fds=True,
|
||||
)
|
||||
os.close(slave_fd)
|
||||
output = b""
|
||||
try:
|
||||
deadline = time.monotonic() + 3.0
|
||||
while time.monotonic() < deadline:
|
||||
rlist, _, _ = select.select([master_fd], [], [], 0.2)
|
||||
if rlist:
|
||||
output += os.read(master_fd, 4096)
|
||||
if b"Timer: 10m" in output:
|
||||
break
|
||||
self.assertIn(b"Timer: 10m", output)
|
||||
os.write(master_fd, b"q")
|
||||
rc = proc.wait(timeout=4)
|
||||
self.assertEqual(rc, 0)
|
||||
err = proc.stderr.read().decode("utf-8", errors="replace")
|
||||
self.assertEqual(err.strip(), "")
|
||||
finally:
|
||||
os.close(master_fd)
|
||||
if proc.stderr is not None:
|
||||
proc.stderr.close()
|
||||
if proc.poll() is None:
|
||||
proc.kill()
|
||||
proc.wait(timeout=3)
|
||||
|
||||
def test_pty_expiry_any_key_and_sighup_clean(self):
|
||||
master_fd, slave_fd = pty.openpty()
|
||||
proc = subprocess.Popen(
|
||||
[TIMER_SH, "timerrun", "1s"],
|
||||
env=self.env,
|
||||
stdin=slave_fd,
|
||||
stdout=slave_fd,
|
||||
stderr=subprocess.PIPE,
|
||||
close_fds=True,
|
||||
)
|
||||
os.close(slave_fd)
|
||||
try:
|
||||
deadline = time.monotonic() + 4.0
|
||||
while time.monotonic() < deadline and not os.path.exists(self.ring_flag):
|
||||
rlist, _, _ = select.select([master_fd], [], [], 0.1)
|
||||
if rlist:
|
||||
os.read(master_fd, 4096)
|
||||
self.assertTrue(os.path.exists(self.ring_flag), "ring flag must appear on PTY expiry")
|
||||
os.write(master_fd, b"\r")
|
||||
rc = proc.wait(timeout=4)
|
||||
self.assertEqual(rc, 0)
|
||||
err = proc.stderr.read().decode("utf-8", errors="replace")
|
||||
self.assertEqual(err.strip(), "")
|
||||
self.assertFalse(os.path.exists(self.ring_flag), "keypress must clear ring flag")
|
||||
finally:
|
||||
os.close(master_fd)
|
||||
if proc.stderr is not None:
|
||||
proc.stderr.close()
|
||||
if proc.poll() is None:
|
||||
proc.kill()
|
||||
proc.wait(timeout=3)
|
||||
|
||||
proc_hup = subprocess.Popen(
|
||||
[TIMER_SH, "timerrun", "10m"],
|
||||
env=self.env,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
try:
|
||||
timer_dir = self.env["SXMO_TIMER_DIR"]
|
||||
deadline = time.monotonic() + 3.0
|
||||
while time.monotonic() < deadline:
|
||||
if os.path.isdir(timer_dir) and os.listdir(timer_dir):
|
||||
break
|
||||
time.sleep(0.05)
|
||||
self.assertTrue(os.listdir(timer_dir), "expected timer state file before SIGHUP")
|
||||
proc_hup.send_signal(1)
|
||||
_, err_hup = proc_hup.communicate(timeout=4)
|
||||
self.assertEqual(err_hup.strip(), "")
|
||||
self.assertEqual([f for f in os.listdir(timer_dir) if f.endswith(".timer")], [])
|
||||
finally:
|
||||
if proc_hup.poll() is None:
|
||||
proc_hup.kill()
|
||||
proc_hup.wait(timeout=3)
|
||||
if proc_hup.stderr is not None:
|
||||
proc_hup.stderr.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user