Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1bb3b4436 | ||
|
|
9705273f92 | ||
|
|
81d609fed3 | ||
|
|
fc62400157 |
@@ -237,7 +237,9 @@ jobs:
|
||||
- name: QEMU busybox fetch regression tests
|
||||
# Retry on a bad sha256, the cached copy, and a server that answers
|
||||
# and then stalls (#1588), against local listeners: no network.
|
||||
run: bash qemu/tests/busybox-fetch.sh
|
||||
run: |
|
||||
bash qemu/tests/busybox-fetch.sh
|
||||
bash qemu/tests/busybox-source-mirror.sh
|
||||
- name: unpack-buildroot regression tests
|
||||
# Fresh unpack, leave-existing-tree-alone, and every refusal path
|
||||
# (unpatched selectors, bad tarball, half-present tree, failed
|
||||
|
||||
@@ -372,7 +372,7 @@ index a99846f4e..4fc64f33d 100644
|
||||
+ * by this point, so nothing puts it back underneath us.
|
||||
+ */
|
||||
+ if ((priv->cpll_hz % rate) && (priv->gpll_hz % rate)) {
|
||||
+ ulong want = rate * 32;
|
||||
+ ulong want = 900 * MHz;
|
||||
+
|
||||
+ if (want >= 300 * MHz && want <= 1200 * MHz &&
|
||||
+ !rockchip_pll_set_rate(&rv1106_pll_clks[CPLL],
|
||||
|
||||
@@ -142,10 +142,10 @@ index 52cd612d1..a81071566 100644
|
||||
obj-$(CONFIG_AUTOBOOT) += autoboot.o
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/flare_ab.c b/sysdrv/source/uboot/u-boot/common/flare_ab.c
|
||||
new file mode 100644
|
||||
index 000000000..6a5a07e37
|
||||
index 000000000..ec685444d
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/flare_ab.c
|
||||
@@ -0,0 +1,642 @@
|
||||
@@ -0,0 +1,709 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0+
|
||||
+/*
|
||||
+ * flare-edge A/B slot boot for U-Boot proper.
|
||||
@@ -175,6 +175,9 @@ index 000000000..6a5a07e37
|
||||
+#include <part.h>
|
||||
+#include <flare_ab.h>
|
||||
+#include <android_avb/avb_ab_flow.h>
|
||||
+#if defined(CONFIG_DRM_ROCKCHIP)
|
||||
+#include <video_rockchip.h>
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Per-power-session boot-attempt escalation (warehouse deployment).
|
||||
@@ -215,6 +218,8 @@ index 000000000..6a5a07e37
|
||||
+ */
|
||||
+#define FLARE_AB_GLB_RST_ST 0xff3b0c04u /* CRU reset-status: 0 on POR */
|
||||
+#define FLARE_AB_SESSION_REG 0xff020210u /* PMU GRF OS_REG4: attempt count */
|
||||
+#define FLARE_AB_GLB_SRST_FST 0xff3b0c08u /* CRU glb_srst_fst: global reset */
|
||||
+#define FLARE_AB_GLB_SRST_KEY 0xfdb9u /* poke value that starts the reset */
|
||||
+/*
|
||||
+ * Attempts on the selected committed slot before failing over to the other
|
||||
+ * committed slot; the other slot then gets the same budget before recovery.
|
||||
@@ -551,7 +556,12 @@ index 000000000..6a5a07e37
|
||||
+ return other;
|
||||
+ }
|
||||
+
|
||||
+ printf("FLARE-AB: both committed slots failed this power session, recovery\n");
|
||||
+ if (slot_is_bootable(&ab_data.slots[other]) &&
|
||||
+ ab_data.slots[other].successful_boot)
|
||||
+ printf("FLARE-AB: both committed slots failed this power session, recovery\n");
|
||||
+ else
|
||||
+ printf("FLARE-AB: slot %s failed %d attempts this session, no committed alternative, recovery\n",
|
||||
+ pref ? "_b" : "_a", FLARE_AB_SLOT_TRIES);
|
||||
+ flare_ab_force_recovery = 1;
|
||||
+ return pref;
|
||||
+}
|
||||
@@ -707,6 +717,58 @@ index 000000000..6a5a07e37
|
||||
+ ab_data_write(dev_desc, &ab_data);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Escalating reset after a failed storage boot.
|
||||
+ *
|
||||
+ * Do not call do_reset() here. On this SoC the U-Boot WARM request
|
||||
+ * (sysreset_rockchip, ARM32 path) writes CRU glb_srst_snd (0xeca8), which
|
||||
+ * does not reset the chip (flare-edge#4554). The p54 splash stall cause is
|
||||
+ * not established (flare-edge#4569). The reset that works is the CRU
|
||||
+ * glb_srst_fst poke that the Linux restart path and the bench scenarios use
|
||||
+ * (docs/boot-flow.md, "Watchdog / reset facts"). It is a warm reset, so
|
||||
+ * glb_rst_st stays nonzero and OS_REG4 carries the attempt count.
|
||||
+ */
|
||||
+static void flare_ab_global_reset(void)
|
||||
+{
|
||||
+ flare_ab_reg_write(FLARE_AB_GLB_SRST_FST, FLARE_AB_GLB_SRST_KEY);
|
||||
+ /*
|
||||
+ * A taken reset never returns. Reaching the next statement means the
|
||||
+ * chip did not reset, so give the reset time to land before the caller
|
||||
+ * falls through to the USB download screens.
|
||||
+ */
|
||||
+ udelay(100000);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * USB download: the terminal state of every failed boot with no slot or
|
||||
+ * recovery FIT left (decision 2026-11-06, flare-edge#3118 cause 3).
|
||||
+ *
|
||||
+ * The sad-face screen is logo_recovery.bmp. rockchip_show_bmp() can fail
|
||||
+ * (-ENOMEM when the heap cannot hold the decode scratch after the failed FIT
|
||||
+ * loads), and do_download() ignores that return, so the splash would stay up
|
||||
+ * with no serial line saying why. The draw is made here and its result is
|
||||
+ * logged. do_download() paints the same image again as its first step.
|
||||
+ *
|
||||
+ * `download` serves rockusb and is not expected to return. If it does (the
|
||||
+ * USB session ended), the screen is painted again and download is re-entered
|
||||
+ * after a pause, so the unit stays USB-flashable and never stops silently at
|
||||
+ * the splash. This function does not return.
|
||||
+ */
|
||||
+static void flare_ab_usb_download(void)
|
||||
+{
|
||||
+ int rc;
|
||||
+
|
||||
+ for (;;) {
|
||||
+#if defined(CONFIG_DRM_ROCKCHIP)
|
||||
+ rc = rockchip_show_bmp("logo_recovery.bmp");
|
||||
+ printf("FLARE-AB: logo_recovery.bmp shown=%d\n", rc);
|
||||
+#endif
|
||||
+ rc = run_command("download", 0);
|
||||
+ printf("FLARE-AB: download returned %d, re-entering\n", rc);
|
||||
+ udelay(1000000);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void flare_ab_boot_failed(void)
|
||||
+{
|
||||
+ if (!flare_ab_enabled())
|
||||
@@ -723,8 +785,7 @@ index 000000000..6a5a07e37
|
||||
+ * it over the existing USB port.
|
||||
+ */
|
||||
+ printf("FLARE-AB: recovery FIT unbootable, entering USB download\n");
|
||||
+ run_command("download", 0);
|
||||
+ hang();
|
||||
+ flare_ab_usb_download();
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
@@ -740,8 +801,14 @@ index 000000000..6a5a07e37
|
||||
+ * written to flash for a committed slot.
|
||||
+ */
|
||||
+ printf("FLARE-AB: slot boot failed, resetting\n");
|
||||
+ do_reset(NULL, 0, 0, NULL);
|
||||
+ hang();
|
||||
+ flare_ab_global_reset();
|
||||
+ /*
|
||||
+ * The reset did not take. Do not spin silently at the splash: enter the
|
||||
+ * same USB download screens as the recovery branch above (sad face and
|
||||
+ * USB plug, logo_recovery.bmp), where a host can reflash the unit.
|
||||
+ */
|
||||
+ printf("FLARE-AB: reset did not take, entering USB download\n");
|
||||
+ flare_ab_usb_download();
|
||||
+}
|
||||
+
|
||||
+void flare_ab_update_root_partition(void)
|
||||
@@ -841,7 +908,7 @@ index 182c03771..ad73662eb 100644
|
||||
return -1;
|
||||
diff --git a/sysdrv/source/uboot/u-boot/include/flare_ab.h b/sysdrv/source/uboot/u-boot/include/flare_ab.h
|
||||
new file mode 100644
|
||||
index 000000000..d009525e0
|
||||
index 000000000..6e51b405e
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/flare_ab.h
|
||||
@@ -0,0 +1,73 @@
|
||||
@@ -857,7 +924,7 @@ index 000000000..d009525e0
|
||||
+ * per-attempt tries decrement, and fallback to the recovery FIT when
|
||||
+ * both slots are exhausted.
|
||||
+ *
|
||||
+ * Linux-side counterpart: flared's slotctl module — the ONLY writer of
|
||||
+ * Linux-side counterpart: flared's slotctl module, the ONLY writer of
|
||||
+ * this metadata from userspace (CI-enforced).
|
||||
+ */
|
||||
+
|
||||
@@ -891,7 +958,7 @@ index 000000000..d009525e0
|
||||
+/*
|
||||
+ * One boot attempt against the selected slot: decrement tries_remaining
|
||||
+ * iff the slot is not yet successful (single-sector write, and no write
|
||||
+ * at all in the successful steady state — spec fault 14 by construction).
|
||||
+ * at all in the successful steady state, spec fault 14 by construction).
|
||||
+ * No-op in recovery fallback mode or on a non-A/B layout.
|
||||
+ */
|
||||
+void flare_ab_boot_attempt(void);
|
||||
|
||||
@@ -121,7 +121,8 @@ bb_main() {
|
||||
rm -f "$bin.inputs"
|
||||
|
||||
tar="${BB_SRC_TARBALL:-$out/busybox-${BB_SRC_VER}.tar.bz2}"
|
||||
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source"
|
||||
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source" \
|
||||
"$BB_SRC_MIRROR_URL"
|
||||
|
||||
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
|
||||
# Expanded now on purpose: the trap must remove this run's directory.
|
||||
|
||||
+8
-1
@@ -11,6 +11,9 @@ BB_SRC_VER=1.37.0
|
||||
# Read by build-busybox.sh, which sources this file.
|
||||
# shellcheck disable=SC2034
|
||||
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
|
||||
# Buildroot mirrors this exact pinned release; verification is unchanged.
|
||||
# shellcheck disable=SC2034
|
||||
BB_SRC_MIRROR_URL="https://sources.buildroot.net/busybox/busybox-${BB_SRC_VER}.tar.bz2"
|
||||
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
|
||||
|
||||
qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
@@ -18,9 +21,10 @@ qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
# Download URL to DEST and verify it against the sha256 WANT. A DEST that
|
||||
# already matches is kept. FAILS CLOSED: three bounded attempts, then exit 1;
|
||||
# a mismatching download never lands at DEST.
|
||||
# Usage: qemu_fetch_verified URL WANT DEST LABEL
|
||||
# Usage: qemu_fetch_verified URL WANT DEST LABEL [MIRROR_URL]
|
||||
qemu_fetch_verified() {
|
||||
local url="$1" want="$2" dest="$3" label="$4" got
|
||||
local mirror="${5:-}"
|
||||
if [ -f "$dest" ]; then
|
||||
got="$(sha256sum "$dest" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
@@ -40,6 +44,9 @@ qemu_fetch_verified() {
|
||||
local attempt tmp="${dest}.download.$$"
|
||||
rm -f "$tmp"
|
||||
for attempt in 1 2 3; do
|
||||
if [ "$attempt" -gt 1 ] && [ -n "$mirror" ]; then
|
||||
url="$mirror"
|
||||
fi
|
||||
qemu_log "downloading $url (attempt $attempt/3)"
|
||||
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
|
||||
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
|
||||
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# The sourced downloader runs before the later production-call test stub.
|
||||
# shellcheck disable=SC2218
|
||||
set -euo pipefail
|
||||
|
||||
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
QEMU_DIR="$(cd "$TEST_DIR/.." && pwd)"
|
||||
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/busybox-source-mirror.XXXXXX")"
|
||||
trap 'rm -rf "$SCRATCH"' EXIT
|
||||
|
||||
mkdir -p "$SCRATCH/bin"
|
||||
printf 'pinned source fixture' > "$SCRATCH/good"
|
||||
WANT="$(sha256sum "$SCRATCH/good" | awk '{print $1}')"
|
||||
export MIRROR_LOG="$SCRATCH/requests" MIRROR_GOOD="$SCRATCH/good"
|
||||
export MIRROR_MODE=good
|
||||
cat > "$SCRATCH/bin/curl" <<'CURL'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
url= out=
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-o) shift; out="$1" ;;
|
||||
https://*) url="$1" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
printf '%s\n' "$url" >> "$MIRROR_LOG"
|
||||
[ -n "$out" ] || exit 2
|
||||
case "$url" in
|
||||
https://primary.invalid/source) exit 28 ;;
|
||||
https://mirror.invalid/source)
|
||||
if [ "$MIRROR_MODE" = good ]; then cp "$MIRROR_GOOD" "$out";
|
||||
else printf 'corrupt mirror response' > "$out"; fi ;;
|
||||
*) exit 2 ;;
|
||||
esac
|
||||
CURL
|
||||
chmod 0755 "$SCRATCH/bin/curl"
|
||||
export PATH="$SCRATCH/bin:$PATH"
|
||||
# shellcheck source=qemu/lib.sh disable=SC1091
|
||||
source "$QEMU_DIR/lib.sh"
|
||||
|
||||
qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
||||
"$SCRATCH/fetched" source https://mirror.invalid/source
|
||||
cmp "$SCRATCH/good" "$SCRATCH/fetched"
|
||||
printf '%s\n' https://primary.invalid/source https://mirror.invalid/source > "$SCRATCH/expected"
|
||||
cmp "$MIRROR_LOG" "$SCRATCH/expected"
|
||||
echo 'PASS primary timeout uses verified mirror'
|
||||
|
||||
: > "$MIRROR_LOG"
|
||||
qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
||||
"$SCRATCH/fetched" source https://mirror.invalid/source
|
||||
test ! -s "$MIRROR_LOG"
|
||||
echo 'PASS verified cache avoids both sources'
|
||||
|
||||
export MIRROR_MODE=bad
|
||||
: > "$MIRROR_LOG"
|
||||
if (qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
||||
"$SCRATCH/refused" source https://mirror.invalid/source) > "$SCRATCH/refusal" 2>&1; then
|
||||
echo 'FAIL corrupt mirror was accepted' >&2
|
||||
exit 1
|
||||
fi
|
||||
test "$(wc -l < "$MIRROR_LOG")" -eq 3
|
||||
test ! -e "$SCRATCH/refused"
|
||||
test -z "$(find "$SCRATCH" -maxdepth 1 -name 'refused.download.*' -print -quit)"
|
||||
grep -q 'after 3 verified attempts' "$SCRATCH/refusal"
|
||||
echo 'PASS corrupt mirror refused within three attempts'
|
||||
|
||||
# Exercise the production source call with the downloader intercepted only
|
||||
# after build-busybox.sh loads its constants. Refuse before extraction.
|
||||
# shellcheck source=qemu/build-busybox.sh disable=SC1091
|
||||
source "$QEMU_DIR/build-busybox.sh"
|
||||
mkdir -p "$SCRATCH/toolchain"
|
||||
printf '#!/bin/sh\nexit 0\n' > "$SCRATCH/toolchain/fake-gcc"
|
||||
chmod 0755 "$SCRATCH/toolchain/fake-gcc"
|
||||
qemu_fetch_verified() {
|
||||
[ "$1" = "$BB_SRC_URL" ] && [ "$2" = "$BB_SRC_SHA256" ]
|
||||
[ "$5" = "$BB_SRC_MIRROR_URL" ]
|
||||
printf '%s\n' 'production mirror call verified' > "$SCRATCH/wired"
|
||||
return 42
|
||||
}
|
||||
set +e
|
||||
(set -e; OUT="$SCRATCH/build" CROSS_COMPILE="$SCRATCH/toolchain/fake-" JOBS=1 bb_main) \
|
||||
> "$SCRATCH/wiring-log" 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
if [ "$status" -ne 42 ]; then
|
||||
cat "$SCRATCH/wiring-log" >&2
|
||||
echo 'FAIL production source call did not stop at the verified downloader' >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -qx 'production mirror call verified' "$SCRATCH/wired"
|
||||
echo 'PASS production source fetch supplies pinned mirror'
|
||||
Reference in New Issue
Block a user