Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67da1141a0 | ||
|
|
5f36beb44a | ||
|
|
eb0691d84f | ||
|
|
4636f0fe4c | ||
|
|
fe29ece741 | ||
|
|
b30621e372 | ||
|
|
0cf46ba1a4 | ||
|
|
5fd6d2da5b |
@@ -111,7 +111,8 @@ jobs:
|
||||
shellcheck -x qemu/*.sh qemu/tests/*.sh build/*.sh \
|
||||
qemu/rootfs/etc/warden-lib.sh qemu/rootfs/etc/rc \
|
||||
qemu/rootfs/sbin/init qemu/rootfs/init tests/mk-bootimg/*.sh \
|
||||
tests/fetch-vendor/*.sh tests/fetch-buildroot-tarball/*.sh
|
||||
tests/fetch-vendor/*.sh tests/fetch-buildroot-tarball/*.sh \
|
||||
tests/unpack-buildroot/*.sh
|
||||
- name: cache apt archives (python3-pil)
|
||||
# Same cost class as the busybox binary cached below: a system package
|
||||
# plus its libjpeg/libpng transitive deps, downloaded fresh on every
|
||||
@@ -166,6 +167,11 @@ jobs:
|
||||
# Retry-on-mismatch, cleanup, and the already-verified
|
||||
# short-circuit, against a fake curl on PATH: no network.
|
||||
run: bash tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh
|
||||
- name: unpack-buildroot regression tests
|
||||
# Fresh unpack, leave-existing-tree-alone, and every refusal path
|
||||
# (unpatched selectors, bad tarball, half-present tree, failed
|
||||
# fetch), against a stub fetch script: no network (issue #4).
|
||||
run: bash tests/unpack-buildroot/run-unpack-buildroot-tests.sh
|
||||
- name: mk-bootimg boot.img validation regression tests
|
||||
# Guards issue #22 (a missing/erroring fdtget silently skipping the
|
||||
# data-position check) plus the FIT metadata and per-image
|
||||
@@ -340,10 +346,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install analyzers
|
||||
# The job image's Python is PEP 668 "externally managed", so a plain
|
||||
# pip install is refused. GitHub's hosted runners set this same
|
||||
# variable; here every job runs in a throwaway container on a
|
||||
# throwaway VM (the GARM runners), so nothing outlives the job.
|
||||
env:
|
||||
PIP_BREAK_SYSTEM_PACKAGES: "1"
|
||||
run: |
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq cppcheck shellcheck
|
||||
pip install --quiet lizard ruff
|
||||
sudo npm install --silent -g jscpd
|
||||
sudo env "PATH=$PATH" npm install --silent -g jscpd
|
||||
curl -fsSL -o /tmp/scc.tar.gz \
|
||||
https://github.com/boyter/scc/releases/download/v3.6.0/scc_Linux_x86_64.tar.gz
|
||||
sudo tar -C /usr/local/bin -xzf /tmp/scc.tar.gz scc
|
||||
|
||||
@@ -12,13 +12,9 @@
|
||||
# Same shape as fetch-kernel-tarball.sh, deliberately: a version bump edits this
|
||||
# file and the pin beside it, nothing else. FAILS CLOSED on a missing pin.
|
||||
#
|
||||
# Not wired into build-firmware.sh or CI yet -- tools/build-firmware.sh stages
|
||||
# sdk-patches/buildroot/ onto whatever buildroot tree the vendor SDK already
|
||||
# has, it does not yet extract this pinned tarball over it. Exercised today by
|
||||
# tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh and by
|
||||
# running the script by hand; wiring it into the real build path is a separate
|
||||
# change (it has to reconcile the pristine tree with the existing SDK buildroot
|
||||
# checkout first).
|
||||
# Called by build/unpack-buildroot.sh, which flare-edge's
|
||||
# tools/build-firmware.sh runs after applying luckfox-sdk-patches/ (issue #4).
|
||||
# Tested by tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh.
|
||||
#
|
||||
# Usage: fetch-buildroot-tarball.sh <destination-path>
|
||||
set -euo pipefail
|
||||
|
||||
@@ -66,7 +66,7 @@ tree_path() {
|
||||
}
|
||||
|
||||
rc=0
|
||||
while IFS=$'\t' read -r name url commit desc; do
|
||||
while IFS=$'\t' read -r name url commit _desc; do
|
||||
case "$name" in ''|\#*) continue ;; esac
|
||||
path="$(tree_path "$name")"
|
||||
|
||||
|
||||
+3
-3
@@ -52,8 +52,8 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$KERNEL" ] && [ -f "$KERNEL" ] || { echo "FATAL: --kernel: no such file" >&2; exit 1; }
|
||||
[ -n "$DTB" ] && [ -f "$DTB" ] || { echo "FATAL: --dtb: no such file" >&2; exit 1; }
|
||||
{ [ -n "$KERNEL" ] && [ -f "$KERNEL" ]; } || { echo "FATAL: --kernel: no such file" >&2; exit 1; }
|
||||
{ [ -n "$DTB" ] && [ -f "$DTB" ]; } || { echo "FATAL: --dtb: no such file" >&2; exit 1; }
|
||||
[ -n "$OUT" ] || { echo "FATAL: --out is required" >&2; exit 1; }
|
||||
command -v mkimage >/dev/null || {
|
||||
echo "FATAL: mkimage not on PATH (Debian/Ubuntu: u-boot-tools)" >&2; exit 1; }
|
||||
@@ -76,7 +76,7 @@ if [ -z "$RTOOL" ]; then
|
||||
[ -x "$c" ] && { RTOOL="$c"; break; }
|
||||
done
|
||||
fi
|
||||
[ -n "$RTOOL" ] && [ -x "$RTOOL" ] || {
|
||||
{ [ -n "$RTOOL" ] && [ -x "$RTOOL" ]; } || {
|
||||
echo "FATAL: resource_tool not found; pass --resource-tool PATH" >&2; exit 1; }
|
||||
|
||||
WORKDIR="$(mktemp -d)"
|
||||
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
# Unpack the pinned Buildroot tree where the vendor SDK builds it.
|
||||
#
|
||||
# The vendor SDK ships buildroot-2023.02.6. WardenOS builds against
|
||||
# buildroot-2025.02.8, which is not in the vendor checkout, so a clean checkout
|
||||
# plus luckfox-sdk-patches/ had nothing to build (blueflare/bfe-core1106-sdk#4).
|
||||
# This script closes that gap: it fetches the tarball with
|
||||
# fetch-buildroot-tarball.sh (sha256-pinned, fails closed) and unpacks it to
|
||||
# sysdrv/source/buildroot/buildroot-<ver>, the path the patched project/build.sh
|
||||
# and sysdrv/Makefile select.
|
||||
#
|
||||
# Idempotent. An SDK that already has the tree is left alone, so the
|
||||
# persistent CI SDK and the workstation SDK are untouched. A partial unpack
|
||||
# never lands at the final path: the tarball is unpacked into a scratch
|
||||
# directory beside it and moved into place only when complete.
|
||||
#
|
||||
# Our own Buildroot delta (defconfigs, package patches, the busybox applet
|
||||
# patch) is NOT applied here. flare-edge's tools/build-firmware.sh stages it
|
||||
# after this script runs, the same way it applies the rest of the series.
|
||||
#
|
||||
# Usage: unpack-buildroot.sh <vendor-sdk-dir>
|
||||
#
|
||||
# The tarball is cached at sysdrv/source/buildroot/buildroot-<ver>.tar.xz
|
||||
# (inside a directory the vendor .gitignore already ignores); set
|
||||
# WARDEN_BUILDROOT_TARBALL to use another path.
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # build/
|
||||
FETCH="$HERE/fetch-buildroot-tarball.sh"
|
||||
SDK="${1:?usage: unpack-buildroot.sh <vendor-sdk-dir>}"
|
||||
|
||||
die() { echo "unpack-buildroot: FATAL: $*" >&2; exit 1; }
|
||||
|
||||
[ -f "$FETCH" ] || die "missing $FETCH"
|
||||
BRVER="$(sed -n 's/^BRVER=//p' "$FETCH" | head -1)"
|
||||
case "$BRVER" in
|
||||
''|*[!0-9.]*) die "cannot read BRVER from $FETCH" ;;
|
||||
esac
|
||||
|
||||
# The SDK must already select this version. Both selectors come from
|
||||
# luckfox-sdk-patches/board/ (0006 for project/build.sh, 0009 for
|
||||
# sysdrv/Makefile); if either still names another tree the series has not
|
||||
# been applied, and unpacking would only hide that.
|
||||
BUILD_SH="$SDK/project/build.sh"
|
||||
MAKEFILE="$SDK/sysdrv/Makefile"
|
||||
[ -f "$BUILD_SH" ] || die "no vendor SDK at $SDK (missing project/build.sh)"
|
||||
[ -f "$MAKEFILE" ] || die "no vendor SDK at $SDK (missing sysdrv/Makefile)"
|
||||
# shellcheck disable=SC2016 # the literal ${SDK_SYSDRV_DIR} text in build.sh
|
||||
sel_build="$(sed -n 's|^BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/||p' "$BUILD_SH" | head -1)"
|
||||
sel_make="$(sed -n 's/^BUILDROOT_VER[[:space:]]*?=[[:space:]]*//p' "$MAKEFILE" | head -1)"
|
||||
[ "$sel_build" = "buildroot-$BRVER" ] ||
|
||||
die "project/build.sh selects '${sel_build:-nothing}', not buildroot-$BRVER (apply luckfox-sdk-patches/board first)"
|
||||
[ "$sel_make" = "buildroot-$BRVER" ] ||
|
||||
die "sysdrv/Makefile selects '${sel_make:-nothing}', not buildroot-$BRVER (apply luckfox-sdk-patches/board first)"
|
||||
|
||||
PARENT="$SDK/sysdrv/source/buildroot"
|
||||
TREE="$PARENT/buildroot-$BRVER"
|
||||
TB="${WARDEN_BUILDROOT_TARBALL:-$PARENT/buildroot-$BRVER.tar.xz}"
|
||||
|
||||
if [ -f "$TREE/Makefile" ] && [ -d "$TREE/configs" ] && [ -d "$TREE/package" ]; then
|
||||
echo "buildroot-$BRVER: tree already present at ${TREE#"$SDK"/}"
|
||||
exit 0
|
||||
fi
|
||||
# Something is at the path but it is not a Buildroot tree. Deleting it here
|
||||
# could destroy build output in a shared SDK, so say so and stop.
|
||||
[ ! -e "$TREE" ] || die "$TREE exists but is not a complete Buildroot tree; remove it and rerun"
|
||||
|
||||
mkdir -p "$PARENT"
|
||||
bash "$FETCH" "$TB"
|
||||
|
||||
SCRATCH="$(mktemp -d "$PARENT/.unpack-buildroot.XXXXXX")"
|
||||
[ -d "$SCRATCH" ] || die "mktemp failed under $PARENT"
|
||||
cleanup() { rm -rf "$SCRATCH"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "== unpacking buildroot-$BRVER into ${TREE#"$SDK"/}"
|
||||
tar -xJf "$TB" -C "$SCRATCH"
|
||||
[ -f "$SCRATCH/buildroot-$BRVER/Makefile" ] ||
|
||||
die "tarball did not contain buildroot-$BRVER/Makefile"
|
||||
mv "$SCRATCH/buildroot-$BRVER" "$TREE"
|
||||
echo "buildroot-$BRVER: unpacked"
|
||||
@@ -17,7 +17,8 @@
|
||||
# release tarball has no commit to name:
|
||||
#
|
||||
# linux-6.18.46 build/fetch-kernel-tarball.sh
|
||||
# buildroot-2025.02.8 build/fetch-buildroot-tarball.sh
|
||||
# buildroot-2025.02.8 build/fetch-buildroot-tarball.sh (unpacked into the
|
||||
# vendor SDK by build/unpack-buildroot.sh)
|
||||
#
|
||||
# The buildroot one matters more than it looks. The firmware builds against
|
||||
# sysdrv/source/buildroot/buildroot-2025.02.8 inside the vendor SDK, and the
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ execute code on private infrastructure (ADR-0007).
|
||||
| `mcdc` | ubuntu-latest | 100% MC/DC enforced on every `drivers/*/test` (gcc-14 `-fcondition-coverage`). |
|
||||
| `bench` | ubuntu-latest | Smoke-runs the sim + rs485-bridge micro-benchmarks; emits ns/op trend JSON. |
|
||||
| `patches-apply` | ubuntu-latest | Fetches pristine linux-6.18.46 (cached, sha256-verified) and applies `patches/*` in order. |
|
||||
| `qemu-tools` | ubuntu-latest | shellcheck on `qemu/**.sh`, `tests/mk-bootimg/*.sh`, `tests/fetch-vendor/*.sh`, `tests/fetch-buildroot-tarball/*.sh`; runs the offline regression tests for the mk-bootimg probe, boot.img validation, run.sh argv ordering, mkimage's SEED_DIR hook, staged rootfs permissions, fetch-vendor, fetch-buildroot-tarball, and its own CI wiring; builds the initramfs (pinned busybox) and the A/B disk image. |
|
||||
| `qemu-tools` | ubuntu-latest | shellcheck on `qemu/**.sh`, `tests/mk-bootimg/*.sh`, `tests/fetch-vendor/*.sh`, `tests/fetch-buildroot-tarball/*.sh`, `tests/unpack-buildroot/*.sh`; runs the offline regression tests for the mk-bootimg probe, boot.img validation, run.sh argv ordering, mkimage's SEED_DIR hook, staged rootfs permissions, fetch-vendor, fetch-buildroot-tarball, unpack-buildroot, and its own CI wiring; builds the initramfs (pinned busybox) and the A/B disk image. |
|
||||
| `quality` | ubuntu-latest | Codacy-style grade computed in-pipeline: clippy, cppcheck, shellcheck, ruff, lizard, jscpd, cargo-audit feed `tools/quality/score.py` (SQALE debt ratio + a separate worst-of security axis; SonarQube's published thresholds). Uploads `quality.json`; fails if the security grade is worse than C. |
|
||||
| `kernel-build` | ubuntu-latest, **dispatch-only** | apt-installs the cross toolchain + qemu, `build/build-kernel.sh` -> `zImage` + `rv1106-warden.dtb`, QEMU `-M virt` boot smoke (fail-closed), artifact upload (best-effort). Trigger: `gh workflow run ci.yml`. |
|
||||
| `prune-artifacts` | ubuntu-latest, dispatch-only | Deletes `kernel-rv1106` artifacts beyond the newest 3. |
|
||||
|
||||
@@ -57,7 +57,9 @@ luckfox-sdk-patches/uboot/include/ new source files
|
||||
luckfox-sdk-patches/kernel/patches/ diffs against sysdrv/source/kernel/
|
||||
luckfox-sdk-patches/kernel/configs/ new kernel config fragments
|
||||
luckfox-sdk-patches/wifi/patches/ diffs against sysdrv/drv_ko/wifi/ (out-of-tree modules)
|
||||
luckfox-sdk-patches/board/patches/ diffs against project/ (board .mk + the build driver)
|
||||
luckfox-sdk-patches/board/patches/ diffs against project/ and sysdrv/ build files (board .mk,
|
||||
build drivers, Makefiles, init overlays); may delete files
|
||||
luckfox-sdk-patches/buildroot/ our delta on the Buildroot tree (see "Buildroot" below)
|
||||
```
|
||||
|
||||
Paths inside each patch are relative to the vendor SDK root, so apply with
|
||||
@@ -87,6 +89,29 @@ skipped; else if `git apply --check` succeeds it is applied; else it is a hand-
|
||||
patched SDK carrying an equivalent (or a genuine conflict) and the script warns
|
||||
and continues rather than aborting the build.
|
||||
|
||||
## Buildroot
|
||||
|
||||
The vendor checkout ships buildroot-2023.02.6; WardenOS builds against
|
||||
buildroot-2025.02.8, which is not in the vendor checkout.
|
||||
`board/patches/0006-buildroot-2025.patch` (project/build.sh) and
|
||||
`board/patches/0009-sysdrv-buildroot-2025.patch` (sysdrv/Makefile) select it,
|
||||
and `../build/unpack-buildroot.sh` puts the pristine tree at
|
||||
`sysdrv/source/buildroot/buildroot-2025.02.8`: it fetches the tarball with
|
||||
`../build/fetch-buildroot-tarball.sh` (sha256-pinned) and leaves an existing
|
||||
tree alone. flare-edge's `tools/build-firmware.sh` runs it right after
|
||||
applying the patches, then stages `buildroot/files/` and applies
|
||||
`buildroot/patches/` onto the tree (issue #4).
|
||||
|
||||
## Completeness check
|
||||
|
||||
flare-edge's `tools/verify-sdk-patches.sh` replays this series onto the vendor
|
||||
base and compares the result with an SDK checkout. It also fails when the SDK
|
||||
has a tracked change (edit or deletion) that no patch, no fragment and no
|
||||
entry in flare-edge's `tools/sdk-delta-allowlist.txt` accounts for, and when
|
||||
the 86Panel board config names a kernel or U-Boot config fragment that
|
||||
neither the vendor base nor this directory provides. Before that check, five
|
||||
real deltas lived only in copies of one SDK tree (issue #4).
|
||||
|
||||
## What each patch does
|
||||
|
||||
### `uboot/patches/0001-display-and-boot-timing.patch`
|
||||
@@ -269,6 +294,19 @@ had masked it (the reproducibility gap `tools/build-firmware.sh` exists to close
|
||||
`sysdrv/source/uboot/u-boot/configs/` (it is a whole new file, not a diff);
|
||||
the board `.mk` patch is what references it by name.
|
||||
|
||||
### `board/patches/0009` to `0013` (issue #4)
|
||||
|
||||
Deltas that lived only in the workstation SDK until issue #4. Each patch
|
||||
header explains its change.
|
||||
|
||||
| patch | file | what it does |
|
||||
|---|---|---|
|
||||
| `0009-sysdrv-buildroot-2025.patch` | `sysdrv/Makefile` | `BUILDROOT_VER` to 2025.02.8 (the tree the `buildroot` target builds); relaxes the vendor unpack fallback's `cp` lines |
|
||||
| `0010-drop-2023-buildroot-package-patches.patch` | `sysdrv/tools/board/buildroot/{busybox,hcitool}_patch/` | deletes five 2023-era package patches the fallback would copy into Buildroot |
|
||||
| `0011-oem-flare-minimize.patch` | `project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh` | `flare_minimize`: strips camera/ISP files and modules from /oem |
|
||||
| `0012-drop-s50sshd.patch` | `overlay-luckfox-buildroot-init/etc/init.d/S50sshd` | deletes the generic sshd starter; dropbear provides SSH |
|
||||
| `0013-e2fsprogs-build-cflags.patch` | `sysdrv/tools/board/e2fsprogs/Makefile` | `BUILD_CFLAGS` so the host helpers build with gcc 14 |
|
||||
|
||||
## Config fragments
|
||||
|
||||
| fragment | why |
|
||||
@@ -278,6 +316,8 @@ had masked it (the reproducibility gap `tools/build-firmware.sh` exists to close
|
||||
| `uboot/flare-bootcount.config` | boot-failure fallback to `altbootcmd=download` -> MaskRom |
|
||||
| `uboot/flare-spl-brom.config` | builds `spl_bootrom.o`; does *not* set `SPL_ROCKCHIP_BACK_TO_BROM`, which would flip `SPL_MMC_SUPPORT` off |
|
||||
| `kernel/flare-backlight.config` | `CONFIG_BACKLIGHT_PWM=y`. As `=m` the backlight class device does not exist until userspace `insmod`s it at ~3.3-3.7 s, which is when the logo is being replaced anyway |
|
||||
| `kernel/flare-wireguard.config` | `CONFIG_WIREGUARD=y` for the vendor 5.10 kernel, which builds the recovery image. Named by the 86Panel board `.mk`; untracked in the workstation SDK until issue #4 |
|
||||
| `kernel/rv1106-usb-host-ethernet.config` | USB-Ethernet class drivers (with the `USB_NET_DRIVERS` menu gate) for the vendor 5.10 kernel. Same history as `flare-wireguard.config` |
|
||||
| `kernel/flare-fbcon.config` | `# CONFIG_LOGO is not set` (the SDK ships the LuckFox fox-head over our logo) plus `FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y` (fbcon seizing the fb destroyed the `drm_logo` image U-Boot handed over) |
|
||||
|
||||
## Measured boot timeline
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
Build buildroot-2025.02.8 from sysdrv/Makefile too.
|
||||
|
||||
0006-buildroot-2025.patch points project/build.sh at buildroot-2025.02.8, but
|
||||
sysdrv/Makefile has its own default, BUILDROOT_VER, and that is the one the
|
||||
`buildroot` target actually builds. Left at the vendor's 2023.02.6, a clean
|
||||
checkout configures and builds the old tree.
|
||||
|
||||
The same Makefile carries the vendor's fallback that unpacks
|
||||
tools/board/buildroot/$(BUILDROOT_VER).tar.gz when the tree is missing and
|
||||
copies the vendor defconfigs and package patches into it. Two relaxations
|
||||
keep that fallback usable with 2025.02.8:
|
||||
|
||||
- `*_defconfig` instead of only luckfox_pico_w_defconfig, so any defconfig
|
||||
staged beside the vendor ones is copied too.
|
||||
- `|| true` on the busybox and hcitool patch copies, because
|
||||
0010-drop-2023-buildroot-package-patches.patch empties those directories.
|
||||
|
||||
The WardenOS build does not use the fallback: flare-edge's
|
||||
tools/build-firmware.sh unpacks the pinned, sha256-verified tarball with
|
||||
build/unpack-buildroot.sh before the SDK build runs, so the Makefile's
|
||||
`test -d` finds the tree and skips its own unpack and copies.
|
||||
|
||||
diff --git a/sysdrv/Makefile b/sysdrv/Makefile
|
||||
index 5edb8f875..c173c219e 100644
|
||||
--- a/sysdrv/Makefile
|
||||
+++ b/sysdrv/Makefile
|
||||
@@ -281,7 +281,7 @@ BUSYBOX_DIR := $(SYSDRV_DIR)/source/busybox
|
||||
SYSDRV_BUSYBOX_OBJS_OUTPUT_DIR ?= $(BUSYBOX_DIR)/objs_$(BUSYBOX_CFG)
|
||||
|
||||
BUILDROOT_CFG ?= config_normal
|
||||
-BUILDROOT_VER ?= buildroot-2023.02.6
|
||||
+BUILDROOT_VER ?= buildroot-2025.02.8
|
||||
BUILDROOT_DIR := $(SYSDRV_DIR)/source/buildroot
|
||||
|
||||
CUSTOM_VER ?= custom
|
||||
@@ -599,11 +599,11 @@ buildroot_create:
|
||||
mkdir -p $(BUILDROOT_DIR)
|
||||
tar xzf $(SYSDRV_DIR)/tools/board/buildroot/$(BUILDROOT_VER).tar.gz -C $(BUILDROOT_DIR)
|
||||
cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/
|
||||
- cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_w_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/
|
||||
+ cp $(SYSDRV_DIR)/tools/board/buildroot/*_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/
|
||||
cp $(SYSDRV_DIR)/tools/board/buildroot/busybox.config $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/
|
||||
- cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/
|
||||
+ cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/ || true
|
||||
cp ${MPV_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/mpv/
|
||||
- cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/
|
||||
+ cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ || true
|
||||
|
||||
buildroot: prepare
|
||||
@echo -e "$(C_GREEN) ==sysdrv== build buildroot $(C_NORMAL)"
|
||||
@@ -611,11 +611,11 @@ buildroot: prepare
|
||||
mkdir -p $(BUILDROOT_DIR) ;\
|
||||
tar xzf $(SYSDRV_DIR)/tools/board/buildroot/$(BUILDROOT_VER).tar.gz -C $(BUILDROOT_DIR) ;\
|
||||
cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
|
||||
- cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_w_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
|
||||
+ cp $(SYSDRV_DIR)/tools/board/buildroot/*_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
|
||||
cp $(SYSDRV_DIR)/tools/board/buildroot/busybox.config $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ ;\
|
||||
- cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/ ;\
|
||||
+ cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/ || true ;\
|
||||
cp ${MPV_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/mpv/ ;\
|
||||
- cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ ;\
|
||||
+ cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ || true ;\
|
||||
);
|
||||
|
||||
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) $(BUILDROOT_DEFCONFIG) -C $(BUILDROOT_DIR)/$(BUILDROOT_VER)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
Strip camera and ISP payload from /oem.
|
||||
|
||||
luckfox-buildroot-oem-pre.sh runs over the OEM staging tree before it is
|
||||
packed. flare_minimize() removes what WardenOS never uses because no image
|
||||
sensor is fitted: the ISP tuning files (about 32 MB), the rkaiq 3A library
|
||||
and servers, the camera capture kernel modules, and the camera and MPI
|
||||
sample binaries.
|
||||
|
||||
NPU, video codec, RGA and rockit are kept on purpose. WiFi/BT, touch and the
|
||||
insmod scripts are not touched.
|
||||
|
||||
diff --git a/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh b/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh
|
||||
index 4187457d4..de2bf74e6 100755
|
||||
--- a/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh
|
||||
+++ b/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh
|
||||
@@ -46,4 +46,37 @@ function remove_data()
|
||||
#=========================
|
||||
# run
|
||||
#=========================
|
||||
-remove_data
|
||||
\ No newline at end of file
|
||||
+remove_data
|
||||
+#=========================
|
||||
+# flare-edge: drop camera / ISP from /oem
|
||||
+#
|
||||
+# Camera is out of scope for the Warden gateway role (no sensor attached).
|
||||
+# NPU, video codec, RGA and rockit are KEPT deliberately - they are onboard
|
||||
+# hardware we chose to retain. WiFi/BT (aic8800*), touch (goodix) and the
|
||||
+# insmod scripts are never touched here.
|
||||
+#=========================
|
||||
+function flare_minimize()
|
||||
+{
|
||||
+ KO=$RK_PROJECT_PACKAGE_OEM_DIR/usr/ko
|
||||
+
|
||||
+ # ISP tuning data - by far the biggest item in /oem (~32MB)
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/share/iqfiles
|
||||
+
|
||||
+ # ISP 3A library and its servers
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/lib/librkaiq*
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/rkaiq_3A_server
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/rkaiq_tool_server
|
||||
+
|
||||
+ # camera capture path: ISP, CIF, MIPI CSI-2 D-PHY, and the sensor drivers
|
||||
+ lf_rm $KO/video_rkisp.ko $KO/video_rkcif.ko
|
||||
+ lf_rm $KO/phy-rockchip-csi2-dphy.ko $KO/phy-rockchip-csi2-dphy-hw.ko
|
||||
+ lf_rm $KO/sc3336.ko $KO/mis5001.ko $KO/gspca_main.ko
|
||||
+
|
||||
+ # camera/ISP demo + sample binaries (keep luckfox_*_test and modetest:
|
||||
+ # those are the GPIO/UART/I2C/SPI/PWM/display bring-up tools we want)
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/sample_*
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/rk_mpi_*
|
||||
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/simple_*
|
||||
+}
|
||||
+
|
||||
+flare_minimize
|
||||
@@ -0,0 +1,65 @@
|
||||
Remove the generic S50sshd init script.
|
||||
|
||||
overlay-luckfox-buildroot-init is in the 86Panel board's RK_POST_OVERLAY.
|
||||
Its S50sshd runs `ssh-keygen -A` inline. With no hardware RNG and no saved
|
||||
seed on a freshly written rootfs, getrandom() blocks, and rcS is sequential,
|
||||
so every init script sorting after it (S50usbdevice among them) never ran
|
||||
and the board came up with no reachable interface.
|
||||
|
||||
WardenOS gets its SSH server from Buildroot's dropbear package, selected by
|
||||
flare_warden_defconfig, which installs its own init script.
|
||||
|
||||
diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S50sshd b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S50sshd
|
||||
deleted file mode 100755
|
||||
index e5b9c4451..000000000
|
||||
--- a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S50sshd
|
||||
+++ /dev/null
|
||||
@@ -1,48 +0,0 @@
|
||||
-#!/bin/sh
|
||||
-#
|
||||
-# sshd Starts sshd.
|
||||
-#
|
||||
-
|
||||
-# Make sure the ssh-keygen progam exists
|
||||
-[ -f /usr/bin/ssh-keygen ] || exit 0
|
||||
-
|
||||
-umask 077
|
||||
-
|
||||
-start() {
|
||||
- chown root:root /var/empty/
|
||||
- # Create any missing keys
|
||||
- /usr/bin/ssh-keygen -A
|
||||
-
|
||||
- printf "Starting sshd: "
|
||||
- /usr/sbin/sshd
|
||||
- touch /var/lock/sshd
|
||||
- echo "OK"
|
||||
-}
|
||||
-stop() {
|
||||
- printf "Stopping sshd: "
|
||||
- killall sshd
|
||||
- rm -f /var/lock/sshd
|
||||
- echo "OK"
|
||||
-}
|
||||
-restart() {
|
||||
- stop
|
||||
- start
|
||||
-}
|
||||
-
|
||||
-case "$1" in
|
||||
- start)
|
||||
- start
|
||||
- ;;
|
||||
- stop)
|
||||
- stop
|
||||
- ;;
|
||||
- restart|reload)
|
||||
- restart
|
||||
- ;;
|
||||
- *)
|
||||
- echo "Usage: $0 {start|stop|restart}"
|
||||
- exit 1
|
||||
-esac
|
||||
-
|
||||
-exit $?
|
||||
-
|
||||
@@ -0,0 +1,21 @@
|
||||
Build e2fsprogs host helpers with gcc 14.
|
||||
|
||||
The vendor's e2fsprogs 1.43.9 compiles a few helper programs for the build
|
||||
host (BUILD_CC) while cross-building the target tools. That source relies on
|
||||
implicit function declarations and implicit int, which gcc 14 turns into
|
||||
errors, so the host helper build fails. BUILD_CFLAGS demotes those two back
|
||||
to warnings for the host helpers only; the target CFLAGS are unchanged.
|
||||
|
||||
diff --git a/sysdrv/tools/board/e2fsprogs/Makefile b/sysdrv/tools/board/e2fsprogs/Makefile
|
||||
index 14ab9e503..baa541093 100644
|
||||
--- a/sysdrv/tools/board/e2fsprogs/Makefile
|
||||
+++ b/sysdrv/tools/board/e2fsprogs/Makefile
|
||||
@@ -20,7 +20,7 @@ all:
|
||||
mkdir -p $(CURRENT_DIR)/$(PKG_BIN)/usr/; \
|
||||
pushd $(CURRENT_DIR)/$(PKG_NAME)/; \
|
||||
./configure --host=$(SYSDRV_CROSS) --target=$(SYSDRV_CROSS) CFLAGS="$(SYSDRV_CROSS_CFLAGS)" \
|
||||
- LDFLAGS="$(SYSDRV_CROSS_CFLAGS)" --prefix=$(CURRENT_DIR)/$(PKG_BIN) \
|
||||
+ LDFLAGS="$(SYSDRV_CROSS_CFLAGS)" BUILD_CFLAGS="-Wno-implicit-function-declaration -Wno-implicit-int" --prefix=$(CURRENT_DIR)/$(PKG_BIN) \
|
||||
--disable-nls \
|
||||
--disable-debugfs --disable-imager --disable-defrag --enable-fsck --enable-resizer \
|
||||
--disable-testio-debug --disable-rpath --enable-symlink-install --disable-fuse2fs; \
|
||||
@@ -0,0 +1,10 @@
|
||||
# WireGuard, built in rather than as a module.
|
||||
#
|
||||
# =y not =m deliberately: modules live on the oem partition and must be
|
||||
# reflashed in lockstep with the kernel, and this one is ~40KB. Paying that in
|
||||
# boot.img is cheaper than another matched-pair failure mode.
|
||||
#
|
||||
# Everything WireGuard needs it "select"s for itself (NET_UDP_TUNNEL,
|
||||
# DST_CACHE, CRYPTO_LIB_CURVE25519, CRYPTO_LIB_CHACHA20POLY1305), so unlike the
|
||||
# USB-Ethernet fragment there is no menu gate to open first. Verify anyway.
|
||||
CONFIG_WIREGUARD=y
|
||||
@@ -0,0 +1,20 @@
|
||||
# USB host + USB-Ethernet class drivers (flare-edge).
|
||||
#
|
||||
# The first symbol is the MENU GATE. Every driver below lives inside the
|
||||
# USB_NET_DRIVERS menuconfig, so without it kconfig discards the lot in
|
||||
# silence -- no warning, and not even the usual "not in final .config" from
|
||||
# merge_config.sh.
|
||||
#
|
||||
# Do not begin a comment line here with a hash followed by CONFIG_. That is
|
||||
# exactly the "is not set" syntax, so merge_config.sh parses the prose as a
|
||||
# directive and reports it as a redefinition of the symbol it names.
|
||||
CONFIG_USB_NET_DRIVERS=y
|
||||
CONFIG_USB_USBNET=y
|
||||
CONFIG_USB_NET_CDCETHER=y
|
||||
CONFIG_USB_NET_CDC_NCM=y
|
||||
CONFIG_USB_NET_CDC_EEM=y
|
||||
CONFIG_USB_RTL8152=y
|
||||
CONFIG_USB_NET_AX8817X=y
|
||||
CONFIG_USB_NET_AX88179_178A=y
|
||||
CONFIG_USB_NET_SMSC95XX=y
|
||||
CONFIG_USB_NET_MCS7830=y
|
||||
+27
-1
@@ -186,10 +186,16 @@ place_partition() {
|
||||
# scenarios. Bytes mirror flare-edge tools/mk-misc.py provisioning
|
||||
# defaults (A: prio 15 successful, B: prio 14 successful, CRC32-BE).
|
||||
misc) stage="__misc__" ;;
|
||||
# env carries a REAL U-Boot environment: flared clears bootcount there
|
||||
# before an intentional reboot, and treats a zeroed (bad-CRC) env as
|
||||
# "bookkeeping not durable", so a factory reset on the rig was always
|
||||
# refused (flare-edge#62). Format mirrors flare-edge flared/src/envf.rs
|
||||
# and tools/envf.py: LE CRC32 of the rest, NUL-separated entries.
|
||||
env) stage="__env__" ;;
|
||||
# Boot-chain partitions the VM never reads: present at the right offsets,
|
||||
# left zeroed. Enumerated (not a wildcard) so a typo'd name in
|
||||
# blkdevparts.conf fails HERE, not as a confusing mount error at boot.
|
||||
env|idblock|uboot|boot_a|boot_b|recovery) stage="" ;;
|
||||
idblock|uboot|boot_a|boot_b|recovery) stage="" ;;
|
||||
*) echo "FATAL: unknown partition name '$name' in blkdevparts.conf" >&2; exit 1 ;;
|
||||
esac
|
||||
DISK_END_TRACK "$off" "$size"
|
||||
@@ -220,6 +226,26 @@ PYMISC
|
||||
qemu_log " $name: AvbABData provisioned @ +2048"
|
||||
return 0
|
||||
fi
|
||||
if [ "$stage" = "__env__" ]; then
|
||||
python3 - "$img" "$size" <<'PYENV'
|
||||
import struct, sys, zlib
|
||||
img, size = sys.argv[1], int(sys.argv[2])
|
||||
ENV_SIZE = 0x8000 # CONFIG_ENV_SIZE; flared refuses any other length
|
||||
if size < ENV_SIZE:
|
||||
sys.exit(f"FATAL: env partition is {size} bytes, need {ENV_SIZE}")
|
||||
body = bytearray(ENV_SIZE - 4)
|
||||
entries = b"bootcount=0\0\0" # one entry, then the empty terminator
|
||||
body[:len(entries)] = entries
|
||||
env = struct.pack("<I", zlib.crc32(bytes(body)) & 0xFFFFFFFF) + bytes(body)
|
||||
buf = bytearray(size)
|
||||
buf[:ENV_SIZE] = env
|
||||
open(img, "wb").write(buf)
|
||||
PYENV
|
||||
dd if="$img" of="$DISK" bs=4096 seek=$((off / 4096)) \
|
||||
conv=notrunc,sparse status=none
|
||||
qemu_log " $name: U-Boot env provisioned (bootcount=0)"
|
||||
return 0
|
||||
fi
|
||||
mkfs_part "$stage" "$size" "$img"
|
||||
dd if="$img" of="$DISK" bs=4096 seek=$((off / 4096)) \
|
||||
conv=notrunc,sparse status=none
|
||||
|
||||
+61
-2
@@ -716,7 +716,9 @@ class Ctx:
|
||||
need_ctl, need_imgtools and fresh_region move here since verb handlers,
|
||||
not drive(), are what call them now). One instance per run."""
|
||||
|
||||
def __init__(self, s, f, size, ctl, refs, refs_path, rs485_control, outdir, script_path):
|
||||
def __init__(self, s, f, size, ctl, refs, refs_path, rs485_control, outdir, script_path,
|
||||
console_path=None):
|
||||
self.console_path = console_path
|
||||
self.s = s
|
||||
self.f = f
|
||||
self.size = size
|
||||
@@ -809,6 +811,61 @@ def verb_sleep(ctx, lineno, cmd, args, line):
|
||||
return "ok", ""
|
||||
|
||||
|
||||
REBOOT_MARKER = b"reboot: Restarting system"
|
||||
PANIC_MARKER = b"Kernel panic"
|
||||
|
||||
|
||||
def verb_expect_reboot(ctx, lineno, cmd, args, line):
|
||||
"""expect_reboot TIMEOUT_S: the guest reboots, in an orderly way, within
|
||||
TIMEOUT_S seconds (flare-edge#62). For an action whose correct outcome IS a
|
||||
reboot (factory reset, Reboot, the A/B Boot button), which used to be
|
||||
untestable here: run.sh boots with -no-reboot, so the reboot ends the VM.
|
||||
|
||||
Passes only when both hold: the console shows the kernel's orderly restart
|
||||
line, written after this step began, and QEMU is gone (QMP closed or
|
||||
reporting shutdown). A kernel panic, a VM that exits without the orderly
|
||||
line, and a VM still running at the deadline all fail. It must be a
|
||||
script's last command: nothing can run on a VM that has left."""
|
||||
timeout = float(args[0])
|
||||
if not ctx.console_path:
|
||||
sys.exit(f"FATAL: {ctx.script_path}:{lineno}: '{cmd}' needs --console")
|
||||
try:
|
||||
start = os.path.getsize(ctx.console_path)
|
||||
except OSError:
|
||||
start = 0
|
||||
deadline = time.monotonic() + timeout
|
||||
|
||||
def console_since_start():
|
||||
try:
|
||||
with open(ctx.console_path, "rb") as fh:
|
||||
fh.seek(start)
|
||||
return fh.read()
|
||||
except OSError:
|
||||
return b""
|
||||
|
||||
while True:
|
||||
try:
|
||||
gone = rpc(ctx.s, ctx.f, {"execute": "query-status"}).get("status") == "shutdown"
|
||||
except (RuntimeError, OSError, ValueError):
|
||||
gone = True
|
||||
# Read the console AFTER asking whether QEMU is gone: the guest's last
|
||||
# lines (the restart line, or a panic) arrive just before it exits,
|
||||
# and a read taken first would judge a finished reboot on stale text.
|
||||
tail = console_since_start()
|
||||
if PANIC_MARKER in tail:
|
||||
return "fail", "kernel panic, not an orderly reboot"
|
||||
restarted = REBOOT_MARKER in tail
|
||||
if gone:
|
||||
if restarted:
|
||||
return "ok", ""
|
||||
return "fail", "the VM exited without the kernel's orderly restart line"
|
||||
if time.monotonic() >= deadline:
|
||||
if restarted:
|
||||
return "fail", f"the guest restarted but QEMU was still running after {timeout:g}s"
|
||||
return "fail", f"no reboot within {timeout:g}s"
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
def verb_echo(ctx, lineno, cmd, args, line):
|
||||
print(f" [{lineno}] {' '.join(args)}", flush=True)
|
||||
return None
|
||||
@@ -1098,6 +1155,7 @@ VERBS = {
|
||||
"assert_region": verb_assert_region,
|
||||
"wait_region": verb_wait_region,
|
||||
"assert_ocr": verb_assert_ocr,
|
||||
"expect_reboot": verb_expect_reboot,
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,7 +1178,8 @@ def drive(s, f, script_path, outdir, size, ctl_path=None, console_path=None, ref
|
||||
print(f" [{lineno}] {tag}{cmd}{(' -- ' + detail) if detail else ''}", flush=True)
|
||||
|
||||
refs_path = refs_path or os.path.join(outdir, "refs.json")
|
||||
ctx = Ctx(s, f, size, ctl, load_refs(refs_path), refs_path, rs485_control, outdir, script_path)
|
||||
ctx = Ctx(s, f, size, ctl, load_refs(refs_path), refs_path, rs485_control, outdir, script_path,
|
||||
console_path)
|
||||
console = ConsoleWatch(console_path)
|
||||
|
||||
for lineno, raw in enumerate(lines, 1):
|
||||
|
||||
@@ -98,15 +98,21 @@ printf '#!/usr/bin/env python3\nimport sys; sys.exit(1)\n' > "$FLARE_EDGE/tools/
|
||||
# without a subshell: run_rig's RIG_OUT/RIG_RC writes land here directly, so
|
||||
# nothing needs to be re-serialized as text and re-parsed back out below.
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK='' run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case A: never-appeared rs.sock fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case A: never-appeared rs.sock fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 bus socket never appeared' \
|
||||
&& pass "case A: FATAL names the missing rs.sock" \
|
||||
|| fail "case A: FATAL names the missing rs.sock: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF '== rs485 simulator:' \
|
||||
&& fail "case A: printed the rs485-live success line over a bus that was never up: $RIG_OUT" \
|
||||
|| pass "case A: never claims the bus is live"
|
||||
if [ "$RIG_RC" -ne 0 ]; then
|
||||
pass "case A: never-appeared rs.sock fails the run (rc=$RIG_RC)"
|
||||
else
|
||||
fail "case A: never-appeared rs.sock fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 bus socket never appeared'; then
|
||||
pass "case A: FATAL names the missing rs.sock"
|
||||
else
|
||||
fail "case A: FATAL names the missing rs.sock: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF '== rs485 simulator:'; then
|
||||
fail "case A: printed the rs485-live success line over a bus that was never up: $RIG_OUT"
|
||||
else
|
||||
pass "case A: never claims the bus is live"
|
||||
fi
|
||||
|
||||
# --- case B: rs.sock is up but socat never creates rs.pty -------------------
|
||||
work="$SCRATCH/b"; build_rig "$work"
|
||||
@@ -117,12 +123,16 @@ FAKEBIN="$SCRATCH/fakebin-b"; mkdir -p "$FAKEBIN"
|
||||
printf '#!/usr/bin/env bash\necho "FAKE SOCAT: simulated failure" >&2\nexit 1\n' > "$FAKEBIN/socat"
|
||||
chmod +x "$FAKEBIN/socat"
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 PATH="$FAKEBIN:$PATH" run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case B: socat never linking rs.pty fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case B: socat never linking rs.pty fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 socat never created rs.pty' \
|
||||
&& pass "case B: FATAL names the missing rs.pty" \
|
||||
|| fail "case B: FATAL names the missing rs.pty: $RIG_OUT"
|
||||
if [ "$RIG_RC" -ne 0 ]; then
|
||||
pass "case B: socat never linking rs.pty fails the run (rc=$RIG_RC)"
|
||||
else
|
||||
fail "case B: socat never linking rs.pty fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 socat never created rs.pty'; then
|
||||
pass "case B: FATAL names the missing rs.pty"
|
||||
else
|
||||
fail "case B: FATAL names the missing rs.pty: $RIG_OUT"
|
||||
fi
|
||||
|
||||
# --- case C: rs.sock+rs.pty are up but mbsim.py crashes before rs.ctl -------
|
||||
work="$SCRATCH/c"; build_rig "$work"
|
||||
@@ -135,15 +145,21 @@ sys.stderr.write("FAKE MBSIM: simulated crash before opening the control socket\
|
||||
sys.exit(1)
|
||||
EOS
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 TEST_MBSIM_PID_FILE='' run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case C: mbsim.py crashing before rs.ctl fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case C: mbsim.py crashing before rs.ctl fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 simulator (mbsim.py) never came up' \
|
||||
&& pass "case C: FATAL names the dead simulator" \
|
||||
|| fail "case C: FATAL names the dead simulator: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FAKE MBSIM: simulated crash' \
|
||||
&& pass "case C: mbsim.log is dumped on failure" \
|
||||
|| fail "case C: mbsim.log is dumped on failure: $RIG_OUT"
|
||||
if [ "$RIG_RC" -ne 0 ]; then
|
||||
pass "case C: mbsim.py crashing before rs.ctl fails the run (rc=$RIG_RC)"
|
||||
else
|
||||
fail "case C: mbsim.py crashing before rs.ctl fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 simulator (mbsim.py) never came up'; then
|
||||
pass "case C: FATAL names the dead simulator"
|
||||
else
|
||||
fail "case C: FATAL names the dead simulator: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FAKE MBSIM: simulated crash'; then
|
||||
pass "case C: mbsim.log is dumped on failure"
|
||||
else
|
||||
fail "case C: mbsim.log is dumped on failure: $RIG_OUT"
|
||||
fi
|
||||
|
||||
# --- case D: a sim process that ignores SIGTERM is still reaped ------------
|
||||
work="$SCRATCH/d"; build_rig "$work"
|
||||
|
||||
@@ -858,6 +858,72 @@ class DriveConsoleCheck(unittest.TestCase):
|
||||
self.assertTrue(all(r["line"] == 1 for r in rows))
|
||||
|
||||
|
||||
class ExpectReboot(unittest.TestCase):
|
||||
"""expect_reboot (flare-edge#62): an action whose correct outcome is a
|
||||
reboot ends the VM on this rig (-no-reboot), so the reboot itself is the
|
||||
thing to assert. QEMU's behaviour is scripted through the fake rpc: each
|
||||
query-status call can append console output and then report the VM gone."""
|
||||
|
||||
def run_reboot(self, steps, before=b"", timeout="2"):
|
||||
d = tempfile.mkdtemp(prefix="console.")
|
||||
console = os.path.join(d, "console.log")
|
||||
with open(console, "wb") as fh:
|
||||
fh.write(before)
|
||||
calls = []
|
||||
|
||||
def rpc(sock, sock_file, obj):
|
||||
if obj.get("execute") != "query-status":
|
||||
return fake_rpc(sock, sock_file, obj)
|
||||
step = steps[min(len(calls), len(steps) - 1)]
|
||||
calls.append(step)
|
||||
text, state = step
|
||||
if text:
|
||||
with open(console, "ab") as fh:
|
||||
fh.write(text)
|
||||
if state == "gone":
|
||||
raise RuntimeError("QMP connection closed")
|
||||
return {"status": state}
|
||||
|
||||
return run_script(f"expect_reboot {timeout}\n", rpc_fn=rpc, console_path=console)
|
||||
|
||||
def test_orderly_reboot_passes(self):
|
||||
rc, by, rows = self.run_reboot([
|
||||
(b"", "running"),
|
||||
(b"[ 12.3] reboot: Restarting system\n", "running"),
|
||||
(b"", "gone"),
|
||||
])
|
||||
self.assertIsNone(rc)
|
||||
self.assertEqual(rows[-1]["status"], "ok", rows)
|
||||
|
||||
def test_qmp_reporting_shutdown_counts_as_gone(self):
|
||||
rc, by, rows = self.run_reboot([(b"reboot: Restarting system\n", "shutdown")])
|
||||
self.assertEqual(rows[-1]["status"], "ok", rows)
|
||||
|
||||
def test_no_reboot_before_the_deadline_fails(self):
|
||||
rc, by, rows = self.run_reboot([(b"", "running")], timeout="0.5")
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("no reboot within", rows[-1]["detail"])
|
||||
|
||||
def test_a_kernel_panic_is_not_a_reboot(self):
|
||||
rc, by, rows = self.run_reboot([
|
||||
(b"Kernel panic - not syncing: Attempted to kill init!\n"
|
||||
b"reboot: Restarting system\n", "gone"),
|
||||
])
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("kernel panic", rows[-1]["detail"])
|
||||
|
||||
def test_exiting_without_the_orderly_line_fails(self):
|
||||
rc, by, rows = self.run_reboot([(b"", "gone")])
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("without the kernel's orderly restart line", rows[-1]["detail"])
|
||||
|
||||
def test_a_restart_line_from_before_the_step_does_not_count(self):
|
||||
rc, by, rows = self.run_reboot([(b"", "gone")],
|
||||
before=b"reboot: Restarting system\n")
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("without the kernel's orderly restart line", rows[-1]["detail"])
|
||||
|
||||
|
||||
class FullscreenToggleTracksRealState(unittest.TestCase):
|
||||
"""qemu/tests/scripts/fullscreen-toggle-tracks-real-state.txt, offline:
|
||||
`home` clears the dashboard's real fullscreen state directly, and a
|
||||
|
||||
@@ -195,7 +195,7 @@ if [ -n "$RS485_DEVICES" ]; then
|
||||
# simulator the serial device it expects; mbsim then answers the guest's
|
||||
# Modbus polls with the corpus profiles' own register maps.
|
||||
command -v socat >/dev/null || { echo "FATAL: --rs485-devices needs socat" >&2; exit 1; }
|
||||
[ -n "${FLARE_EDGE:-}" ] && [ -f "$FLARE_EDGE/tools/modbus-sim/mbsim.py" ] || {
|
||||
{ [ -n "${FLARE_EDGE:-}" ] && [ -f "$FLARE_EDGE/tools/modbus-sim/mbsim.py" ]; } || {
|
||||
echo "FATAL: --rs485-devices needs FLARE_EDGE to point at a flare-edge checkout (mbsim.py)" >&2; exit 1; }
|
||||
wait_for_path "$WORK/rs.sock"
|
||||
[ -S "$WORK/rs.sock" ] || {
|
||||
|
||||
@@ -37,6 +37,7 @@ scripts=(
|
||||
"qemu/tests/stage-rootfs-perms.sh"
|
||||
"tests/fetch-vendor/run-fetch-vendor-tests.sh"
|
||||
"tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh"
|
||||
"tests/unpack-buildroot/run-unpack-buildroot-tests.sh"
|
||||
"tests/mk-bootimg/run-boot-img-validate-tests.sh"
|
||||
"tests/mk-bootimg/run-help-tests.sh"
|
||||
"tests/mk-bootimg/run-ci-wiring-tests.sh"
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regression tests for build/unpack-buildroot.sh (blueflare/bfe-core1106-sdk#4).
|
||||
#
|
||||
# A clean vendor checkout plus luckfox-sdk-patches/ could not build WardenOS
|
||||
# because nothing put buildroot-2025.02.8 where the SDK builds it. The unpack
|
||||
# script is now the thing that does, and the persistent CI SDK depends on it
|
||||
# leaving an existing tree alone. These cases pin both halves: a fresh SDK
|
||||
# gets a complete tree, an existing tree is never touched or re-fetched, and
|
||||
# every refusal (unpatched selectors, a bad tarball, a half-present tree, a
|
||||
# failed fetch) leaves no tree and no scratch directory behind.
|
||||
#
|
||||
# Runs the real script, copied beside a stub fetch-buildroot-tarball.sh that
|
||||
# copies a local fixture tarball instead of downloading. No network, no SDK.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
SCRIPT="$HERE/../../build/unpack-buildroot.sh"
|
||||
[ -f "$SCRIPT" ] || { echo "FAIL: script not found at $SCRIPT"; exit 1; }
|
||||
|
||||
FAIL=0
|
||||
ok() { printf '[PASS] %s\n' "$1"; }
|
||||
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||
|
||||
TMP="$(mktemp -d)" || { echo "FAIL: mktemp -d failed"; exit 1; }
|
||||
[ -d "$TMP" ] || { echo "FAIL: mktemp -d failed"; exit 1; }
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
VER=2025.02.8
|
||||
|
||||
# Fixture tarballs: a minimal Buildroot-shaped tree, and one without Makefile.
|
||||
mk_tarball() { # mk_tarball <out.tar.xz> <with-makefile:0|1>
|
||||
local out="$1" mf="$2" src
|
||||
src="$(mktemp -d "$TMP/src.XXXXXX")"
|
||||
mkdir -p "$src/buildroot-$VER/configs" "$src/buildroot-$VER/package/busybox"
|
||||
printf 'CONFIG\n' > "$src/buildroot-$VER/package/busybox/busybox.config"
|
||||
[ "$mf" = 1 ] && printf 'all:\n' > "$src/buildroot-$VER/Makefile"
|
||||
tar -cJf "$out" -C "$src" "buildroot-$VER"
|
||||
}
|
||||
mk_tarball "$TMP/good.tar.xz" 1
|
||||
mk_tarball "$TMP/nomakefile.tar.xz" 0
|
||||
|
||||
# setup <case> <tarball-or-FAIL> -> fixture dir holding build/ and sdk/
|
||||
setup() {
|
||||
local dir="$TMP/$1" src="$2"
|
||||
mkdir -p "$dir/build" "$dir/sdk/project" "$dir/sdk/sysdrv/source/buildroot"
|
||||
cp "$SCRIPT" "$dir/build/unpack-buildroot.sh"
|
||||
{
|
||||
echo '#!/usr/bin/env bash'
|
||||
echo "BRVER=$VER"
|
||||
echo "echo fetch-called >> \"$dir/fetch-calls\""
|
||||
if [ "$src" = FAIL ]; then echo 'exit 1'; else echo "cp \"$src\" \"\$1\""; fi
|
||||
} > "$dir/build/fetch-buildroot-tarball.sh"
|
||||
# shellcheck disable=SC2016 # build.sh carries the literal text
|
||||
printf 'BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-%s\n' "$VER" \
|
||||
> "$dir/sdk/project/build.sh"
|
||||
printf 'BUILDROOT_VER ?= buildroot-%s\n' "$VER" > "$dir/sdk/sysdrv/Makefile"
|
||||
printf '%s' "$dir"
|
||||
}
|
||||
|
||||
run() { # run <dir> -> $OUT, $RC
|
||||
OUT="$(bash "$1/build/unpack-buildroot.sh" "$1/sdk" 2>&1)"; RC=$?
|
||||
}
|
||||
tree() { printf '%s' "$1/sdk/sysdrv/source/buildroot/buildroot-$VER"; }
|
||||
fetches() { [ -f "$1/fetch-calls" ] && wc -l < "$1/fetch-calls" || echo 0; }
|
||||
no_scratch() { ! compgen -G "$1/sdk/sysdrv/source/buildroot/.unpack-buildroot.*" >/dev/null; }
|
||||
|
||||
# A. Fresh SDK: fetched once, unpacked to the selected path, no scratch left.
|
||||
d="$(setup fresh "$TMP/good.tar.xz")"; run "$d"
|
||||
if [ "$RC" -eq 0 ] && [ -f "$(tree "$d")/Makefile" ] && [ -f "$(tree "$d")/package/busybox/busybox.config" ] \
|
||||
&& [ "$(fetches "$d")" -eq 1 ] && no_scratch "$d"; then
|
||||
ok "fresh SDK: tree unpacked, one fetch, no scratch left"
|
||||
else
|
||||
bad "fresh SDK: tree unpacked, one fetch, no scratch left (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# B. Rerun on that SDK: already present, no second fetch, content untouched.
|
||||
printf 'LOCAL\n' > "$(tree "$d")/package/busybox/busybox.config"
|
||||
run "$d"
|
||||
if [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'tree already present' \
|
||||
&& [ "$(fetches "$d")" -eq 1 ] && grep -qx LOCAL "$(tree "$d")/package/busybox/busybox.config"; then
|
||||
ok "existing tree: left alone, not re-fetched"
|
||||
else
|
||||
bad "existing tree: left alone, not re-fetched (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# C. project/build.sh still selects the vendor tree: refuse, fetch nothing.
|
||||
d="$(setup unpatched-build "$TMP/good.tar.xz")"
|
||||
# shellcheck disable=SC2016 # build.sh carries the literal text
|
||||
printf 'BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2023.02.6\n' > "$d/sdk/project/build.sh"
|
||||
run "$d"
|
||||
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'project/build.sh selects' \
|
||||
&& [ "$(fetches "$d")" -eq 0 ] && [ ! -e "$(tree "$d")" ]; then
|
||||
ok "unpatched project/build.sh: refused before fetching"
|
||||
else
|
||||
bad "unpatched project/build.sh: refused before fetching (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# D. sysdrv/Makefile still selects the vendor tree: refuse, fetch nothing.
|
||||
d="$(setup unpatched-make "$TMP/good.tar.xz")"
|
||||
printf 'BUILDROOT_VER ?= buildroot-2023.02.6\n' > "$d/sdk/sysdrv/Makefile"
|
||||
run "$d"
|
||||
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'sysdrv/Makefile selects' \
|
||||
&& [ "$(fetches "$d")" -eq 0 ] && [ ! -e "$(tree "$d")" ]; then
|
||||
ok "unpatched sysdrv/Makefile: refused before fetching"
|
||||
else
|
||||
bad "unpatched sysdrv/Makefile: refused before fetching (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# E. Tarball without a Buildroot Makefile: refuse, no tree, no scratch.
|
||||
d="$(setup bad-tarball "$TMP/nomakefile.tar.xz")"; run "$d"
|
||||
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'did not contain' \
|
||||
&& [ ! -e "$(tree "$d")" ] && no_scratch "$d"; then
|
||||
ok "tarball without Makefile: refused, nothing left behind"
|
||||
else
|
||||
bad "tarball without Makefile: refused, nothing left behind (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# F. A half-present tree (an interrupted hand unpack): refuse, keep it as is.
|
||||
d="$(setup half-tree "$TMP/good.tar.xz")"
|
||||
mkdir -p "$(tree "$d")/output"; printf 'keep\n' > "$(tree "$d")/output/marker"
|
||||
run "$d"
|
||||
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'not a complete Buildroot tree' \
|
||||
&& [ -f "$(tree "$d")/output/marker" ] && [ "$(fetches "$d")" -eq 0 ]; then
|
||||
ok "half-present tree: refused and left untouched"
|
||||
else
|
||||
bad "half-present tree: refused and left untouched (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# G. Fetch fails (network down, sha256 mismatch): nonzero, no tree.
|
||||
d="$(setup fetch-fails FAIL)"; run "$d"
|
||||
if [ "$RC" -ne 0 ] && [ ! -e "$(tree "$d")" ] && no_scratch "$d"; then
|
||||
ok "failed fetch: nonzero, no tree"
|
||||
else
|
||||
bad "failed fetch: nonzero, no tree (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "ALL UNPACK-BUILDROOT TESTS PASSED"; else echo "UNPACK-BUILDROOT TESTS FAILED"; fi
|
||||
exit "$FAIL"
|
||||
Reference in New Issue
Block a user