Finalize verified 2720 Flip release source and untrack image outputs

This commit is contained in:
Luxferre committed 2026-11-09 23:04:13 +02:00
1 parent 2a3078e42c
commit 1c011b360a
121 files changed
+8467 -686

No files matched your search

+80 -1
View File
@@ -87,10 +87,19 @@ if command -v docker >/dev/null 2>&1; then
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/netfilter/xt_owner.ko.zst" ] || \
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/netfilter/nft_redir.ko.zst" ] || \
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/leds/leds-msm8905-torch.ko.zst" ] || \
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko.zst" ]; then
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/camera/msm8905-cam.ko.zst" ] || \
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux/mux-core.ko.zst" ] || \
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux/mux-gpio.ko.zst" ] || \
[ ! -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi/spi-mux.ko.zst" ]; then
echo " -> Missing prebuilt kernel modules or DTBs; running scripts/build-kernel-audio.sh..."
"$BASE_DIR/scripts/build-kernel-audio.sh"
fi
if [ ! -x "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/bananarchy-lid" ] || \
[ ! -x "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/bananarchy-cover-idle" ] || \
[ ! -x "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/bananarchy-volume-keys" ]; then
echo " -> Missing compiled idle daemons; running scripts/build-bananarchy-daemons.sh..."
"$BASE_DIR/scripts/build-bananarchy-daemons.sh"
fi
if [ ! -f "$BASE_DIR/prebuilt/bantam/bantam" ]; then
echo " -> Missing prebuilt bantam binary; running scripts/build-bantam.sh..."
"$BASE_DIR/scripts/build-bantam.sh"
@@ -100,6 +109,45 @@ fi
echo "[1/4] Installing Bananarchy rootfs overlay (artwork, branding, Sxmo 240x320, UCM, udev)..."
rm -f "$TARGET_ROOTFS/usr/bin/bantam" "$TARGET_ROOTFS/usr/local/bin/bantam" "$TARGET_ROOTFS/etc/doas.d/wheel.conf"
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"
for daemon in bananarchy-lid bananarchy-cover-idle bananarchy-volume-keys; do
cp -af "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/$daemon" \
"$TARGET_ROOTFS/usr/bin/$daemon"
chmod 0755 "$TARGET_ROOTFS/usr/bin/$daemon"
done
ln -sfn /bin/busybox "$TARGET_ROOTFS/sbin/init"
# Some rootfs trees were snapshotted before BusyBox installed its applet
# symlinks. /bin/ash is the "user" login shell and /bin/grep is used by
# openrc-run.sh; without them sshd rejects the account and the udev service
# fails, leaving /dev/input/event* root-owned and untagged so Xorg cannot
# attach the keypad. Never overwrite a real binary, only fill in gaps.
APPLET_LIST="$BASE_DIR/scripts/busybox-applets.txt"
if [ -f "$APPLET_LIST" ]; then
while IFS= read -r applet; do
[ -n "$applet" ] || continue
if [ ! -e "$TARGET_ROOTFS/bin/$applet" ]; then
[ ! -L "$TARGET_ROOTFS/bin/$applet" ] || \
rm -f "$TARGET_ROOTFS/bin/$applet"
ln -s /bin/busybox "$TARGET_ROOTFS/bin/$applet"
fi
done < "$APPLET_LIST"
fi
# /sbin was pruned too: reboot/poweroff/halt (Sxmo power menu), syslogd,
# klogd, mdev, ip-* helpers and the ifconfig/route tools live there.
SBIN_LIST="$BASE_DIR/scripts/busybox-sbin-applets.txt"
if [ -f "$SBIN_LIST" ]; then
while IFS= read -r applet; do
[ -n "$applet" ] || continue
if [ ! -e "$TARGET_ROOTFS/sbin/$applet" ]; then
[ ! -L "$TARGET_ROOTFS/sbin/$applet" ] || \
rm -f "$TARGET_ROOTFS/sbin/$applet"
ln -s /bin/busybox "$TARGET_ROOTFS/sbin/$applet"
fi
done < "$SBIN_LIST"
fi
if [ -x "$BASE_DIR/scripts/version.sh" ]; then
"$BASE_DIR/scripts/version.sh" "$TARGET_ROOTFS"
fi
@@ -203,6 +251,16 @@ if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/wcn36xx" ] && \
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/wcn36xx/"*.ko.zst \
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx/"
fi
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux" ]; then
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux"
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux/"*.ko.zst \
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux/"
fi
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi" ]; then
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi"
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi/"*.ko.zst \
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi/"
fi
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs" ] && \
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs" ]; then
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs/"*.ko.zst \
@@ -329,6 +387,7 @@ rm -rf \
ln -sf /etc/init.d/kill-plymouth "$TARGET_ROOTFS/etc/runlevels/default/kill-plymouth"
ln -sf /etc/init.d/bananarchy-power-policy "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-power-policy"
ln -sf /etc/init.d/bananarchy-time-sync "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-time-sync"
ln -sf /etc/init.d/bananarchy-sshd-debug "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-sshd-debug"
mkdir -p "$TARGET_ROOTFS/var/lib/tinydm"
ln -sf /usr/share/xsessions/sxmo.desktop "$TARGET_ROOTFS/var/lib/tinydm/default-session.desktop"
@@ -370,4 +429,24 @@ if [ -f "$TARGET_ROOTFS/boot/extlinux/extlinux.conf" ]; then
sed -i "s|^[[:space:]]*fdt .*|\tfdt /$DTB_FILE|" "$TARGET_ROOTFS/boot/extlinux/extlinux.conf"
fi
# sshd's StrictModes rejects authorized_keys when $HOME/.ssh is group/world
# writable or the file is owned by the wrong uid. cp -af preserves the source
# modes but not numeric uids, so enforce both after the overlay copy.
chmod 644 "$TARGET_ROOTFS/etc/pam.d/sshd" \
"$TARGET_ROOTFS/etc/ssh/sshd_config.d/90-bananarchy-access.conf" \
2>/dev/null || true
chown 0:0 "$TARGET_ROOTFS/etc/pam.d/sshd" \
"$TARGET_ROOTFS/etc/ssh/sshd_config.d/90-bananarchy-access.conf" \
2>/dev/null || true
for ssh_home in "$TARGET_ROOTFS/etc/skel/.ssh" \
"$TARGET_ROOTFS/home/user/.ssh" \
"$TARGET_ROOTFS/root/.ssh"; do
[ -d "$ssh_home" ] || continue
chmod 700 "$ssh_home"
chmod 600 "$ssh_home/authorized_keys" 2>/dev/null || true
done
chown -R 10000:10000 "$TARGET_ROOTFS/home/user/.ssh" 2>/dev/null || true
chown -R 0:0 "$TARGET_ROOTFS/etc/skel/.ssh" "$TARGET_ROOTFS/root/.ssh" \
2>/dev/null || true
echo "Bananarchy overlay applied to $TARGET_ROOTFS for device $DEVICE."
+76
View File
@@ -0,0 +1,76 @@
#!/bin/sh
# Build the compiled idle daemons for nokia-beatles and related MSM8909 targets.
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
SRC_DIR="$BASE_DIR/src/bananarchy-daemons"
PREBUILT="$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin"
OVERLAY="$BASE_DIR/overlay/rootfs/usr/bin"
NAMES="bananarchy-lid bananarchy-cover-idle bananarchy-volume-keys"
check_artifacts() {
for name in $NAMES; do
prebuilt="$PREBUILT/$name"
overlay="$OVERLAY/$name"
[ -x "$prebuilt" ] || {
echo "[!] missing compiled daemon: $prebuilt" >&2
return 1
}
[ -x "$overlay" ] || {
echo "[!] missing overlay daemon: $overlay" >&2
return 1
}
cmp -s "$prebuilt" "$overlay" || {
echo "[!] compiled daemon drift: $name" >&2
return 1
}
if [ "$(head -c 4 "$prebuilt" | od -An -tx1 | tr -d ' \n')" != "7f454c46" ]; then
echo "[!] $name is not an ELF binary" >&2
return 1
fi
if ! readelf -h "$prebuilt" 2>/dev/null | grep -q 'Machine:.*ARM'; then
echo "[!] $name is not an ARM binary" >&2
return 1
fi
done
echo "[ok] compiled idle daemons are ARM ELF binaries and overlay is in sync"
}
if [ "${1:-}" = "--check" ]; then
check_artifacts
exit 0
fi
docker run --rm --network=host \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-v "$BASE_DIR:/bananarchy" \
alpine:3.24 sh -eu -c '
cat > /etc/apk/repositories <<EOF
https://mirror.nura.eco/postmarketos/v26.06
https://dl-cdn.alpinelinux.org/alpine/edge/main
https://dl-cdn.alpinelinux.org/alpine/edge/community
https://dl-cdn.alpinelinux.org/alpine/edge/testing
EOF
mkdir -p /etc/apk/keys
cp /bananarchy/keys/*.rsa.pub /etc/apk/keys/
apk add --no-cache build-base gcc-armv7 binutils-armv7 \
musl-dev-armv7 linux-headers >/dev/null
mkdir -p /bananarchy/prebuilt/bananarchy-daemons/usr/bin \
/bananarchy/overlay/rootfs/usr/bin
for name in bananarchy-lid bananarchy-cover-idle bananarchy-volume-keys; do
armv7-alpine-linux-musleabihf-gcc -std=c11 -O2 -Wall -Wextra -Werror -s \
-I/bananarchy/src/bananarchy-daemons \
-o "/bananarchy/prebuilt/bananarchy-daemons/usr/bin/$name" \
"/bananarchy/src/bananarchy-daemons/$name.c"
cp -a "/bananarchy/prebuilt/bananarchy-daemons/usr/bin/$name" \
"/bananarchy/overlay/rootfs/usr/bin/$name"
echo "[+] built $name"
done
chown -R "$HOST_UID:$HOST_GID" \
/bananarchy/prebuilt/bananarchy-daemons \
/bananarchy/overlay/rootfs/usr/bin/bananarchy-lid \
/bananarchy/overlay/rootfs/usr/bin/bananarchy-cover-idle \
/bananarchy/overlay/rootfs/usr/bin/bananarchy-volume-keys
'
check_artifacts
+23 -3
View File
@@ -131,6 +131,10 @@ EOF
KBUILD_MODPOST_WARN=1 M=drivers/power/supply modules
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- -j"$(nproc)" \
KBUILD_MODPOST_WARN=1 M=drivers/net/wireless/ath/wcn36xx modules
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- -j"$(nproc)" \
KBUILD_MODPOST_WARN=1 M=drivers/mux modules
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- -j"$(nproc)" \
KBUILD_MODPOST_WARN=1 M=drivers/spi modules
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- -j"$(nproc)" \
KBUILD_MODPOST_WARN=1 M=drivers/gpu/drm/msm modules
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- -j"$(nproc)" \
@@ -169,6 +173,8 @@ EOF
/bananarchy/prebuilt/kernel-6.12.1-msm8916/netfilter \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/leds \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/camera \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/mux \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/spi \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/dtbs
cp -a sound/soc/qcom/qdsp6/*.ko /bananarchy/prebuilt/kernel-6.12.1-msm8916/qdsp6/
cp -a sound/soc/qcom/snd-soc-qcom-common.ko sound/soc/qcom/snd-soc-apq8016-sbc.ko \
@@ -188,6 +194,10 @@ EOF
/bananarchy/prebuilt/kernel-6.12.1-msm8916/leds/
cp -a /bananarchy/src/msm8905-cam/msm8905-cam.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/camera/
cp -a drivers/mux/mux-core.ko drivers/mux/mux-gpio.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/mux/
cp -a drivers/spi/spi-mux.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/spi/
armv7-alpine-linux-musleabihf-strip --strip-unneeded \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/qdsp6/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/qcom/*.ko \
@@ -198,7 +208,9 @@ EOF
/bananarchy/prebuilt/kernel-6.12.1-msm8916/drm/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/netfilter/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/leds/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/camera/*.ko
/bananarchy/prebuilt/kernel-6.12.1-msm8916/camera/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/mux/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/spi/*.ko
for ko in \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/qdsp6/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/qcom/*.ko \
@@ -209,14 +221,18 @@ EOF
/bananarchy/prebuilt/kernel-6.12.1-msm8916/drm/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/netfilter/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/leds/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/camera/*.ko; do
/bananarchy/prebuilt/kernel-6.12.1-msm8916/camera/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/mux/*.ko \
/bananarchy/prebuilt/kernel-6.12.1-msm8916/spi/*.ko; do
zstd -f -q -k "$ko" -o "${ko}.zst"
done
mkdir -p /bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/sound/soc/qcom/qdsp6 \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/bluetooth \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/mux \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/spi
cp -a /bananarchy/prebuilt/kernel-6.12.1-msm8916/qdsp6/*.ko.zst \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/sound/soc/qcom/qdsp6/
cp -a /bananarchy/prebuilt/kernel-6.12.1-msm8916/qcom/*.ko.zst \
@@ -229,6 +245,10 @@ EOF
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply/
cp -a /bananarchy/prebuilt/kernel-6.12.1-msm8916/wcn36xx/*.ko.zst \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx/
cp -a /bananarchy/prebuilt/kernel-6.12.1-msm8916/mux/*.ko.zst \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/mux/
cp -a /bananarchy/prebuilt/kernel-6.12.1-msm8916/spi/*.ko.zst \
/bananarchy/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/drivers/spi/
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- \
M=/bananarchy/src/leds-msm8905-torch clean
make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- \
+154
View File
@@ -0,0 +1,154 @@
#!/bin/sh
# Build the nokia-beatles lk2nd boot images from upstream source.
#
# ./scripts/build-lk2nd-beatles.sh build normal + diagnostic + display
# ./scripts/build-lk2nd-beatles.sh --check validate the shipped images only
# ./scripts/build-lk2nd-beatles.sh --only normal build just one variant
# ./scripts/build-lk2nd-beatles.sh --force-panel-init append lk2nd.force-panel-init to
# the normal image cmdline
# WITH_DISPLAY=1 ./scripts/build-lk2nd-beatles.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
PATCH="$BASE_DIR/bootloader/lk2nd/nokia-beatles.patch"
NORMAL_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-beatles.img"
DIAG_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-beatles-diagnostic.img"
DISPLAY_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-beatles-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,beatles"
# Default: lk2nd.no-display keeps a RAM-only framebuffer and never touches
# QUP SPI before USB is up. The panel can then be enabled at runtime with
# "fastboot oem display-init", which is safe because all QUP and clock polls
# are bounded. The -display.img variant uses lk2nd.display=on for boot-time
# panel initialization.
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,beatles lk2nd.no-display"
CMD_DISPLAY="lk2nd lk2nd.compatible=nokia,beatles lk2nd.display=on"
check_images() {
python3 "$BASE_DIR/scripts/check-lk2nd-beatles.py" \
--image "$NORMAL_IMAGE" --patch "$PATCH" --expect-fastboot 0
python3 "$BASE_DIR/scripts/check-lk2nd-beatles.py" \
--image "$DIAG_IMAGE" --patch "$PATCH" --expect-fastboot 1
python3 "$BASE_DIR/scripts/check-lk2nd-beatles.py" \
--image "$DISPLAY_IMAGE" --patch "$PATCH" --expect-fastboot 0 \
--expect-display 1 --allow-missing-cookie
}
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 "$PATCH" ]; then
echo "[!] missing $PATCH" >&2
exit 1
fi
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
if git -C "$SRC" apply --check --reverse "$PATCH" 2>/dev/null; then
echo "[*] nokia-beatles patch already applied"
else
echo "[*] applying nokia-beatles patch"
git -C "$SRC" apply --check "$PATCH"
git -C "$SRC" apply "$PATCH"
fi
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-beatles-a1109-r3 "" "$CMD_BASE" "$NORMAL_IMAGE"
fi
if [ "$ONLY" = all ] || [ "$ONLY" = diagnostic ]; then
# Forced fastboot + no SPI display: decisive probe when lk2nd hangs before
# USB. Run "fastboot oem display-init" / "oem display-test" from here to
# bring up the GC9305 panel without reflashing; "oem screenshot" verifies
# the framebuffer and "oem scan-dtb" stages the exact kernel DTB.
build_variant diagnostic bananarchy-beatles-a1109-diag-r3 \
"DEBUG=2 LK2ND_FORCE_FASTBOOT=1" "$CMD_DIAG" "$DIAG_IMAGE"
fi
if [ "$ONLY" = all ] || [ "$ONLY" = display ]; then
build_variant display bananarchy-beatles-a1109-display-r3 "" "$CMD_DISPLAY" "$DISPLAY_IMAGE"
fi
check_images
+95
View File
@@ -0,0 +1,95 @@
arch
ash
base64
bash
bbconfig
busybox
busybox-extras
cat
chattr
chgrp
chmod
chown
conspy
coreutils
cp
date
dd
df
dmesg
dnsdomainname
dumpkmap
echo
ed
egrep
false
fatattr
fdflush
fgrep
findmnt
fsync
getopt
grep
gunzip
gzip
hostname
ionice
iostat
ipcalc
kill
kmod
link
linux32
linux64
ln
login
ls
lsattr
lsblk
lsfd
lzop
makemime
mkdir
mknod
mktemp
more
mount
mountpoint
mpstat
mv
netstat
nice
pidof
ping
ping6
pipe_progress
pipesz
printenv
ps
pwd
rc-status
red
reformime
rev
rm
rmdir
run-parts
sed
setpriv
setserial
sh
sleep
stat
stty
su
sync
tar
touch
true
udevadm
umount
uname
usleep
watch
wdctl
zcat
+33
View File
@@ -0,0 +1,33 @@
acpid
adjtimex
arp
fbsplash
getty
halt
ifconfig
ifenslave
inotifyd
ipaddr
iplink
ipneigh
iproute
iprule
iptunnel
klogd
loadkmap
logread
mdev
nameif
poweroff
raidautorun
reboot
route
setconsole
slattach
sysctl
syslogd
tunctl
udhcpc
vconfig
watchdog
zcip
+151
View File
@@ -0,0 +1,151 @@
#!/usr/bin/env python3
"""Validate the 2720 Flip boot image before it is flashed over EDL.
Checks the Android header, the kernel+0x2c appended-DTB pointer, the exact
stock Qualcomm match IDs and the 512 MiB memory fallback inside the DTB. Skips
cleanly when the image has not been built yet, so check-rebuild.sh stays useful
in a fresh clone.
"""
import os
import struct
import sys
BOOT_MAGIC = b"ANDROID!"
FDT_MAGIC = 0xd00dfeed
DTB_OFFSET_FIELD = 0x2c
BOOT_PARTITION_BYTES = 26165248
FDT_BEGIN_NODE = 1
FDT_END_NODE = 2
FDT_PROP = 3
FDT_NOP = 4
FDT_END = 9
STOCK_MSM_ID = struct.pack(">2I", 0x14b, 0)
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)
def align(value, page):
return (value + page - 1) // page * page
def parse_fdt(data):
vals = struct.unpack_from(">10I", data, 0)
magic, totalsize, off_struct, off_strings, off_rsv, version = vals[:6]
size_strings, size_struct = vals[8], vals[9]
if magic != FDT_MAGIC:
raise ValueError("bad FDT magic")
if version not in (16, 17):
raise ValueError("unsupported FDT version %d" % version)
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[stack[-1]] = {}
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 main():
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
boot = os.path.join(base, "images", "boot-bananarchy-nokia-beatles.img")
if not os.path.isfile(boot):
print("[skip] 2720 boot image not built yet")
return 0
data = open(boot, "rb").read()
problems = []
if data[:8] != BOOT_MAGIC:
problems.append("not an Android boot image")
fields = struct.unpack_from("<8s8I", data, 0)
kernel_size, kernel_addr, ramdisk_size, ramdisk_addr = fields[1:5]
second_size, second_addr, tags_addr, page = fields[5:9]
if page != 2048:
problems.append("page size is %d, expected 2048" % page)
if len(data) > BOOT_PARTITION_BYTES:
problems.append("boot image is larger than the 25 MiB boot partition")
cmdline = data[64:576].split(b"\0")[0].decode("utf-8", "replace")
cmdline_parts = cmdline.split()
if "earlycon" in cmdline_parts:
problems.append("cmdline still contains earlycon")
if "quiet" not in cmdline_parts or "splash" not in cmdline_parts:
problems.append("cmdline is missing 'quiet splash' (Plymouth never starts)")
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:
problems.append("boot header load addresses do not match the stock 2720")
kernel_off = page
dtb_rel = struct.unpack_from("<I", data, kernel_off + DTB_OFFSET_FIELD)[0]
dtb_abs = kernel_off + dtb_rel
if not 0 < dtb_rel < kernel_size:
problems.append("kernel+0x2c points outside the kernel payload")
elif data[dtb_abs:dtb_abs + 4] != b"\xd0\x0d\xfe\xed":
problems.append("kernel+0x2c does not point at an FDT header")
else:
dtb = data[dtb_abs:kernel_off + kernel_size]
nodes, totalsize = parse_fdt(dtb)
if totalsize > len(dtb):
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)
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)
mem = None
for path, props in nodes.items():
if props.get("device_type") == b"memory\0":
mem = props
break
if mem is None:
problems.append("appended DTB has no /memory node")
elif mem.get("reg") != MEMORY_512M:
problems.append("appended DTB /memory:reg is not the 512 MiB fallback")
if ramdisk_size <= 0 or second_size != 0:
problems.append("unexpected ramdisk/second sizes")
if problems:
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")
return 0
if __name__ == "__main__":
sys.exit(main())
+471
View File
@@ -0,0 +1,471 @@
#!/usr/bin/env python3
"""Validate the source-built nokia-beatles lk2nd boot image.
The 2720's MSM8905 is a partial-goods (2-core) part. Its stock aboot calls
update_partial_goods_dtb_nodes() on the QCDT-selected DTB and ASSERTs when
/cpus, /cpus/cpu@2 or /cpus/cpu@3 (with a 4-byte device_type) is missing:
"Failed to get parent node: /cpus" then "panic: ASSERT FAILED at
(platform/msm_shared/partial_goods.c:80): 0". Upstream lk2nd DTBs have no
/cpus, so every lk2nd image crashed into Sahara memory-debug EDL before lk2nd
ran. The port adds /cpus to the common dtsi (all QCDT DTBs) plus a compact
/lk2nd/nokia-beatles node in the existing msm8905-qrd-skub DTB.
Checks (all offline, pure Python):
* Android boot.img header, cmdline and SEANDROIDENFORCE trailer.
* QCDT v2 exact 2720 entry (0x14b / 0x1000b / 0x100 / 0) and the QRD
fallback entry (0x14b / 0xb / 0x100); both must share one DTB.
* Every unique QCDT DTB has /cpus/cpu@2 and /cpus/cpu@3 with a 4-byte
device_type (the partial-goods ASSERT fix).
* The selected DTB's stock root IDs and the beatles device node.
* The beatles device node: model, compatible, match-panel, dtb-files and
all three aboot panel names, with the GC9305 v2 panel init stream.
* The patch and the shared parser header in the repo are in sync.
Use --emit-streams-header PATH to generate a C array for the host unit test
bootloader/lk2nd/test_spi_panel_init.c.
"""
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",
)
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"):
if needed not in subnodes:
problems.append(prefix + "missing %s (upstream node lost)" % needed)
node = "/lk2nd/nokia-beatles"
if node not in nodes:
problems.append(prefix + "missing /lk2nd/nokia-beatles")
return None
props = nodes[node]
if prop_str(nodes, node, "model") != "Nokia 2720 Flip":
problems.append(prefix + "wrong model %r" % prop_str(nodes, node, "model"))
if prop_str(nodes, node, "compatible") != "nokia,beatles":
problems.append(prefix + "wrong compatible %r" %
prop_str(nodes, node, "compatible"))
if "lk2nd,match-panel" not in props:
problems.append(prefix + "beatles node lost lk2nd,match-panel")
if prop_str(nodes, node, "lk2nd,dtb-files") != "msm8905-nokia-beatles":
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-beatles.img"))
ap.add_argument("--patch", default=os.path.join(base, "bootloader", "lk2nd", "nokia-beatles.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")
ap.add_argument("--allow-missing-cookie", action="store_true",
help="allow the known-good display image built before the low-bit reboot cookie")
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, ramdisk_addr = hdr[1:5]
second_size, second_addr, tags_addr, 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,beatles"] 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"):
if marker not in data:
problems.append("binary is missing %r" % marker.decode("ascii", "replace"))
if not args.allow_missing_cookie and \
b"beatles low-bit reboot cookie" not in data:
problems.append("binary is missing b'beatles 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 = {}
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 2720"),
(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 2720 QCDT entries must share the same DTB")
# Every QCDT DTB must survive aboot's partial-goods DTB patch.
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("2720 DTB is not an FDT")
else:
try:
nodes, totalsize = fdt_nodes(dtb)
if totalsize > dtb_size:
problems.append("2720 DTB is truncated (%d > %d)" %
(totalsize, dtb_size))
stream = check_device_node(nodes, "2720 DTB", problems)
except ValueError as exc:
problems.append("2720 DTB: %s" % exc)
# The shared parser header is stored verbatim in the repo for the host test.
header_path = os.path.join(base, "bootloader", "lk2nd", "spi-panel-init.h")
if not os.path.isfile(args.patch):
problems.append("missing source patch %s" % args.patch)
elif not os.path.isfile(header_path):
problems.append("missing %s" % header_path)
else:
patch_text = open(args.patch, "r").read()
want = open(header_path, "r").read()
got = extract_patch_file(patch_text, "lk2nd/include/lk2nd/spi-panel-init.h")
if got != want:
problems.append("bootloader/lk2nd/spi-panel-init.h is out of sync with the patch")
for needed in (
"app/aboot/aboot.c",
"lk2nd/boot/extlinux.c",
"lk2nd/device/2nd/scan-boot.c",
"lk2nd/device/dts/lk2nd.dtsi",
"lk2nd/device/dts/msm8909/nokia-beatles.dtsi",
"lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts",
"lk2nd/device/2nd/spi-display.c",
"lk2nd/fastboot/fetch.c",
"platform/msm_shared/mdss_spi.c",
"platform/msm_shared/reboot.c",
):
if "diff --git a/%s b/%s" % (needed, needed) not in patch_text:
problems.append("patch is missing %s" % needed)
if "mdss_spi_panel_init_commands" not in patch_text or \
"lk2nd,panel-init" not in patch_text:
problems.append("patch is missing the panel initialization code")
if "diff --git a/lk2nd/device/dts/lk2nd.dtsi" not in patch_text:
problems.append("patch is missing the /cpus fix in lk2nd.dtsi")
if "oem scan-boot" not in patch_text:
problems.append("patch is missing the oem scan-boot diagnostic command")
if "diff --git a/lk2nd/ramoops/ramoops.c" not in patch_text:
problems.append("patch is missing the always-on ramoops console fix")
if "scan-only: final kernel cmdline/DTB ready" not in patch_text:
problems.append("patch is missing the final-DTB scan-only hook")
if "No valid pstore console" not in patch_text:
problems.append("patch is missing ramoops console validation")
if "SPI panel fallback from QCDT" not in patch_text:
problems.append("patch is missing the chain-loaded panel fallback")
if "per-word SPEW log" not in patch_text:
problems.append("patch is missing the QUP log flood fix")
if "offset is not block-aligned" not in patch_text:
problems.append("patch is missing the block-safe read-partition guard")
for needed in (
"diff --git a/platform/msm_shared/spi_qup.c" in patch_text,
"diff --git a/platform/msm_shared/clock_lib2.c" in patch_text,
):
if not needed:
problems.append("patch is missing a bounded QUP/clock poll")
if "oem display-init" not in patch_text:
problems.append("patch is missing the runtime display probe")
if "lk2nd.display=on" not in patch_text:
problems.append("patch is missing the boot-time display option")
if "platform/msm_shared/reboot.c" not in patch_text or \
"beatles low-bit reboot cookie" not in patch_text:
problems.append("patch is missing the low-bit lk2nd menu reboot cookie")
if problems:
for problem in problems:
print("FAIL: %s" % problem)
return 1
print("[ok] source-built beatles 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] 2720 DTB keeps the upstream board-id order and carries the "
"beatles node with the GC9305 v2 panel init stream")
print("[ok] patch/header in sync")
if args.emit_streams_header:
out = ["/* generated by scripts/check-lk2nd-beatles.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())
+625 -3
View File
@@ -131,6 +131,545 @@ if ! grep -q '^from Library\.sahara import qualcomm_sahara$' "$BASE_DIR/flash-ed
fail "flash-edl.py is missing the Sahara client import"
fi
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
if ! grep -q "\"$dev\":" "$BASE_DIR/flash-edl.py"; then
fail "DEVICE_LOADERS is missing $dev"
fi
done
for mbn in 8110.mbn 2720.mbn 2720v.mbn 800t.mbn 8k.mbn; do
if [ ! -s "$BASE_DIR/bootloader/loaders/$mbn" ]; then
fail "missing bootloader/loaders/$mbn"
fi
done
for mapping in \
'"nokia-beatles": "2720.mbn"' \
'"nokia-tough": "800t.mbn"' \
'"nokia-sparkler": "8k.mbn"' \
'"nokia-leo": "8k.mbn"' \
'"us": "2720v.mbn"'; do
if ! grep -qF "$mapping" "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py loader mapping lost: $mapping"
fi
done
if ! grep -q '^VARIANT_LOADER_IDENTITIES' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the variant identity map"
fi
if ! grep -q '^EDL_PIDS = ' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the EDL PID auto-detection list"
fi
for edlpid in 9008 900E 9006; do
if ! grep -qi "0x$edlpid" "$BASE_DIR/flash-edl.py"; then
fail "EDL_PIDS is missing 0x$edlpid"
fi
done
if ! grep -q '^BOOT_IMAGE_DEVICES' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the boot-image device list"
fi
if ! grep -q '^BOOT_METHOD_PARTITIONS' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the method-to-partition map"
fi
if ! grep -q '^def resolve_boot_method' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing resolve_boot_method()"
fi
if ! grep -q '^def resolve_wipe_system' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the system wipe guard"
fi
if ! grep -q '^def verify_partition' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the partition read-back verification"
fi
if ! grep -q '^BOOT_METHOD_TARGETS' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the dual boot/recovery target map"
fi
if ! grep -q '^def dump_diagnostics' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the EDL diagnostic partition dump"
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"
fi
for variant in normal diagnostic display; do
case "$variant" in
normal)
image="$BASE_DIR/images/boot-lk2nd-nokia-beatles.img"
opts="--expect-fastboot 0"
label="source-built nokia-beatles lk2nd"
;;
diagnostic)
image="$BASE_DIR/images/boot-lk2nd-nokia-beatles-diagnostic.img"
opts="--expect-fastboot 1"
label="nokia-beatles forced-fastboot diagnostic image"
;;
display)
image="$BASE_DIR/images/boot-lk2nd-nokia-beatles-display.img"
opts="--expect-fastboot 0 --expect-display 1 --allow-missing-cookie"
label="nokia-beatles known-good display lk2nd image"
;;
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-beatles.py" \
--image "$image" $opts; then
fail "$label validation failed"
fi
done
if ! grep -qF 'BEATLES_LK2ND_IMAGE = "images/boot-lk2nd-nokia-beatles-display.img"' \
"$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py no longer defaults to the display-enabled lk2nd image"
fi
if ! grep -qF 'target_names = ("boot", "recovery", "lk2nd")' \
"$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py no longer refreshes the separate lk2nd partition"
fi
for f in bootloader/lk2nd/nokia-beatles.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
if [ ! -f "$BASE_DIR/$f" ]; then
fail "missing nokia-beatles lk2nd port file: $f"
fi
done
if [ -f "$BASE_DIR/scripts/make-beatles-lk2nd-bootimg.py" ]; then
fail "obsolete binary-patch lk2nd script is still present"
fi
if grep -q 'target_parts\[0\]\[1\]' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py still writes only the first lk2nd target slot"
fi
if ! grep -q 'write_partition(fh, args.lun, part, source)' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py lost the multi-target write loop"
fi
if ! grep -q 'def source_for(name):' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py lost the Argon-shaped hybrid per-slot source"
fi
if [ ! -f "$BASE_DIR/scripts/dump-edl-crash.py" ]; then
fail "missing scripts/dump-edl-crash.py"
fi
if ! grep -q '^UNLOCK_DEFAULT_DEVICES' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the locked-bootloader unlock default"
fi
if ! grep -q '^def unlock_devinfo' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the devinfo unlock helper"
fi
if ! grep -q '^OEM_UNLOCK_PARTITIONS' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the RPMB unlock prerequisite map"
fi
if ! grep -q '^def enable_oem_unlock' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the config/frp OEM unlock helper"
fi
if [ ! -f "$BASE_DIR/scripts/make-oem-unlock-config.py" ]; then
fail "missing scripts/make-oem-unlock-config.py"
fi
if [ ! -f "$BASE_DIR/scripts/make-unlocked-devinfo.py" ]; then
fail "missing scripts/make-unlocked-devinfo.py"
fi
if ! grep -q 'boot-bananarchy-\$TARGET_DEVICE.img' "$BASE_DIR/rebuild-image.sh"; then
fail "rebuild-image.sh no longer exports a standalone boot.img"
fi
if [ ! -L "$BASE_DIR/overlay/rootfs/sbin/init" ] || \
[ "$(readlink "$BASE_DIR/overlay/rootfs/sbin/init")" != "/bin/busybox" ]; then
fail "overlay/rootfs/sbin/init is no longer a /bin/busybox symlink"
fi
for cmdline_file in "$BASE_DIR"/devices/*/kernel-cmdline.conf \
"$BASE_DIR"/overlay/rootfs/usr/lib/kernel-cmdline.d/50-device-*.conf; do
if grep -qxF 'earlycon' "$cmdline_file"; then
fail "$(basename "$cmdline_file") still contains earlycon"
fi
done
# A pre-existing rootfs/ build tree is reused by rebuild-image.sh, so its
# copies of the device cmdline fragments must stay in sync with the overlay.
for cmdline_file in "$BASE_DIR"/rootfs/usr/lib/kernel-cmdline.d/50-device-*.conf; do
[ -f "$cmdline_file" ] || continue
if grep -qxF 'earlycon' "$cmdline_file"; then
fail "rootfs/usr/lib/kernel-cmdline.d/$(basename "$cmdline_file") still contains earlycon"
fi
done
echo "[check] BusyBox applet symlinks..."
APPLET_LIST="$BASE_DIR/scripts/busybox-applets.txt"
if [ ! -f "$APPLET_LIST" ]; then
fail "missing scripts/busybox-applets.txt"
fi
for applet in ash grep sed ps; do
if ! grep -qxF "$applet" "$APPLET_LIST"; then
fail "scripts/busybox-applets.txt is missing $applet"
fi
done
if ! grep -q 'busybox-applets.txt' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "the overlay no longer restores missing BusyBox applet symlinks"
fi
# The shipped rootfs is validated by scripts/sync-beatles-bootfs.py --check
# and by an explicit image build; the overlay script above is the source of
# truth for the applet symlinks, so avoid extracting a 1.3 GiB partition here.
RAW_IMAGE="$BASE_DIR/images/bananarchy-nokia-beatles.img"
if [ -f "$RAW_IMAGE" ] && [ "$(stat -c %s "$RAW_IMAGE")" -lt 1000000000 ]; then
fail "the shipped raw image is truncated"
fi
echo "[check] Known-good flashable image set..."
for pair in \
"b4d0555f17dd1e224069641603ff3d120fd3ea5c219a34de227caf240a077558 images/bananarchy-nokia-argon.img" \
"e2267187c58920b5c5b822d940b81e0df8f59e7788fed00e3d31dfbdb290c7fc images/bananarchy-nokia-beatles.img" \
"6715abd414fd02fd21ca8c2cd621a8a21e78f46d079b2d185b38a1f7a4a3e659 images/boot-bananarchy-nokia-beatles.img" \
"e1fdd8551b6393184a465638881b63ca58c04e1e8f655f092260a18379e1cbe6 images/boot-lk2nd-nokia-beatles-display.img"; do
set -- $pair
want=$1
path="$BASE_DIR/$2"
if [ ! -f "$path" ]; then
echo "[skip] local build output $2 is absent; prepare-release.sh will rebuild it"
continue
elif [ "$(sha256sum "$path" | cut -d' ' -f1)" != "$want" ]; then
fail "$2 no longer matches the physically verified known-good image"
fi
done
echo "[check] Compiled idle daemons..."
DAEMONS="bananarchy-lid bananarchy-cover-idle bananarchy-volume-keys"
for daemon in $DAEMONS; do
for artifact in "prebuilt/bananarchy-daemons/usr/bin/$daemon" \
"overlay/rootfs/usr/bin/$daemon"; do
path="$BASE_DIR/$artifact"
if [ ! -x "$path" ]; then
fail "missing compiled daemon: $artifact"
continue
fi
if [ "$(head -c 4 "$path" | od -An -tx1 | tr -d ' \n')" != "7f454c46" ] || \
! readelf -h "$path" 2>/dev/null | grep -q 'Machine:.*ARM'; then
fail "$artifact is not an ARM ELF binary"
fi
done
if ! cmp -s "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/$daemon" \
"$BASE_DIR/overlay/rootfs/usr/bin/$daemon"; then
fail "compiled daemon drift: $daemon"
fi
done
if ! "$BASE_DIR/scripts/build-bananarchy-daemons.sh" --check >/dev/null 2>&1; then
fail "compiled idle daemon build check failed"
fi
for src in src/bananarchy-daemons/common.h \
src/bananarchy-daemons/bananarchy-lid.c \
src/bananarchy-daemons/bananarchy-cover-idle.c \
src/bananarchy-daemons/bananarchy-volume-keys.c; do
if [ ! -f "$BASE_DIR/$src" ]; then
fail "missing C daemon source: $src"
fi
done
if ! grep -q 'CLOSED_MASK' "$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c" || \
! grep -q 'sxmo_state.sh' "$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c" || \
! grep -q 'strcmp(level, "low")' "$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c"; then
fail "the compiled lid daemon lost its raw hall GPIO fallback"
fi
if ! grep -q 'SOCK_DGRAM' "$BASE_DIR/src/bananarchy-daemons/bananarchy-cover-idle.c" || \
! grep -q 'STATUS' "$BASE_DIR/src/bananarchy-daemons/bananarchy-cover-idle.c"; then
fail "the compiled cover daemon lost the coverctl protocol"
fi
if grep -qF 'mmap(' "$BASE_DIR/src/bananarchy-daemons/bananarchy-cover-idle.c" || \
! grep -qF 'write_all' "$BASE_DIR/src/bananarchy-daemons/bananarchy-cover-idle.c" || \
! grep -qF 'fb_geometry' "$BASE_DIR/src/bananarchy-daemons/bananarchy-cover-idle.c"; then
fail "the cover renderer lost the 32-bpp fbdev write() path"
fi
if ! grep -q 'flock' "$BASE_DIR/src/bananarchy-daemons/common.h" || \
! grep -q 'prune_devices' "$BASE_DIR/src/bananarchy-daemons/common.h" || \
! grep -q 'setuid(SESSION_UID)' "$BASE_DIR/src/bananarchy-daemons/common.h" || \
! grep -q 'KEY_VOLUMEUP' "$BASE_DIR/src/bananarchy-daemons/common.h"; then
fail "the compiled daemons lost singleton/stale-fd/privilege guards"
fi
if grep -RInE "bananarchy-(lid|cover-idle|volume-keys)\.py" \
"$BASE_DIR/overlay/rootfs/etc/init.d" "$BASE_DIR/src/bananarchy-daemons" \
>/dev/null 2>&1; then
fail "a Python daemon reference remains in the idle service wiring"
fi
for stale in overlay/rootfs/usr/bin/bananarchy-lid.py \
overlay/rootfs/usr/bin/bananarchy-cover-idle.py \
overlay/rootfs/usr/bin/bananarchy-volume-keys.py \
rootfs/usr/bin/bananarchy-lid.py \
rootfs/usr/bin/bananarchy-cover-idle.py \
rootfs/usr/bin/bananarchy-volume-keys.py; do
if [ -e "$BASE_DIR/$stale" ] || [ -L "$BASE_DIR/$stale" ]; then
fail "retired Python daemon still present: $stale"
fi
done
for svc in bananarchy-lid bananarchy-cover-display bananarchy-volume-keys; do
case "$svc" in
bananarchy-lid) want='command="/usr/bin/bananarchy-lid"' ;;
bananarchy-cover-display) want='command="/usr/bin/bananarchy-cover-idle"' ;;
bananarchy-volume-keys) want='command="/usr/bin/bananarchy-volume-keys"' ;;
esac
if ! grep -qF "$want" "$BASE_DIR/overlay/rootfs/etc/init.d/$svc"; then
fail "$svc does not start its compiled daemon"
fi
done
if ! grep -qF 'xset r rate 180 30' \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh"; then
fail "the X session no longer lowers keypad auto-repeat delay"
fi
for hook in overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh \
overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh \
overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh; do
if ! grep -qF 'superctl stop sxmo_networkmonitor' "$BASE_DIR/$hook" || \
! grep -qF 'bananarchy_kill_matches "nmcli device monitor"' "$BASE_DIR/$hook"; then
fail "$hook no longer stops the nmcli device monitor poller"
fi
done
echo "[check] Camera, volume keys and cover spidev wiring..."
HW_MODULES="$BASE_DIR/overlay/rootfs/etc/modules-load.d/bananarchy-hardware.conf"
if [ ! -f "$HW_MODULES" ] || ! grep -q '^msm8905-cam' "$HW_MODULES"; then
fail "the camera driver is no longer loaded at boot"
fi
if ! grep -q 'msm8905-cam' "$BASE_DIR/overlay/rootfs/etc/local.d/10-bananarchy-hardware.start"; then
fail "the local.d hardware fallback no longer loads the camera driver"
fi
if [ ! -f "$BASE_DIR/scripts/busybox-sbin-applets.txt" ] || \
! grep -qxF 'reboot' "$BASE_DIR/scripts/busybox-sbin-applets.txt"; then
fail "the /sbin BusyBox applet list is missing reboot (Sxmo power menu)"
fi
if ! grep -q 'busybox-sbin-applets.txt' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "the overlay no longer restores /sbin BusyBox applets"
fi
if ! grep -qF 'rm -f "$TARGET_ROOTFS/bin/$applet"' \
"$BASE_DIR/scripts/apply-bananarchy-overlay.sh" || \
! grep -qF 'rm -f "$TARGET_ROOTFS/sbin/$applet"' \
"$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "the overlay no longer repairs dangling BusyBox applet symlinks"
fi
if ! grep -q 'bananarchy_set_sink_volume' "$BASE_DIR/overlay/rootfs/usr/bin/sxmo_audio.sh"; then
fail "sxmo_audio.sh no longer mirrors volume into the PipeWire sink"
fi
if ! grep -q 'bananarchy_vol_debounce' "$BASE_DIR/overlay/rootfs/usr/bin/sxmo_audio.sh"; then
fail "double volume steps are no longer debounced"
fi
if ! grep -q 'poll(fds' "$BASE_DIR/src/bananarchy-daemons/bananarchy-volume-keys.c" || \
! grep -q 'drop_device' "$BASE_DIR/src/bananarchy-daemons/bananarchy-volume-keys.c"; then
fail "the compiled volume daemon lost its stale-fd pruning"
fi
if grep -q '/usr/bin/su' "$BASE_DIR/src/bananarchy-daemons/"*.c; then
fail "the compiled daemons still call the nonexistent /usr/bin/su"
fi
if ! grep -q 'proc/uptime' "$BASE_DIR/overlay/rootfs/usr/bin/sxmo_audio.sh"; then
fail "the volume debounce is no longer timestamp based"
fi
if ! grep -q 'bananarchy-volume-keys' "$BASE_DIR/overlay/rootfs/etc/init.d/bananarchy-volume-keys"; then
fail "the volume-key service is missing"
fi
if ! grep -q 'spidev@1' "$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" || \
! dtc -I dtb -O dts "$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb" 2>/dev/null | \
grep -q 'spidev@1'; then
fail "the cover panel spidev@1 node is missing from the shipping DTS/DTB"
fi
if ! grep -q '^dc_gpio = -1' "$BASE_DIR/overlay/rootfs/etc/bananarchy/cover-display.conf"; then
fail "the cover daemon config would collide with the internal panel DC GPIO"
fi
echo "[check] USB SSH access and boot splash..."
PAM_SSHD="$BASE_DIR/overlay/rootfs/etc/pam.d/sshd"
SSHD_ACCESS="$BASE_DIR/overlay/rootfs/etc/ssh/sshd_config.d/90-bananarchy-access.conf"
if [ ! -f "$PAM_SSHD" ] || ! grep -q 'pam_unix.so' "$PAM_SSHD"; then
fail "overlay/rootfs/etc/pam.d/sshd is missing (UsePAM yes cannot authenticate)"
fi
if [ ! -f "$SSHD_ACCESS" ] || \
! grep -q '^PasswordAuthentication yes' "$SSHD_ACCESS" || \
! grep -q '^KbdInteractiveAuthentication yes' "$SSHD_ACCESS"; then
fail "sshd access drop-in no longer enables password authentication"
fi
for ak in "$BASE_DIR"/overlay/rootfs/etc/skel/.ssh/authorized_keys \
"$BASE_DIR"/overlay/rootfs/home/user/.ssh/authorized_keys \
"$BASE_DIR"/overlay/rootfs/root/.ssh/authorized_keys; do
if [ ! -f "$ak" ] || ! cmp -s "$ak" "$BASE_DIR/keys/phone_id_ed25519.pub"; then
fail "${ak#$BASE_DIR/} no longer carries the phone SSH key"
fi
done
if ! grep -q 'chmod 700 "$ssh_home"' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh" || \
! grep -q 'chown -R 10000:10000' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "the overlay no longer fixes authorized_keys ownership/modes"
fi
if ! grep -q 'SSHD_BINARY="/usr/sbin/sshd.pam"' "$BASE_DIR/overlay/rootfs/etc/conf.d/sshd"; then
fail "the PAM-enabled sshd binary is no longer pinned"
fi
if ! grep -q '^ListenAddress 172.16.42.1:2222' "$BASE_DIR/overlay/rootfs/etc/ssh/sshd_config_debug" || \
grep -qE '^[[:space:]]*UsePAM' "$BASE_DIR/overlay/rootfs/etc/ssh/sshd_config_debug"; then
fail "the USB-only fallback sshd config is no longer PAM-free and USB-only"
fi
if ! grep -q 'def release_cmdline' "$BASE_DIR/scripts/sync-beatles-bootfs.py" || \
! grep -q "missing 'quiet splash'" "$BASE_DIR/scripts/sync-beatles-bootfs.py"; then
fail "sync-beatles-bootfs.py no longer restores/guards the quiet splash cmdline"
fi
if ! grep -q "Plymouth never starts" "$BASE_DIR/scripts/check-beatles-bootimg.py"; then
fail "check-beatles-bootimg.py no longer guards the splash cmdline"
fi
echo "[check] 2720 Flip keypad and cover display support..."
for f in overlay/rootfs/usr/lib/udev/rules.d/99-bananarchy-keypad.rules \
overlay/rootfs/usr/share/X11/xorg.conf.d/60-bananarchy-keypad.conf \
overlay/rootfs/usr/bin/bananarchy-keypad-diagnose.sh \
overlay/rootfs/usr/bin/bananarchy-coverd \
overlay/rootfs/usr/bin/bananarchy-cover-msg \
overlay/rootfs/etc/init.d/bananarchy-cover-display \
overlay/rootfs/etc/bananarchy/cover-display.conf \
devices/nokia-beatles/cover-panel.dtsi \
devices/nokia-beatles/nokia,beatles-gc9305-ext-panel.bin \
devices/nokia-beatles/nokia,beatles-gc9305-ext-panel.txt; do
if [ ! -f "$BASE_DIR/$f" ]; then
fail "missing $f"
fi
done
if ! grep -q 'MatchProduct "keypad"' \
"$BASE_DIR/overlay/rootfs/usr/share/X11/xorg.conf.d/60-bananarchy-keypad.conf"; then
fail "the keypad Xorg InputClass lost its explicit MatchProduct"
fi
if ! grep -q 'ID_INPUT_KEYBOARD' \
"$BASE_DIR/overlay/rootfs/usr/lib/udev/rules.d/99-bananarchy-keypad.rules"; then
fail "the keypad udev rule no longer forces ID_INPUT_KEYBOARD"
fi
if ! grep -q 'TAG+="seat"' \
"$BASE_DIR/overlay/rootfs/etc/udev/rules.d/99-bananarchy-input-seat.rules"; then
fail "the input seat udev rule no longer tags event nodes for elogind"
fi
if [ "$(head -c 4 "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-coverd" | od -An -tx1 | tr -d ' \n')" != "7f454c46" ]; then
fail "bananarchy-coverd is no longer the compiled armv7 daemon"
fi
if ! cmp -s "$BASE_DIR/prebuilt/bananarchy-coverd/usr/bin/bananarchy-coverd" \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-coverd"; then
fail "the cover daemon binary drifted from prebuilt/"
fi
if ! grep -q 'lid-profile' "$BASE_DIR/overlay/rootfs/etc/init.d/bananarchy-cover-display"; then
fail "the flip-device cover service lost its lid-profile gate"
fi
COVER_SCRATCH="/tmp/bantam/9064bb701d9e9f7c6412f0ea6846d88a"
COVER_DTBO="$COVER_SCRATCH/cover-panel-check.dtbo"
COVER_DTS="$COVER_SCRATCH/beatles-cover-check.dts"
COVER_DTS_BUILD="$COVER_SCRATCH/beatles-dts-check.dtb"
BEATLES_DTB="$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb"
BEATLES_DTS="$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts"
mkdir -p "$COVER_SCRATCH"
if ! dtc -@ -I dts -O dtb -o "$COVER_DTBO" \
"$BASE_DIR/devices/nokia-beatles/cover-panel.dtsi" >/dev/null 2>&1; then
fail "devices/nokia-beatles/cover-panel.dtsi does not compile"
fi
if ! dtc -I dts -O dtb -o "$COVER_DTS_BUILD" "$BEATLES_DTS" >/dev/null 2>&1; then
fail "the shipping beatles DTS does not compile"
fi
if ! cmp -s "$COVER_DTS_BUILD" "$BEATLES_DTB"; then
fail "the shipping beatles DTB drifted from its DTS source"
fi
if ! dtc -I dtb -O dts -o "$COVER_DTS" "$BEATLES_DTB" >/dev/null 2>&1; then
fail "the shipping beatles DTB cannot be decompiled"
fi
for token in 'qcom,msm-id = <0x14b 0x00>;' \
'qcom,board-id = <0x1000b 0x100>;' \
'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;'; do
if ! grep -qF "$token" "$COVER_DTS"; then
fail "the shipping beatles DTB lost a stock Qualcomm ID ($token)"
fi
done
if grep -qF 'compatible = "spi-mux"' "$COVER_DTS" || \
grep -qF 'compatible = "gpio-mux"' "$COVER_DTS"; then
fail "the shipping beatles DTB still applies the hardware-gated cover overlay"
fi
if ! grep -A4 'spidev@1 {' "$COVER_DTS" | grep -qF 'status = "okay"'; then
fail "the shipping beatles DTB lost the spidev@1 diagnostic fallback"
fi
rm -f "$COVER_DTBO" "$COVER_DTS" "$COVER_DTS_BUILD"
for opt in CONFIG_MULTIPLEXER=m CONFIG_MUX_GPIO=m CONFIG_SPI_MUX=m; do
if ! grep -qxF "$opt" "$BASE_DIR/patches/kernel/config-bananarchy-msm8909.armv7"; then
fail "kernel config is missing $opt (cover panel spi-mux)"
fi
done
echo "[check] 2720 Flip appended DTB..."
BEATLES_DTS="$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts"
if ! grep -qF 'qcom,msm-id = <0x14b 0x00>;' "$BEATLES_DTS"; then
fail "nokia-beatles DTS lost the stock MSM8905 msm-id"
fi
if ! grep -qF 'qcom,board-id = <0x1000b 0x100>;' "$BEATLES_DTS"; then
fail "nokia-beatles DTS lost the exact stock QRD SKUB board-id"
fi
if ! grep -qF 'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;' "$BEATLES_DTS"; then
fail "nokia-beatles DTS lost the stock pmic-id"
fi
if ! grep -qF 'reg = <0x80000000 0x20000000>;' "$BEATLES_DTS"; then
fail "nokia-beatles DTS lost the 512 MiB memory fallback"
fi
if [ -f "$BASE_DIR/images/boot-bananarchy-nokia-beatles.img" ]; then
if ! python3 "$BASE_DIR/scripts/check-beatles-bootimg.py"; then
fail "2720 boot image validation failed"
fi
else
echo "[skip] local build output images/boot-bananarchy-nokia-beatles.img is absent; prepare-release.sh will rebuild it"
fi
if [ -f "$BASE_DIR/images/bananarchy-nokia-beatles.img" ]; then
if ! python3 "$BASE_DIR/scripts/sync-beatles-bootfs.py" --check --raw-image "$BASE_DIR/images/bananarchy-nokia-beatles.img"; then
fail "2720 raw image pmOS_boot filesystem is damaged or stale"
fi
else
echo "[skip] local build output images/bananarchy-nokia-beatles.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" \
"$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/kernel-config" \
"$BASE_DIR/overlay/rootfs/boot/config"; do
if grep -qE '^CONFIG_PSTORE_BLK(_[A-Z0-9_]+)?=' "$cfg" 2>/dev/null || \
grep -qx 'CONFIG_PSTORE_ZONE=y' "$cfg" 2>/dev/null || \
! grep -qxF '# CONFIG_PSTORE_BLK is not set' "$cfg"; then
fail "${cfg#"$BASE_DIR/"} still carries the abandoned pstore_blk diagnostic config"
fi
done
for sysmap in "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/System.map" \
"$BASE_DIR/overlay/rootfs/boot/System.map"; do
if grep -q 'pstore_blk_get_config' "$sysmap"; then
fail "${sysmap#"$BASE_DIR/"} was built with pstore_blk"
fi
done
for art in prebuilt/kernel-6.12.1-msm8916/mux/mux-core.ko.zst \
prebuilt/kernel-6.12.1-msm8916/mux/mux-gpio.ko.zst \
prebuilt/kernel-6.12.1-msm8916/spi/spi-mux.ko.zst; do
if [ ! -f "$BASE_DIR/$art" ]; then
fail "missing built spi-mux module: $art"
fi
done
if ! grep -q 'M=drivers/mux modules' "$BASE_DIR/scripts/build-kernel-audio.sh" || \
! grep -q 'M=drivers/spi modules' "$BASE_DIR/scripts/build-kernel-audio.sh"; then
fail "build-kernel-audio.sh no longer builds the spi-mux modules"
fi
for mod in mux-core mux-gpio spi-mux; do
if ! grep -qxF "$mod" "$BASE_DIR/overlay/rootfs/etc/modules-load.d/bananarchy-hardware.conf"; then
fail "modules-load.d is missing $mod"
fi
done
if ! grep -q 'PON_SOFT_RB_SPARE.*0x02U' "$BASE_DIR/src/leds-msm8905-torch/leds-msm8905-torch.c"; then
fail "the torch reboot cookie no longer selects the lk2nd Fastboot menu"
fi
for stale in images/boot-bananarchy-nokia-beatles-debug.img \
images/boot-bananarchy-nokia-beatles-ramoops.img; do
if [ -f "$BASE_DIR/$stale" ]; then
fail "stale diagnostic boot image is still present: $stale"
fi
done
LK2ND_PATCH="$BASE_DIR/bootloader/lk2nd/nokia-beatles.patch"
if ! grep -qF 'platform/msm_shared/reboot.c' "$LK2ND_PATCH" || \
! grep -qF 'beatles low-bit reboot cookie' "$LK2ND_PATCH"; then
fail "lk2nd patch is missing the low-bit Fastboot menu reboot cookie"
fi
if grep -q -- '--debug-boot' "$BASE_DIR/flash-edl.py" || \
grep -q 'resolve_beatles_debug_boot_image' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py still references the abandoned debug boot image"
fi
echo "[check] Plugin artifacts..."
for source in "$BASE_DIR"/src/dwm-plugins/*_plugin.cpp; do
name="$(basename "$source" _plugin.cpp)"
@@ -233,6 +772,84 @@ if [ "$FOCUS_CALLS" -lt 2 ]; then
fail "link focus and wrap toggle must both call ensureFocusedLinkVisible"
fi
echo "[check] Flip lid responsiveness..."
LID_SRC="$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c"
for token in '#define LID_STABLE_MS 80' 'BA_EVIOCGSW' 'LID_STATE_FILE' \
'LOCKER_FIFO' 'unlink(LOCK_FLAG)'; do
if ! grep -qF "$token" "$LID_SRC"; then
fail "the compiled lid daemon lost the low-latency EV_SW/unlock path ($token)"
fi
done
if grep -qF 'closed != was_closed' "$LID_SRC" || \
grep -qF '#define LID_STABLE_MS 600' "$LID_SRC"; then
fail "the compiled lid daemon still accepts slow immediate hall transitions"
fi
echo "[check] Fast X startup and boot keypad state..."
if ! grep -q '^rc_parallel="YES"' "$BASE_DIR/overlay/rootfs/etc/rc.conf"; then
fail "OpenRC parallel startup is disabled"
fi
if grep -qF 'after *' "$BASE_DIR/overlay/rootfs/etc/init.d/local"; then
fail "the local service still deadlocks with parallel startup via 'after *'"
fi
if ! grep -q '^udev_settle_timeout=2' \
"$BASE_DIR/overlay/rootfs/etc/conf.d/udev-settle"; then
fail "udev-settle can still hold X startup behind missing modem firmware"
fi
if ! grep -qF '/run/bananarchy/lid-state' \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh"; then
fail "X no longer uses the debounced lid state at boot"
fi
if ! grep -qF 'Keep the first 10 s of an open-lid boot unlocked' \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh"; then
fail "X lost the open-lid boot unlock guard against transient xlocker state"
fi
if ! grep -qF 'dwm-plugin dmenu close' \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh" || \
! grep -qF 'xdotool key --clearmodifiers Escape' \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh"; then
fail "X lost the one-shot stale startup keyboard grab cleanup"
fi
if ! grep -qF 'before bananarchy-cover-display tinydm' \
"$BASE_DIR/overlay/rootfs/etc/init.d/bananarchy-lid"; then
fail "the lid daemon no longer starts before tinydm"
fi
for f in etc/rc.conf etc/conf.d/udev-settle \
usr/bin/bananarchy-x11-session.sh etc/init.d/bananarchy-lid \
etc/init.d/bananarchy-sshd-debug etc/init.d/local \
etc/local.d/20-bananarchy-sshd-debug.start; do
if ! cmp -s "$BASE_DIR/overlay/rootfs/$f" "$BASE_DIR/rootfs/$f"; then
fail "live rootfs copy drifted from overlay: $f"
fi
done
if [ ! -L "$BASE_DIR/overlay/rootfs/etc/runlevels/default/bananarchy-sshd-debug" ]; then
fail "the USB diagnostic sshd is missing from the default runlevel"
fi
if ! grep -qF 'rc-service bananarchy-sshd-debug status' \
"$BASE_DIR/overlay/rootfs/etc/local.d/20-bananarchy-sshd-debug.start" || \
! grep -qF 'ln -sf /etc/init.d/bananarchy-sshd-debug' \
"$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "the USB diagnostic sshd fallback is not independently started"
fi
if ! grep -qF 'cmd == "CLOSE" || cmd == "UNLOCK"' \
"$BASE_DIR/src/dwm-plugins/locker_plugin.cpp" || \
! grep -qF 'unlockPhone(false);' \
"$BASE_DIR/src/dwm-plugins/locker_plugin.cpp"; then
fail "locker.so no longer releases a stale grab on a trusted lid-open CLOSE"
fi
echo "[check] Known-good keypad wake guard..."
if ! grep -qF 'last_wake_ms) < 350' "$BASE_DIR/src/sxmo-dwm/dwm.c" || \
grep -qF 'WAKE_KEY_DEBOUNCE_MS' "$BASE_DIR/src/sxmo-dwm/dwm.c"; then
fail "dwm no longer uses the known-good 350 ms wake guard"
fi
if ! grep -qF 'writeSoftkeySuppress(nowMs() + 120)' \
"$BASE_DIR/src/dwm-plugins/locker_plugin.cpp" || \
grep -qF 'lockActivatedMs < 80' \
"$BASE_DIR/src/dwm-plugins/locker_plugin.cpp"; then
fail "locker still suppresses unlock keypad input too long"
fi
echo "[check] Status bar clock freshness..."
DMENU_SRC="$BASE_DIR/src/sxmo-dmenu/dmenu.c"
UNLOCK_HOOK="$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_unlock.sh"
@@ -265,7 +882,8 @@ for f in "$NET_EVENT" "$NET_DISPATCH"; do
fi
done
for hook in "$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh" \
"$BASE_DIR/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh"; do
"$BASE_DIR/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh" \
"$BASE_DIR/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh"; do
if grep -q 'superctl start sxmo_networkmonitor' "$hook"; then
fail "${hook#$BASE_DIR/} still starts the nmcli device monitor poller"
fi
@@ -369,8 +987,12 @@ if ! command -v docker >/dev/null 2>&1; then
fi
echo "[check] Version helper..."
VERSION="$("$BASE_DIR/scripts/version.sh" --print 2>/dev/null || true)"
CODENAME="$("$BASE_DIR/scripts/version.sh" --print-codename 2>/dev/null || true)"
# 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).
VERSION="$(BANANARCHY_VERSION=a1108 BANANARCHY_CODENAME=dejavu \
"$BASE_DIR/scripts/version.sh" --print 2>/dev/null || true)"
CODENAME="$(BANANARCHY_VERSION=a1108 BANANARCHY_CODENAME=dejavu \
"$BASE_DIR/scripts/version.sh" --print-codename 2>/dev/null || true)"
if [ "$VERSION" != "a1108" ]; then
fail "scripts/version.sh --print must return a1108"
fi
+188
View File
@@ -0,0 +1,188 @@
#!/usr/bin/env python3
"""Dump Sahara memory-debug regions from a crashed 2720 over EDL.
No stock fastboot is needed. Power-cycle the phone into 05c6:900e first so a
fresh Sahara HELLO is available, then run this script. Output goes to
backup/crash-<timestamp>/. The memory table lists aboot/TZ crash regions;
`strings` on the dumps usually reveals the last error messages.
"""
import argparse
import os
import struct
import sys
import time
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(BASE_DIR / ".flash-deps"))
import usb.core # noqa: E402
import usb.util # noqa: E402
VID = 0x05C6
PIDS = (0x900E, 0x9008, 0x9006)
CMD_HELLO_RSP = 0x2
CMD_SWITCH_MODE = 0xC
CMD_MEMORY_READ = 0xA
CMD_MEMORY_DEBUG = 0x9
MODE_MEMORY_DEBUG = 0x2
MODE_COMMAND = 0x3
TABLE_ENTRY_SIZE = 3 * 4 + 20 + 20
def find_device():
for pid in PIDS:
dev = usb.core.find(idVendor=VID, idProduct=pid)
if dev:
return dev, pid
return None, None
def endpoints(dev):
try:
if dev.is_kernel_driver_active(0):
dev.detach_kernel_driver(0)
except Exception:
pass
try:
dev.set_configuration()
except Exception:
pass
try:
usb.util.claim_interface(dev, 0)
except Exception:
pass
epin = epout = None
for intf in dev.get_active_configuration():
for ep in intf:
if ep.bmAttributes != 2:
continue
direction = usb.util.endpoint_direction(ep.bEndpointAddress)
if direction == usb.util.ENDPOINT_IN and epin is None:
epin = ep
if direction == usb.util.ENDPOINT_OUT and epout is None:
epout = ep
return epin, epout
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--out", default="")
parser.add_argument("--timeout", type=int, default=8)
args = parser.parse_args()
dev, pid = find_device()
if not dev:
print("FAIL: no Qualcomm EDL device (05c6:900e/9008/9006)")
return 1
print("device", hex(pid))
epin, epout = endpoints(dev)
if not epin or not epout:
print("FAIL: no bulk endpoints")
return 1
def read(n=0x1000, t=None):
return bytes(dev.read(epin.bEndpointAddress, n,
timeout=t or args.timeout * 1000))
def write(data):
try:
return dev.write(epout.bEndpointAddress, data,
timeout=args.timeout * 1000)
except Exception as exc:
print("FAIL: USB write failed (%s). Power-cycle the phone to get a "
"fresh Sahara HELLO." % exc)
raise SystemExit(1)
outdir = Path(args.out) if args.out else (
BASE_DIR / "backup" / ("crash-" + time.strftime("%Y%m%d-%H%M%S")))
outdir.mkdir(parents=True, exist_ok=True)
# Ask the target to leave memory-debug wait state and re-send HELLO.
write(struct.pack("<3I", CMD_SWITCH_MODE, 0xC, MODE_COMMAND))
try:
hello = read(0x1000)
except Exception as exc:
print("FAIL: no fresh Sahara HELLO (%s). Power-cycle the phone." % exc)
return 1
if len(hello) < 48:
print("FAIL: short HELLO (%d bytes)" % len(hello))
return 1
fields = struct.unpack_from("<12I", hello)
print("HELLO cmd=%#x len=%d version=%d mode=%#x" %
(fields[0], fields[1], fields[2], fields[5]))
(outdir / "hello.bin").write_bytes(hello)
if fields[5] == 0:
print("Sahara mode 0 = IMAGE_TX_PENDING (plain EDL, waiting for a "
"programmer), not memory-debug.")
print("No crash dump is available in this state. The phone did not "
"enter the crash-dump path; use flash-edl.sh normally.")
return 0
if fields[5] != MODE_MEMORY_DEBUG:
print("Sahara mode %#x is not memory-debug; no dump available." %
fields[5])
return 0
write(struct.pack("<12I", CMD_HELLO_RSP, 0x30, 2, 1, 0,
MODE_MEMORY_DEBUG, 0, 0, 0, 0, 0, 0))
try:
rsp = read(0x1000)
except Exception as exc:
print("FAIL: no memory-debug response (%s)" % exc)
return 1
if len(rsp) < 16:
print("FAIL: short memory-debug response")
return 1
cmd, length = struct.unpack_from("<2I", rsp)
print("response cmd=%#x len=%d" % (cmd, length))
if cmd != CMD_MEMORY_DEBUG:
print("FAIL: target did not enter memory debug (cmd=%#x)" % cmd)
return 1
table_addr, table_len = struct.unpack_from("<2I", rsp, 8)
print("memory table %#x / %#x bytes" % (table_addr, table_len))
if not table_addr or not table_len or table_len > 0x100000:
print("FAIL: implausible memory table")
return 1
pos = 0
table = b""
while pos < table_len:
n = min(0x800, table_len - pos)
write(struct.pack("<4I", CMD_MEMORY_READ, 16, table_addr + pos, n))
try:
chunk = read(n)
except Exception as exc:
print("FAIL reading table at %#x: %s" % (pos, exc))
return 1
table += chunk[:n]
pos += len(chunk)
(outdir / "memory_table.bin").write_bytes(table)
for i in range(0, len(table) - TABLE_ENTRY_SIZE + 1, TABLE_ENTRY_SIZE):
save, base, size = struct.unpack_from("<3I", table, i)
desc = table[i + 12:i + 32].rstrip(b"\0").decode("utf-8", "replace")
name = table[i + 32:i + 52].rstrip(b"\0").decode("utf-8", "replace")
idx = i // TABLE_ENTRY_SIZE
print("region %d save=%#x base=%#x size=%#x desc=%r file=%r" %
(idx, save, base, size, desc, name))
if not base or not size or size > 0x1000000:
continue
pos = 0
blob = b""
while pos < size:
n = min(0x800, size - pos)
write(struct.pack("<4I", CMD_MEMORY_READ, 16, base + pos, n))
try:
chunk = read(n)
except Exception:
break
blob += chunk[:n]
pos += len(chunk)
safe = (name or ("region%d" % idx)).replace("/", "_")
(outdir / (safe + ".bin")).write_bytes(blob)
print(" dumped %s (%d bytes)" % (safe, len(blob)))
print("done:", outdir)
return 0
if __name__ == "__main__":
sys.exit(main())
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""Produce a config/frp image with the OEM allow-unlock flag set.
aboot's read_allow_oem_unlock() checks the LSB of the last byte of the
"config" (or "frp") partition. Setting it allows 'fastboot oem unlock-go'
to write the authoritative RPMB devinfo on VB1/secure-boot devices.
"""
import argparse
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument("locked")
parser.add_argument("unlocked")
args = parser.parse_args()
data = bytearray(open(args.locked, "rb").read())
if not data:
print("FAIL: input is empty")
return 1
print("locked : last byte=%d" % data[-1])
data[-1] |= 1
with open(args.unlocked, "wb") as handle:
handle.write(data)
print("unlocked: last byte=%d -> %s (%d bytes)" %
(data[-1], args.unlocked, len(data)))
return 0
if __name__ == "__main__":
sys.exit(main())
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""Produce an unlocked devinfo image from a locked EDL dump.
The stock 2720 aboot is locked (devinfo.is_unlocked=0) and verifies boot
images against Nokia_beatles certificates. Setting byte 13 to 1 makes aboot
skip signed-boot verification. Keep the original dump to relock later.
"""
import argparse
import os
import sys
MAGIC = b"ANDROID-BOOT!"
UNLOCKED_OFFSET = 13
TAMPERED_OFFSET = 14
def main():
parser = argparse.ArgumentParser()
parser.add_argument("locked")
parser.add_argument("unlocked")
args = parser.parse_args()
data = bytearray(open(args.locked, "rb").read())
if bytes(data[:len(MAGIC)]) != MAGIC:
print("FAIL: input is not an ANDROID-BOOT! devinfo image")
return 1
print("locked : is_unlocked=%d is_tampered=%d" %
(data[UNLOCKED_OFFSET], data[TAMPERED_OFFSET]))
data[UNLOCKED_OFFSET] = 1
data[TAMPERED_OFFSET] = 0
with open(args.unlocked, "wb") as handle:
handle.write(data)
print("unlocked: is_unlocked=%d is_tampered=%d -> %s (%d bytes)" %
(data[UNLOCKED_OFFSET], data[TAMPERED_OFFSET], args.unlocked, len(data)))
return 0
if __name__ == "__main__":
sys.exit(main())
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
"""Rewrite the cmdline field of an Android v0 boot.img header.
Only the 512-byte cmdline field changes; kernel, ramdisk, DTB and load
addresses stay byte-identical, so the image still fits its partition.
"""
import argparse
import os
import struct
import sys
BOOT_MAGIC = b"ANDROID!"
CMDLINE_OFFSET = 64
CMDLINE_SIZE = 512
def main():
parser = argparse.ArgumentParser()
parser.add_argument("src")
parser.add_argument("dst")
parser.add_argument("--cmdline", required=True)
args = parser.parse_args()
data = bytearray(open(args.src, "rb").read())
if len(data) < CMDLINE_OFFSET + CMDLINE_SIZE or data[:8] != BOOT_MAGIC:
print("FAIL: not an Android boot image")
return 1
raw = args.cmdline.encode("utf-8")
if len(raw) >= CMDLINE_SIZE:
print("FAIL: cmdline is too long (%d >= %d)" % (len(raw), CMDLINE_SIZE))
return 1
old = bytes(data[CMDLINE_OFFSET:CMDLINE_OFFSET + CMDLINE_SIZE]).rstrip(b"\0")
data[CMDLINE_OFFSET:CMDLINE_OFFSET + CMDLINE_SIZE] = (
raw + b"\0" * (CMDLINE_SIZE - len(raw)))
with open(args.dst, "wb") as handle:
handle.write(data)
fields = struct.unpack_from("<8s8I", data)
print("old cmdline: %r" % old.decode("utf-8", "replace"))
print("new cmdline: %r" % args.cmdline)
print("kernel=%d ramdisk=%d page=%d -> %s (%d bytes)" %
(fields[1], fields[3], fields[8], args.dst, len(data)))
return 0
if __name__ == "__main__":
sys.exit(main())
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
"""Replace the appended DTB in a 2720 Flip Android boot image.
The stock aboot finds the appended DTB through the 32-bit value at kernel+0x2c.
Keeping that pointer and rebuilding the page-aligned kernel/ramdisk layout lets
us ship a corrected DTB without rebuilding the whole 1.6 GiB rootfs image.
This tool ONLY touches the standalone Android boot.img. The raw image written
to `userdata` is an MBR disk image whose first partition is an ext2 pmOS_boot
filesystem; never write an Android boot.img at raw offset 1 MiB. To update the
boot.img/DTB/extlinux.conf inside that filesystem use sync-beatles-bootfs.py.
"""
import argparse
import os
import struct
import sys
FDT_MAGIC = b"\xd0\x0d\xfe\xed"
BOOT_MAGIC = b"ANDROID!"
DTB_OFFSET_FIELD = 0x2c
ID_OFFSET = 576
ID_SIZE = 32
def align(value, page):
return (value + page - 1) // page * page
def parse_header(data):
if len(data) < 48 or data[:8] != BOOT_MAGIC:
raise ValueError("not an Android boot image")
fields = struct.unpack_from("<8s8I", data, 0)
return {
"kernel_size": fields[1],
"kernel_addr": fields[2],
"ramdisk_size": fields[3],
"ramdisk_addr": fields[4],
"second_size": fields[5],
"second_addr": fields[6],
"tags_addr": fields[7],
"page_size": fields[8],
}
def repack(old, dtb):
hdr = parse_header(old)
page = hdr["page_size"]
kernel_off = page
dtb_rel = struct.unpack_from("<I", old, kernel_off + DTB_OFFSET_FIELD)[0]
if not 0 < dtb_rel < hdr["kernel_size"]:
raise ValueError("kernel+0x2c does not point inside the kernel payload")
dtb_abs = kernel_off + dtb_rel
if old[dtb_abs:dtb_abs + 4] != FDT_MAGIC:
raise ValueError("kernel+0x2c does not point at an FDT header")
zimage = old[kernel_off:dtb_abs]
ramdisk_off = kernel_off + align(hdr["kernel_size"], page)
ramdisk = old[ramdisk_off:ramdisk_off + hdr["ramdisk_size"]]
second_off = ramdisk_off + align(hdr["ramdisk_size"], page)
second = old[second_off:second_off + hdr["second_size"]]
new_kernel_size = len(zimage) + len(dtb)
header = bytearray(old[:page])
struct.pack_into("<I", header, 8, new_kernel_size)
header[ID_OFFSET:ID_OFFSET + ID_SIZE] = b"\0" * ID_SIZE
out = bytearray(header)
kernel_payload = zimage + dtb
out += kernel_payload + b"\0" * (align(new_kernel_size, page) - new_kernel_size)
out += ramdisk + b"\0" * (align(hdr["ramdisk_size"], page) - hdr["ramdisk_size"])
out += second + b"\0" * (align(hdr["second_size"], page) - hdr["second_size"])
return bytes(out), new_kernel_size, dtb_rel
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--boot-image", required=True)
parser.add_argument("--dtb", required=True)
parser.add_argument("--output", required=True)
args = parser.parse_args()
old = open(args.boot_image, "rb").read()
dtb = open(args.dtb, "rb").read()
if dtb[:4] != FDT_MAGIC:
raise ValueError("--dtb is not a flattened device tree")
new, kernel_size, dtb_rel = repack(old, dtb)
tmp = args.output + ".tmp"
with open(tmp, "wb") as handle:
handle.write(new)
os.replace(tmp, args.output)
print("kernel payload: zImage=%d dtb=%d total=%d" % (dtb_rel, len(dtb), kernel_size))
print("boot image: %d -> %d bytes" % (len(old), len(new)))
return 0
if __name__ == "__main__":
sys.exit(main())
+262
View File
@@ -0,0 +1,262 @@
#!/usr/bin/env python3
"""Repair/validate the pmOS_boot ext2 filesystem inside a 2720 raw image.
The raw image written to `userdata` is an MBR disk image whose first
partition (LBA 2048, 256 MiB) is an ext2 filesystem containing
/vmlinuz, /initramfs, /qcom-msm8905-nokia-beatles.dtb, /boot.img and
/extlinux/extlinux.conf. lk2nd mounts that filesystem to find
extlinux.conf. An earlier repack mistakenly wrote an Android boot.img at
offset 1 MiB, destroying the ext2 superblock; lk2nd then found no
bootable fs and hung.
This tool extracts that partition, updates the boot.img, DTB and (optionally)
extlinux.conf with debugfs, and writes it back at the MBR-specified offset.
Use --check to validate without modifying anything.
"""
import argparse
import hashlib
import os
import struct
import subprocess
import sys
import tempfile
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
EXT2_MAGIC_OFFSET = 1080
EXT2_MAGIC = b"\x53\xef"
BOOT_FS_FILES = {
"boot.img": BASE_DIR / "images" / "boot-bananarchy-nokia-beatles.img",
"qcom-msm8905-nokia-beatles.dtb":
BASE_DIR / "devices" / "nokia-beatles" / "qcom-msm8905-nokia-beatles.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"
def release_cmdline(conf):
"""Restore the shipping cmdline (quiet splash) in an extlinux.conf.
The pmOS initramfs defaults to nosplash=y and only starts plymouthd when
the literal "splash" parameter is present. Kernel-level debugging used the
replace-with-DEBUG_PREFIX path below; without the reverse conversion the
shipped image keeps loglevel=8/initcall_debug and never shows a boot splash.
"""
if DEBUG_PREFIX in conf:
conf = conf.replace(DEBUG_PREFIX, QUIET_PREFIX, 1)
if QUIET_PREFIX not in conf:
conf = conf.replace("append ", "append " + QUIET_PREFIX + " ", 1)
return conf
def debug_cmdline(conf):
if QUIET_PREFIX in conf:
conf = conf.replace(QUIET_PREFIX, DEBUG_PREFIX, 1)
elif DEBUG_PREFIX not in conf:
conf = conf.replace("append ", "append " + DEBUG_PREFIX + " ", 1)
return conf
def mbr_first_partition(data):
if len(data) < 512 or data[510:512] != b"\x55\xaa":
raise ValueError("raw image has no MBR signature")
entry = data[446:462]
ptype = entry[4]
lba, sectors = struct.unpack_from("<II", entry, 8)
if ptype != 0x83 or not lba or not sectors:
raise ValueError("first MBR entry is not a Linux partition")
return lba * 512, sectors * 512
def run_debugfs(fs, commands):
with tempfile.NamedTemporaryFile("w", suffix=".cmd", delete=False) as handle:
handle.write("\n".join(commands) + "\n")
cmd_file = handle.name
try:
proc = subprocess.run(["debugfs", "-w", "-f", cmd_file, fs],
capture_output=True, text=True)
if proc.returncode != 0:
raise ValueError("debugfs failed: %s" % (proc.stdout + proc.stderr).strip())
finally:
os.unlink(cmd_file)
def cat(fs, path):
proc = subprocess.run(["debugfs", "-R", "cat %s" % path, fs],
capture_output=True)
if proc.returncode != 0:
raise ValueError("cannot read %s from boot fs" % path)
return proc.stdout
def sha(data):
return hashlib.sha256(data).hexdigest()
def validate_cmdline(conf, allow_debug=False):
append = ""
for line in conf.splitlines():
if line.strip().startswith("append "):
append = line.strip()[len("append "):]
break
if not append:
raise ValueError("extlinux.conf has no append line")
parts = append.split()
if "earlycon" in parts:
raise ValueError("extlinux.conf still contains earlycon")
if not allow_debug:
if "splash" not in parts or "quiet" not in parts:
raise ValueError("extlinux.conf is missing 'quiet splash' (no Plymouth splash at boot)")
for flag in ("loglevel=8", "ignore_loglevel", "initcall_debug"):
if flag in parts:
raise ValueError("extlinux.conf still has kernel debug flag %s" % flag)
for flag in BOOT_CMD_FLAGS.split():
if flag not in parts:
raise ValueError("extlinux.conf is missing %s" % flag)
return append
def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False):
raw = open(raw_path, "rb").read(1024 * 1024 + 4096)
offset, size = mbr_first_partition(raw)
if len(raw) < offset + 2048 or raw[offset + EXT2_MAGIC_OFFSET:offset + EXT2_MAGIC_OFFSET + 2] != EXT2_MAGIC:
raise ValueError("pmOS_boot ext2 superblock is missing at %#x "
"(raw image was overwritten by an Android boot.img)" % offset)
with tempfile.NamedTemporaryFile(suffix=".img", delete=False) as handle:
fs = handle.name
try:
with open(raw_path, "rb") as src, open(fs, "wb") as dst:
src.seek(offset)
left = size
while left > 0:
chunk = src.read(min(1 << 20, left))
if not chunk:
break
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")
validate_cmdline(conf, allow_debug)
for name, expected in BOOT_FS_FILES.items():
got = sha(cat(fs, "/" + name))
want = sha(open(expected, "rb").read())
if got != want:
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))
return offset, size, fs
finally:
if fs and os.path.exists(fs):
os.unlink(fs)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--raw-image", default=str(BASE_DIR / "images" / "bananarchy-nokia-beatles.img"))
parser.add_argument("--source-boot-fs", default="",
help="Pristine ext2 boot-fs image to seed from when the "
"raw image's superblock is destroyed")
parser.add_argument("--debug-cmdline", action="store_true",
help="Replace 'quiet splash' in extlinux.conf with "
"verbose/panic settings (diagnostic builds only)")
parser.add_argument("--allow-debug", action="store_true",
help="With --check, accept a diagnostic cmdline")
parser.add_argument("--check", action="store_true")
args = parser.parse_args()
dtb = BOOT_FS_FILES["qcom-msm8905-nokia-beatles.dtb"]
boot_img = BOOT_FS_FILES["boot.img"]
for path in (args.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)
return 0
except ValueError as exc:
print("FAIL: %s" % exc)
return 1
raw = open(args.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
try:
if args.source_boot_fs:
with open(args.source_boot_fs, "rb") as src, open(fs, "wb") as dst:
while True:
chunk = src.read(1 << 20)
if not chunk:
break
dst.write(chunk)
else:
with open(args.raw_image, "rb") as src, open(fs, "wb") as dst:
src.seek(offset)
left = size
while left > 0:
chunk = src.read(min(1 << 20, left))
if not chunk:
break
dst.write(chunk)
left -= len(chunk)
if os.path.getsize(fs) != size:
raise ValueError("source boot fs is %d bytes, expected %d" %
(os.path.getsize(fs), size))
if open(fs, "rb").read(EXT2_MAGIC_OFFSET + 2)[EXT2_MAGIC_OFFSET:EXT2_MAGIC_OFFSET + 2] != EXT2_MAGIC:
raise ValueError("source boot fs has no ext2 superblock")
commands = []
for name, host_path in BOOT_FS_FILES.items():
commands += ["rm /%s" % name,
"write %s /%s" % (host_path, name)]
conf = cat(fs, "/extlinux/extlinux.conf").decode("utf-8", "replace")
new_conf = conf
new_conf = debug_cmdline(new_conf) if args.debug_cmdline else release_cmdline(new_conf)
new_conf = new_conf.replace(" earlycon ", " ")
new_conf = new_conf.replace("append earlycon ", "append ")
new_conf = new_conf.replace("append earlycon", "append")
validate_cmdline(new_conf, allow_debug=args.debug_cmdline)
if new_conf != conf:
with tempfile.NamedTemporaryFile("w", suffix=".conf", delete=False) as handle:
handle.write(new_conf)
conf_file = handle.name
commands += ["rm /extlinux/extlinux.conf",
"write %s /extlinux/extlinux.conf" % conf_file]
conf_tmp = conf_file
else:
conf_tmp = None
run_debugfs(fs, commands)
if conf_tmp:
os.unlink(conf_tmp)
with open(args.raw_image, "r+b") as dst, open(fs, "rb") as src:
dst.seek(offset)
while True:
chunk = src.read(1 << 20)
if not chunk:
break
dst.write(chunk)
print("patched pmOS_boot at %#x (%d bytes)" % (offset, size))
except (ValueError, OSError) as exc:
print("FAIL: %s" % exc)
return 1
finally:
if os.path.exists(fs):
os.unlink(fs)
try:
check(args.raw_image, dtb, boot_img)
except ValueError as exc:
print("FAIL: %s" % exc)
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
+16 -1
View File
@@ -46,6 +46,14 @@ def regular_files(root):
return result
def is_elf(path):
try:
with open(path, "rb") as handle:
return handle.read(4) == b"\x7fELF"
except OSError:
return False
by_name = {}
for path in regular_files(prebuilt_root):
by_name.setdefault(os.path.basename(path), []).append(path)
@@ -62,7 +70,14 @@ for target in regular_files(overlay_root):
source = candidate
break
if source is None and candidates:
source = candidates[0]
bin_dir = os.path.join(overlay_root, "usr", "bin") + os.sep
local_bin_dir = os.path.join(overlay_root, "usr", "local", "bin") + os.sep
for candidate in candidates:
if is_elf(candidate) and not target.startswith(bin_dir) and \
not target.startswith(local_bin_dir):
continue
source = candidate
break
if source is None:
continue
matched += 1
+165
View File
@@ -0,0 +1,165 @@
#!/usr/bin/env python3
"""Host tests for the source-built nokia-beatles lk2nd port.
Runs the image validator, compiles the shared C panel-init walker against the
actual byte streams extracted from the shipped QCDT DTB, and checks that the
repository wiring (build script, patch, flasher) still points at the port.
"""
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-beatles.py")
build = os.path.join(BASE, "scripts", "build-lk2nd-beatles.sh")
patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-beatles.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-beatles.img", 0, 0, False),
("images/boot-lk2nd-nokia-beatles-diagnostic.img", 1, 0, False),
("images/boot-lk2nd-nokia-beatles-display.img", 0, 1, True),
)
for image, fastboot, display, allow_missing_cookie 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)]
if allow_missing_cookie:
cmd.append("--allow-missing-cookie")
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-beatles.sh"),
(patch, "nokia-beatles.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("--force-panel-init" in script,
"build script supports forcing the panel init replay")
ok &= check('--with-display' in script and 'WITH_DISPLAY' in script,
"build script can re-enable the SPI display")
ok &= check("make TOOLCHAIN_PREFIX=arm-none-eabi-" in script and
"MKBOOTIMG_CMDLINE=" in script,
"build script uses the cross toolchain and beatles cmdline")
patch_text = open(patch).read()
ok &= check("lk2nd/device/dts/lk2nd.dtsi" in patch_text and
"nokia-beatles.dtsi" in patch_text and
"msm8905-qrd-skub.dts" in patch_text and
"lk2nd,panel-init" in patch_text and
"mdss_spi_panel_init_commands" in patch_text,
"patch contains the /cpus fix, device node, panel init data and driver hook")
ok &= check("oem scan-boot" in patch_text,
"patch contains the oem scan-boot extlinux probe")
ok &= check("oem scan-dtb" in patch_text,
"patch contains the oem scan-dtb kernel DTB probe")
ok &= check("lk2nd/ramoops/ramoops.c" in patch_text,
"patch contains the always-on ramoops console fix")
ok &= check("oem display-init" in patch_text,
"patch contains the runtime SPI display probe")
ok &= check("lk2nd.display=on" in patch_text,
"patch contains the boot-time display option")
ok &= check("platform/msm_shared/reboot.c" in patch_text and
"beatles low-bit reboot cookie" in patch_text,
"patch contains the low-bit lk2nd menu reboot cookie")
ok &= check("QUP_FIFO_TIMEOUT" in patch_text and "CLK_POLL_TIMEOUT" in patch_text,
"patch bounds QUP and clock register polls")
ok &= check("lk2nd/device/2nd/spi-display.c" in patch_text,
"patch contains the safe SPI display init")
ok &= check("app/aboot/aboot.c" in patch_text and
"scan-only: final kernel cmdline/DTB ready" in patch_text,
"patch stages the final DTB after lk2nd DT updates")
ok &= check("No valid pstore console" in patch_text,
"patch validates and bounds the ramoops console")
ok &= check("SPI panel fallback from QCDT" in patch_text,
"patch supports chain-loaded SPI panel probes")
ok &= check("per-word SPEW log" in patch_text,
"patch removes the QUP FIFO log flood")
ok &= check("lk2nd/fastboot/fetch.c" in patch_text and
"aligned read exceeds partition" in patch_text,
"patch makes oem read-partition block-safe")
flasher = open(os.path.join(BASE, "flash-edl.py")).read()
ok &= check("headless" not in flasher.lower(),
"flasher no longer describes a headless lk2nd")
ok &= check("images/boot-lk2nd-nokia-beatles-display.img" in flasher,
"flasher defaults to the display-enabled beatles lk2nd image")
ok &= check('target_names = ("boot", "recovery", "lk2nd")' in flasher,
"flasher refreshes the separate lk2nd partition")
ok &= check('"--lk2nd-image"' in flasher and "args.lk2nd_image" in flasher,
"flasher can override the beatles lk2nd image for diagnostics")
preflight = open(os.path.join(BASE, "scripts", "check-rebuild.sh")).read()
ok &= check("check-lk2nd-beatles.py" in preflight,
"check-rebuild.sh validates the beatles lk2nd image")
gcc = shutil.which("gcc") or shutil.which("cc")
if gcc:
with tempfile.TemporaryDirectory() as tmp:
streams = os.path.join(tmp, "panel_streams.h")
r = subprocess.run([sys.executable, validator,
"--image", "images/boot-lk2nd-nokia-beatles.img",
"--emit-streams-header", streams],
cwd=BASE, capture_output=True, text=True)
ok &= check(r.returncode == 0, "panel init streams extracted from 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:
print(r.stderr.strip())
r = run([binary])
print(r.stdout.strip())
print(r.stderr.strip())
ok &= check(r.returncode == 0,
"host C unit test accepts the GC9305 v2 init stream")
else:
print("[skip] no host C compiler; C unit test skipped")
print("[%s] nokia-beatles lk2nd port tests" % ("ok" if ok else "FAIL"))
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())