Compare commits
89
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b771db225e | ||
|
|
70ce85ada3 | ||
|
|
5dd20f09b7 | ||
|
|
3baa28a20e | ||
|
|
d1011ce9d8 | ||
|
|
fabd79f60e | ||
|
|
0d00b93a63 | ||
|
|
b8d9d541fe | ||
|
|
1e182a44e4 | ||
|
|
bbc91618f8 | ||
|
|
579ac260ca | ||
|
|
0232823855 | ||
|
|
61ecfac844 | ||
|
|
ff3d1de088 | ||
|
|
8fc32976a5 | ||
|
|
0c98a6018f | ||
|
|
820af4baaa | ||
|
|
37037926df | ||
|
|
4d30c3083b | ||
|
|
b4596ed737 | ||
|
|
4ff7c19537 | ||
|
|
a9f2b9b26a | ||
|
|
6e51f1a0e5 | ||
|
|
333c237949 | ||
|
|
f46a3519aa | ||
|
|
f04a31dc06 | ||
|
|
a4bbfbd83b | ||
|
|
7d5686e287 | ||
|
|
de1b973aa4 | ||
|
|
bd4eb5c201 | ||
|
|
eebfd23a96 | ||
|
|
06b86e68b4 | ||
|
|
9998182ef5 | ||
|
|
dd15eac1a8 | ||
|
|
eeb779b41b | ||
|
|
5494b87dc3 | ||
|
|
13cd0c63be | ||
|
|
d279bc4c9f | ||
|
|
44b96074ed | ||
|
|
b7be6f7fbe | ||
|
|
7d18896a0d | ||
|
|
b94fd156b4 | ||
|
|
f435a7d665 | ||
|
|
be4ad86230 | ||
|
|
aadf0e7f07 | ||
|
|
6f931bf3ad | ||
|
|
5507842878 | ||
|
|
35dc64714e | ||
|
|
cf72a6dcbc | ||
|
|
0589829619 | ||
|
|
8615f7c13a | ||
|
|
469f31c278 | ||
|
|
aa6956f595 | ||
|
|
445b2082f5 | ||
|
|
0360b8dc46 | ||
|
|
d22c900fb6 | ||
|
|
b7125fc4a7 | ||
|
|
35f3ca10eb | ||
|
|
8212bf5feb | ||
|
|
8c4870c6fb | ||
|
|
92d601f585 | ||
|
|
65a6800228 | ||
|
|
d01add5646 | ||
|
|
a828667b0f | ||
|
|
45569611da | ||
|
|
b18ed3888b | ||
|
|
d746ceba6d | ||
|
|
5f3db8453b | ||
|
|
85dc1ee04d | ||
|
|
6576a4a506 | ||
|
|
9b0659d30c | ||
|
|
317ae087fd | ||
|
|
07db1b9ec0 | ||
|
|
67da1141a0 | ||
|
|
5f36beb44a | ||
|
|
eb0691d84f | ||
|
|
4636f0fe4c | ||
|
|
fe29ece741 | ||
|
|
b30621e372 | ||
|
|
0cf46ba1a4 | ||
|
|
5fd6d2da5b | ||
|
|
ed87da1159 | ||
|
|
44b551f1d1 | ||
|
|
d266e0774f | ||
|
|
8066ef7d79 | ||
|
|
f6add60a9c | ||
|
|
4a5481b6a5 | ||
|
|
9ff60d60db | ||
|
|
e12bb2c554 |
+174
-2
@@ -111,7 +111,10 @@ 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/fetch-kernel-tarball/*.sh tests/unpack-buildroot/*.sh
|
||||
- name: qemu init shellcheck regression test
|
||||
run: bash tests/qemu-init/run-init-shellcheck-tests.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
|
||||
@@ -148,11 +151,72 @@ jobs:
|
||||
# on the debug channel. All offline (a stub qemu-system-arm on
|
||||
# PATH), so it runs on every push/PR, not only a real boot.
|
||||
run: bash qemu/tests/run-sh-args-test.sh
|
||||
- name: rig init honours reboot/poweroff/halt (#5)
|
||||
run: bash qemu/tests/init-power-signals-test.sh
|
||||
- name: rig init daemon order matches the panel (flare-edge#348)
|
||||
run: bash qemu/tests/init-daemon-order-test.sh
|
||||
- name: rig bus starts when the payload carries a broker (flare-edge#1754)
|
||||
# A stub broker stands in for mosquitto (the runner has none), and
|
||||
# once more under busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/init-rig-bus-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-rig-bus-test.sh
|
||||
fi
|
||||
- name: rig control bridge waits out a slow UI and reaches the test hook (flare-edge#1448, #2054)
|
||||
# Once more under busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/ctl-bridge-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/ctl-bridge-test.sh
|
||||
fi
|
||||
- name: rig agent runs framed scripts under a deadline (flare-edge M9 soak-lite)
|
||||
# warden_agent against request lines on stdin; once more under
|
||||
# busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/agent-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/agent-test.sh
|
||||
fi
|
||||
- name: rig init boots through the shipped init chain (flare-edge#2210)
|
||||
# warden_init_chain against stub scripts and the warden.initchain
|
||||
# wiring in sbin/init; once more under busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/init-chain-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-chain-test.sh
|
||||
fi
|
||||
- name: rig debug shell works without cttyhack (flare-edge#2210)
|
||||
# The panel's BusyBox has no cttyhack; warden.shell then opens the
|
||||
# console tty itself. Once more under busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/console-shell-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/console-shell-test.sh
|
||||
fi
|
||||
- name: panel BusyBox config and build helpers (flare-edge#2210)
|
||||
# panel.config carries the image's applet patch, the rig fragment only
|
||||
# changes linking, Kconfig rewrites and applet drift are caught: offline.
|
||||
run: bash qemu/tests/busybox-panel-test.sh
|
||||
- name: ui-drive.sh / ui-shot.sh UI start wait regression test (flare-edge#2295)
|
||||
# The console line that means "UI started" differs between a direct
|
||||
# start and a shipped init chain boot; every marker is checked
|
||||
# against sbin/init, and a chain failure fails at once.
|
||||
run: bash qemu/tests/ui-start-test.sh
|
||||
- name: mkimage.sh ROOTFS_OVERLAY regression test (flare-edge#2210)
|
||||
# The panel's scripts land in both slots with their modes; an overlay
|
||||
# reaching outside etc/ and usr/, or holding a symlink, writes no image.
|
||||
run: bash qemu/tests/rootfs-overlay.sh
|
||||
- name: mkimage.sh SEED_DIR regression test
|
||||
# Only ui-drive.sh --seed (a real VM boot) exercises this hook
|
||||
# otherwise; this builds the same unprivileged mkfs.ext4 image and
|
||||
# reads it back with debugfs, no VM needed.
|
||||
run: bash qemu/tests/seed-dir.sh
|
||||
- name: mkimage.sh PAYLOAD_DIR regression test (flare-edge#2054)
|
||||
# A run's own payload set (the hook set) lands in both slots, the
|
||||
# default still reads qemu/payload, and ui-drive.sh checks the same
|
||||
# directory; images read back with debugfs, no VM.
|
||||
run: bash qemu/tests/payload-dir.sh
|
||||
- name: qemu_stage_rootfs permission regression test
|
||||
# Git tracks only the executable bit, so a fresh checkout can land
|
||||
# the source etc/shadow world-readable under a permissive umask;
|
||||
@@ -166,6 +230,19 @@ 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: fetch-kernel-tarball regression tests
|
||||
# Bounded curl and no partial tarball after a failed fetch (#1588),
|
||||
# against a fake curl on PATH: no network.
|
||||
run: bash tests/fetch-kernel-tarball/run-fetch-kernel-tarball-tests.sh
|
||||
- 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
|
||||
- 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
|
||||
@@ -190,6 +267,83 @@ jobs:
|
||||
run: bash qemu/mkinitramfs.sh
|
||||
- name: build A/B disk image
|
||||
run: bash qemu/mkimage.sh
|
||||
- name: cache panel BusyBox source
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: qemu/out/busybox-1.37.0.tar.bz2
|
||||
key: busybox-src-1.37.0
|
||||
- name: build the panel BusyBox and check it against the bench capture (flare-edge#2210)
|
||||
# The image's BusyBox version, applet config and Buildroot patches,
|
||||
# linked static (qemu/build-busybox.sh). Its applet list and every
|
||||
# applet's --help must equal the panel's own binary's (captured on
|
||||
# bench a), run here through qemu-user. Then an initramfs with it.
|
||||
run: |
|
||||
sudo apt-get install -y -qq gcc-arm-linux-gnueabihf qemu-user
|
||||
bash qemu/build-busybox.sh
|
||||
QEMU_USER="qemu-arm" bash qemu/tests/busybox-panel-help.sh
|
||||
RIG_BUSYBOX=panel bash qemu/mkinitramfs.sh
|
||||
# A job without the cross compiler takes the binary as BUSYBOX,
|
||||
# checked by its .inputs (flare-edge flow jobs).
|
||||
RIG_BUSYBOX=panel BUSYBOX=qemu/out/busybox-armv7l-panel bash qemu/mkinitramfs.sh
|
||||
|
||||
kernel-symbols:
|
||||
# The symbol gate (rebuild M0, kernel_symbols_exist): expand the real
|
||||
# configuration (pristine tarball + patch series + warden_defconfig) and
|
||||
# assert build/required-symbols.txt and probe-symbols.txt against the final
|
||||
# .config, without compiling. olddefconfig drops a symbol that does not exist
|
||||
# or whose dependencies are unmet without a word; this is what turns that
|
||||
# into a red check on every push, in seconds rather than the ~9 minutes of a
|
||||
# kernel build. The generic arm cross toolchain is enough: only the compiler
|
||||
# version text of the configuration depends on it.
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: offline symbol-list tests
|
||||
run: bash tests/required-symbols/run-required-symbols-tests.sh
|
||||
- name: install cross toolchain + kernel config deps
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq gcc-arm-linux-gnueabihf bc bison flex libssl-dev
|
||||
- name: provision `python` (SDK quirk, the build calls bare python)
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/bin"
|
||||
ln -sf "$(command -v python3)" "$RUNNER_TEMP/bin/python"
|
||||
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
|
||||
- name: cache pristine kernel tarball
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/linux-6.18.46.tar.xz
|
||||
key: linux-6.18.46-tarball
|
||||
- name: expand the configuration and assert the symbols
|
||||
env:
|
||||
# WORK must be OUTSIDE the repo checkout (git apply, issue #1).
|
||||
WORK: ${{ runner.temp }}/kcfg-work
|
||||
CONFIG_OUT: ${{ runner.temp }}/final.config
|
||||
CROSS_COMPILE: arm-linux-gnueabihf-
|
||||
WARDEN_CONFIG_ONLY: "1"
|
||||
run: |
|
||||
export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz"
|
||||
bash build/build-kernel.sh
|
||||
test -s "$CONFIG_OUT" && test -s "$CONFIG_OUT.sha256"
|
||||
# the sidecar is the sha256 of the file it sits beside
|
||||
test "$(sha256sum "$CONFIG_OUT" | cut -d' ' -f1)" = "$(cat "$CONFIG_OUT.sha256")"
|
||||
- name: the expansion is deterministic (same inputs, same digest)
|
||||
env:
|
||||
WORK: ${{ runner.temp }}/kcfg-work-2
|
||||
CONFIG_OUT: ${{ runner.temp }}/final-2.config
|
||||
CROSS_COMPILE: arm-linux-gnueabihf-
|
||||
WARDEN_CONFIG_ONLY: "1"
|
||||
run: |
|
||||
export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz"
|
||||
bash build/build-kernel.sh
|
||||
cmp "${{ runner.temp }}/final.config" "$CONFIG_OUT"
|
||||
- name: the digest does not depend on the host python (issue #19)
|
||||
env:
|
||||
CROSS_COMPILE: arm-linux-gnueabihf-
|
||||
run: |
|
||||
export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz"
|
||||
bash tests/required-symbols/run-config-determinism-tests.sh
|
||||
|
||||
patches-apply:
|
||||
# The RV1106 series must apply cleanly onto pristine linux-6.18.46.
|
||||
@@ -212,6 +366,13 @@ jobs:
|
||||
&& echo "applied $p" || { echo "FAILED to apply $p"; exit 1; }
|
||||
done
|
||||
echo "full series applied cleanly onto pristine 6.18.46"
|
||||
- name: arm32 vDSO stays off the virtual counter (bfe-core1106-sdk#35)
|
||||
# The kernel times on the physical counter and the firmware leaves
|
||||
# CNTVOFF non-zero, so the vDSO clock must stay off: the DT property and
|
||||
# the arm_arch_timer.c fallback both have to survive in the patched tree.
|
||||
run: |
|
||||
bash tests/arch-timer/run-check-vdso-counter-tests.sh
|
||||
python3 tests/arch-timer/check-vdso-counter.py /tmp/linux-6.18.46
|
||||
|
||||
# Automatic artifact GC (mirrors flare-edge). An exceeded account-wide Actions
|
||||
# storage quota blocks ALL new runs (startup_failure), not just uploads, so
|
||||
@@ -310,6 +471,11 @@ jobs:
|
||||
bash qemu/mkinitramfs.sh
|
||||
bash qemu/tests/boot-smoke.sh \
|
||||
"$RUNNER_TEMP/kbuild-out/linux-6.18.46/arch/arm/boot/zImage"
|
||||
# Once more with the panel's BusyBox (RIG_BUSYBOX=panel, flare-edge#2210).
|
||||
OUT="$RUNNER_TEMP/panel-rig" RIG_BUSYBOX=panel bash qemu/mkinitramfs.sh
|
||||
bash qemu/tests/boot-smoke.sh \
|
||||
"$RUNNER_TEMP/kbuild-out/linux-6.18.46/arch/arm/boot/zImage" \
|
||||
"$RUNNER_TEMP/panel-rig/initramfs.cpio.gz"
|
||||
# Best-effort: the build IS the gate. Uploading the zImage/dtb to GitHub
|
||||
# artifact storage can fail on an account-wide storage-quota hit (recalculated
|
||||
# every 6-12h) that has nothing to do with this build. Don't red-X a good
|
||||
@@ -340,10 +506,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
|
||||
|
||||
@@ -47,11 +47,19 @@ Add `WARDEN_KCONFIG_FRAGMENT=qemu/configs/virt.fragment` to step 1 for the
|
||||
kernel variant with the simulator's extra devices; `qemu/README.md` has the
|
||||
scenario tests (portal, OTA apply, display + touch, watchdog).
|
||||
|
||||
Every kernel symbol the platform needs is listed in `build/required-symbols.txt`
|
||||
(and `build/probe-symbols.txt` for a symbol under test). `build-kernel.sh` asserts
|
||||
both against the final `.config`, because `olddefconfig` drops an unknown or
|
||||
unsatisfied symbol without a word. `WARDEN_CONFIG_ONLY=1 CONFIG_OUT=<file>` stops
|
||||
after that assertion, so the gate takes seconds; `<file>.sha256` holds the digest
|
||||
of the final `.config` that firmware images record as `KCONFIG_SHA256`.
|
||||
|
||||
## Layout
|
||||
|
||||
| Directory | Contents |
|
||||
|---|---|
|
||||
| `patches/` | the RV1106 forward-port onto pristine linux-6.18.46, subsystem-split |
|
||||
| `luckfox-sdk-patches/` | the delta against the **legacy** vendor Luckfox SDK (U-Boot 2017.09, optionally the vendor 5.10.160 kernel, wifi driver, board build, buildroot) -- moved from `blueflare/flare-edge`'s `sdk-patches/` on 2026-09-15; unrelated to `patches/` above |
|
||||
| `build/` | hermetic kernel build: pinned fetch -> apply patches -> `zImage` + dtb; `vendor.manifest` pins the third-party trees this platform builds against (LVGL, the vendor RV1106 SDK) to exact commits, and `fetch-vendor.sh` obtains and verifies them |
|
||||
| `qemu/` | device simulator: QEMU `-M virt` boots the real kernel and real userspace |
|
||||
| `sim/` | register-level hardware models (Rust): membus, HPMCU, CRU, Modbus, RGA, NPU |
|
||||
|
||||
@@ -19,6 +19,15 @@
|
||||
# (qemu/configs/virt.fragment builds the QEMU -M virt variant);
|
||||
# every fragment option is verified to have taken effect
|
||||
# WARDEN_CCACHE=1 compile through ccache (CI caches ~/.ccache)
|
||||
# WARDEN_CONFIG_ONLY=1
|
||||
# stop after the configuration and the symbol assertions
|
||||
# (no compile): a seconds-long symbol gate for CI and the
|
||||
# pre-build identity of /etc/warden-release. Needs CONFIG_OUT
|
||||
# or an explicit WORK, because a scratch WORK is removed.
|
||||
# CONFIG_OUT where the final .config is copied (default
|
||||
# $WORK/final.config); ${CONFIG_OUT}.sha256 gets its sha256
|
||||
# (hex only). Written by both modes: the config-only value
|
||||
# must equal the full build's, and the build checks it.
|
||||
# WARDEN_MODULES_COLLECT
|
||||
# space-separated in-tree dirs whose .ko files are wanted
|
||||
# (e.g. "drivers/net/wireless/aic8800"). Runs a full
|
||||
@@ -32,6 +41,10 @@ set -euo pipefail
|
||||
|
||||
KVER=6.18.46
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # build/
|
||||
# shellcheck source=build/lib-required-symbols.sh
|
||||
. "$HERE/lib-required-symbols.sh"
|
||||
REQ_SYMBOLS="$HERE/required-symbols.txt"
|
||||
PROBE_SYMBOLS="$HERE/probe-symbols.txt"
|
||||
REPO="$(cd "$HERE/.." && pwd)"
|
||||
PATCHES="$REPO/patches"
|
||||
JOBS="${JOBS:-$(nproc)}"
|
||||
@@ -48,6 +61,16 @@ else
|
||||
WORK_OWNED=1
|
||||
fi
|
||||
trap '[ "${WORK_OWNED:-0}" = 1 ] && rm -rf "$WORK"' EXIT
|
||||
CONFIG_ONLY="${WARDEN_CONFIG_ONLY:-0}"
|
||||
case "$CONFIG_ONLY" in
|
||||
0|1) ;;
|
||||
*) echo "FATAL: WARDEN_CONFIG_ONLY must be 0 or 1, got '$CONFIG_ONLY'" >&2; exit 1 ;;
|
||||
esac
|
||||
if [ "$CONFIG_ONLY" = 1 ] && [ "$WORK_OWNED" = 1 ] && [ -z "${CONFIG_OUT:-}" ]; then
|
||||
echo "FATAL: WARDEN_CONFIG_ONLY=1 needs CONFIG_OUT (or an explicit WORK): a scratch WORK is removed on exit" >&2
|
||||
exit 1
|
||||
fi
|
||||
CONFIG_OUT="${CONFIG_OUT:-$WORK/final.config}"
|
||||
|
||||
log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
|
||||
@@ -121,6 +144,18 @@ command -v "${CROSS_COMPILE}gcc" >/dev/null \
|
||||
|| { echo "cross toolchain ${CROSS_COMPILE}gcc not on PATH (set SDK_TC, or CROSS_COMPILE to one that is)" >&2; exit 1; }
|
||||
make -C "$SRC" ARCH=arm CROSS_COMPILE="$CROSS_COMPILE" olddefconfig >/dev/null
|
||||
|
||||
# Took-effect assertion for every symbol the platform needs. olddefconfig drops
|
||||
# a defconfig line whose dependencies are unmet, or whose symbol does not exist,
|
||||
# without a word: flare-edge#533 shipped a firewall that quietly stopped
|
||||
# covering IPv6 that way. build/required-symbols.txt (and build/probe-symbols.txt
|
||||
# for a probe kernel) is the one list; every symbol in it is built in (=y, the
|
||||
# panel has no /lib/modules) or explicitly unset.
|
||||
# The probe list may be empty (every probe has passed); the required list may not.
|
||||
PROBE_LISTS=()
|
||||
[ -n "$(req_assertions "$PROBE_SYMBOLS")" ] && PROBE_LISTS=("$PROBE_SYMBOLS")
|
||||
req_assert_config "$SRC/.config" "$REQ_SYMBOLS" ${PROBE_LISTS[@]+"${PROBE_LISTS[@]}"} || exit 1
|
||||
log "required symbols verified in final .config ($(req_assertions "$REQ_SYMBOLS" | wc -l) required, $(req_assertions "$PROBE_SYMBOLS" | wc -l) probe)"
|
||||
|
||||
# Fragment took-effect assertion: merge_config -m only pastes text, and
|
||||
# olddefconfig silently resolves any symbol whose dependencies are unmet:
|
||||
# a fragment option could be dropped without a word. Verify every explicit
|
||||
@@ -151,6 +186,21 @@ if [ -n "${WARDEN_KCONFIG_FRAGMENT:-}" ]; then
|
||||
log "fragment options verified in final .config"
|
||||
fi
|
||||
|
||||
# The final .config, and its identity. KCONFIG_SHA256 in /etc/warden-release is
|
||||
# this digest (the whole file, compiler version text included): CONFIG_IKCONFIG_PROC
|
||||
# embeds a byte copy, so /proc/config.gz hashes to the same value.
|
||||
emit_config_identity() {
|
||||
mkdir -p "$(dirname "$CONFIG_OUT")"
|
||||
cp "$SRC/.config" "$CONFIG_OUT"
|
||||
sha256sum "$CONFIG_OUT" | awk '{print $1}' > "$CONFIG_OUT.sha256"
|
||||
echo "final.config sha256: $(cat "$CONFIG_OUT.sha256")"
|
||||
}
|
||||
if [ "$CONFIG_ONLY" = 1 ]; then
|
||||
emit_config_identity
|
||||
log "config-only: symbols verified, stopping before the compile"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Optional ccache (CI: cache ~/.ccache across dispatches; harmless if unset).
|
||||
KCC="${CROSS_COMPILE}gcc"
|
||||
if [ "${WARDEN_CCACHE:-0}" = 1 ]; then
|
||||
@@ -185,6 +235,9 @@ if [ -n "${WARDEN_MODULES_COLLECT:-}" ]; then
|
||||
ls -la "$MODOUT"
|
||||
fi
|
||||
|
||||
# Identity of the .config the compile actually used, not the one before it.
|
||||
emit_config_identity
|
||||
|
||||
Z="$SRC/arch/arm/boot/zImage"
|
||||
D="$SRC/arch/arm/boot/dts/rockchip/rv1106-warden.dtb"
|
||||
log "build OK"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,16 @@ TB="${1:?usage: fetch-kernel-tarball.sh <destination-path>}"
|
||||
}
|
||||
if [ ! -f "$TB" ]; then
|
||||
echo "== downloading $URL"
|
||||
curl --retry 3 --retry-delay 5 --retry-connrefused -fSL "$URL" -o "$TB"
|
||||
# Bounded (#1588): a connection that opens and then stalls gives up after
|
||||
# 30 s below 10 KiB/s and is retried, instead of holding the job until its
|
||||
# own timeout. The download lands beside $TB and is renamed only when curl
|
||||
# succeeds, so a failed fetch never leaves a partial tarball that the next
|
||||
# run would take as present and then reject on its sha256.
|
||||
tmp="$TB.download.$$"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
curl --retry 2 --retry-delay 5 --retry-connrefused --connect-timeout 20 \
|
||||
--speed-limit 10240 --speed-time 30 --max-time 600 -fSL "$URL" -o "$tmp"
|
||||
mv -f "$tmp" "$TB"
|
||||
fi
|
||||
want="$(cat "$SHA_FILE")"
|
||||
got="$(sha256sum "$TB" | awk '{print $1}')"
|
||||
|
||||
@@ -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")"
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# shellcheck shell=bash
|
||||
# Shared by build-kernel.sh and the symbol tests (tests/required-symbols/).
|
||||
#
|
||||
# build/required-symbols.txt is the source of record for every kernel symbol
|
||||
# the platform needs (rebuild M0, names.md 21.1). Format, one item per line:
|
||||
#
|
||||
# CONFIG_X=y assert the symbol is =y in the final .config
|
||||
# # CONFIG_X is not set assert the symbol is NOT set (an explicit unset)
|
||||
# ## tier R section header (R required, C recommended,
|
||||
# A assertion only / derived, never in a defconfig)
|
||||
# # any other text comment
|
||||
# (blank lines ignored)
|
||||
#
|
||||
# build/probe-symbols.txt has the same format for tier P: symbols built into
|
||||
# the test kernel to run a probe. They are asserted like the others, and join
|
||||
# required-symbols.txt only when the probe passes.
|
||||
|
||||
# req_assertions FILE: print the assertion lines of FILE.
|
||||
req_assertions() {
|
||||
grep -E '^(CONFIG_[A-Za-z0-9_]+=[ymn]|# CONFIG_[A-Za-z0-9_]+ is not set)$' "$1" || true
|
||||
}
|
||||
|
||||
# req_assert_config CONFIG LIST...: check each assertion of each LIST against
|
||||
# CONFIG (a final .config). Prints one FATAL line per failure and returns 1 if
|
||||
# any failed. A missing or empty LIST is itself a failure (fail closed).
|
||||
req_assert_config() {
|
||||
local cfg="$1" list line opt n bad=0
|
||||
shift
|
||||
[ -s "$cfg" ] || { echo "FATAL: config '$cfg' is missing or empty" >&2; return 1; }
|
||||
for list in "$@"; do
|
||||
[ -f "$list" ] || { echo "FATAL: symbol list '$list' is missing" >&2; return 1; }
|
||||
n=0
|
||||
while IFS= read -r line; do
|
||||
n=$((n + 1))
|
||||
case "$line" in
|
||||
CONFIG_*=*)
|
||||
grep -qxF "$line" "$cfg" || {
|
||||
echo "FATAL: required option $line is not in the final .config (unmet Kconfig dependency, or the symbol does not exist?)" >&2
|
||||
bad=1
|
||||
} ;;
|
||||
"# CONFIG_"*" is not set")
|
||||
# An unset holds if the symbol is absent or shown as "is not set";
|
||||
# only a live =value fails (a dependency may hide the symbol).
|
||||
opt="${line#\# }"; opt="${opt% is not set}"
|
||||
grep -qE "^$opt=" "$cfg" && {
|
||||
echo "FATAL: option $opt must not be set but is in the final .config" >&2
|
||||
bad=1
|
||||
} ;;
|
||||
esac
|
||||
done < <(req_assertions "$list")
|
||||
[ "$n" -gt 0 ] || { echo "FATAL: symbol list '$list' holds no assertions" >&2; return 1; }
|
||||
done
|
||||
return "$bad"
|
||||
}
|
||||
+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)"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
## Tier P: symbols built into a test kernel to run a probe (rebuild M0).
|
||||
## Asserted like required-symbols.txt. A symbol moves to required-symbols.txt when its probe
|
||||
## passes on the panel, and leaves this file and the defconfig when it fails.
|
||||
##
|
||||
## Empty on purpose: probe V3 (hardware RNG, N-36, d06 O14, d09 T14) passed on 2026-10-09, so
|
||||
## CONFIG_HW_RANDOM and CONFIG_HW_RANDOM_ROCKCHIP moved to required-symbols.txt. An empty list
|
||||
## is valid for this file (build-kernel.sh skips it); required-symbols.txt may never be empty.
|
||||
@@ -0,0 +1,83 @@
|
||||
## Kernel symbols the platform needs. Source of record (rebuild M0, names.md
|
||||
## 21.1): build-kernel.sh asserts every line against the final .config, the
|
||||
## tests/required-symbols guards read this file, and the FE kernel_symbols_exist
|
||||
## gate checks every CONFIG_ name in the specs against it and the Kconfig tree.
|
||||
## Format: see build/lib-required-symbols.sh. Tier P lives in probe-symbols.txt.
|
||||
##
|
||||
## tier R already shipped (flare-edge#533)
|
||||
CONFIG_NF_DEFRAG_IPV6=y
|
||||
CONFIG_IP6_NF_IPTABLES=y
|
||||
CONFIG_IP6_NF_IPTABLES_LEGACY=y
|
||||
CONFIG_IP6_NF_FILTER=y
|
||||
##
|
||||
## tier R cgroup v2 controllers (W-D7)
|
||||
CONFIG_MEMCG=y
|
||||
CONFIG_CGROUP_PIDS=y
|
||||
CONFIG_CGROUP_SCHED=y
|
||||
CONFIG_FAIR_GROUP_SCHED=y
|
||||
CONFIG_CFS_BANDWIDTH=y
|
||||
##
|
||||
## tier R byte metering (D50 D51 D52)
|
||||
CONFIG_NETFILTER_XT_MATCH_CGROUP=y
|
||||
CONFIG_NETFILTER_XT_CONNMARK=y
|
||||
CONFIG_NETFILTER_XT_MARK=y
|
||||
CONFIG_IP6_NF_MANGLE=y
|
||||
##
|
||||
## tier R /proc/config.gz (D51)
|
||||
CONFIG_IKCONFIG=y
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
##
|
||||
## tier R uid fallback and NOTRACK (SCH-04, flare-edge#537)
|
||||
CONFIG_NETFILTER_XT_MATCH_OWNER=y
|
||||
CONFIG_IP_NF_RAW=y
|
||||
CONFIG_IP6_NF_RAW=y
|
||||
CONFIG_NETFILTER_XT_TARGET_CT=y
|
||||
##
|
||||
## tier R namespaces and PSI (SCH-04, NN-11)
|
||||
CONFIG_NAMESPACES=y
|
||||
CONFIG_UTS_NS=y
|
||||
CONFIG_IPC_NS=y
|
||||
CONFIG_PID_NS=y
|
||||
CONFIG_NET_NS=y
|
||||
CONFIG_USER_NS=y
|
||||
CONFIG_PSI=y
|
||||
##
|
||||
## tier R nftables (N-40)
|
||||
CONFIG_NF_TABLES=y
|
||||
CONFIG_NF_TABLES_IPV4=y
|
||||
CONFIG_NF_TABLES_IPV6=y
|
||||
CONFIG_NFT_CT=y
|
||||
CONFIG_NFT_MASQ=y
|
||||
CONFIG_NFT_NAT=y
|
||||
CONFIG_NFT_LIMIT=y
|
||||
CONFIG_NFT_SOCKET=y
|
||||
CONFIG_NFT_REJECT=y
|
||||
##
|
||||
## tier R hardware RNG (N-36, d06 O14). Probe V3 passed on the bench panel on 2026-10-09
|
||||
## (/dev/hwrng from rockchip-rng, 2.6 MB read in 2.4 s, 1 FIPS 140-2 failure in 1000 blocks), so
|
||||
## the two symbols moved here from probe-symbols.txt.
|
||||
CONFIG_HW_RANDOM=y
|
||||
CONFIG_HW_RANDOM_ROCKCHIP=y
|
||||
##
|
||||
## tier A power: no suspend (Noah 2026-10-09). The two lines below are derived
|
||||
## off with it; assert them so a Kconfig change cannot bring them back.
|
||||
# CONFIG_SUSPEND is not set
|
||||
# CONFIG_PM_SLEEP is not set
|
||||
##
|
||||
## tier C recommended
|
||||
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
|
||||
CONFIG_NF_CONNTRACK_PROCFS=y
|
||||
##
|
||||
## tier A assertion only (a defconfig line is optional)
|
||||
CONFIG_SECCOMP=y
|
||||
CONFIG_SECCOMP_FILTER=y
|
||||
CONFIG_MULTIUSER=y
|
||||
CONFIG_SYSVIPC=y
|
||||
# CONFIG_RT_GROUP_SCHED is not set
|
||||
# CONFIG_TIME_NS is not set
|
||||
##
|
||||
## tier A derived (selected or defaulted by other symbols; never in a defconfig)
|
||||
CONFIG_NF_CONNTRACK_MARK=y
|
||||
CONFIG_SOCK_CGROUP_DATA=y
|
||||
CONFIG_NFT_REJECT_IPV4=y
|
||||
CONFIG_NFT_REJECT_IPV6=y
|
||||
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,15 +17,17 @@
|
||||
# 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
|
||||
# vendor SDK ships 2023.02.6 -- so that tree is not in the vendor checkout, was
|
||||
# not in this manifest, and had no recorded origin at all. A clean rebuild
|
||||
# silently used the vendor's older buildroot and produced a different userspace
|
||||
# (flare-edge#135). Our delta on top of it is captured in the flare-edge repo at
|
||||
# sdk-patches/buildroot/.
|
||||
# (flare-edge#135). Our delta on top of it is captured in this repo at
|
||||
# luckfox-sdk-patches/buildroot/ (moved 2026-09-15 from the flare-edge repo's
|
||||
# sdk-patches/buildroot/).
|
||||
#
|
||||
# Format: name<TAB>url<TAB>commit<TAB>description
|
||||
# Blank lines and lines starting with '#' are ignored.
|
||||
|
||||
@@ -138,6 +138,8 @@ CONFIG_NET=y
|
||||
CONFIG_PACKET=y
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_INET=y
|
||||
CONFIG_IP_ADVANCED_ROUTER=y
|
||||
CONFIG_IP_MULTIPLE_TABLES=y
|
||||
CONFIG_IP_PNP=y
|
||||
CONFIG_IP_PNP_DHCP=y
|
||||
CONFIG_IP_PNP_BOOTP=y
|
||||
@@ -1370,3 +1372,124 @@ CONFIG_IP_NF_FILTER=y
|
||||
CONFIG_IP_NF_TARGET_REJECT=y
|
||||
CONFIG_IP_NF_NAT=y
|
||||
CONFIG_IP_NF_MANGLE=y
|
||||
#
|
||||
# IPv6 netfilter (flare-edge#533). Without it ip6tables has no filter table
|
||||
# ("Table does not exist"), so the IPv4 default-drop INPUT policy in
|
||||
# S35iptables never applied to IPv6 and every listener bound to :: (dropbear,
|
||||
# telnetd, the web UI) was reachable over IPv6. Four symbols, all built in
|
||||
# because the panel has no /lib/modules:
|
||||
# IP6_NF_IPTABLES + IP6_NF_IPTABLES_LEGACY the ip6tables core, legacy
|
||||
# flavour (the userland is legacy)
|
||||
# IP6_NF_FILTER the filter table; it defaults to
|
||||
# =m under legacy, so =y is explicit
|
||||
# NF_DEFRAG_IPV6 IPv6 reassembly for conntrack, so
|
||||
# the state/conntrack matches work
|
||||
# (NF_CONNTRACK selects it when
|
||||
# IPV6 is on; listed so the set is
|
||||
# visible and guarded)
|
||||
# No new match symbols: the icmp6 match is part of the ip6_tables core
|
||||
# (IP6_NF_IPTABLES); tcp/udp matches are in xt_tcpudp, always built with
|
||||
# XTABLES; state, limit and conntrack are the family-agnostic matches enabled
|
||||
# above.
|
||||
CONFIG_NF_DEFRAG_IPV6=y
|
||||
CONFIG_IP6_NF_IPTABLES=y
|
||||
CONFIG_IP6_NF_IPTABLES_LEGACY=y
|
||||
CONFIG_IP6_NF_FILTER=y
|
||||
#
|
||||
# Cgroup v2 controllers, byte metering, raw table, namespaces and PSI
|
||||
# (rebuild M0; D50 D51 D52 W-D7 SCH-04 N-40 NN-11). The single kernel flash:
|
||||
# every option later work needs, so no second t2 update reaches a panel.
|
||||
# build/required-symbols.txt is the source of record and build-kernel.sh
|
||||
# asserts every line of it against the final .config. All built in: the panel
|
||||
# has no /lib/modules.
|
||||
#
|
||||
# Per-app limits (W-D7): memory.max / memory.events / memory.oom.group,
|
||||
# pids.max, cpu.weight and the cpu.max hard cap.
|
||||
CONFIG_MEMCG=y
|
||||
CONFIG_CGROUP_PIDS=y
|
||||
CONFIG_CGROUP_SCHED=y
|
||||
CONFIG_FAIR_GROUP_SCHED=y
|
||||
CONFIG_CFS_BANDWIDTH=y
|
||||
# RT group scheduling would block the v2 cpu controller; it must stay off.
|
||||
# CONFIG_RT_GROUP_SCHED is not set
|
||||
#
|
||||
# Byte metering by cgroup (D50 D51 D52): the cgroup match, CONNMARK so inbound
|
||||
# replies inherit the service, the mark match, and the ip6tables mangle table
|
||||
# (it defaults to =m under legacy). The meter itself is nftables since N-40.
|
||||
CONFIG_NETFILTER_XT_MATCH_CGROUP=y
|
||||
CONFIG_NETFILTER_XT_CONNMARK=y
|
||||
CONFIG_NETFILTER_XT_MARK=y
|
||||
CONFIG_IP6_NF_MANGLE=y
|
||||
#
|
||||
# /proc/config.gz (D51). IKCONFIG is a tristate: it must be =y, no module tree.
|
||||
# The whole .config digest (KCONFIG_SHA256 in /etc/warden-release) equals the
|
||||
# sha256 of the decompressed embed.
|
||||
CONFIG_IKCONFIG=y
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
#
|
||||
# Uid fallback metering (SCH-04), and the raw table with the CT target for the
|
||||
# NOTRACK of the discovery sweep (flare-edge#537). The legacy tables stay for
|
||||
# that interim and for any legacy tool in the image.
|
||||
CONFIG_NETFILTER_XT_MATCH_OWNER=y
|
||||
CONFIG_IP_NF_RAW=y
|
||||
CONFIG_IP6_NF_RAW=y
|
||||
CONFIG_NETFILTER_XT_TARGET_CT=y
|
||||
#
|
||||
# Cheap rule helpers. CONNTRACK_PROCFS keeps /proc/net/nf_conntrack so the
|
||||
# cause of #537 and its fix can be proven (C14).
|
||||
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
|
||||
CONFIG_NF_CONNTRACK_PROCFS=y
|
||||
#
|
||||
# Namespaces for future app sandboxing (SCH-04, NN-11): NAMESPACES is a prompt
|
||||
# only under EXPERT and defaults off there, so it needs this line. All five
|
||||
# sub-options are set; USER_NS stays closed at runtime by
|
||||
# user.max_user_namespaces=0 (S02warden-sysctl) until the app sandbox needs it.
|
||||
# TIME_NS defaults on, so it is unset explicitly.
|
||||
CONFIG_NAMESPACES=y
|
||||
CONFIG_UTS_NS=y
|
||||
CONFIG_IPC_NS=y
|
||||
CONFIG_PID_NS=y
|
||||
CONFIG_NET_NS=y
|
||||
CONFIG_USER_NS=y
|
||||
# CONFIG_TIME_NS is not set
|
||||
#
|
||||
# Pressure stall information (SCH-04): /proc/pressure/* and per-cgroup
|
||||
# cpu.pressure and memory.pressure. On at boot (PSI_DEFAULT_DISABLED stays off).
|
||||
CONFIG_PSI=y
|
||||
#
|
||||
# nftables (N-40): the applier and the meter target nft in the families ip and
|
||||
# ip6. Counters, meta, payload, sets and jump are nf_tables core; there is no
|
||||
# NFT_COUNTER symbol. NFT_REJECT_IPV4 and NFT_REJECT_IPV6 have no prompt and
|
||||
# derive from NFT_REJECT, so they are asserted in required-symbols.txt and
|
||||
# never set here (a line for a promptless symbol is dropped).
|
||||
CONFIG_NF_TABLES=y
|
||||
CONFIG_NF_TABLES_IPV4=y
|
||||
CONFIG_NF_TABLES_IPV6=y
|
||||
CONFIG_NFT_CT=y
|
||||
CONFIG_NFT_MASQ=y
|
||||
CONFIG_NFT_NAT=y
|
||||
CONFIG_NFT_LIMIT=y
|
||||
CONFIG_NFT_SOCKET=y
|
||||
CONFIG_NFT_REJECT=y
|
||||
#
|
||||
# No suspend (rebuild M0, Noah 2026-10-09): the panel is wall powered and never
|
||||
# sleeps the SoC, and nothing in the product wakes it. Turning SUSPEND off lets
|
||||
# Kconfig drop everything that existed only for it: PM_SLEEP and PM_SLEEP_SMP,
|
||||
# SUSPEND_FREEZER and FREEZER, PM_GENERIC_DOMAINS_SLEEP, FW_CACHE (firmware
|
||||
# cached across a suspend) and VT_CONSOLE_SLEEP. PM_SLEEP_SMP was also the only
|
||||
# thing selecting HOTPLUG_CPU on this one-core SoC, and an SMP ARM kernel offers
|
||||
# KEXEC and CRASH_DUMP only with it, so those go too (nothing uses them: the
|
||||
# kexec flash path was a 5.10 experiment). PM, PM_CLK, runtime PM and
|
||||
# ARM_CPU_SUSPEND (kept by ARM_PSCI_FW) stay, because the USB, DRM and Wi-Fi
|
||||
# drivers use runtime PM. Hibernation was already off. The AIC8800 driver must
|
||||
# keep building and loading; the SDK build and the slot test prove it.
|
||||
# CONFIG_SUSPEND is not set
|
||||
# PM_SLEEP has no prompt and follows SUSPEND; the line records the expected result, and
|
||||
# required-symbols.txt asserts it against the final .config.
|
||||
# CONFIG_PM_SLEEP is not set
|
||||
#
|
||||
# Probe tier (N-36, d06 O14, probe V3): the Rockchip hardware RNG, built into
|
||||
# the test kernel. build/probe-symbols.txt lists it; it moves to
|
||||
# required-symbols.txt only if V3 passes on the panel, and comes out of this
|
||||
# file if it fails.
|
||||
CONFIG_HW_RANDOM_ROCKCHIP=y
|
||||
|
||||
@@ -82,7 +82,7 @@ tiered:
|
||||
behind a small injectable seam, mock its world, build
|
||||
`-fcondition-coverage`, enforce via the shared `drivers/enforce-mcdc.sh`
|
||||
(gcc-14 `gcov --conditions`) in the CI `mcdc` job (the proven flare-edge
|
||||
`tests/uboot-ab` method). **Done:** `relays.c` (40/40 conditions) and
|
||||
`tests/uboot-ab` method). **Done:** `relays.c` (50/50 conditions) and
|
||||
`freshness.c` (66/66). **Next in:** the modbus master and the RGA
|
||||
dispatch, with the ADR-0005 unification (`drivers/README.md`).
|
||||
- **Tier 2, near-mainline small drivers -> branch coverage + fault
|
||||
|
||||
+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. |
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
> **Outcome tested:** A relay is exported transparently and driven without disturbing a held contact.
|
||||
|
||||
**Coverage**: relays.c: 40/40 conditions, 100% MC/DC (CI-enforced)
|
||||
**Coverage**: relays.c: 50/50 conditions, 100% MC/DC (CI-enforced)
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A[warden_relay_set idx,on] --> B{idx < COUNT?}
|
||||
B -- no --> Z[no-op]
|
||||
B -- yes --> C{exported?}
|
||||
B -- yes --> P{all sysfs paths fit PATH_MAX?}
|
||||
P -- no --> Z3[log to stderr, no-op]
|
||||
P -- yes --> C{exported?}
|
||||
C -- no --> D[write export] --> E{exported now?}
|
||||
E -- no --> Z2[give up]
|
||||
E -- yes --> F
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ Self-contained logic with a clean seam, measured to **100% MC/DC** (gcc-14
|
||||
|
||||
| Driver | Seam | MC/DC |
|
||||
|---|---|---|
|
||||
| `relays/` | `relay_io` vtable (sysfs backend + in-memory fake) | 40/40 conditions, 100% |
|
||||
| `relays/` | `relay_io` vtable (sysfs backend + in-memory fake) | 50/50 conditions, 100% |
|
||||
| `freshness/` | produce/render callbacks (the "no stale numbers" guard) | 66/66 conditions, 100% |
|
||||
|
||||
**Adding a Tier-1 driver:** copy `<name>.{c,h}` here, put the hardware/OS calls behind
|
||||
|
||||
+60
-28
@@ -1,5 +1,6 @@
|
||||
#include "relays.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -8,6 +9,8 @@
|
||||
/* GPIO1_A0 and GPIO1_A1; gpiochip1 base is 32. See relays.h. */
|
||||
static const int s_gpio[WARDEN_RELAY_COUNT] = { 32, 33 };
|
||||
static const char * const s_name[WARDEN_RELAY_COUNT] = { "Relay 1", "Relay 2" };
|
||||
/* The same numbers as the strings written to `export`, so no runtime formatting. */
|
||||
static const char * const s_gpio_str[WARDEN_RELAY_COUNT] = { "32", "33" };
|
||||
|
||||
/* ---- default sysfs backend (Tier-2 plumbing; covered by integration tests) ---- */
|
||||
|
||||
@@ -64,11 +67,46 @@ const char * warden_relay_name(uint32_t idx)
|
||||
return idx < WARDEN_RELAY_COUNT ? s_name[idx] : "-";
|
||||
}
|
||||
|
||||
static bool exported(int gpio)
|
||||
/**
|
||||
* Every sysfs path one relay operation can touch. Each holds PATH_MAX bytes, so
|
||||
* any root the kernel would accept fits.
|
||||
*/
|
||||
struct relay_paths {
|
||||
char gpio[PATH_MAX]; /* <root>/gpioN */
|
||||
char export_[PATH_MAX]; /* <root>/export */
|
||||
char direction[PATH_MAX]; /* <root>/gpioN/direction */
|
||||
char value[PATH_MAX]; /* <root>/gpioN/value */
|
||||
};
|
||||
|
||||
/**
|
||||
* Format the paths for relay @p idx up front. A `$WARDEN_GPIO_ROOT` too long for
|
||||
* any of them is refused with a log line, never truncated: a cut-short path
|
||||
* would silently report both relays unavailable, or name a different node.
|
||||
*/
|
||||
static bool relay_paths(uint32_t idx, struct relay_paths * rp)
|
||||
{
|
||||
char p[80];
|
||||
snprintf(p, sizeof(p), "%s/gpio%d", gpio_root(), gpio);
|
||||
return s_io->exists(p);
|
||||
const char * root = gpio_root();
|
||||
int gpio = s_gpio[idx];
|
||||
const int n[] = {
|
||||
snprintf(rp->gpio, sizeof(rp->gpio), "%s/gpio%d", root, gpio),
|
||||
snprintf(rp->export_, sizeof(rp->export_), "%s/export", root),
|
||||
snprintf(rp->direction, sizeof(rp->direction), "%s/gpio%d/direction", root, gpio),
|
||||
snprintf(rp->value, sizeof(rp->value), "%s/gpio%d/value", root, gpio),
|
||||
};
|
||||
for(size_t i = 0; i < sizeof(n) / sizeof(n[0]); i++) {
|
||||
/* The unsigned cast also maps an encoding error (n < 0) to "does not fit". */
|
||||
if((unsigned)n[i] >= PATH_MAX) {
|
||||
fprintf(stderr, "relays: WARDEN_GPIO_ROOT is too long (%zu bytes): sysfs paths "
|
||||
"under it exceed PATH_MAX (%d), refusing it\n", strlen(root), PATH_MAX);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool exported(const struct relay_paths * rp)
|
||||
{
|
||||
return s_io->exists(rp->gpio);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,28 +115,21 @@ static bool exported(int gpio)
|
||||
* relay the first time this page is opened; reading the current level first and
|
||||
* writing it straight back makes the export transparent.
|
||||
*/
|
||||
static bool ensure_ready(int gpio)
|
||||
static bool ensure_ready(uint32_t idx, const struct relay_paths * rp)
|
||||
{
|
||||
if(!exported(gpio)) {
|
||||
char ex[80], n[16];
|
||||
snprintf(ex, sizeof(ex), "%s/export", gpio_root());
|
||||
snprintf(n, sizeof(n), "%d", gpio);
|
||||
s_io->write(ex, n);
|
||||
if(!exported(gpio)) return false;
|
||||
if(!exported(rp)) {
|
||||
s_io->write(rp->export_, s_gpio_str[idx]);
|
||||
if(!exported(rp)) return false;
|
||||
}
|
||||
|
||||
char p[96];
|
||||
snprintf(p, sizeof(p), "%s/gpio%d/direction", gpio_root(), gpio);
|
||||
char dir[16] = "";
|
||||
if(!s_io->read_line(p, dir, sizeof(dir))) return false;
|
||||
if(!s_io->read_line(rp->direction, dir, sizeof(dir))) return false;
|
||||
|
||||
if(strncmp(dir, "out", 3) != 0) {
|
||||
/* Preserve the level across the switch to output. */
|
||||
char vp[96];
|
||||
int cur;
|
||||
snprintf(vp, sizeof(vp), "%s/gpio%d/value", gpio_root(), gpio);
|
||||
if(!s_io->read_int(vp, &cur)) cur = 0;
|
||||
s_io->write(p, cur ? "high" : "low");
|
||||
if(!s_io->read_int(rp->value, &cur)) cur = 0;
|
||||
s_io->write(rp->direction, cur ? "high" : "low");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -106,27 +137,28 @@ static bool ensure_ready(int gpio)
|
||||
bool warden_relay_available(uint32_t idx)
|
||||
{
|
||||
if(idx >= WARDEN_RELAY_COUNT) return false;
|
||||
return ensure_ready(s_gpio[idx]);
|
||||
struct relay_paths rp;
|
||||
if(!relay_paths(idx, &rp)) return false;
|
||||
return ensure_ready(idx, &rp);
|
||||
}
|
||||
|
||||
bool warden_relay_get(uint32_t idx)
|
||||
{
|
||||
if(idx >= WARDEN_RELAY_COUNT) return false;
|
||||
if(!exported(s_gpio[idx])) return false;
|
||||
struct relay_paths rp;
|
||||
if(!relay_paths(idx, &rp)) return false;
|
||||
if(!exported(&rp)) return false;
|
||||
|
||||
char p[96];
|
||||
int v;
|
||||
snprintf(p, sizeof(p), "%s/gpio%d/value", gpio_root(), s_gpio[idx]);
|
||||
if(!s_io->read_int(p, &v)) v = 0;
|
||||
if(!s_io->read_int(rp.value, &v)) v = 0;
|
||||
return v != 0;
|
||||
}
|
||||
|
||||
void warden_relay_set(uint32_t idx, bool on)
|
||||
{
|
||||
if(idx >= WARDEN_RELAY_COUNT) return;
|
||||
if(!ensure_ready(s_gpio[idx])) return;
|
||||
|
||||
char p[96];
|
||||
snprintf(p, sizeof(p), "%s/gpio%d/value", gpio_root(), s_gpio[idx]);
|
||||
s_io->write(p, on ? "1" : "0");
|
||||
struct relay_paths rp;
|
||||
if(!relay_paths(idx, &rp)) return;
|
||||
if(!ensure_ready(idx, &rp)) return;
|
||||
s_io->write(rp.value, on ? "1" : "0");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* the decision logic runs and is measured to 100% MC/DC on the host, and the
|
||||
* gpio root is `$WARDEN_GPIO_ROOT`-overridable so the real backend can run
|
||||
* against a scratch tree in an integration test.
|
||||
*
|
||||
* Paths are built in PATH_MAX buffers. A root too long for its longest path
|
||||
* ("<root>/gpioNN/direction" within PATH_MAX) is refused with a stderr line, and
|
||||
* every call then reports unavailable / off / no-op; it is never truncated.
|
||||
*/
|
||||
#ifndef WARDEN_RELAYS_H
|
||||
#define WARDEN_RELAYS_H
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "../relays.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -30,11 +32,12 @@ static struct {
|
||||
const char *read_line_val;
|
||||
bool read_int_ok;
|
||||
int read_int_val;
|
||||
char last_write_path[160];
|
||||
char last_write_path[PATH_MAX];
|
||||
char last_write_val[32];
|
||||
int exists_calls;
|
||||
} fk;
|
||||
|
||||
static bool fk_exists(const char *p) { (void)p; return fk.exists_ret; }
|
||||
static bool fk_exists(const char *p) { (void)p; fk.exists_calls++; return fk.exists_ret; }
|
||||
static void fk_write(const char *p, const char *v) {
|
||||
snprintf(fk.last_write_path, sizeof fk.last_write_path, "%s", p);
|
||||
snprintf(fk.last_write_val, sizeof fk.last_write_val, "%s", v);
|
||||
@@ -56,6 +59,104 @@ static const struct relay_io FAKE = { fk_exists, fk_write, fk_read_line, fk_read
|
||||
|
||||
static void fk_reset(void) { memset(&fk, 0, sizeof fk); }
|
||||
|
||||
/* ---- stderr capture: proves a refusal is logged, not silent ---- */
|
||||
|
||||
static char g_err[1024];
|
||||
static int g_saved_stderr = -1;
|
||||
static char g_err_path[] = "/tmp/warden-relays-stderr-XXXXXX";
|
||||
|
||||
static void err_begin(void)
|
||||
{
|
||||
int fd = mkstemp(g_err_path);
|
||||
assert(fd >= 0);
|
||||
fflush(stderr);
|
||||
g_saved_stderr = dup(2);
|
||||
dup2(fd, 2);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void err_end(void)
|
||||
{
|
||||
fflush(stderr);
|
||||
dup2(g_saved_stderr, 2);
|
||||
close(g_saved_stderr);
|
||||
FILE *f = fopen(g_err_path, "r");
|
||||
size_t n = f ? fread(g_err, 1, sizeof g_err - 1, f) : 0;
|
||||
g_err[n] = '\0';
|
||||
if(f) fclose(f);
|
||||
unlink(g_err_path);
|
||||
memcpy(g_err_path + strlen(g_err_path) - 6, "XXXXXX", 6);
|
||||
}
|
||||
|
||||
/* A root of exactly @p len bytes ("/" then 'a's); it need not exist for fake io. */
|
||||
static char g_long[PATH_MAX + 64];
|
||||
static const char *long_root(size_t len)
|
||||
{
|
||||
assert(len >= 1 && len < sizeof g_long);
|
||||
g_long[0] = '/';
|
||||
memset(g_long + 1, 'a', len - 1);
|
||||
g_long[len] = '\0';
|
||||
return g_long;
|
||||
}
|
||||
|
||||
/* Root-length bounds (issue #10). The longest path is "<root>/gpio32/direction",
|
||||
* so a root of PATH_MAX - 1 - strlen("/gpio32/direction") bytes is the longest
|
||||
* that fits. One byte more must be refused loudly, never truncated. */
|
||||
static void long_root_unit_tests(void)
|
||||
{
|
||||
const size_t max_root = PATH_MAX - 1 - strlen("/gpio32/direction");
|
||||
|
||||
/* Well past the old 80/96-byte buffers but inside PATH_MAX: works, and the
|
||||
* io sees the full, untruncated path. */
|
||||
fk_reset(); fk.exists_ret = true; fk.read_line_ok = true; fk.read_line_val = "out\n";
|
||||
setenv("WARDEN_GPIO_ROOT", long_root(200), 1);
|
||||
warden_relay_set(0, true);
|
||||
EXPECT(strcmp(fk.last_write_val, "1") == 0);
|
||||
EXPECT(strlen(fk.last_write_path) == 200 + strlen("/gpio32/value"));
|
||||
EXPECT(strncmp(fk.last_write_path, g_long, 200) == 0);
|
||||
EXPECT(strcmp(fk.last_write_path + 200, "/gpio32/value") == 0);
|
||||
|
||||
/* Exactly at the bound: still accepted. */
|
||||
fk_reset(); fk.exists_ret = true; fk.read_line_ok = true; fk.read_line_val = "out\n";
|
||||
setenv("WARDEN_GPIO_ROOT", long_root(max_root), 1);
|
||||
EXPECT(warden_relay_available(0) == true);
|
||||
|
||||
/* One byte over: "<root>/gpio32" still fits, the direction path does not.
|
||||
* Every entry point refuses, logs, and never touches the io. */
|
||||
setenv("WARDEN_GPIO_ROOT", long_root(max_root + 1), 1);
|
||||
fk_reset(); fk.exists_ret = true; fk.read_line_ok = true; fk.read_line_val = "out\n";
|
||||
fk.read_int_ok = true; fk.read_int_val = 1;
|
||||
err_begin();
|
||||
EXPECT(warden_relay_available(0) == false);
|
||||
err_end();
|
||||
EXPECT(strstr(g_err, "WARDEN_GPIO_ROOT is too long") != NULL);
|
||||
EXPECT(fk.exists_calls == 0);
|
||||
|
||||
err_begin();
|
||||
EXPECT(warden_relay_get(0) == false);
|
||||
err_end();
|
||||
EXPECT(strstr(g_err, "WARDEN_GPIO_ROOT is too long") != NULL);
|
||||
EXPECT(fk.exists_calls == 0);
|
||||
|
||||
err_begin();
|
||||
warden_relay_set(1, true);
|
||||
err_end();
|
||||
EXPECT(strstr(g_err, "WARDEN_GPIO_ROOT is too long") != NULL);
|
||||
EXPECT(fk.last_write_path[0] == '\0');
|
||||
EXPECT(fk.exists_calls == 0);
|
||||
|
||||
/* A root longer than PATH_MAX itself: refused the same way. */
|
||||
setenv("WARDEN_GPIO_ROOT", long_root(PATH_MAX + 10), 1);
|
||||
fk_reset(); fk.exists_ret = true;
|
||||
err_begin();
|
||||
EXPECT(warden_relay_available(1) == false);
|
||||
err_end();
|
||||
EXPECT(strstr(g_err, "WARDEN_GPIO_ROOT is too long") != NULL);
|
||||
EXPECT(fk.exists_calls == 0);
|
||||
|
||||
unsetenv("WARDEN_GPIO_ROOT");
|
||||
}
|
||||
|
||||
static void unit_tests(void)
|
||||
{
|
||||
warden_relay__set_io(&FAKE);
|
||||
@@ -142,18 +243,20 @@ static void unit_tests(void)
|
||||
fk_reset(); fk.exists_ret = true; fk.read_line_ok = true; fk.read_line_val = "out\n";
|
||||
warden_relay_set(0, false);
|
||||
EXPECT(strcmp(fk.last_write_val, "0") == 0);
|
||||
|
||||
long_root_unit_tests();
|
||||
}
|
||||
|
||||
/* ---------------- layer 2: real sysfs backend over a scratch tree ---------------- */
|
||||
|
||||
static char g_root[128];
|
||||
static char g_root[PATH_MAX];
|
||||
|
||||
static void wr(const char *rel, const char *content) {
|
||||
char p[256]; snprintf(p, sizeof p, "%s/%s", g_root, rel);
|
||||
char p[PATH_MAX + 64]; snprintf(p, sizeof p, "%s/%s", g_root, rel);
|
||||
FILE *f = fopen(p, "w"); if(f) { fputs(content, f); fclose(f); }
|
||||
}
|
||||
static void mkgpio(int n) {
|
||||
char p[256]; snprintf(p, sizeof p, "%s/gpio%d", g_root, n); mkdir(p, 0777);
|
||||
char p[PATH_MAX + 64]; snprintf(p, sizeof p, "%s/gpio%d", g_root, n); mkdir(p, 0777);
|
||||
}
|
||||
|
||||
static void integration_tests(void)
|
||||
@@ -207,6 +310,24 @@ static void integration_tests(void)
|
||||
wr("gpio33/direction", "in\n");
|
||||
wr("gpio33/value", "1\n");
|
||||
EXPECT(warden_relay_available(1) == true); /* reads value=1, writes direction "high" */
|
||||
|
||||
/* Issue #10: a real scratch tree under a root far longer than the old 80/96-byte
|
||||
* buffers (the simulator's case). Both relays must be available and switchable. */
|
||||
for(int i = 0; i < 5; i++) {
|
||||
size_t l = strlen(g_root);
|
||||
snprintf(g_root + l, sizeof g_root - l, "/%s", "long-scratch-directory-component-for-issue-10");
|
||||
EXPECT(mkdir(g_root, 0777) == 0);
|
||||
}
|
||||
EXPECT(strlen(g_root) > 200);
|
||||
setenv("WARDEN_GPIO_ROOT", g_root, 1);
|
||||
mkgpio(32); mkgpio(33);
|
||||
wr("gpio32/direction", "out\n"); wr("gpio32/value", "0\n");
|
||||
wr("gpio33/direction", "out\n"); wr("gpio33/value", "0\n");
|
||||
EXPECT(warden_relay_available(0) == true);
|
||||
EXPECT(warden_relay_available(1) == true);
|
||||
warden_relay_set(1, true);
|
||||
EXPECT(warden_relay_get(1) == true);
|
||||
EXPECT(warden_relay_get(0) == false);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
@@ -337,12 +337,21 @@ static struct rockchip_clk_branch rv1106_clk_branches[] __initdata = {
|
||||
/* PD_CORE */
|
||||
GATE(CLK_PVTM_CORE, "clk_pvtm_core", "xin24m", 0,
|
||||
RV1106_CORECLKGATE_CON(0), 14, GFLAGS),
|
||||
GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", 0,
|
||||
/* clk_core_mcu_rtc is the 24 MHz mtime of the HPMCU, kept up for the
|
||||
* mtime safety tick. Nothing in Linux claims it, so clk_disable_unused()
|
||||
* would gate it after boot; IGNORE_UNUSED keeps it running, like
|
||||
* clk_core_mcu below (rebuild M0, SCH-01). */
|
||||
GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", CLK_IGNORE_UNUSED,
|
||||
RV1106_CORECLKGATE_CON(1), 6, GFLAGS),
|
||||
COMPOSITE(HCLK_CPU, "hclk_cpu", mux_gpll_24m_p, CLK_IS_CRITICAL,
|
||||
RV1106_CORECLKSEL_CON(2), 5, 1, MFLAGS, 0, 5, DFLAGS,
|
||||
RV1106_CORECLKGATE_CON(0), 12, GFLAGS),
|
||||
COMPOSITE(CLK_CORE_MCU, "clk_core_mcu", mux_gpll_24m_p, 0,
|
||||
/* The HPMCU (RISC-V SCR1 coprocessor) runs on clk_core_mcu, but nothing in
|
||||
* Linux claims it, so clk_disable_unused() switches it off at boot and any
|
||||
* firmware loaded into the coprocessor never executes. Mark it
|
||||
* IGNORE_UNUSED so the coprocessor clock stays up (5.10 left it running;
|
||||
* our 6.18 disabled it). A future remoteproc/coproc driver could claim it. */
|
||||
COMPOSITE(CLK_CORE_MCU, "clk_core_mcu", mux_gpll_24m_p, CLK_IGNORE_UNUSED,
|
||||
RV1106_CORECLKSEL_CON(3), 11, 1, MFLAGS, 6, 5, DFLAGS,
|
||||
RV1106_CORECLKGATE_CON(1), 1, GFLAGS),
|
||||
COMPOSITE_NOMUX(0, "pclk_dbg", "armclk", CLK_IS_CRITICAL,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
* RV1106 USB2 PHY: single OTG port at 0xff3e0000 (ported from the vendor driver;
|
||||
* fields map 1:1 to 6.18 except utmi_iddig -> utmi_id, and the 5.10-only
|
||||
* iddig_output/iddig_en/bvalid_grf_sel are dropped). Signal-quality phy_tuning is
|
||||
* left off for now (guarded, so NULL is safe): the phy is functional without it.
|
||||
* iddig_output/iddig_en/bvalid_grf_sel are dropped). Signal-quality phy_tuning
|
||||
* was originally left off here; it is now implemented (patches/27-usb-phy-tuning.patch)
|
||||
* because "functional without it" turned out not to mean reliable -- see #160.
|
||||
*/
|
||||
static const struct rockchip_usb2phy_cfg rv1106_phy_cfgs[] = {
|
||||
{
|
||||
.reg = 0xff3e0000,
|
||||
.num_ports = 1,
|
||||
.phy_tuning = rv1106_usb2phy_tuning,
|
||||
.clkout_ctl = { 0x0058, 4, 4, 1, 0 },
|
||||
.port_cfgs = {
|
||||
[USB2PHY_PORT_OTG] = {
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
# luckfox-sdk-patches
|
||||
|
||||
The Luckfox SDK (`LuckfoxTECH/luckfox-pico`, pinned in `../build/vendor.manifest`
|
||||
as `luckfox-pico`) is a ~2 GB vendor checkout and is deliberately **not** in
|
||||
this repo. Our changes to it were, until now, living only as uncommitted
|
||||
edits in one person's working copy -- which is how a stale second copy on
|
||||
another machine came within one command of silently reverting a day of work.
|
||||
This directory is the tracked form of those changes.
|
||||
|
||||
**Moved here 2026-09-15** from `sdk-patches/` in `blueflare/flare-edge`
|
||||
(source commit `flare-edge@86d4633`), so the SDK repo -- not the firmware
|
||||
repo that merely consumes it -- is the single canonical home for every
|
||||
kernel/U-Boot/driver delta. flare-edge's `tools/build-firmware.sh` and
|
||||
friends now read this directory through the `vendor/warden-sdk` submodule
|
||||
instead of a same-repo `sdk-patches/`.
|
||||
|
||||
**Vendor base: `824b817f8`** of <https://github.com/LuckfoxTECH/luckfox-pico>
|
||||
(`Pullrequest 260319 (#355)`) -- the same commit `../build/vendor.manifest`
|
||||
pins. Every patch here is `git diff` against that commit and has been
|
||||
verified with `git apply --check` against a pristine tree at that revision.
|
||||
If the vendor base moves, re-verify before trusting them.
|
||||
|
||||
**Not `patches/`, and not `sdk/`.** This repo's top-level `patches/` is a
|
||||
different, unrelated thing: the from-scratch Linux 6.18.46 forward-port
|
||||
series (see `../patches/README.md`). `luckfox-sdk-patches/` patches the
|
||||
**legacy** vendor tree instead (U-Boot 2017.09 and, optionally, the vendor
|
||||
5.10.160 kernel) -- naming it `luckfox-sdk-patches/` keeps the two
|
||||
unmistakable next to each other. It also isn't named plain `sdk/`, carrying
|
||||
forward the original naming rule from its flare-edge home: that repo's
|
||||
`ui-src/pkgconfig-stub/libdrm.pc` resolves `${pcfiledir}/../../sdk`, so a
|
||||
directory named `sdk/` anywhere it might be checked out alongside would
|
||||
shadow the real vendor SDK checkout. That specific collision cannot happen
|
||||
in this repo, but the name stayed to avoid a second rename and to keep the
|
||||
provenance trail (wiki, commit messages, flare-edge doc citations) legible
|
||||
across the move. Do not rename it.
|
||||
|
||||
## License
|
||||
|
||||
Everything here is a `git diff` against Rockchip/Luckfox's GPL-2.0 vendor
|
||||
U-Boot (2017.09) and Linux (5.10.160) forks, plus a handful of small
|
||||
standalone files we authored (`uboot/include/flare_touch.h`,
|
||||
`uboot/include/flare_trace.h`, the bluez5 `wordexp.h` compat shim, the mpv
|
||||
Bessel-function patch). The diffs are themselves GPL-2.0 derivative work,
|
||||
consistent with this repo's repo-wide GPL-2.0-only license (`../LICENSE`);
|
||||
the small standalone files carry no GPL restriction of their own but are
|
||||
distributed here under the same license for simplicity. Unlike `../patches/`
|
||||
(the 6.18 port), no per-driver provenance ledger exists for this directory
|
||||
yet -- everything here predates that convention. If one is wanted, it
|
||||
belongs beside `../kernel/rv1106-enablement/PROVENANCE.md`.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
luckfox-sdk-patches/uboot/patches/ diffs against sysdrv/source/uboot/u-boot/
|
||||
luckfox-sdk-patches/uboot/configs/ new config fragments (not patches -- whole new files)
|
||||
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/ 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)
|
||||
luckfox-sdk-patches/tests/ regression tests for the series (see "Regression tests")
|
||||
```
|
||||
|
||||
Paths inside each patch are relative to the vendor SDK root, so apply with
|
||||
`-p1` from there:
|
||||
|
||||
```sh
|
||||
cd /path/to/vendor/sdk
|
||||
for p in /path/to/warden-sdk/luckfox-sdk-patches/uboot/patches/*.patch \
|
||||
/path/to/warden-sdk/luckfox-sdk-patches/kernel/patches/*.patch \
|
||||
/path/to/warden-sdk/luckfox-sdk-patches/board/patches/*.patch; do
|
||||
git apply --check "$p" && git apply "$p"
|
||||
done
|
||||
cp /path/to/warden-sdk/luckfox-sdk-patches/uboot/configs/*.config sysdrv/source/uboot/u-boot/configs/
|
||||
cp /path/to/warden-sdk/luckfox-sdk-patches/uboot/include/*.h sysdrv/source/uboot/u-boot/include/
|
||||
cp /path/to/warden-sdk/luckfox-sdk-patches/kernel/configs/*.config sysdrv/source/kernel/arch/arm/configs/
|
||||
```
|
||||
|
||||
**You no longer have to run the above by hand.** flare-edge's
|
||||
`tools/build-firmware.sh` (in the `blueflare/flare-edge` repo, which carries
|
||||
this SDK as the `vendor/warden-sdk` submodule) applies everything in
|
||||
`luckfox-sdk-patches/` (patches idempotently, config fragments by copy)
|
||||
before it builds -- see its `apply_sdk_patches` step. The manual recipe is
|
||||
kept here as documentation of *what* that step does and for one-off use against
|
||||
a pristine tree. Idempotency rule the script uses per patch: if
|
||||
`git apply --reverse --check` succeeds the patch is already in the tree and is
|
||||
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).
|
||||
|
||||
## Regression tests
|
||||
|
||||
`tests/test-adbd-no-tcp.sh BASE_DIR PATCH_FILE|none` applies the board patch to
|
||||
a copy of the base tree and runs the android-tools rule of the Makefile under
|
||||
make. It checks the adbd TCP listener removal (flare-edge#3129), the rule's
|
||||
fail-closed behaviour (bfe-core1106-sdk#45) and the adbd rebuild gate as the
|
||||
Makefile evaluates it, including a changed source tarball (bfe-core1106-sdk#44,
|
||||
#46, #49). `BASE_DIR` is the luckfox base
|
||||
commit 824b817f8, `sysdrv/tools/board/android-tools` only:
|
||||
|
||||
git -C <luckfox-sdk> archive 824b817f8 sysdrv/tools/board/android-tools | tar -C BASE_DIR -xf -
|
||||
sh tests/test-adbd-no-tcp.sh BASE_DIR board/patches/0015-adbd-no-tcp-listener.patch
|
||||
sh tests/adbd-no-tcp-cases.sh BASE_DIR board/patches/0015-adbd-no-tcp-listener.patch
|
||||
|
||||
The toolchain is a stub: the compiler stub only creates its output file, so
|
||||
nothing is compiled. Run the test with `none` as the patch file to see the base
|
||||
fail. `adbd-no-tcp-cases.sh` runs the real patch (must pass), the unpatched base
|
||||
and four mutants of the patch (each must fail for the reason it names).
|
||||
|
||||
## 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`
|
||||
|
||||
The U-Boot boot logo never appeared at all before this, and four separate bugs
|
||||
had to be fixed before it did. Each was measured on hardware, not inferred.
|
||||
|
||||
| file | fix |
|
||||
|---|---|
|
||||
| `rockchip_display.c` | `malloc` -> `calloc`. `enabled_at_spl` is only ever assigned under `#ifdef CONFIG_SPL_BUILD`, so in U-Boot proper it read uninitialised heap. Garbage read as truthy meant `display_enable()` skipped the connector pre-enable/enable path -- the only path that reaches `backlight_enable()`. |
|
||||
| `pwm_backlight.c` | `args.args[2] & 1`. The DT has `pwms = <&pwm1 0 100000 50000>`; assigning `50000` to a `bool` polarity field inverted the PWM. Measured `DUTY=0x26e8` (99.6%) with `CTRL=0x13`; after the fix `CTRL=0x0b`. The backlight was running at 0.4%. |
|
||||
| `clk_rv1106.c` | Two bugs. `rv1106_clk_set_rate()` returned a stale `ret` instead of the computed `rate`, so it always reported 0 Hz. And `DCLK_VOP_DIV_MASK` is 5 bits (max /32) while `DIV_ROUND_UP(1188 MHz, 30 MHz) = 40` wrote 39, truncated to 7 -- **the VOP was running at 125 MHz, not 30**. Now clamps to 32, picks the closest parent, and retunes CPLL 1000 -> 960 MHz when neither divides evenly, giving exactly 30.000 MHz. |
|
||||
| `rockchip_panel.c` | `FLARE_PANEL_SETTLE_MS`: wait after scanout starts before switching the backlight on. See the comment in the file -- it distinguishes two artefacts that look similar and have different causes. |
|
||||
| `board.c` | Release `RGB_RES` (GPIO0_A1) at the top of `board_init()` instead of `board_late_init()`, and `FLARE_TRACE` instrumentation. `setup_download_mode()` is deliberately kept **first** in `board_late_init()`: moving the logo ahead of it pushed BOOT-key sampling from 1.18 s to ~4-5 s and the key had to be held for eight seconds. |
|
||||
| `rv1106-u-boot.dtsi` | `u-boot,spl-boot-order = <&emmc>`. It was `<&sdmmc, &spi_nor, &spi_nand, &emmc>` -- the only fitted medium was last. Walking the dead entries cost **267 ms** every boot: ~212 ms failing to identify a non-existent SPI-NAND (`unknown raw ID 0 0 0`) and ~57 ms probing an SD slot this board does not have (`sdmmc` is wired to the AIC8800 WiFi as SDIO). **This file is shared by every rv1106 U-Boot build in the tree**; an SD- or SPI-NAND-booting variant would no longer boot. |
|
||||
| `console.c` | Timestamp every console line, including from SPL. Needed two fixes: the stock code formats with `%5lu.%06lu`, which `CONFIG_USE_TINY_PRINTF` cannot render (it supports only `%c %s %u %d %x`), and it hooked `puts()`, which SPL never calls -- tiny printf goes character-at-a-time through `putc()`. Costs 324 B of SPL. |
|
||||
| `rockchip_post_csc.c` | Add `#include <common.h>`. An upstream SDK bug, not a consequence of our config -- the vendor's own `rv1106_defconfig` also lacks `CONFIG_DM_I2C`. |
|
||||
|
||||
### `uboot/patches/0002-boot-robustness.patch`
|
||||
|
||||
Unattended recovery: `spl-boot-order.c` + `spl.c` register `BOOT_DEVICE_BOOTROM`
|
||||
as a last-resort SPL load method so a failed U-Boot load drops to MaskRom
|
||||
instead of hanging, and `bootcount/Kconfig` exposes `BOOTCOUNT_LIMIT` so
|
||||
repeated boot failures fall through to `altbootcmd`. The defconfig change adds
|
||||
the bootcount variables to `CONFIG_ENVF_LIST`.
|
||||
|
||||
**Provenance note:** this is boot-robustness rather than display work and may
|
||||
overlap with reliability work done in a parallel session. Review before merging.
|
||||
|
||||
### `kernel/patches/0001-panel-mcu-reset-and-logo-route.patch`
|
||||
|
||||
Two hunks, both display:
|
||||
|
||||
- **`&panel`** -- removes `reset-gpios` and `reset-delay-ms`. GPIO0_A1 is *not*
|
||||
the panel's reset. Per the 86Panel schematic, net `RGB_RES` ties SoC GPIO0_A1,
|
||||
the panel RESET pin (FPC 6) and the `NRST` of a WCH **CH32V003** MCU (U6)
|
||||
together; that MCU's only wired pins are SPI to the same FPC, and its sole job
|
||||
is to clock the panel's initialisation sequence in. Handing the GPIO to
|
||||
`panel-simple` therefore made `drm_panel_prepare()` **reboot the panel
|
||||
initialiser while the VOP was already scanning out** -- which is the faint
|
||||
coloured vertical banding seen for ~1-3 s on every boot, and why adding a
|
||||
"reset" never cured it. Luckfox deleted these same two properties in
|
||||
`e2b0ffa22`. An earlier revision of our tree re-added them, having read that
|
||||
deletion as an accidental regression. **Confirmed fixed on hardware.**
|
||||
`backlight` stays, because U-Boot's `rockchip_panel.c` takes its backlight
|
||||
handle from this node.
|
||||
- **`&route_rgb`** -- `status = "okay"`. The rest of the RGB pipeline is already
|
||||
enabled in `rv1106-luckfox-pico-86panel-ipc.dtsi`; `route_rgb` was the only
|
||||
piece left off, and without it U-Boot's `rockchip_display` finds no route and
|
||||
skips drawing entirely.
|
||||
|
||||
Deliberately **excluded** from this patch, though present in the same file in
|
||||
the working tree: the `model` rename, and a `dr_mode = "peripheral"` revert that
|
||||
was a bench workaround to keep the USB network gadget stable for flashing. The
|
||||
latter is superseded by the live USB role-switching work on `main`.
|
||||
|
||||
### `kernel/patches/0005-pstore-ramoops.patch`
|
||||
|
||||
Adds a `ramoops@0f000000` node (1 MiB @ 240 MiB) to `reserved-memory` in
|
||||
`rv1106-luckfox-pico-86panel-ipc.dtsi` so pstore/ramoops has a DRAM region that
|
||||
survives a reset. Pairs with the `CONFIG_PSTORE*` lines in
|
||||
`kernel/configs/flare-edge.config`: the kernel console ring + oops/panic survive
|
||||
into the next boot (`/sys/fs/pstore`), which is the ONLY way to diagnose a
|
||||
pre-userspace hang (the c8a3 `0x40000` class) with no serial console. Placed
|
||||
HIGH, above the low kernel-image/DTB/initrd zone, so the carve-out can only
|
||||
remove kernel RAM -- it cannot recreate the c8a3 under-reservation collision.
|
||||
Needs a `boot.img` reflash.
|
||||
|
||||
### `kernel/patches/0006-reboot-mode-maskrom.patch`
|
||||
|
||||
Adds `&reboot_mode { mode-maskrom = <0xEF08A53C>; };` (`BOOT_BROM_DOWNLOAD`) to
|
||||
the 86Panel ipc.dtsi, so the OS helper `warden-maskrom maskrom`
|
||||
(`reboot(RESTART2,"maskrom")`) writes that magic to the boot-mode reg
|
||||
(`0xff020200`) and the next reset enters **true BootROM MaskRom** -- where
|
||||
`upgrade_tool db`+`wl` / `provision-ab.sh` flash reliably. The stock
|
||||
`mode-loader`/`-bootloader` only reach U-Boot rockusb "Loader" mode, whose
|
||||
multi-partition WL is unreliable (writes report 100% but may not persist).
|
||||
One-shot (PMU-domain reg, cleared by POR). Verified: the DTB compiles and
|
||||
carries `mode-maskrom=0xEF08A53C`. Needs a `boot.img` reflash -- and the FIRST
|
||||
deployment still needs one physical-MaskRom flash (chicken-and-egg), after which
|
||||
remote MaskRom flashing works. Independent hunk (end of ipc.dtsi) -- applies in
|
||||
any order vs 0005.
|
||||
|
||||
### `buildroot/files/package/mpv/0002-change-j1.patch`
|
||||
|
||||
Swaps mpv's `j1(x)` (video/out/filter_kernels.c, backing the EWA/jinc
|
||||
scalers) for a local `BesselJ1()`. Needed because this target's uClibc-ng
|
||||
does not provide `j1()`/`j0()`/`jn()` -- confirmed absent from
|
||||
`libuClibc-1.0.31.so` in the arm-rockchip830-linux-uclibcgnueabihf
|
||||
sysroot, the same kind of gap the bluez5_utils wordexp patch works around
|
||||
for a different function.
|
||||
|
||||
The first version of `BesselJ1()` summed a fixed 11-term power series.
|
||||
`jinc()` multiplies its argument by M_PI before calling it, and mpv's
|
||||
`--scale-radius` is user-settable, so any radius reaching roughly x=20
|
||||
already returns garbage: 11 terms had not converged there, so the value
|
||||
was 3.1e6 instead of the correct 0.0668, growing to 3.3e42 by x=1000.
|
||||
The current version sums a term-to-term-ratio series while each new term
|
||||
is still negligible (stable for the range where that converges) and
|
||||
falls back to the standard second-order asymptotic expansion for Bessel
|
||||
functions beyond that, checked against the host's real `j1()` across
|
||||
x in [0, 5000]: max absolute error 5e-8. `tools/bessel-j1-test.sh` pulls
|
||||
whatever `BesselJ1()` the patch currently carries out of the diff and
|
||||
checks it the same way, so a regression back to an unconverged series
|
||||
is caught there instead of showing up as scaler artifacts on a panel.
|
||||
|
||||
### `buildroot/files/package/bluez5_utils/0001-add-uclibc-wordexp-compat.patch`
|
||||
|
||||
Adds a `wordexp.h` at the BlueZ source root: a minimal wordexp(3)/wordfree(3)
|
||||
for uClibc-ng, which this toolchain does not provide. `bluetoothctl` and a few
|
||||
BlueZ tools include `<wordexp.h>` unconditionally and only ever pass
|
||||
`WRDE_NOCMD` ("no command substitution"), so a whitespace/quote tokenizer is a
|
||||
semantically complete substitute -- the same kind of gap the mpv `j1()` patch
|
||||
above works around for a different function.
|
||||
|
||||
`WRDE_APPEND` lets a caller accumulate words across more than one call onto
|
||||
the same `wordexp_t`. An allocation failure partway through such a call used
|
||||
to free the words the *earlier* call had already produced and leave
|
||||
`we_wordv` pointing at memory `realloc()` had already relocated or freed --
|
||||
reachable any time a second `WRDE_APPEND` call runs out of memory, not only
|
||||
under theoretical low-memory conditions. Fixed by capturing the pre-call word
|
||||
count and only ever freeing/relocating entries at or past it.
|
||||
|
||||
`tools/wordexp-test.sh` extracts `wordexp.h` from this patch's diff into a
|
||||
scratch dir (nothing else in the tree has a copy -- it is a full new-file
|
||||
patch, applied only during a firmware build) and runs `tools/wordexp_test.c`
|
||||
against it: plain and quoted tokenizing, an unterminated quote, growth past
|
||||
the initial capacity, `WRDE_APPEND` across two calls, and the allocation-
|
||||
failure case above. Wired into CI's `daemons` job.
|
||||
|
||||
### Seatbelt build changes (docs/firmware-update.md section 6.6)
|
||||
|
||||
The firmware-update **seatbelt** (auto-revert of a bad remote reflash) needs a
|
||||
handful of small U-Boot/OS build changes. Design section 6.6 lists six; items **1, 3,
|
||||
4** are the low-risk, independently-shippable wiring, and they were -- until now -- present only in one person's hand-patched SDK, which is the exact "stale
|
||||
second copy nearly reverted a day of work" trap that created this directory.
|
||||
They are tracked here and applied by `tools/build-firmware.sh`, so a clean SDK
|
||||
checkout plus that script reproduces them with no manual editing.
|
||||
|
||||
| section 6.6 | tracked as | what it does |
|
||||
|---|---|---|
|
||||
| **item 1** | `board/patches/0001-86panel-seatbelt-wiring.patch` (first hunk) + `uboot/configs/flare-bootcount.config` | Wires the bootcount fragment into the build: appends `flare-bootcount.config` to `RK_UBOOT_DEFCONFIG_FRAGMENT` in the 86Panel board `.mk`. The fragment itself (already tracked, see the Config-fragments table) turns on `CONFIG_BOOTCOUNT{,_LIMIT,_ENV}` and the extended `CONFIG_ENVF_LIST`. Without the wiring the fragment is inert and U-Boot never counts boots -- the seatbelt's U-Boot layer (section 6.1) is silently absent. |
|
||||
| **item 3** | `board/patches/0001-86panel-seatbelt-wiring.patch` (second hunk) + `board/patches/0002-build-honor-bootargs-extra.patch` | `panic=10` on the kernel cmdline (`sys_bootargs`) so a kernel panic **reboots** after 10 s instead of hanging (section 6.4). The board `.mk` sets `RK_BOOTARGS_EXTRA="panic=10"`; the second patch teaches `project/build.sh`'s `__GET_BOOTARGS_FROM_BOARD_CFG()` to append `RK_BOOTARGS_EXTRA` verbatim to `sys_bootargs` (the same place it already appends `rk_dma_heap_cma=`). That variable flows to `RK_KERNEL_CMDLINE_FRAGMENT` -> `sysdrv/Makefile`'s `KERNEL_CMDLINE_FRAGMENT` -> the actual boot args. The hook is generic and inert: a board that never sets `RK_BOOTARGS_EXTRA` is unaffected. |
|
||||
| **item 4** | `kernel/patches/0002-watchdog-enable.patch` | Enables the hardware watchdog DT node -- `&wdt { status = "okay"; };` on the 86Panel board dts. `CONFIG_DW_WATCHDOG` is already built, but `rv1106.dtsi` ships `wdt` `disabled`, so `/dev/watchdog` does not exist until this override. Once present, `warden-flared` pets it only while healthy; a post-boot hang then hard-resets and converges to `altbootcmd` -> recovery, the backstop to bootcount (section 6.7). Needs a `boot.img` reflash. |
|
||||
|
||||
Items **2** (provision recovery env at flash time), **5** (recovery partition +
|
||||
image) and **6** (`CONFIG_ENV_OFFSET_REDUND`) are *not* build-time source
|
||||
changes: item 2 is a provisioning-step env write (see `tools/envf.py` and the
|
||||
flash scripts), item 5 is a partition-table + recovery-FIT change scheduled with
|
||||
a hardware-validation pass, and item 6 is a hardening nice-to-have. They are
|
||||
tracked where they live, not here.
|
||||
|
||||
**Apply-order note.** `kernel/patches/0002-watchdog-enable.patch` and the
|
||||
existing `kernel/patches/0001-panel-mcu-reset-and-logo-route.patch` both edit
|
||||
the same board dts, but at non-overlapping anchors (0002 inserts after the
|
||||
`&gmac` block near the top; 0001 appends `&panel`/`&route_rgb` at the tail), so
|
||||
they apply in either order. Verified with `git apply --check` against the
|
||||
pristine vendor base and by applying both in sequence.
|
||||
|
||||
**Precise apply targets** (relative to the SDK root -- the same `-p1` convention
|
||||
as every other patch here):
|
||||
|
||||
- `board/patches/0001-86panel-seatbelt-wiring.patch` -> `project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk`
|
||||
- `board/patches/0002-build-honor-bootargs-extra.patch` -> `project/build.sh` (function `__GET_BOOTARGS_FROM_BOARD_CFG`)
|
||||
- `board/patches/0003-build-fix-rkvar-grep-quote.patch` -> `project/build.sh` (functions `unset_env_config_rk`, `unset_board_config_all`)
|
||||
- `kernel/patches/0002-watchdog-enable.patch` -> `sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts`
|
||||
|
||||
**`board/patches/0003-build-fix-rkvar-grep-quote.patch`** -- required by item 3.
|
||||
`unset_board_config_all()` reset-sources every `RK_*` var out of the board `.mk`s
|
||||
with a greedy `grep -oh "^export.*RK_.*="`, whose `.*=` runs to the *last* `=` on
|
||||
the line. Once item 3 adds `export RK_BOOTARGS_EXTRA="panic=10"`, that grep yields
|
||||
`export RK_BOOTARGS_EXTRA="panic=` -- an unbalanced quote that makes the sourced
|
||||
temp file a syntax error and aborts **every** `build.sh` invocation on a clean SDK
|
||||
(`unexpected EOF while looking for matching '"'`). The fix narrows both greps
|
||||
(here and `unset_env_config_rk`) to the variable **name** only,
|
||||
`^export RK_[A-Za-z0-9_]*=`, dropping the value. Without this, a from-scratch
|
||||
checkout cannot build the 86Panel firmware at all; the runner's hand-patched SDK
|
||||
had masked it (the reproducibility gap `tools/build-firmware.sh` exists to close).
|
||||
- `uboot/configs/flare-bootcount.config` is **copied** into
|
||||
`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/0015-adbd-no-tcp-listener.patch` (flare-edge#3129)
|
||||
|
||||
Rockchip's android-tools patch `0015-make-adb-tcp-function-default-enbale.patch`
|
||||
made `adb_main()` open TCP 5555 whenever USB is up, and the non-secure branch
|
||||
opened `tcp:5037` on 127.0.0.1. S50usbdevice starts adbd with no arguments, so
|
||||
every panel ran both (`0.0.0.0:5555` was reachable from the LAN). The patch
|
||||
adds `android-tools-patches/0017-no-adb-tcp-listener.patch`, which removes both
|
||||
calls from the device half of `adb_main()` and runs last in
|
||||
`android-tools.patch.sh`. USB stays the only transport.
|
||||
|
||||
It also changes the Makefile gate. adbd was rebuilt only when `out/usr/bin/adbd`
|
||||
was missing, so a patch-set change never reached an SDK tree that already held
|
||||
the binary (bfe-core1106-sdk#44). `adbd-current.sh` now compares a stamp in
|
||||
`out/.adbd-inputs` with a hash of the Makefile, the gate script, the patch set
|
||||
and the two adbd source tarballs, and the build writes that stamp.
|
||||
|
||||
The rule now stops at the first failed step (a debian series entry, an
|
||||
`android-tools.patch.sh` step run with `-e`, the build, or the copy into
|
||||
`out/usr/bin`), and the stamp is written last. A failed step therefore never
|
||||
leaves a stamp for an adbd that was not built from the patch set
|
||||
(bfe-core1106-sdk#45).
|
||||
|
||||
### `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 |
|
||||
|
||||
### `board/patches/0014-s50usbdevice-unset-role-is-client.patch`
|
||||
|
||||
0004's S50usbdevice gate read an unset role as router, so a fresh `/userdata`
|
||||
never composed the USB gadget and the panel had no `usb0` until its second
|
||||
boot (flare-edge#278). 0014 makes unset mean client (0), like every other
|
||||
role reader; flare-edge's `tests/guards/run-role-default-tests.sh` pins the
|
||||
gate to them. It is a separate patch, not an edit to 0004, because
|
||||
`build-firmware.sh` would skip an edited 0004 as inconclusive on an SDK that
|
||||
already carries 0004 and 0008.
|
||||
|
||||
## Config fragments
|
||||
|
||||
| fragment | why |
|
||||
|---|---|
|
||||
| `uboot/flare-display.config` | the DRM/panel/PWM symbols the logo path needs |
|
||||
| `uboot/flare-verbose.config` | `CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP=y` -- us timestamps on every line. ~15 chars/line ~ 1.3 ms/line at 115200, so read instrumented timings as an upper bound |
|
||||
| `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
|
||||
|
||||
Instrumented boot, t=0 at the BootROM DDR banner:
|
||||
|
||||
| milestone | before this work | after |
|
||||
|---|---|---|
|
||||
| SPL total (self-reported) | 420.6 ms | 153.6 ms |
|
||||
| U-Boot logo drawn | 0.866 s | 0.604 s |
|
||||
| backlight on (logo visible) | 1.157 s | 0.695 s |
|
||||
| kernel handoff | 1.757 s | 1.292 s |
|
||||
| userspace colour splash | 4.335 s | 3.87 s |
|
||||
|
||||
`tools/boot-trace.py` produces this table from a UART capture. It splits U-Boot
|
||||
from kernel at the `Starting kernel` line rather than at the kernel banner,
|
||||
because with `ignore_loglevel` at 115200 the banner is regularly lost to
|
||||
`** N printk messages dropped **`.
|
||||
|
||||
## Still open
|
||||
|
||||
- The white logo starts **inverted and fades to correct** in its first instant.
|
||||
Believed to be the CH32V003's init still completing when the backlight lands,
|
||||
so we see the tail of the driver IC's internal rail ramp; `FLARE_PANEL_SETTLE_MS`
|
||||
is currently `250` as a test of that. The cost-free fix, if confirmed, is to
|
||||
release `RGB_RES` in SPL (~0.03 s) instead of `board_init()` (~0.21 s) and take
|
||||
the settle back toward zero -- that needs an `idblock` flash.
|
||||
- No display-driver-IC part number has been identified. The panel is a 4-inch
|
||||
720x720 RGB666 module, flex marked `BV-FPC39510A-N-V0`. Note the GT911 on this
|
||||
board is the **touch** controller on `i2c3@0x14` and has nothing to do with the
|
||||
display path.
|
||||
@@ -0,0 +1,107 @@
|
||||
diff --git a/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk b/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk
|
||||
index c8687187c..01e95378d 100755
|
||||
--- a/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk
|
||||
+++ b/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk
|
||||
@@ -13,6 +13,13 @@ export RK_APP_TYPE=RK_WIFI_APP
|
||||
# Config CMA size in environment
|
||||
export RK_BOOTARGS_CMA_SIZE="1M"
|
||||
|
||||
+# flare-edge (docs/firmware-update.md §6.6 item 3): extra kernel cmdline
|
||||
+# args, appended verbatim to sys_bootargs by __GET_BOOTARGS_FROM_BOARD_CFG
|
||||
+# in project/build.sh. panic=10 makes a kernel panic REBOOT after 10 s
|
||||
+# instead of hanging, so a bad `major` update is counted by U-Boot's
|
||||
+# bootcount and falls through to altbootcmd -> recovery (§6.4).
|
||||
+export RK_BOOTARGS_EXTRA="panic=10"
|
||||
+
|
||||
# Kernel dts
|
||||
export RK_KERNEL_DTS=rv1106g-luckfox-pico-86panel.dts
|
||||
|
||||
@@ -24,7 +31,7 @@ export RK_KERNEL_DTS=rv1106g-luckfox-pico-86panel.dts
|
||||
export RK_BOOT_MEDIUM=emmc
|
||||
|
||||
# Uboot defconfig fragment
|
||||
-export RK_UBOOT_DEFCONFIG_FRAGMENT="rk-emmc.config rv1106-luckfox-rgb-reset.config"
|
||||
+export RK_UBOOT_DEFCONFIG_FRAGMENT="rk-emmc.config rv1106-luckfox-rgb-reset.config flare-spl-brom.config flare-bootcount.config flare-display.config flare-verbose.config flare-ab.config flare-usb-gadget.config flare-touch.config"
|
||||
|
||||
# specify post.sh for delete/overlay files
|
||||
# export RK_PRE_BUILD_OEM_SCRIPT=rv1103-spi_nor-post.sh
|
||||
@@ -35,7 +42,13 @@ export RK_UBOOT_DEFCONFIG_FRAGMENT="rk-emmc.config rv1106-luckfox-rgb-reset.conf
|
||||
# <partdef> := <size>[@<offset>](part-name)
|
||||
# Note:
|
||||
# If the first partition offset is not 0x0, it must be added. Otherwise, it needn't adding.
|
||||
-export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot),512M(oem),256M(userdata),6G(rootfs)"
|
||||
+#
|
||||
+# flare-edge A/B layout (docs/decisions/0003-partition-layout.md in the repo):
|
||||
+# env/idblock/uboot offsets are fixed (BootROM scans LBA 0x40; SPL reads the
|
||||
+# FIT at byte 0x88000); uboot grows 256K->512K for headroom; misc carries the
|
||||
+# A/B slot metadata (byte 2048) and an INERT BCB (16K); boot/oem/rootfs are
|
||||
+# slotted; recovery holds the never-updated rescue FIT.
|
||||
+export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),512K(uboot),512K(misc),32M(boot_a),32M(boot_b),128M(oem_a),128M(oem_b),1G(rootfs_a),1G(rootfs_b),32M(recovery),1G(userdata)"
|
||||
|
||||
# config partition's filesystem type (squashfs is readonly)
|
||||
# emmc: squashfs/ext4
|
||||
@@ -46,7 +59,9 @@ export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot)
|
||||
# AAAA ----------> partition name
|
||||
# /BBBB/CCCC ----> partition mount point
|
||||
# ext4 ----------> partition filesystem type
|
||||
-export RK_PARTITION_FS_TYPE_CFG=rootfs@IGNORE@ext4,userdata@/userdata@ext4,oem@/oem@ext4
|
||||
+# The _a names key image GENERATION (the build strips _[ab]); runtime mounting
|
||||
+# resolves the ACTIVE slot from warden.slot on the cmdline (mount_part patch).
|
||||
+export RK_PARTITION_FS_TYPE_CFG=rootfs_a@IGNORE@ext4,userdata@/userdata@ext4,oem_a@/oem@ext4
|
||||
|
||||
# config filesystem compress (Just for squashfs or ubifs)
|
||||
# squashfs: lz4/lzo/lzma/xz/gzip, default xz
|
||||
@@ -62,7 +77,7 @@ export RK_PARTITION_FS_TYPE_CFG=rootfs@IGNORE@ext4,userdata@/userdata@ext4,oem@/
|
||||
export LF_TARGET_ROOTFS=buildroot
|
||||
|
||||
# Buildroot defconfig
|
||||
-export RK_BUILDROOT_DEFCONFIG=luckfox_pico_w_defconfig
|
||||
+export RK_BUILDROOT_DEFCONFIG=flare_warden_defconfig
|
||||
|
||||
#################################################
|
||||
# Defconfig
|
||||
@@ -75,7 +90,19 @@ export RK_ARCH=arm
|
||||
export RK_TOOLCHAIN_CROSS=arm-rockchip830-linux-uclibcgnueabihf
|
||||
|
||||
#misc image
|
||||
-export RK_MISC=wipe_all-misc.img
|
||||
+# NEVER the SDK default (recovery-misc.img: BCB says boot-recovery --wipe_all).
|
||||
+# warden-misc.img is generated by tools/mk-misc.py (flare-edge repo): inert
|
||||
+# BCB + A/B metadata with both slots successful, A preferred.
|
||||
+export RK_MISC=warden-misc.img
|
||||
+
|
||||
+# Rescue image: a never-updated kernel+initramfs FIT in the recovery
|
||||
+# partition, booted by U-Boot when both slots are exhausted (or on a BCB
|
||||
+# 'boot-recovery' command). Same kernel fragments as the main image (keep in
|
||||
+# sync with RK_KERNEL_DEFCONFIG_FRAGMENT below: referenced literally here
|
||||
+# because this line exports first): ethernet and WireGuard are built-in, so
|
||||
+# the rescue can get the device reachable.
|
||||
+export RK_ENABLE_RECOVERY=y
|
||||
+export RK_RECOVERY_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config flare-edge.config rv1106-usb-host-ethernet.config flare-wireguard.config flare-backlight.config flare-fbcon.config"
|
||||
|
||||
# Uboot defconfig
|
||||
export RK_UBOOT_DEFCONFIG=luckfox_rv1106_uboot_defconfig
|
||||
@@ -84,7 +111,7 @@ export RK_UBOOT_DEFCONFIG=luckfox_rv1106_uboot_defconfig
|
||||
export RK_KERNEL_DEFCONFIG=luckfox_rv1106_linux_defconfig
|
||||
|
||||
# Kernel defconfig fragment
|
||||
-export RK_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config"
|
||||
+export RK_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config flare-edge.config rv1106-usb-host-ethernet.config flare-wireguard.config flare-backlight.config flare-fbcon.config"
|
||||
|
||||
# Config sensor IQ files
|
||||
# RK_CAMERA_SENSOR_IQFILES format:
|
||||
@@ -104,7 +131,7 @@ export RK_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config
|
||||
export RK_BUILD_APP_TO_OEM_PARTITION=y
|
||||
|
||||
# enable rockchip test
|
||||
-export RK_ENABLE_ROCKCHIP_TEST=y
|
||||
+export RK_ENABLE_ROCKCHIP_TEST=n
|
||||
|
||||
# enable rockchip wifi
|
||||
export RK_ENABLE_WIFI=y
|
||||
@@ -125,4 +152,4 @@ export RK_PRE_BUILD_OEM_SCRIPT=luckfox-buildroot-oem-pre.sh
|
||||
export RK_PRE_BUILD_USERDATA_SCRIPT=luckfox-userdata-pre.sh
|
||||
|
||||
# declare overlay directory
|
||||
-export RK_POST_OVERLAY="overlay-luckfox-buildroot-init overlay-luckfox-buildroot-shadow overlay-luckfox-buildroot-rgb overlay-luckfox-buildroot-86panel"
|
||||
+export RK_POST_OVERLAY="overlay-luckfox-buildroot-init overlay-luckfox-buildroot-shadow overlay-luckfox-buildroot-rgb overlay-luckfox-buildroot-86panel overlay-flare-warden-ui"
|
||||
@@ -0,0 +1,21 @@
|
||||
diff --git a/project/build.sh b/project/build.sh
|
||||
index 18552ca28..6fab50104 100755
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -2161,6 +2161,16 @@ __GET_BOOTARGS_FROM_BOARD_CFG() {
|
||||
if [ -n "$RK_BOOTARGS_CMA_SIZE" ]; then
|
||||
SYS_BOOTARGS="$SYS_BOOTARGS rk_dma_heap_cma=$RK_BOOTARGS_CMA_SIZE"
|
||||
fi
|
||||
+ # flare-edge (docs/firmware-update.md §6.6 item 3): append any extra
|
||||
+ # kernel bootargs the board .mk asks for, verbatim, to sys_bootargs.
|
||||
+ # The 86Panel board sets RK_BOOTARGS_EXTRA="panic=10" so a kernel
|
||||
+ # panic REBOOTS after 10 s instead of hanging -- which is what turns a
|
||||
+ # bad `major` update into a bootcount++ that U-Boot can count toward
|
||||
+ # ${bootlimit} -> ${altbootcmd} -> recovery. Generic + inert: a board
|
||||
+ # that never sets the var is completely unaffected.
|
||||
+ if [ -n "$RK_BOOTARGS_EXTRA" ]; then
|
||||
+ SYS_BOOTARGS="$SYS_BOOTARGS $RK_BOOTARGS_EXTRA"
|
||||
+ fi
|
||||
}
|
||||
|
||||
__LINK_DEFCONFIG_FROM_BOARD_CFG() {
|
||||
@@ -0,0 +1,403 @@
|
||||
Recovery partitions and the recovery ramdisk, in project/.
|
||||
|
||||
The BoardConfig hunks that used to head this patch were removed: patch 0001
|
||||
carries that file's whole delta, and both patches adding RK_BOOTARGS_EXTRA at
|
||||
the same line meant the two could never apply in sequence. What is left here is
|
||||
the part 0001 does not cover.
|
||||
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -1826,7 +1826,18 @@
|
||||
root_dev=\$(mountpoint -n /)
|
||||
root_dev=\${root_dev%% *}
|
||||
partname=\$1
|
||||
-part_dev=/dev/block/by-name/\$1
|
||||
+# flare-edge A/B: a slotted partition name resolves against the slot U-Boot
|
||||
+# actually booted (warden.slot on the cmdline), so /oem always matches the
|
||||
+# running kernel's slot. Falls through unchanged on a non-A/B image.
|
||||
+case "\$partname" in
|
||||
+ *_a|*_b)
|
||||
+ wslot=\$(sed -n 's/.*warden\.slot=\(_[ab]\).*/\1/p' /proc/cmdline)
|
||||
+ if [ -n "\$wslot" ]; then
|
||||
+ partname="\${partname%_[ab]}\$wslot"
|
||||
+ fi
|
||||
+ ;;
|
||||
+esac
|
||||
+part_dev=/dev/block/by-name/\$partname
|
||||
mountpt=\$2
|
||||
part_fstype=\$3
|
||||
part_realdev=\$(realpath \$part_dev)
|
||||
diff --git a/project/scripts/RkLunch-recovery.sh b/project/scripts/RkLunch-recovery.sh
|
||||
index 92c33ac29..9c5160b5f 100755
|
||||
--- a/project/scripts/RkLunch-recovery.sh
|
||||
+++ b/project/scripts/RkLunch-recovery.sh
|
||||
@@ -1,115 +1,270 @@
|
||||
#!/bin/sh
|
||||
+# WardenOS rescue image — runs as the recovery initramfs' RkLunch.sh.
|
||||
+#
|
||||
+# The rescue's ONE job (fota spec §8.2): become reachable and let a human
|
||||
+# recover the device. It is entered when both A/B slots are exhausted, or on
|
||||
+# a BCB 'boot-recovery' command. It restores nothing on its own initiative —
|
||||
+# a technician (or the ops team over the network) drives recovery with the
|
||||
+# helpers this script lays down in /usr/bin. Runbook:
|
||||
+# flare-edge docs/recovery-runbook.md.
|
||||
+#
|
||||
+# Two access paths, both authenticated (getty/telnetd via /bin/login against the
|
||||
+# pinned root credential), kept up together:
|
||||
+# 1. PRIMARY: a CDC-ACM serial console over USB (host opens /dev/ttyACM0). No
|
||||
+# IP — this is the reliable floor that survives the RNDIS usb0 flakiness (#26).
|
||||
+# 2. SECONDARY (network, for bulk image staging): usb0 RNDIS (172.32.0.93/16),
|
||||
+# plus eth0 DHCP -> /userdata/warden/rescue-net static -> link-local
|
||||
+# 169.254.86.86/16, with telnetd on top.
|
||||
+# The 'boot-recovery' BCB is cleared on entry so a failed rescue reboots to
|
||||
+# normal instead of looping.
|
||||
+#
|
||||
+# Source of truth: flare-edge sdk-patches/board/ — edit there, not in a
|
||||
+# built image.
|
||||
|
||||
-SD_DEVICES="mmcblk1 mmcblk2"
|
||||
-DEV_NAME=""
|
||||
-MOUNT_PATH=""
|
||||
-UPDATE_PACKAGE=""
|
||||
-UPDATE_OTA_DIR_PATH=""
|
||||
-delay_time=""
|
||||
-input_file="$1"
|
||||
-input_path="$2"
|
||||
+echo "==== WardenOS rescue image ===="
|
||||
+cat /proc/cmdline
|
||||
|
||||
-sleep 1
|
||||
-echo "Ready to update."
|
||||
+# S15linkmount_recovery already ran linkdev + mounted /userdata (if intact).
|
||||
+mkdir -p /userdata 2>/dev/null
|
||||
+mountpoint -q /userdata || mount /dev/block/by-name/userdata /userdata 2>/dev/null
|
||||
|
||||
-# Use the specified update package in preference.
|
||||
-if [ -f "$input_file" ]; then
|
||||
- UPDATE_PACKAGE=$(realpath $input_file)
|
||||
- UPDATE_OTA_DIR_PATH=$(dirname $UPDATE_PACKAGE)/update
|
||||
- [ -d "$input_path" ] && UPDATE_OTA_DIR_PATH="$input_path/update"
|
||||
+# ONE-SHOT recovery: clear the 'boot-recovery' BCB command (misc @16384) right
|
||||
+# now, so even if this rescue boot goes wrong (unreachable, wedged), a plain
|
||||
+# power-cycle returns to NORMAL boot instead of looping in recovery. The A/B
|
||||
+# slot metadata (misc @2048) is left untouched — this touches only the BCB
|
||||
+# command field. (If recovery was entered via exhausted slots rather than a BCB
|
||||
+# command there is nothing to clear; harmless.) This is the safety net that
|
||||
+# turns a failed rescue from a stranding into a reboot.
|
||||
+_MISC=$(realpath /dev/block/by-name/misc 2>/dev/null)
|
||||
+[ -n "$_MISC" ] && (
|
||||
+ # Backgrounded on purpose: a conv=fsync write to a degraded eMMC (a plausible
|
||||
+ # state on a device that needed recovery) can block in uninterruptible sleep
|
||||
+ # for the block layer's whole command-timeout/retry chain. Do NOT stall the
|
||||
+ # access paths below (ACM console / RNDIS / telnet) waiting on it — one-shot
|
||||
+ # only needs the BCB cleared before the NEXT reboot, and the rescue session
|
||||
+ # outlives a slow write. Report honestly if the write fails.
|
||||
+ if dd if=/dev/zero of="$_MISC" bs=1 seek=16384 count=32 \
|
||||
+ conv=notrunc,fsync 2>/dev/null && sync; then
|
||||
+ echo "rescue: boot-recovery BCB cleared (recovery is one-shot)"
|
||||
+ else
|
||||
+ echo "rescue: WARNING boot-recovery BCB clear FAILED — recovery may re-trigger next boot"
|
||||
+ fi
|
||||
+) &
|
||||
+
|
||||
+# ---- USB gadget: reachable over the same USB port as the main system, NO
|
||||
+# Ethernet cable / disassembly. A COMPOSITE gadget exposing TWO functions:
|
||||
+# - acm.gs0 (CDC-ACM serial): the RELIABLE console. The host just opens
|
||||
+# /dev/ttyACM0 — no netdev, no IP negotiation, none of the RNDIS
|
||||
+# usb0-netdev/IP race that left a rescue boot unreachable (#26). getty
|
||||
+# on /dev/ttyGS0 (below) gives an authenticated login over it.
|
||||
+# - rndis.gs0 (network at 172.32.0.93/16): the BULK path (staging images
|
||||
+# for rescue-restore). Best-effort — when it comes up, telnet works too.
|
||||
+# All built-in (USB_LIBCOMPOSITE / USB_F_ACM / USB_F_RNDIS / USB_CONFIGFS_* /
|
||||
+# USB_DWC3) on the built-in DWC3 UDC (ffb00000.usb).
|
||||
+setup_usb_gadget() {
|
||||
+ CFG=/sys/kernel/config
|
||||
+ mkdir -p $CFG 2>/dev/null
|
||||
+ mount -t configfs none $CFG 2>/dev/null
|
||||
+ G=$CFG/usb_gadget/rescue
|
||||
+ [ -d "$G" ] && return 0
|
||||
+ mkdir -p "$G" 2>/dev/null || return 1
|
||||
+ echo 0x2207 > "$G/idVendor" 2>/dev/null
|
||||
+ echo 0x0019 > "$G/idProduct" 2>/dev/null
|
||||
+ mkdir -p "$G/strings/0x409" 2>/dev/null
|
||||
+ echo "rescue" > "$G/strings/0x409/serialnumber" 2>/dev/null
|
||||
+ echo "BlueFlare" > "$G/strings/0x409/manufacturer" 2>/dev/null
|
||||
+ echo "Warden Rescue" > "$G/strings/0x409/product" 2>/dev/null
|
||||
+ # acm FIRST so the serial console is the primary interface; rndis second.
|
||||
+ mkdir -p "$G/functions/acm.gs0" 2>/dev/null
|
||||
+ mkdir -p "$G/functions/rndis.gs0" 2>/dev/null
|
||||
+ mkdir -p "$G/configs/b.1/strings/0x409" 2>/dev/null
|
||||
+ echo "rescue-acm+rndis" > "$G/configs/b.1/strings/0x409/configuration" 2>/dev/null
|
||||
+ ln -s "$G/functions/acm.gs0" "$G/configs/b.1/" 2>/dev/null
|
||||
+ ln -s "$G/functions/rndis.gs0" "$G/configs/b.1/" 2>/dev/null
|
||||
+ udc=$(ls /sys/class/udc/ 2>/dev/null | head -1)
|
||||
+ [ -n "$udc" ] && echo "$udc" > "$G/UDC" 2>/dev/null
|
||||
+ # ttyGS0 (the ACM console) appears the instant the gadget binds — no netdev,
|
||||
+ # so no race; the getty respawn below just waits for it. The RNDIS usb0
|
||||
+ # netdev is created ASYNCHRONOUSLY and is best-effort (its flakiness, #26, is
|
||||
+ # exactly why the ACM console exists). Poll for it and set the static IP.
|
||||
+ i=0
|
||||
+ while [ $i -lt 20 ]; do
|
||||
+ [ -e /sys/class/net/usb0 ] && break
|
||||
+ sleep 1; i=$((i + 1))
|
||||
+ done
|
||||
+ if [ -e /sys/class/net/usb0 ]; then
|
||||
+ ip link set usb0 up 2>/dev/null
|
||||
+ ip addr add 172.32.0.93/16 dev usb0 2>/dev/null
|
||||
+ echo "rescue: usb0 RNDIS up at 172.32.0.93 (UDC $udc, waited ${i}s)"
|
||||
+ else
|
||||
+ echo "rescue: usb0 netdev never appeared (UDC $udc) — use the /dev/ttyACM0 serial console"
|
||||
+ fi
|
||||
+}
|
||||
+setup_usb_gadget &
|
||||
|
||||
- echo "Update package: $UPDATE_PACKAGE"
|
||||
- mkdir -p $UPDATE_OTA_DIR_PATH
|
||||
- tar -xvf $UPDATE_PACKAGE -C $UPDATE_OTA_DIR_PATH
|
||||
- if [ $? -ne 0 ]; then
|
||||
- echo "Error: Decompression failed, please check the update package(tar)."
|
||||
- exit 1
|
||||
- fi
|
||||
+# ---- network up ----
|
||||
+ip link set lo up 2>/dev/null
|
||||
+if ip link set eth0 up 2>/dev/null; then
|
||||
+ # DHCP in the background; static/link-local addresses coexist with it.
|
||||
+ udhcpc -i eth0 -b -t 10 -T 3 2>/dev/null &
|
||||
|
||||
- sh $UPDATE_OTA_DIR_PATH/RK_OTA_update.sh
|
||||
- if [ $? -eq 0 ]; then
|
||||
- echo "Upgrade successfully."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- reboot
|
||||
- return
|
||||
- else
|
||||
- echo "Error: Upgrade failed, please check the partition."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- exit 1
|
||||
- fi
|
||||
-else
|
||||
- echo "Warning: Update package ($1) was not found, checking SD card..."
|
||||
+ NETCFG=/userdata/warden/rescue-net
|
||||
+ if [ -r "$NETCFG" ]; then
|
||||
+ # PARSE strictly as ip=<cidr> / gw=<addr> — do NOT dot-source. `.`ing this
|
||||
+ # file would EXECUTE it as root: /userdata is writable, so a prior
|
||||
+ # compromise (or any file-write bug) could plant arbitrary shell that runs
|
||||
+ # on every rescue entry, before the telnet credential-pin below, defeating
|
||||
+ # it entirely. Restrict values to IP/CIDR characters.
|
||||
+ ip=$(sed -n 's/^ip=\([0-9./]\{1,32\}\)$/\1/p' "$NETCFG" 2>/dev/null | head -1)
|
||||
+ gw=$(sed -n 's/^gw=\([0-9.]\{1,15\}\)$/\1/p' "$NETCFG" 2>/dev/null | head -1)
|
||||
+ [ -n "$ip" ] && ip addr add "$ip" dev eth0 2>/dev/null
|
||||
+ [ -n "$gw" ] && ip route add default via "$gw" 2>/dev/null
|
||||
+ fi
|
||||
+
|
||||
+ # Link-local last resort — a technician with a laptop and a cable can
|
||||
+ # always reach 169.254.86.86.
|
||||
+ ip addr add 169.254.86.86/16 dev eth0 2>/dev/null
|
||||
fi
|
||||
|
||||
-# Check SD card when not input update package path.
|
||||
-for DEV_NAME in $SD_DEVICES
|
||||
-do
|
||||
- echo "************** DEV_NAME=$DEV_NAME **************"
|
||||
- delay_time=1
|
||||
- mount | grep -i "$DEV_NAME"
|
||||
- if [ $? -eq 0 ]; then
|
||||
- MOUNT_PATH=`mount | grep -i "$DEV_NAME" | awk '{printf $3}'`
|
||||
- echo "SDcard is already mounted in $MOUNT_PATH"
|
||||
- else
|
||||
- MOUNT_PATH=/mnt/sdcard
|
||||
- fi
|
||||
+# WireGuard phone-home if the identity and a rescue peer config survive on
|
||||
+# /userdata (WireGuard is built into this kernel; wg tool if present).
|
||||
+WGCONF=/userdata/warden/rescue-wg.conf
|
||||
+if [ -r "$WGCONF" ] && command -v wg >/dev/null 2>&1; then
|
||||
+ ip link add wg0 type wireguard 2>/dev/null &&
|
||||
+ wg setconf wg0 "$WGCONF" 2>/dev/null &&
|
||||
+ ip link set wg0 up 2>/dev/null &&
|
||||
+ echo "rescue: wg0 up from $WGCONF"
|
||||
+fi
|
||||
|
||||
- while [ $delay_time -le 5 ]
|
||||
- do
|
||||
- usleep 200000
|
||||
- dev=$(ls /dev/$DEV_NAME*)
|
||||
- if [ -n "$dev" ]; then
|
||||
- echo Find the device: $dev
|
||||
- break 2
|
||||
- fi
|
||||
- echo "Find $DEV_NAME failed $delay_time times"
|
||||
- delay_time=$(($delay_time+1))
|
||||
- done
|
||||
-done
|
||||
+# ---- remote access ----
|
||||
+# Authenticated telnet. The recovery ramdisk ships busybox's skeleton
|
||||
+# /etc/shadow (root == the SDK-wide public default "rockchip"), so pin root to a
|
||||
+# known device credential and run telnetd THROUGH /bin/login. Do NOT use
|
||||
+# `telnetd -l /bin/sh`: that execs a root shell on connect with no password
|
||||
+# prompt (reachable over eth0/link-local/usb0), defeating the credential the
|
||||
+# runbook documents.
|
||||
+#
|
||||
+# Credential source, in order: (1) a per-device override on /userdata
|
||||
+# (rescue-shadow, a single "root:<hash>:..." line — the same runtime-override
|
||||
+# pattern as rescue-net/rescue-wg.conf, so production password rotation reaches
|
||||
+# the rescue), else (2) the compiled-in default password 'root'
|
||||
+# (openssl passwd -1 -salt wardenrs root; matches the main firmware).
|
||||
+DEFAULT_ROOT_LINE='root:$1$wardenrs$F.aYwbBz69WjSvwa3RNRF1:19664::::::'
|
||||
+ROOT_LINE=""
|
||||
+RESCUE_SHADOW=/userdata/warden/rescue-shadow
|
||||
+[ -r "$RESCUE_SHADOW" ] && ROOT_LINE=$(grep '^root:' "$RESCUE_SHADOW" 2>/dev/null | head -1)
|
||||
+[ -n "$ROOT_LINE" ] || ROOT_LINE="$DEFAULT_ROOT_LINE"
|
||||
+WANT_HASH=$(printf '%s' "$ROOT_LINE" | cut -d: -f2)
|
||||
|
||||
-if [ -z "$dev" ]; then
|
||||
- echo "Error: Not found device, skipping upgrade."
|
||||
- sh /usr/bin/RK_OTA_erase_misc.sh
|
||||
- [ $? -eq 0 ] && reboot
|
||||
- exit 1
|
||||
+if [ -f /etc/shadow ]; then
|
||||
+ grep -v '^root:' /etc/shadow > /etc/shadow.new 2>/dev/null
|
||||
+ { printf '%s\n' "$ROOT_LINE"; cat /etc/shadow.new; } > /etc/shadow
|
||||
+ rm -f /etc/shadow.new
|
||||
+ chmod 600 /etc/shadow 2>/dev/null
|
||||
fi
|
||||
|
||||
-mkdir -p $MOUNT_PATH
|
||||
-UPDATE_OTA_DIR_PATH=$MOUNT_PATH/update
|
||||
-UPDATE_PACKAGE=$MOUNT_PATH/update_ota.tar
|
||||
+# Fail CLOSED: expose access only if the intended root hash actually landed.
|
||||
+# Exposing a shell over the ramdisk's public 'rockchip' default would be worse
|
||||
+# than no access at all (recover via USB/MaskRom instead). Both the serial
|
||||
+# console (getty->login) and telnet (telnetd -l /bin/login) authenticate against
|
||||
+# this same pinned credential.
|
||||
+GOT_HASH=$(grep '^root:' /etc/shadow 2>/dev/null | head -1 | cut -d: -f2)
|
||||
+if [ -n "$WANT_HASH" ] && [ "$GOT_HASH" = "$WANT_HASH" ]; then
|
||||
+ # PRIMARY, always-reachable path: an authenticated login on the CDC-ACM
|
||||
+ # serial console. The host opens /dev/ttyACM0 (no IP). getty runs /bin/login;
|
||||
+ # the respawn loop waits for ttyGS0 (created when the acm gadget binds) and
|
||||
+ # re-runs getty after each logout, so the console is durable.
|
||||
+ ( while true; do
|
||||
+ [ -e /dev/ttyGS0 ] && getty -L 115200 ttyGS0 vt100
|
||||
+ sleep 1
|
||||
+ done ) &
|
||||
+ echo "rescue: serial console up on /dev/ttyGS0 (host: /dev/ttyACM0), authenticated"
|
||||
+ # SECONDARY: telnet over the network (usb0 RNDIS / eth0), when it comes up.
|
||||
+ telnetd -l /bin/login
|
||||
+ echo "rescue: telnetd up (authenticated: root / device password)"
|
||||
+else
|
||||
+ echo "rescue: root-credential pin FAILED — NO shell exposed; recover via USB/MaskRom"
|
||||
+fi
|
||||
|
||||
-for SD_DEV in $dev
|
||||
-do
|
||||
- echo "************** SD_DEV=$SD_DEV **************"
|
||||
- if mount -t vfat $SD_DEV $MOUNT_PATH ; then
|
||||
- if [ -f $UPDATE_PACKAGE ]; then
|
||||
- echo "Update package: $UPDATE_PACKAGE"
|
||||
- mkdir -p $UPDATE_OTA_DIR_PATH
|
||||
- tar -xvf $UPDATE_PACKAGE -C $UPDATE_OTA_DIR_PATH
|
||||
- if [ $? -ne 0 ]; then
|
||||
- echo "Error: Decompression failed, please check the update package(tar)."
|
||||
- exit 1
|
||||
- fi
|
||||
+# ---- recovery helpers ----
|
||||
+cat >/usr/bin/rescue-status <<'HLP'
|
||||
+#!/bin/sh
|
||||
+echo "== slots (misc AB metadata @2048) =="
|
||||
+MISC=$(realpath /dev/block/by-name/misc)
|
||||
+dd if=$MISC bs=1 skip=2048 count=32 2>/dev/null | hexdump -C
|
||||
+echo "== partitions =="
|
||||
+ls -l /dev/block/by-name/
|
||||
+echo "== staged images (if any) =="
|
||||
+ls -l /userdata/warden/rescue/ 2>/dev/null || echo none
|
||||
+HLP
|
||||
+chmod +x /usr/bin/rescue-status
|
||||
|
||||
- sh $UPDATE_OTA_DIR_PATH/RK_OTA_update.sh
|
||||
- if [ $? -eq 0 ]; then
|
||||
- echo "Upgrade successfully."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- reboot
|
||||
- return
|
||||
- else
|
||||
- echo "Error: Upgrade failed, please check the partition."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- exit 1
|
||||
- fi
|
||||
- else
|
||||
- echo "Warning: Not found update package: $UPDATE_PACKAGE"
|
||||
- fi
|
||||
- umount $MOUNT_PATH
|
||||
- fi
|
||||
+cat >/usr/bin/rescue-slot-reset <<'HLP'
|
||||
+#!/bin/sh
|
||||
+# Reset A/B metadata to provision defaults (A 15/0/1 preferred, B 14/0/1) —
|
||||
+# use after restoring slot images. Bytes generated by (and kept in sync
|
||||
+# with) flare-edge tools/mk-misc.py; CRC32-BE over the first 28 bytes.
|
||||
+set -e
|
||||
+MISC=$(realpath /dev/block/by-name/misc)
|
||||
+printf '\x00\x41\x42\x30\x01\x00\x00\x00\x0f\x00\x01\x00\x0e\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xda\x93\x36\x79' >/tmp/absector
|
||||
+dd if=/tmp/absector of=$MISC bs=1 seek=2048 conv=notrunc,fsync 2>/dev/null
|
||||
+sync
|
||||
+echo "slot metadata reset to provision defaults"
|
||||
+HLP
|
||||
+chmod +x /usr/bin/rescue-slot-reset
|
||||
+
|
||||
+cat >/usr/bin/rescue-restore <<'HLP'
|
||||
+#!/bin/sh
|
||||
+# rescue-restore: write staged images from /userdata/warden/rescue/ onto BOTH
|
||||
+# slots, reset the A/B metadata to provision defaults, reboot.
|
||||
+# Stage boot.img / oem.img / rootfs.img there first (over the rescue
|
||||
+# network), then run this.
|
||||
+#
|
||||
+# `rescue-restore wipe-config` ALSO clears the /userdata rescue overrides
|
||||
+# (rescue-shadow / rescue-net / rescue-wg.conf). A plain restore preserves them
|
||||
+# (they survive reflash by design), but a planted rescue-shadow backdoor or a
|
||||
+# rogue rescue-wg peer would then outlive the reflash — so use wipe-config when
|
||||
+# recovering from a suspected COMPROMISE rather than a plain hardware fault.
|
||||
+set -e
|
||||
+if [ "$1" = "wipe-config" ]; then
|
||||
+ rm -f /userdata/warden/rescue-shadow /userdata/warden/rescue-net \
|
||||
+ /userdata/warden/rescue-wg.conf
|
||||
+ echo "rescue: cleared /userdata rescue overrides (compromise recovery)"
|
||||
+fi
|
||||
+D=/userdata/warden/rescue
|
||||
+for img in boot oem rootfs; do
|
||||
+ [ -r "$D/$img.img" ] || { echo "missing $D/$img.img"; exit 1; }
|
||||
+done
|
||||
+for slot in _a _b; do
|
||||
+ for img in boot oem rootfs; do
|
||||
+ dev=$(realpath /dev/block/by-name/$img$slot)
|
||||
+ sz=$(wc -c < "$D/$img.img")
|
||||
+ echo "writing $img.img -> $dev ($sz bytes)"
|
||||
+ dd if="$D/$img.img" of="$dev" bs=1M conv=fsync
|
||||
+ sync
|
||||
+ # Read-back verify BEFORE the slot-reset below commits both slots as
|
||||
+ # successful. dd alone reports only its own write, not what landed
|
||||
+ # (bad USB stick, dropped transfer, eMMC glitch); writing a truncated
|
||||
+ # image and then stamping the slot "successful" is precisely how a
|
||||
+ # Level-1-recoverable device becomes a Level-2 (MaskRom-only) brick.
|
||||
+ # head -c stops the read at the image length, so this is cheap even for
|
||||
+ # the 1G rootfs (no byte-at-a-time dd).
|
||||
+ src_sum=$(md5sum "$D/$img.img" | cut -d' ' -f1)
|
||||
+ dev_sum=$(dd if="$dev" bs=1M 2>/dev/null | head -c "$sz" | md5sum | cut -d' ' -f1)
|
||||
+ if [ "$src_sum" != "$dev_sum" ]; then
|
||||
+ echo "VERIFY FAILED for $img$slot ($src_sum != $dev_sum)"
|
||||
+ echo "ABORTING: slots NOT committed; re-stage a good $img.img and retry."
|
||||
+ exit 2
|
||||
+ fi
|
||||
+ echo " verified $img$slot ($src_sum)"
|
||||
+ done
|
||||
done
|
||||
+rescue-slot-reset
|
||||
+echo "restore complete; rebooting"
|
||||
+sync
|
||||
+devmem 0xff3b0c08 32 0xfdb9 2>/dev/null || true
|
||||
+reboot -f
|
||||
+HLP
|
||||
+chmod +x /usr/bin/rescue-restore
|
||||
|
||||
-echo "Recovery upgrade failed, skipping."
|
||||
-sh /usr/bin/RK_OTA_erase_misc.sh
|
||||
-[ $? -eq 0 ] && reboot
|
||||
-exit 1
|
||||
+echo "==== rescue ready: telnet in; rescue-status / rescue-restore ===="
|
||||
@@ -0,0 +1,18 @@
|
||||
diff --git a/sysdrv/tools/board/android-tools/S50usbdevice b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
index d29c2334b..b175b77fb 100755
|
||||
--- a/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
+++ b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
@@ -6,6 +6,13 @@
|
||||
# Load default env variables from profiles
|
||||
. /etc/profile
|
||||
|
||||
+# flare-edge: the OTG port is a USB HOST in router (and the unset-role default),
|
||||
+# so building a gadget here is pointless AND harmful — the dwc3 "failed to add
|
||||
+# gadget" + the usb2-phy "illegal mode" it triggers race with the USB-Ethernet
|
||||
+# host enumeration and intermittently kill eth1 at boot. Only run in client role;
|
||||
+# S26usbhost re-invokes this explicitly when switching to client. (unset -> router)
|
||||
+[ "$(cat /userdata/warden/role 2>/dev/null || echo 1)" = "1" ] && exit 0
|
||||
+
|
||||
UMS_EN=off
|
||||
ADB_EN=on
|
||||
MTP_EN=off
|
||||
@@ -0,0 +1,22 @@
|
||||
diff --git a/project/build.sh b/project/build.sh
|
||||
index 6fab501..6adbe35 100755
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -7,7 +7,7 @@ RECORD_IFS="$IFS"
|
||||
|
||||
function unset_env_config_rk() {
|
||||
local tmp_file=$(mktemp)
|
||||
- env | grep -oh "^RK_.*=" >$tmp_file || true
|
||||
+ env | grep -oh "^RK_[A-Za-z0-9_]*=" >$tmp_file || true
|
||||
source $tmp_file
|
||||
rm -f $tmp_file
|
||||
}
|
||||
@@ -383,7 +383,7 @@ function save_board_config() {
|
||||
|
||||
function unset_board_config_all() {
|
||||
local tmp_file=$(mktemp)
|
||||
- grep -oh "^export.*RK_.*=" $(find cfg -name "BoardConfig*.mk") >$tmp_file
|
||||
+ grep -oh "^export RK_[A-Za-z0-9_]*=" $(find cfg -name "BoardConfig*.mk") >$tmp_file
|
||||
source $tmp_file
|
||||
rm -f $tmp_file
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
Point the build at buildroot-2025.02.8.
|
||||
|
||||
The vendor SDK ships buildroot-2023.02.6 and build.sh pointed at it. The tree we
|
||||
actually build against is 2025.02.8, and nothing recorded the switch: a rebuild
|
||||
from a pristine vendor checkout plus this patch series silently produced a
|
||||
different userspace.
|
||||
|
||||
The 2.6 GB tree itself cannot live in this repo and is NOT in the vendor
|
||||
checkout either; obtaining it is covered by the SDK's build/vendor.manifest.
|
||||
This patch records only the one line that selects it.
|
||||
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -34,7 +34,7 @@
|
||||
GLOBAL_SDK_VERSION=""
|
||||
WIFI_NEW_CONF=${SDK_APP_DIR}/wifi_app/wpa_supplicant_new.conf
|
||||
WIFI_CONF=${SDK_APP_DIR}/wifi_app/wpa_supplicant.conf
|
||||
-BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2023.02.6
|
||||
+BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2025.02.8
|
||||
BUILDROOT_CONFIG_FILE=${BUILDROOT_PATH}/.config
|
||||
SDK_CONFIG_DIR=${SDK_ROOT_DIR}/config
|
||||
DTS_CONFIG=${SDK_CONFIG_DIR}/dts_config
|
||||
@@ -0,0 +1,60 @@
|
||||
Authenticate the recovery console (#27).
|
||||
|
||||
The busybox tiny_rootfs skeleton runs `::respawn:-/bin/sh` on /dev/console,
|
||||
which on this board is ttyFIQ0, the debug UART. That is a root prompt with no
|
||||
login for anyone who opens the case, and it bypasses the fail-closed credential
|
||||
pin RkLunch-recovery.sh enforces for every other rescue path. The skeleton's own
|
||||
ttyFIQ0 getty line is commented out directly below it, so the bare shell was the
|
||||
only console and the unauthenticated one.
|
||||
|
||||
build.sh now deletes that line when it stages the ramdisk, and the recovery
|
||||
script spawns an authenticated getty on the console inside its gated block, so
|
||||
a failed pin exposes nothing on the UART either.
|
||||
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -956,6 +956,24 @@
|
||||
cp -fa $PROJECT_TOP_DIR/scripts/RkLunch-recovery.sh $RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/usr/bin/RkLunch.sh
|
||||
cp -fa $PROJECT_TOP_DIR/scripts/boot4recovery.its $RK_PROJECT_PATH_RAMDISK
|
||||
|
||||
+ # flare-edge (#27): the busybox tiny_rootfs skeleton runs an
|
||||
+ # UNAUTHENTICATED root shell on /dev/console -- which on this board is
|
||||
+ # ttyFIQ0, the debug UART:
|
||||
+ #
|
||||
+ # ::respawn:-/bin/sh
|
||||
+ #
|
||||
+ # That hands a root prompt with no login to anyone who opens the case,
|
||||
+ # bypassing the fail-closed credential pin RkLunch-recovery.sh enforces for
|
||||
+ # every other rescue path (ttyGS0 getty, telnetd -l /bin/login). Note the
|
||||
+ # skeleton's own ttyFIQ0 getty line is commented out right below it, so the
|
||||
+ # bare shell was the only console -- and the unauthenticated one.
|
||||
+ #
|
||||
+ # Removed here; RkLunch-recovery.sh spawns an authenticated getty on the
|
||||
+ # console INSIDE its gated block instead, so the debug UART now answers to
|
||||
+ # the same pinned credential as everything else.
|
||||
+ sed -i '/^::respawn:-\/bin\/sh$/d' \
|
||||
+ $RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/etc/inittab
|
||||
+
|
||||
mkdir -p $(dirname $RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT)
|
||||
cat >$RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT <<EOF
|
||||
#!/bin/sh
|
||||
--- a/project/scripts/RkLunch-recovery.sh
|
||||
+++ b/project/scripts/RkLunch-recovery.sh
|
||||
@@ -179,6 +179,17 @@
|
||||
sleep 1
|
||||
done ) &
|
||||
echo "rescue: serial console up on /dev/ttyGS0 (host: /dev/ttyACM0), authenticated"
|
||||
+ # The DEBUG UART (/dev/console -> ttyFIQ0). The ramdisk skeleton used to run
|
||||
+ # `::respawn:-/bin/sh` from its inittab here: a root shell with no login,
|
||||
+ # reachable by anyone who opened the case, bypassing this entire gate (#27).
|
||||
+ # project/build.sh now deletes that line, so the console is owned HERE and
|
||||
+ # authenticates against the same pinned credential as every other path.
|
||||
+ # Inside the gate, so a failed pin exposes nothing on the UART either.
|
||||
+ ( while true; do
|
||||
+ getty -L console 0 vt100
|
||||
+ sleep 1
|
||||
+ done ) &
|
||||
+ echo "rescue: debug-UART console up on /dev/console, authenticated"
|
||||
# SECONDARY: telnet over the network (usb0 RNDIS / eth0), when it comes up.
|
||||
telnetd -l /bin/login
|
||||
echo "rescue: telnetd up (authenticated: root / device password)"
|
||||
@@ -0,0 +1,77 @@
|
||||
flare-edge: compose the USB gadget once, instead of rebinding twice.
|
||||
|
||||
Every unbind/rebind of a live gadget is a full controller teardown; the
|
||||
host loses usb0 and ttyACM0 and the halt times out (issue #145).
|
||||
|
||||
--- a/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
+++ b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
@@ -17,7 +17,13 @@
|
||||
ADB_EN=on
|
||||
MTP_EN=off
|
||||
NTB_EN=off
|
||||
-ACM_EN=off
|
||||
+# flare-edge: composed here rather than linked afterwards by S52usbacm. Every
|
||||
+# unbind/rebind of a live gadget is a full teardown -- the host loses usb0 and
|
||||
+# ttyACM0, and the controller logs "Host halt failed, -110" on the way down --
|
||||
+# so the panel's console function is built into the gadget before it is ever
|
||||
+# bound (issue #145). S52usbacm still runs; it now finds acm already linked,
|
||||
+# skips its rebind, and only starts the ttyGS0 getty.
|
||||
+ACM_EN=on
|
||||
UAC1_EN=off
|
||||
UAC2_EN=off
|
||||
UVC_EN=off
|
||||
@@ -73,6 +79,46 @@
|
||||
mkdir ${USB_FUNCTIONS_DIR}/hid.usb0
|
||||
}
|
||||
|
||||
+# flare-edge: the stable, serial-derived RNDIS MAC. MUST be applied before
|
||||
+# bind_functions links rndis.gs0 into the config, NOT merely before the UDC
|
||||
+# bind: rndis_alloc() runs at link time, takes opts->refcnt and immediately
|
||||
+# captures the MAC via gether_get_host_addr_u8(). After that the configfs
|
||||
+# store returns -EBUSY (u_ether_configfs.h guards on opts->refcnt), so a write
|
||||
+# here is silently discarded and the gadget enumerates with the kernel's
|
||||
+# random MAC (issue #157).
|
||||
+#
|
||||
+# S51usbmac used to repair that afterwards by tearing down a live gadget purely
|
||||
+# to change two strings (issue #145), which is the second enumeration a host
|
||||
+# sees on every boot. It still runs and is now a no-op that confirms the result.
|
||||
+#
|
||||
+# The writes are checked. Losing the stable MAC is not fatal, so this does not
|
||||
+# abort the boot, but it must never fail silently again: silence is exactly how
|
||||
+# #157 survived.
|
||||
+flare_stamp_rndis_mac()
|
||||
+{
|
||||
+ RN=${USB_FUNCTIONS_DIR}/rndis.gs0
|
||||
+ [ -d "$RN" ] || return 0
|
||||
+ SER=$(tr -d '\000' < /proc/device-tree/serial-number 2>/dev/null)
|
||||
+ [ -n "$SER" ] || return 0
|
||||
+ H=$(printf '%s' "$SER" | md5sum | cut -c1-10)
|
||||
+ A=$(echo "$H" | cut -c1-2); B=$(echo "$H" | cut -c3-4)
|
||||
+ C=$(echo "$H" | cut -c5-6); D=$(echo "$H" | cut -c7-8)
|
||||
+ E=$(echo "$H" | cut -c9-10)
|
||||
+ WANT="02:$A:$B:$C:$D:$E"
|
||||
+ # Already ours: S26usbhost re-runs this script on a role switch, and the
|
||||
+ # second run finds configfs present, so configfs_init is skipped and the
|
||||
+ # function is still linked from the first run. The MAC was set correctly
|
||||
+ # then, so writing it again would be refused with -EBUSY and warn about a
|
||||
+ # random MAC that is not in use. Nothing to do, and nothing to report.
|
||||
+ [ "$(cat "$RN/host_addr" 2>/dev/null)" = "$WANT" ] && return 0
|
||||
+ if ! echo "$WANT" > "$RN/host_addr" 2>/dev/null; then
|
||||
+ echo "S50usbdevice: rndis host_addr write refused and the MAC is NOT already correct; the function is linked, so the gadget will use a random MAC (#157)" > /dev/kmsg 2>/dev/null
|
||||
+ return 1
|
||||
+ fi
|
||||
+ echo "06:$A:$B:$C:$D:$E" > "$RN/dev_addr" 2>/dev/null ||
|
||||
+ echo "S50usbdevice: rndis dev_addr write refused (#157)" > /dev/kmsg 2>/dev/null
|
||||
+}
|
||||
+
|
||||
configfs_init()
|
||||
{
|
||||
echo "Debug: configfs_init"
|
||||
@@ -426,6 +450,7 @@
|
||||
use_os_desc
|
||||
echo $PID > ${USB_CONFIGFS_DIR}/idProduct
|
||||
+ flare_stamp_rndis_mac
|
||||
bind_functions
|
||||
pre_run_binary
|
||||
sleep 1
|
||||
UDC=`ls /sys/class/udc/| awk '{print $1}'`
|
||||
@@ -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,45 @@
|
||||
Treat an unset USB role as client in S50usbdevice.
|
||||
|
||||
0004 gated the gadget build on `role || echo 1`, so a fresh /userdata (no
|
||||
role file) read as router and S50usbdevice exited before composing the
|
||||
gadget. Every other reader (flare-edge S26usbhost, S35iptables,
|
||||
usb-nic-hotplug.sh, wifi-link-watchdog.sh, flared's schema) defaults an
|
||||
unset role to client (0), so S26usbhost put the port in device role with no
|
||||
gadget to bind: a freshly provisioned or factory-reset panel had no usb0
|
||||
recovery link until its second boot (flare-edge#278).
|
||||
|
||||
A separate patch rather than an edit to 0004: tools/build-firmware.sh
|
||||
applies the series idempotently, and on an SDK that already carries 0004
|
||||
and 0008 an edited 0004 neither applies nor reverse-applies, so it would be
|
||||
skipped as inconclusive and the old gate would keep shipping. This one
|
||||
applies on top of either a pristine replay or an already-patched tree.
|
||||
|
||||
diff --git a/sysdrv/tools/board/android-tools/S50usbdevice b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
index b521af4..fd8b693 100755
|
||||
--- a/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
+++ b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
@@ -6,12 +6,19 @@
|
||||
# Load default env variables from profiles
|
||||
. /etc/profile
|
||||
|
||||
-# flare-edge: the OTG port is a USB HOST in router (and the unset-role default),
|
||||
-# so building a gadget here is pointless AND harmful — the dwc3 "failed to add
|
||||
+# flare-edge: only build the gadget in client role. A router's OTG port is a
|
||||
+# USB HOST, where a gadget is pointless AND harmful: the dwc3 "failed to add
|
||||
# gadget" + the usb2-phy "illegal mode" it triggers race with the USB-Ethernet
|
||||
-# host enumeration and intermittently kill eth1 at boot. Only run in client role;
|
||||
-# S26usbhost re-invokes this explicitly when switching to client. (unset -> router)
|
||||
-[ "$(cat /userdata/warden/role 2>/dev/null || echo 1)" = "1" ] && exit 0
|
||||
+# host enumeration and intermittently kill eth1 at boot. S26usbhost re-invokes
|
||||
+# this explicitly when switching to client.
|
||||
+#
|
||||
+# An UNSET role is client (0), the fresh-install default every other reader
|
||||
+# uses (S26usbhost, S35iptables, usb-nic-hotplug.sh, wifi-link-watchdog.sh,
|
||||
+# flared's schema). This gate used to read unset as router, so a fresh store
|
||||
+# set the port to device role with no gadget to bind and came up with no usb0
|
||||
+# until a second boot (flare-edge#278). flare-edge's
|
||||
+# tests/guards/run-role-default-tests.sh pins this line to the other readers.
|
||||
+[ "$(cat /userdata/warden/role 2>/dev/null || echo 0)" = "1" ] && exit 0
|
||||
|
||||
UMS_EN=off
|
||||
ADB_EN=on
|
||||
@@ -0,0 +1,158 @@
|
||||
Drop adbd TCP listeners and rebuild on patch change
|
||||
|
||||
Rockchip's 0015 android-tools patch made adbd open TCP 5555 whenever USB is
|
||||
up, and the non-secure branch also opened tcp:5037 on 127.0.0.1. S50usbdevice
|
||||
starts adbd with no arguments, so every panel ran both listeners: 0.0.0.0:5555
|
||||
(reachable from the LAN) and 127.0.0.1:5037. Found on bench panel 10.255.1.55
|
||||
(flare-edge#3129).
|
||||
|
||||
This patch adds android-tools-patches/0017-no-adb-tcp-listener.patch, which
|
||||
removes both calls from the device half of adb_main(), and applies it last in
|
||||
android-tools.patch.sh. USB stays the only transport, so the USB adbd path is
|
||||
unchanged.
|
||||
|
||||
It also closes a build gap (bfe-core1106-sdk#44). The Makefile rebuilt adbd
|
||||
only when out/usr/bin/adbd was missing, so a patch-set change never reached an
|
||||
image built on an SDK tree that already held the binary. The Makefile now
|
||||
gates adbd on adbd-current.sh: the build writes a stamp holding a hash of the
|
||||
Makefile, the gate script, the patch set and the two adbd source tarballs, and
|
||||
a missing or stale stamp rebuilds adbd (bfe-core1106-sdk#49).
|
||||
|
||||
The rule stops at the first failed step: a debian series entry, an
|
||||
android-tools.patch.sh step (run with -e), the build, or the copy into
|
||||
out/usr/bin. The stamp is written last, so no binary that was not built from
|
||||
the patch set gets one (bfe-core1106-sdk#45).
|
||||
|
||||
Regression tests: luckfox-sdk-patches/tests/test-adbd-no-tcp.sh runs the rule
|
||||
under make with stub toolchains. It checks the listeners, the fail-closed
|
||||
cases, the stamp, a source tarball change and the gate that the Makefile
|
||||
evaluates (bfe-core1106-sdk#46, #49). tests/adbd-no-tcp-cases.sh runs the real
|
||||
patch, the unpatched base and mutants that must fail.
|
||||
|
||||
diff --git a/sysdrv/tools/board/android-tools/Makefile b/sysdrv/tools/board/android-tools/Makefile
|
||||
index bb72255..7ec24f7 100644
|
||||
--- a/sysdrv/tools/board/android-tools/Makefile
|
||||
+++ b/sysdrv/tools/board/android-tools/Makefile
|
||||
@@ -23,6 +23,15 @@ PKG_TARBALL_DEBIAN := android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz
|
||||
PKG_BIN := out
|
||||
PKG_INSTALL_BIN_DIR := $(CURRENT_DIR)/$(PKG_BIN)/usr/bin
|
||||
|
||||
+# flare-edge#3129: adbd is rebuilt whenever its inputs change. The stamp holds
|
||||
+# the hash of this Makefile, adbd-current.sh, the android-tools patch set and
|
||||
+# the two adbd source tarballs. An adbd without a matching stamp (left in out/
|
||||
+# by a build from other inputs) is built again from the regenerated source.
|
||||
+# The series, patch, build and copy steps stop the rule on failure; the stamp is
|
||||
+# written last, so no binary that was not built from these inputs gets one (bfe-core1106-sdk#45).
|
||||
+ADBD_STAMP := $(CURRENT_DIR)/$(PKG_BIN)/.adbd-inputs
|
||||
+ADBD_INPUTS := $(shell cat $(CURRENT_DIR)/Makefile $(CURRENT_DIR)/adbd-current.sh $(CURRENT_DIR)/$(PKG_PATCHES_ANDROID_TOOLS)/* $(CURRENT_DIR)/$(PKG_TARBALL_ANDROID_TOOLS) $(CURRENT_DIR)/$(PKG_TARBALL_DEBIAN) | sha256sum | cut -d' ' -f1)
|
||||
+
|
||||
PKG_DEP_OPENSSL := $(CURRENT_DIR)/../toolkits/openssl
|
||||
PKG_DEP_ZLIB := $(CURRENT_DIR)/../toolkits/zlib
|
||||
|
||||
@@ -36,7 +45,7 @@ PKG_CONF_OPTS += -mthumb -Wa,-mimplicit-it=thumb -mthumb-interwork
|
||||
endif
|
||||
|
||||
all: dep-openssl
|
||||
- @test -f $(PKG_INSTALL_BIN_DIR)/adbd || (\
|
||||
+ @sh $(CURRENT_DIR)/adbd-current.sh $(PKG_INSTALL_BIN_DIR)/adbd $(ADBD_STAMP) $(ADBD_INPUTS) || (\
|
||||
rm -rf $(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS); \
|
||||
tar -xf $(PKG_TARBALL_ANDROID_TOOLS); \
|
||||
tar -xf $(PKG_TARBALL_DEBIAN) -C $(PKG_NAME_ANDROID_TOOLS); \
|
||||
@@ -45,16 +54,17 @@ all: dep-openssl
|
||||
pushd $(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS)/; \
|
||||
cp -af $(CURRENT_DIR)/$(PKG_PATCHES_ANDROID_TOOLS)/* ./; \
|
||||
for item in `cat ./debian/patches/series`; do \
|
||||
- patch -p1 < ./debian/patches/$$item; \
|
||||
+ patch -p1 < ./debian/patches/$$item || exit 1; \
|
||||
done; \
|
||||
- $(SHELL) ./android-tools.patch.sh; \
|
||||
+ $(SHELL) -e ./android-tools.patch.sh || exit 1; \
|
||||
CC="$(SYSDRV_CROSS)-gcc" GCC="$(SYSDRV_CROSS)-gcc" CXX="$(SYSDRV_CROSS)-g++" CPP="$(SYSDRV_CROSS)-cpp" \
|
||||
CFLAGS="$(PKG_CONF_OPTS)" CPPFLAGS="$(PKG_CONF_OPTS)" \
|
||||
CXXFLAGS="$(PKG_CONF_OPTS)" LDFLAGS="$(PKG_CONF_OPTS) $(PKG_ADBD_BUILD_STATIC)" \
|
||||
make -j$(SYSDRV_JOBS) -C $(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS)/$(PKG_BIN) \
|
||||
SRCDIR=$(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS) \
|
||||
-f $(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS)/debian/makefiles/adbd.mk 1>/dev/null || exit -1; \
|
||||
- cp -f $(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS)/$(PKG_BIN)/adbd $(PKG_INSTALL_BIN_DIR)/ ; \
|
||||
+ cp -f $(CURRENT_DIR)/$(PKG_NAME_ANDROID_TOOLS)/$(PKG_BIN)/adbd $(PKG_INSTALL_BIN_DIR)/ || exit 1; \
|
||||
+ echo $(ADBD_INPUTS) > $(ADBD_STAMP) || exit 1; \
|
||||
popd; )
|
||||
$(SYSDRV_CROSS)-strip -s $(PKG_INSTALL_BIN_DIR)/adbd ;
|
||||
@mkdir -p $(PKG_BIN)/etc/init.d;
|
||||
diff --git a/sysdrv/tools/board/android-tools/adbd-current.sh b/sysdrv/tools/board/android-tools/adbd-current.sh
|
||||
new file mode 100644
|
||||
index 0000000..df4bd81
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/tools/board/android-tools/adbd-current.sh
|
||||
@@ -0,0 +1,14 @@
|
||||
+#!/bin/sh
|
||||
+# adbd-current.sh ADBD STAMP INPUTS
|
||||
+# Exit 0 when the built adbd is current: it exists and its stamp holds the hash
|
||||
+# of the inputs it was built from (see the stamp logic in the Makefile). Any
|
||||
+# other state, including an adbd left by an older patch set, exits 1 so that
|
||||
+# the Makefile regenerates the android-tools source and builds again.
|
||||
+# flare-edge#3129, luckfox-sdk-patches/tests/test-adbd-no-tcp.sh.
|
||||
+adbd=$1
|
||||
+stamp=$2
|
||||
+inputs=$3
|
||||
+[ -f "$adbd" ] || exit 1
|
||||
+[ -f "$stamp" ] || exit 1
|
||||
+[ "$(cat "$stamp")" = "$inputs" ] || exit 1
|
||||
+exit 0
|
||||
diff --git a/sysdrv/tools/board/android-tools/android-tools-patches/0017-no-adb-tcp-listener.patch b/sysdrv/tools/board/android-tools/android-tools-patches/0017-no-adb-tcp-listener.patch
|
||||
new file mode 100644
|
||||
index 0000000..c487482
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/tools/board/android-tools/android-tools-patches/0017-no-adb-tcp-listener.patch
|
||||
@@ -0,0 +1,42 @@
|
||||
+flare-edge#3129: no adbd TCP listener in the image
|
||||
+
|
||||
+Rockchip's 0015 patch made adb_main() open a TCP listener on 5555 whenever
|
||||
+USB is up (local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT)). The non-secure
|
||||
+branch also installs the tcp:5037 smartsocket listener, bound to 127.0.0.1.
|
||||
+S50usbdevice starts adbd with no arguments, so both listeners were live on
|
||||
+every panel: 0.0.0.0:5555 and 127.0.0.1:5037.
|
||||
+
|
||||
+This patch removes both calls. USB stays the only transport, so the USB adbd
|
||||
+path (the shell over the gadget) is unchanged. The regression test is
|
||||
+luckfox-sdk-patches/tests/test-adbd-no-tcp.sh.
|
||||
+
|
||||
+--- a/core/adbd/adb.c
|
||||
++++ b/core/adbd/adb.c
|
||||
+@@ -1298,13 +1298,9 @@
|
||||
+ capset(&header, cap);
|
||||
+
|
||||
+ D("Local port disabled\n");
|
||||
+- } else {
|
||||
+- char local_name[30];
|
||||
+- build_local_name(local_name, sizeof(local_name), server_port);
|
||||
+- if(install_listener(local_name, "*smartsocket*", NULL, 0)) {
|
||||
+- exit(1);
|
||||
+- }
|
||||
+- }
|
||||
++ }
|
||||
++ /* flare-edge#3129: the non-secure branch installs no smartsocket listener
|
||||
++ either (it was tcp:5037, bound to 127.0.0.1). adbd opens no TCP port. */
|
||||
+
|
||||
+ int usb = 0;
|
||||
+ if (access(USB_ADB_PATH, F_OK) == 0 || access(USB_FFS_ADB_EP0, F_OK) == 0) {
|
||||
+@@ -1327,8 +1323,8 @@
|
||||
+ //} else if (!usb)
|
||||
+ if (usb) {
|
||||
+ printf("Using USB\n");
|
||||
+- // listen on default port
|
||||
+- local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
|
||||
++ // flare-edge#3129: the image opens no TCP listener. USB is the only
|
||||
++ // transport; local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT) is not called.
|
||||
+ }
|
||||
+
|
||||
+ D("adb_main(): pre init_jdwp()\n");
|
||||
diff --git a/sysdrv/tools/board/android-tools/android-tools-patches/android-tools.patch.sh b/sysdrv/tools/board/android-tools/android-tools-patches/android-tools.patch.sh
|
||||
index 2cb01e6..1a0470a 100755
|
||||
--- a/sysdrv/tools/board/android-tools/android-tools-patches/android-tools.patch.sh
|
||||
+++ b/sysdrv/tools/board/android-tools/android-tools-patches/android-tools.patch.sh
|
||||
@@ -17,3 +17,4 @@ patch -p1 < 0014-Specify-login-shell-in-standard-way.patch
|
||||
patch -p1 < 0015-make-adb-tcp-function-default-enbale.patch
|
||||
patch -p1 < 0015-support-rsa-key-authentication.patch
|
||||
patch -p1 < 0016-fix-static-link-dl-lll_unlock_wait_private.patch
|
||||
+patch -p1 < 0017-no-adb-tcp-listener.patch
|
||||
@@ -0,0 +1,76 @@
|
||||
BR2_arm=y
|
||||
BR2_cortex_a7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_PATH="../../../../tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_WCHAR=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CXX=y
|
||||
BR2_PRIMARY_SITE="http://sources.buildroot.net"
|
||||
BR2_OPTIMIZE_3=y
|
||||
BR2_TARGET_GENERIC_HOSTNAME="luckfox pico"
|
||||
BR2_TARGET_GENERIC_ISSUE="Welcome to luckfox pico"
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="luckfox"
|
||||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||
BR2_PACKAGE_GZIP=y
|
||||
BR2_PACKAGE_P7ZIP=y
|
||||
BR2_PACKAGE_UNZIP=y
|
||||
BR2_PACKAGE_XZ=y
|
||||
BR2_PACKAGE_ZIP=y
|
||||
BR2_PACKAGE_E2FSPROGS=y
|
||||
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
|
||||
BR2_PACKAGE_EVTEST=y
|
||||
BR2_PACKAGE_PYTHON3=y
|
||||
BR2_PACKAGE_PYTHON3_SSL=y
|
||||
BR2_PACKAGE_PYTHON_AIOHTTP=y
|
||||
BR2_PACKAGE_PYTHON_CLICK=y
|
||||
BR2_PACKAGE_PYTHON_ITSDANGEROUS=y
|
||||
BR2_PACKAGE_PYTHON_JINJA2=y
|
||||
BR2_PACKAGE_PYTHON_PERIPHERY=y
|
||||
BR2_PACKAGE_PYTHON_PILLOW=y
|
||||
BR2_PACKAGE_PYTHON_SERIAL=y
|
||||
BR2_PACKAGE_PYTHON_SETUPTOOLS=y
|
||||
BR2_PACKAGE_PYTHON_SMBUS_CFFI=y
|
||||
BR2_PACKAGE_PYTHON_SPIDEV=y
|
||||
BR2_PACKAGE_PYTHON_WERKZEUG=y
|
||||
BR2_PACKAGE_CA_CERTIFICATES=y
|
||||
BR2_PACKAGE_GNUTLS=y
|
||||
BR2_PACKAGE_LIBMD=y
|
||||
BR2_PACKAGE_FREETYPE=y
|
||||
BR2_PACKAGE_LIBDRM=y
|
||||
BR2_PACKAGE_DTC=y
|
||||
BR2_PACKAGE_DTC_PROGRAMS=y
|
||||
BR2_PACKAGE_LIBV4L=y
|
||||
BR2_PACKAGE_LIBV4L_UTILS=y
|
||||
BR2_PACKAGE_LIBCURL=y
|
||||
BR2_PACKAGE_LIBCURL_CURL=y
|
||||
BR2_PACKAGE_LIBCURL_VERBOSE=y
|
||||
BR2_PACKAGE_LIBRSYNC=y
|
||||
BR2_PACKAGE_PCRE2=y
|
||||
BR2_PACKAGE_PCRE2_16=y
|
||||
BR2_PACKAGE_PCRE2_32=y
|
||||
BR2_PACKAGE_BMON=y
|
||||
BR2_PACKAGE_DHCPCD=y
|
||||
BR2_PACKAGE_IPERF=y
|
||||
BR2_PACKAGE_IPERF3=y
|
||||
BR2_PACKAGE_IPTABLES=y
|
||||
BR2_PACKAGE_IPTABLES_BPF_NFSYNPROXY=y
|
||||
BR2_PACKAGE_IPTABLES_NFTABLES=y
|
||||
BR2_PACKAGE_LRZSZ=y
|
||||
BR2_PACKAGE_NTP=y
|
||||
BR2_PACKAGE_OPENSSH=y
|
||||
BR2_PACKAGE_RSYNC=y
|
||||
BR2_PACKAGE_SOCAT=y
|
||||
BR2_PACKAGE_WGET=y
|
||||
BR2_PACKAGE_BASH=y
|
||||
BR2_PACKAGE_BASH_LOADABLE_EXAMPLES=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
BR2_PACKAGE_TIME=y
|
||||
BR2_PACKAGE_HTOP=y
|
||||
BR2_PACKAGE_UTIL_LINUX_LIBMOUNT=y
|
||||
BR2_PACKAGE_NANO=y
|
||||
BR2_PACKAGE_HOST_DTC=y
|
||||
@@ -0,0 +1,113 @@
|
||||
BR2_arm=y
|
||||
BR2_cortex_a7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_PATH="../../../../tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_WCHAR=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CXX=y
|
||||
BR2_PRIMARY_SITE="http://sources.buildroot.net"
|
||||
BR2_OPTIMIZE_3=y
|
||||
BR2_TARGET_GENERIC_HOSTNAME="luckfox pico"
|
||||
BR2_TARGET_GENERIC_ISSUE="Welcome to luckfox pico"
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="luckfox"
|
||||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||
BR2_PACKAGE_ALSA_UTILS=y
|
||||
BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
|
||||
BR2_PACKAGE_ALSA_UTILS_ACONNECT=y
|
||||
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
|
||||
BR2_PACKAGE_ALSA_UTILS_APLAY=y
|
||||
BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y
|
||||
BR2_PACKAGE_BLUEZ_ALSA=y
|
||||
BR2_PACKAGE_BLUEZ_ALSA_HCITOP=y
|
||||
BR2_PACKAGE_BLUEZ_ALSA_RFCOMM=y
|
||||
BR2_PACKAGE_FFMPEG_FFPLAY=y
|
||||
BR2_PACKAGE_FFMPEG_FFPROBE=y
|
||||
BR2_PACKAGE_FFMPEG_AVRESAMPLE=y
|
||||
BR2_PACKAGE_JACK2=y
|
||||
BR2_PACKAGE_JACK2_LEGACY=y
|
||||
BR2_PACKAGE_JACK2_DBUS=y
|
||||
BR2_PACKAGE_MADPLAY=y
|
||||
BR2_PACKAGE_MPV=y
|
||||
BR2_PACKAGE_PULSEAUDIO=y
|
||||
BR2_PACKAGE_SOX=y
|
||||
BR2_PACKAGE_GZIP=y
|
||||
BR2_PACKAGE_P7ZIP=y
|
||||
BR2_PACKAGE_UNZIP=y
|
||||
BR2_PACKAGE_XZ=y
|
||||
BR2_PACKAGE_ZIP=y
|
||||
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
|
||||
BR2_PACKAGE_SDL2_GFX=y
|
||||
BR2_PACKAGE_SDL2_IMAGE=y
|
||||
BR2_PACKAGE_SDL2_MIXER=y
|
||||
BR2_PACKAGE_SDL2_NET=y
|
||||
BR2_PACKAGE_SDL2_TTF=y
|
||||
BR2_PACKAGE_VULKAN_HEADERS=y
|
||||
BR2_PACKAGE_DBUS_CPP=y
|
||||
BR2_PACKAGE_DBUS_TRIGGERD=y
|
||||
BR2_PACKAGE_EVTEST=y
|
||||
BR2_PACKAGE_PYTHON3_SSL=y
|
||||
BR2_PACKAGE_PYTHON_AIOHTTP=y
|
||||
BR2_PACKAGE_PYTHON_CLICK=y
|
||||
BR2_PACKAGE_PYTHON_ITSDANGEROUS=y
|
||||
BR2_PACKAGE_PYTHON_JINJA2=y
|
||||
BR2_PACKAGE_PYTHON_PERIPHERY=y
|
||||
BR2_PACKAGE_PYTHON_PILLOW=y
|
||||
BR2_PACKAGE_PYTHON_SERIAL=y
|
||||
BR2_PACKAGE_PYTHON_SETUPTOOLS=y
|
||||
BR2_PACKAGE_PYTHON_SMBUS_CFFI=y
|
||||
BR2_PACKAGE_PYTHON_SPIDEV=y
|
||||
BR2_PACKAGE_PYTHON_WERKZEUG=y
|
||||
BR2_PACKAGE_LIBAO=y
|
||||
BR2_PACKAGE_PORTAUDIO=y
|
||||
BR2_PACKAGE_CA_CERTIFICATES=y
|
||||
BR2_PACKAGE_LIBDRM=y
|
||||
BR2_PACKAGE_DTC=y
|
||||
BR2_PACKAGE_DTC_PROGRAMS=y
|
||||
BR2_PACKAGE_LIBV4L=y
|
||||
BR2_PACKAGE_LIBV4L_UTILS=y
|
||||
BR2_PACKAGE_CJSON=y
|
||||
BR2_PACKAGE_CJSON_UTILS=y
|
||||
BR2_PACKAGE_LIBCURL=y
|
||||
BR2_PACKAGE_LIBCURL_CURL=y
|
||||
BR2_PACKAGE_LIBCURL_VERBOSE=y
|
||||
BR2_PACKAGE_LIBRSYNC=y
|
||||
BR2_PACKAGE_PCRE2=y
|
||||
BR2_PACKAGE_PCRE2_16=y
|
||||
BR2_PACKAGE_PCRE2_32=y
|
||||
BR2_PACKAGE_BLUEZ_TOOLS=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_TOOLS=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_EXPERIMENTAL=y
|
||||
BR2_PACKAGE_BMON=y
|
||||
BR2_PACKAGE_DHCPCD=y
|
||||
BR2_PACKAGE_IPERF=y
|
||||
BR2_PACKAGE_IPERF3=y
|
||||
BR2_PACKAGE_IPTABLES=y
|
||||
BR2_PACKAGE_IPTABLES_BPF_NFSYNPROXY=y
|
||||
BR2_PACKAGE_IPTABLES_NFTABLES=y
|
||||
BR2_PACKAGE_IW=y
|
||||
BR2_PACKAGE_LRZSZ=y
|
||||
BR2_PACKAGE_NTP=y
|
||||
BR2_PACKAGE_OPENSSH=y
|
||||
BR2_PACKAGE_PPPD=y
|
||||
BR2_PACKAGE_PPPD_FILTER=y
|
||||
BR2_PACKAGE_PPPD_RADIUS=y
|
||||
BR2_PACKAGE_RSYNC=y
|
||||
BR2_PACKAGE_SAMBA4=y
|
||||
BR2_PACKAGE_SOCAT=y
|
||||
BR2_PACKAGE_WGET=y
|
||||
BR2_PACKAGE_BASH=y
|
||||
BR2_PACKAGE_BASH_LOADABLE_EXAMPLES=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
BR2_PACKAGE_TIME=y
|
||||
BR2_PACKAGE_HTOP=y
|
||||
BR2_PACKAGE_PROCPS_NG=y
|
||||
BR2_PACKAGE_UTIL_LINUX_LIBMOUNT=y
|
||||
BR2_PACKAGE_NANO=y
|
||||
BR2_PACKAGE_HOST_DTC=y
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
Add a minimal wordexp(3) for uClibc-ng, which the Rockchip toolchain
|
||||
builds without. BlueZ (bluetoothctl via src/shared/shell.c, and a few
|
||||
tools) includes <wordexp.h> unconditionally; DEFAULT_INCLUDES=-I. makes
|
||||
this top-level header resolve. WRDE_NOCMD is always passed, so a
|
||||
whitespace/quote tokenizer is a semantically complete substitute.
|
||||
|
||||
Signed-off-by: BlueFlare Warden <noah@wildrosemining.com>
|
||||
|
||||
diff --git a/wordexp.h b/wordexp.h
|
||||
new file mode 100644
|
||||
index 0000000..1111111
|
||||
--- /dev/null
|
||||
+++ b/wordexp.h
|
||||
@@ -0,0 +1,171 @@
|
||||
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
+/*
|
||||
+ * Minimal wordexp(3) for uClibc-ng.
|
||||
+ *
|
||||
+ * The Rockchip external toolchain's uClibc-ng is built without wordexp, so it
|
||||
+ * ships no <wordexp.h>. Several BlueZ sources (src/shared/shell.c, which is
|
||||
+ * bluetoothctl's command reader, plus a few tools) include <wordexp.h>
|
||||
+ * unconditionally and call wordexp()/wordfree(). They always pass WRDE_NOCMD
|
||||
+ * -- "no command substitution" -- and use the result only to split a command
|
||||
+ * line into words, so a whitespace/quote tokenizer is a semantically complete
|
||||
+ * substitute. This is deliberately NOT a general shell expander: no globbing,
|
||||
+ * no variable or command substitution (WRDE_NOCMD is precisely the request to
|
||||
+ * omit those). Placed at the BlueZ source root, where DEFAULT_INCLUDES = -I.
|
||||
+ * makes <wordexp.h> resolve to it.
|
||||
+ */
|
||||
+#ifndef _WORDEXP_H_
|
||||
+#define _WORDEXP_H_
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <ctype.h>
|
||||
+
|
||||
+#define WRDE_DOOFFS 0x0001
|
||||
+#define WRDE_APPEND 0x0002
|
||||
+#define WRDE_NOCMD 0x0004
|
||||
+#define WRDE_REUSE 0x0008
|
||||
+#define WRDE_SHOWERR 0x0010
|
||||
+#define WRDE_UNDEF 0x0020
|
||||
+
|
||||
+enum {
|
||||
+ WRDE_SUCCESS = 0,
|
||||
+ WRDE_NOSPACE = 1,
|
||||
+ WRDE_BADCHAR = 2,
|
||||
+ WRDE_BADVAL = 3,
|
||||
+ WRDE_CMDSUB = 4,
|
||||
+ WRDE_SYNTAX = 5,
|
||||
+};
|
||||
+
|
||||
+typedef struct {
|
||||
+ size_t we_wordc; /* number of words */
|
||||
+ char **we_wordv; /* NULL-terminated vector of words */
|
||||
+ size_t we_offs; /* reserved-slot count; also used as a scratch flag
|
||||
+ by shell.c, which never passes WRDE_DOOFFS */
|
||||
+} wordexp_t;
|
||||
+
|
||||
+__attribute__((unused))
|
||||
+static int wordexp(const char *words, wordexp_t *we, int flags)
|
||||
+{
|
||||
+ size_t n, i;
|
||||
+ char **vec;
|
||||
+ const char *p;
|
||||
+ int appending;
|
||||
+ size_t orig_n; /* we->we_wordc as of function entry, so a failure
|
||||
+ partway through a WRDE_APPEND call can put the
|
||||
+ vector back to exactly its pre-call length rather
|
||||
+ than leaving it part-grown or short a
|
||||
+ terminator */
|
||||
+
|
||||
+ if (words == NULL || we == NULL)
|
||||
+ return WRDE_BADCHAR;
|
||||
+
|
||||
+ appending = (flags & WRDE_APPEND) && we->we_wordv != NULL;
|
||||
+ if (appending) {
|
||||
+ n = we->we_wordc; /* append to the existing vector */
|
||||
+ vec = we->we_wordv;
|
||||
+ } else {
|
||||
+ n = 0;
|
||||
+ vec = calloc(1, sizeof(char *));
|
||||
+ if (vec == NULL)
|
||||
+ return WRDE_NOSPACE;
|
||||
+ }
|
||||
+ orig_n = n;
|
||||
+
|
||||
+ for (p = words; *p != '\0'; ) {
|
||||
+ size_t cap = 16, len = 0;
|
||||
+ char *w, *tw, **t;
|
||||
+
|
||||
+ while (*p != '\0' && isspace((unsigned char)*p))
|
||||
+ p++;
|
||||
+ if (*p == '\0')
|
||||
+ break;
|
||||
+
|
||||
+ w = malloc(cap);
|
||||
+ if (w == NULL)
|
||||
+ goto nospace;
|
||||
+
|
||||
+ while (*p != '\0' && !isspace((unsigned char)*p)) {
|
||||
+ char c;
|
||||
+
|
||||
+ if (*p == '\'' || *p == '"') {
|
||||
+ char q = *p++;
|
||||
+ while (*p != '\0' && *p != q) {
|
||||
+ if (len + 1 >= cap) {
|
||||
+ cap *= 2;
|
||||
+ tw = realloc(w, cap);
|
||||
+ if (tw == NULL) { free(w); goto nospace; }
|
||||
+ w = tw;
|
||||
+ }
|
||||
+ w[len++] = *p++;
|
||||
+ }
|
||||
+ if (*p == q)
|
||||
+ p++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (*p == '\\' && p[1] != '\0')
|
||||
+ p++;
|
||||
+ c = *p++;
|
||||
+ if (len + 1 >= cap) {
|
||||
+ cap *= 2;
|
||||
+ tw = realloc(w, cap);
|
||||
+ if (tw == NULL) { free(w); goto nospace; }
|
||||
+ w = tw;
|
||||
+ }
|
||||
+ w[len++] = c;
|
||||
+ }
|
||||
+ w[len] = '\0';
|
||||
+
|
||||
+ t = (char **)realloc(vec, (n + 2) * sizeof(char *));
|
||||
+ if (t == NULL) { free(w); goto nospace; }
|
||||
+ vec = t;
|
||||
+ vec[n++] = w;
|
||||
+ vec[n] = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (n == 0)
|
||||
+ vec[0] = NULL; /* keep the vector NULL-terminated */
|
||||
+
|
||||
+ we->we_wordv = vec;
|
||||
+ we->we_wordc = n;
|
||||
+ return WRDE_SUCCESS;
|
||||
+
|
||||
+nospace:
|
||||
+ if (appending) {
|
||||
+ /* vec already carries every word from before this call --
|
||||
+ realloc() preserves existing contents whether it
|
||||
+ relocates the block. Only entries at orig_n and above are
|
||||
+ this call's own; free those and put the vector back to
|
||||
+ exactly its pre-call length. vec, not we->we_wordv, is what
|
||||
+ still points at that data: realloc() may already have
|
||||
+ relocated or freed the pointer we->we_wordv held on entry,
|
||||
+ which is exactly why the old cleanup here could free the
|
||||
+ caller's pre-existing words and leave we->we_wordv
|
||||
+ dangling. */
|
||||
+ for (i = orig_n; i < n; i++)
|
||||
+ free(vec[i]);
|
||||
+ vec[orig_n] = NULL;
|
||||
+ we->we_wordv = vec;
|
||||
+ we->we_wordc = orig_n;
|
||||
+ } else {
|
||||
+ for (i = 0; i < n; i++)
|
||||
+ free(vec[i]);
|
||||
+ free(vec);
|
||||
+ }
|
||||
+ return WRDE_NOSPACE;
|
||||
+}
|
||||
+
|
||||
+__attribute__((unused))
|
||||
+static void wordfree(wordexp_t *we)
|
||||
+{
|
||||
+ size_t i;
|
||||
+
|
||||
+ if (we == NULL || we->we_wordv == NULL)
|
||||
+ return;
|
||||
+ for (i = 0; i < we->we_wordc; i++)
|
||||
+ free(we->we_wordv[i]);
|
||||
+ free(we->we_wordv);
|
||||
+ we->we_wordv = NULL;
|
||||
+ we->we_wordc = 0;
|
||||
+}
|
||||
+
|
||||
+#endif /* _WORDEXP_H_ */
|
||||
@@ -0,0 +1,84 @@
|
||||
Bessel J1 for mpv's EWA/jinc scaler. The Rockchip external toolchain's
|
||||
uClibc-ng does not provide j1()/j0()/jn() -- confirmed absent from
|
||||
libuClibc-1.0.31.so in the arm-rockchip830-linux-uclibcgnueabihf sysroot
|
||||
this SDK builds against, the same gap the bluez5_utils wordexp patch in
|
||||
this series works around for a different function. jinc() (video/out/
|
||||
filter_kernels.c) scales its argument by M_PI before calling this, and
|
||||
mpv's --scale-radius is user-settable, so BesselJ1 has to be accurate
|
||||
over the whole double range a real j1() would cover, not just small
|
||||
arguments -- the version this replaces summed a fixed 11-term power
|
||||
series whose terms have not converged by the time n runs out for any
|
||||
x much past 6 or 7, and are off by 7+ orders of magnitude by x=20.
|
||||
|
||||
--- a/video/out/filter_kernels.c 2024-04-26 11:14:00.377199103 +0800
|
||||
+++ b/video/out/filter_kernels.c 2024-04-26 11:13:50.217202856 +0800
|
||||
@@ -32,6 +32,60 @@
|
||||
|
||||
// NOTE: all filters are designed for discrete convolution
|
||||
|
||||
+/*
|
||||
+ * mpv's libm on this target is uClibc-ng, which does not provide
|
||||
+ * j1()/j0()/jn() -- confirmed absent from libuClibc-1.0.31.so in the
|
||||
+ * arm-rockchip830-linux-uclibcgnueabihf sysroot this SDK builds
|
||||
+ * against. jinc() (below) scales its argument by M_PI before calling
|
||||
+ * this, and --scale-radius is user-settable, so this has to hold up
|
||||
+ * over the whole double range, not just small arguments.
|
||||
+ *
|
||||
+ * A plain power series is only exact up to about x=20 in double
|
||||
+ * precision: past that, terms grow before they shrink, and summing
|
||||
+ * large alternating terms loses precision to cancellation. So this
|
||||
+ * sums the series -- by a term-to-term ratio rather than separate
|
||||
+ * factorial()/power() calls, which also keeps it from overflowing at
|
||||
+ * large n -- only while each new term is still negligible against the
|
||||
+ * running sum, and falls back to the standard second-order asymptotic
|
||||
+ * expansion for Bessel functions (Abramowitz & Stegun 9.2.5/9.2.6,
|
||||
+ * order 1) once x passes that point. Checked against libm's j1() on
|
||||
+ * the build host across x in [0, 5000]: max absolute error 5e-8, max
|
||||
+ * relative error 5e-5 away from J1's zero crossings, where any finite
|
||||
+ * error reads large against a reference near zero.
|
||||
+ */
|
||||
+static double warden_j1_series(double x)
|
||||
+{
|
||||
+ double half = x / 2.0;
|
||||
+ double term = half;
|
||||
+ double sum = term;
|
||||
+ double xsq = -(half * half);
|
||||
+ for (int n = 1; n < 80; n++) {
|
||||
+ term *= xsq / ((double)n * (double)(n + 1));
|
||||
+ sum += term;
|
||||
+ if (fabs(term) < 1e-18 * fabs(sum))
|
||||
+ break;
|
||||
+ }
|
||||
+ return sum;
|
||||
+}
|
||||
+
|
||||
+static double warden_j1_asymptotic(double x)
|
||||
+{
|
||||
+ double omega = x - 3.0 * M_PI / 4.0;
|
||||
+ double x2 = x * x;
|
||||
+ double p = 1.0 + 15.0 / (128.0 * x2) - 4725.0 / (32768.0 * x2 * x2);
|
||||
+ double q = 3.0 / (8.0 * x) - 105.0 / (1024.0 * x2 * x)
|
||||
+ + 363825.0 / (1310720.0 * x2 * x2 * x);
|
||||
+ return sqrt(2.0 / (M_PI * x)) * (p * cos(omega) - q * sin(omega));
|
||||
+}
|
||||
+
|
||||
+static double BesselJ1(double x)
|
||||
+{
|
||||
+ int neg = x < 0;
|
||||
+ double ax = fabs(x);
|
||||
+ double r = (ax < 12.0) ? warden_j1_series(ax) : warden_j1_asymptotic(ax);
|
||||
+ return neg ? -r : r;
|
||||
+}
|
||||
+
|
||||
const struct filter_window *mp_find_filter_window(const char *name)
|
||||
{
|
||||
if (!name)
|
||||
@@ -324,7 +378,7 @@
|
||||
if (fabs(x) < 1e-8)
|
||||
return 1.0;
|
||||
x *= M_PI;
|
||||
- return 2.0 * j1(x) / x;
|
||||
+ return 2.0 * BesselJ1(x) / x;
|
||||
}
|
||||
|
||||
static double sphinx(params *p, double x)
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
From: BlueFlare Warden <noah@wildrosemining.com>
|
||||
Subject: [PATCH] datatype: take the cgroupv2 id from the directory's file handle
|
||||
|
||||
"socket cgroupv2 level N <path>" compares the 64-bit kernfs id of the cgroup.
|
||||
nft built it from st_ino, which equals the id only on 64-bit kernels. On a
|
||||
32-bit kernel (armv7) the id is (generation << 32) | ino and st_ino carries the
|
||||
low half, so every rule built from a path compared against the wrong value and
|
||||
never matched: nothing was counted per service.
|
||||
|
||||
The directory's file handle holds the whole id on both. It is read with the raw
|
||||
name_to_handle_at syscall because uClibc has no wrapper. The listing path (id
|
||||
back to a name) uses the same helper.
|
||||
|
||||
Found on the WardenOS panel kernel (6.18.46, armv7) with nftables 1.1.0.
|
||||
|
||||
diff --git a/src/datatype.c b/src/datatype.c
|
||||
index d398a9c..289f930 100644
|
||||
--- a/src/datatype.c
|
||||
+++ b/src/datatype.c
|
||||
@@ -19,7 +19,10 @@
|
||||
#include <linux/netfilter.h>
|
||||
#include <linux/icmpv6.h>
|
||||
#include <dirent.h>
|
||||
+#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <sys/syscall.h>
|
||||
+#include <unistd.h>
|
||||
|
||||
#include <nftables.h>
|
||||
#include <datatype.h>
|
||||
@@ -1605,12 +1608,47 @@ const struct datatype policy_type = {
|
||||
|
||||
#define SYSFS_CGROUPSV2_PATH "/sys/fs/cgroup"
|
||||
|
||||
+/* The id the kernel compares in "socket cgroupv2" is the 64-bit kernfs id of
|
||||
+ * the cgroup directory. On 64-bit kernels that is st_ino, but on 32-bit kernels
|
||||
+ * it is (generation << 32) | ino and st_ino carries only the low half, so a
|
||||
+ * rule built from st_ino never matches. The file handle of the directory holds
|
||||
+ * the full id on both. The handle is read with the raw syscall: uClibc has no
|
||||
+ * name_to_handle_at() or struct file_handle. Fall back to st_ino where the
|
||||
+ * syscall is missing. */
|
||||
+static bool cgroupv2_path_id(const char *path, uint64_t *id)
|
||||
+{
|
||||
+#ifdef __NR_name_to_handle_at
|
||||
+ struct {
|
||||
+ unsigned int handle_bytes;
|
||||
+ int handle_type;
|
||||
+ unsigned char f_handle[sizeof(uint64_t)];
|
||||
+ } h;
|
||||
+ int mount_id;
|
||||
+
|
||||
+ h.handle_bytes = sizeof(h.f_handle);
|
||||
+ if (syscall(__NR_name_to_handle_at, AT_FDCWD, path, &h, &mount_id, 0) == 0 &&
|
||||
+ h.handle_bytes == sizeof(*id)) {
|
||||
+ memcpy(id, h.f_handle, sizeof(*id));
|
||||
+ return true;
|
||||
+ }
|
||||
+#endif
|
||||
+ {
|
||||
+ struct stat st;
|
||||
+
|
||||
+ if (stat(path, &st) < 0)
|
||||
+ return false;
|
||||
+ *id = st.st_ino;
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static char *cgroupv2_get_path(const char *path, uint64_t id)
|
||||
{
|
||||
char dent_name[PATH_MAX + 1];
|
||||
char *cgroup_path = NULL;
|
||||
struct dirent *dent;
|
||||
struct stat st;
|
||||
+ uint64_t dent_id;
|
||||
DIR *d;
|
||||
|
||||
d = opendir(path);
|
||||
@@ -1626,7 +1664,7 @@ static char *cgroupv2_get_path(const char *path, uint64_t id)
|
||||
path, dent->d_name);
|
||||
dent_name[sizeof(dent_name) - 1] = '\0';
|
||||
|
||||
- if (dent->d_ino == id) {
|
||||
+ if (cgroupv2_path_id(dent_name, &dent_id) && dent_id == id) {
|
||||
cgroup_path = xstrdup(dent_name);
|
||||
break;
|
||||
}
|
||||
@@ -1674,7 +1712,9 @@ static struct error_record *cgroupv2_type_parse(struct parse_ctx *ctx,
|
||||
return error(&sym->location, "cgroupv2 path fails: %s",
|
||||
strerror(errno));
|
||||
|
||||
- ino = st.st_ino;
|
||||
+ if (!cgroupv2_path_id(cgroupv2_path, &ino))
|
||||
+ return error(&sym->location, "cgroupv2 path fails: %s",
|
||||
+ strerror(errno));
|
||||
*res = constant_expr_alloc(&sym->location, &cgroupv2_type,
|
||||
BYTEORDER_HOST_ENDIAN,
|
||||
sizeof(ino) * BITS_PER_BYTE, &ino);
|
||||
@@ -0,0 +1,74 @@
|
||||
The busybox applet set this image ships.
|
||||
|
||||
Not a preference: two things in the firmware depend on it directly.
|
||||
CONFIG_FEATURE_FANCY_SLEEP=y is why `sleep 0.1` works in the init scripts, and
|
||||
`# CONFIG_TIMEOUT is not set` is why S09splash's touch probe cannot use
|
||||
timeout(1) and backgrounds a reader instead. It also builds telnetd in.
|
||||
|
||||
This file lived only in the vendor SDK's unpacked buildroot tree, which is not
|
||||
in the vendor checkout and not in any manifest, so none of that was recorded
|
||||
anywhere (#135).
|
||||
|
||||
--- a/package/busybox/busybox.config
|
||||
+++ b/package/busybox/busybox.config
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.36.1
|
||||
-# Wed May 8 17:25:31 2024
|
||||
+# Sat Dec 9 10:36:18 2023
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -782,7 +782,7 @@
|
||||
# CONFIG_FEATURE_CROND_D is not set
|
||||
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
|
||||
CONFIG_FEATURE_CROND_SPECIAL_TIMES=y
|
||||
-CONFIG_FEATURE_CROND_DIR="/etc/cron"
|
||||
+CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
|
||||
CONFIG_CRONTAB=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
@@ -835,7 +835,7 @@
|
||||
CONFIG_PARTPROBE=y
|
||||
# CONFIG_RAIDAUTORUN is not set
|
||||
# CONFIG_READAHEAD is not set
|
||||
-# CONFIG_RFKILL is not set
|
||||
+CONFIG_RFKILL=y
|
||||
CONFIG_RUNLEVEL=y
|
||||
# CONFIG_RX is not set
|
||||
CONFIG_SEEDRNG=y
|
||||
@@ -968,18 +968,18 @@
|
||||
CONFIG_ROUTE=y
|
||||
# CONFIG_SLATTACH is not set
|
||||
# CONFIG_SSL_CLIENT is not set
|
||||
-# CONFIG_TC is not set
|
||||
-# CONFIG_FEATURE_TC_INGRESS is not set
|
||||
+CONFIG_TC=y
|
||||
+CONFIG_FEATURE_TC_INGRESS=y
|
||||
# CONFIG_TCPSVD is not set
|
||||
# CONFIG_UDPSVD is not set
|
||||
CONFIG_TELNET=y
|
||||
CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
CONFIG_FEATURE_TELNET_WIDTH=y
|
||||
-# CONFIG_TELNETD is not set
|
||||
-# CONFIG_FEATURE_TELNETD_STANDALONE is not set
|
||||
-CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0
|
||||
-# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
|
||||
+CONFIG_TELNETD=y
|
||||
+CONFIG_FEATURE_TELNETD_STANDALONE=y
|
||||
+CONFIG_FEATURE_TELNETD_PORT_DEFAULT=23
|
||||
+CONFIG_FEATURE_TELNETD_INETD_WAIT=y
|
||||
CONFIG_TFTP=y
|
||||
# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set
|
||||
CONFIG_FEATURE_TFTP_HPA_COMPAT=y
|
||||
@@ -1016,7 +1016,7 @@
|
||||
CONFIG_FEATURE_UDHCPC_ARPING=y
|
||||
CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y
|
||||
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
-CONFIG_UDHCPC6_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
+CONFIG_UDHCPC6_DEFAULT_SCRIPT=""
|
||||
# CONFIG_UDHCPC6 is not set
|
||||
# CONFIG_FEATURE_UDHCPC6_RFC3646 is not set
|
||||
# CONFIG_FEATURE_UDHCPC6_RFC4704 is not set
|
||||
@@ -0,0 +1,9 @@
|
||||
# flare-edge: build the PWM backlight driver in, not as a module.
|
||||
#
|
||||
# Building the PWM backlight as a module means its class device does not exist
|
||||
# until userspace insmods pwm_bl.ko (~3.3-3.7s, via S25backlight). The
|
||||
# U-Boot -> kernel drm_logo boot-splash handoff replaces its framebuffer
|
||||
# at almost exactly that same time, so there is effectively no window
|
||||
# where a backlight device exists AND the logo is still on screen.
|
||||
# Built-in makes the device exist from early kernel boot instead.
|
||||
CONFIG_BACKLIGHT_PWM=y
|
||||
@@ -0,0 +1,104 @@
|
||||
# flare-edge kernel config fragment
|
||||
#
|
||||
# Merged by the RK build: BoardConfig-...-86Panel-IPC.mk names this file in
|
||||
# the kernel fragment list (".mk:88"), and tools/build-firmware.sh's
|
||||
# copy_fragments step installs it into arch/arm/configs/ before the kernel
|
||||
# build. (It had, until now, existed ONLY as an untracked hand-edit in the SDK
|
||||
# working copy at arch/arm/configs/flare-edge.config -- the exact stale-copy
|
||||
# trap sdk-patches/ exists to close. This tracked form is authoritative.)
|
||||
|
||||
# --- kexec (SSH-side kernel swap, no flash writes) -------------------------
|
||||
# Enable kexec so a new kernel can be booted from a running SSH session
|
||||
# with zero writes to flash. The stock image has this stubbed out: all of
|
||||
# sys_kexec_load / sys_kexec_file_load / compat_sys_kexec_load resolve to
|
||||
# the same sys_ni_syscall address, so the syscall is absent.
|
||||
#
|
||||
# KEXEC depends on (!SMP || PM_SLEEP_SMP) && MMU. RV1106 is a single-core
|
||||
# Cortex-A7 and symmetric multiprocessing is disabled in the base defconfig,
|
||||
# so the dependency is satisfied.
|
||||
CONFIG_KEXEC=y
|
||||
|
||||
# --- RGA2 2D engine + CMA dma-buf heaps (graph-scroll offload) --------------
|
||||
# warden: enable the RV1106 RGA2 2D engine (/dev/rga) for graph-scroll offload.
|
||||
# Builtin (not =m) so devtmpfs auto-creates the node at boot; the rga2 DT node is
|
||||
# already status="okay" via rv1106-evb.dtsi, so no device-tree change is needed.
|
||||
CONFIG_ROCKCHIP_MULTI_RGA=y
|
||||
# Portable CMA dma-buf allocator (/dev/dma_heap/cma) for contiguous, RGA-safe
|
||||
# (no-IOMMU) graph canvas buffers; reuses the existing 10MB linux,cma pool.
|
||||
CONFIG_DMABUF_HEAPS=y
|
||||
CONFIG_DMABUF_HEAPS_CMA=y
|
||||
|
||||
# --- host-side USB-Ethernet class drivers (router mode adds a LAN port) ------
|
||||
# In router mode S26usbhost flips the OTG port to USB HOST so a USB-Ethernet
|
||||
# adapter enumerates as an extra network port. The stock defconfig ships
|
||||
# the USB network driver menu disabled, so even once the DTS dr_mode="otg" host
|
||||
# switch (sdk-patches/kernel/patches/0003-usb-otg-dual-role.patch) brings xHCI
|
||||
# up, no ethN netdev would be created. Build these in (=y, not =m) so a NIC works
|
||||
# with zero userspace insmod, from early boot. Covers the common adapter silicon:
|
||||
# CDC-ECM/NCM (generic), ASIX AX88xxx (2.0 + gigabit), Realtek RTL8152/8153.
|
||||
# Trim to the adapters actually deployed if image size matters.
|
||||
CONFIG_USB_NET_DRIVERS=y
|
||||
CONFIG_USB_USBNET=y
|
||||
CONFIG_USB_NET_CDCETHER=y
|
||||
CONFIG_USB_NET_CDC_NCM=y
|
||||
CONFIG_USB_NET_AX8817X=y
|
||||
CONFIG_USB_NET_AX88179_178A=y
|
||||
CONFIG_USB_RTL8152=y
|
||||
|
||||
# --- WireGuard (FLARE management mesh) --------------------------------------
|
||||
# Kernel WireGuard is the chosen mesh transport (module + userspace `wg`, not
|
||||
# boringtun). The base luckfox_rv1106_linux_defconfig ALREADY builds it in
|
||||
# (built in at line ~212), and =y Kconfig-selects its crypto/UDP-tunnel
|
||||
# deps (CHACHA20POLY1305, CURVE25519, NET_UDP_TUNNEL), so nothing is missing and
|
||||
# no dep lines are needed here. We PIN =y (rather than the =m the task named, or
|
||||
# omitting it) so a future defconfig drift cannot silently drop the mesh
|
||||
# transport -- and so this fragment documents that WireGuard is a hard build
|
||||
# requirement. =y > =m here: no insmod, present from boot. Do NOT set =m: that
|
||||
# would DOWNGRADE the built-in to a module and merge_config would flag the
|
||||
# conflict.
|
||||
CONFIG_WIREGUARD=y
|
||||
|
||||
# --- 802.1Q VLAN (per-port router subnets, MikroTik switch termination) --------
|
||||
# router.c terminates each per-port subnet as an eth1.<vid> 802.1Q subinterface
|
||||
# (`ip link add link eth1 name eth1.<vid> type vlan id <vid>`), which needs 8021q
|
||||
# in the kernel; without it that call returns EOPNOTSUPP, so the VLAN config
|
||||
# screen + MikroTik app could program a switch the warden itself cannot route.
|
||||
#
|
||||
# ABI NOTE (root-caused on hardware 2026-08-13): enabling this inserts a
|
||||
# `struct vlan_info *vlan_info;` into `struct net_device`
|
||||
# (include/linux/netdevice.h, under the VLAN feature guard), which
|
||||
# shifts the offset of every field after it. The out-of-tree aic8800 wifi driver
|
||||
# and the modular cfg80211.ko MUST be rebuilt against this config or they read
|
||||
# net_device at stale offsets and NULL-deref at boot (crash in rwnx_interface_add
|
||||
# -> the "white logo" hang). A clean image build does this correctly:
|
||||
# build.sh kernel (mrproper -> clean VLAN kernel)
|
||||
# build.sh rootfs (rebuilds drv_ko/aic8800 + cfg80211.ko against that kernel)
|
||||
# build.sh firmware
|
||||
# so boot.img and the /oem modules always ship as a consistent set. NEVER flash a
|
||||
# VLAN boot.img over non-VLAN modules (that is what produced the hang during
|
||||
# incremental testing). =y (not =m): =m also flips IS_ENABLED, so it changes the
|
||||
# ABI identically while adding an insmod step for no benefit here.
|
||||
CONFIG_VLAN_8021Q=y
|
||||
|
||||
# --- pstore/ramoops: persistent crash/boot log across a reset -----------------
|
||||
# The debug UART is unwirable (under the daughterboard) and the USB CDC-ACM
|
||||
# console (S52usbacm) only comes up in userspace, so NEITHER can capture a
|
||||
# pre-userspace kernel hang -- which is exactly the class that bricked c8a3
|
||||
# (a load address in unreserved kernel RAM, hung before eth0). pstore/ramoops
|
||||
# keeps the kernel console ring + any oops/panic in a reserved DRAM region that
|
||||
# survives the reset (warm reset preserves DRAM), so the NEXT boot can read
|
||||
# /sys/fs/pstore and see the last words before the hang. Pairs with the already-
|
||||
# shipped `panic=10` cmdline + enabled watchdog (a hang -> reset -> log persists)
|
||||
# and the warden-flight recorder (which drains /sys/fs/pstore to /userdata, so
|
||||
# the log is also MaskRom-`dd`-recoverable off a brick).
|
||||
#
|
||||
# The DRAM region is carved by a `ramoops@0f000000` reserved-memory node
|
||||
# (sdk-patches/kernel/patches/0005-pstore-ramoops.patch): 1 MiB at 240 MiB, HIGH
|
||||
# above the low kernel/DTB/initrd load zone, so reserving it can only remove RAM
|
||||
# from the kernel -- it CANNOT recreate the c8a3 under-reservation collision.
|
||||
# console-size captures dmesg (the boot log); record-size captures oops/panic.
|
||||
CONFIG_PSTORE=y
|
||||
CONFIG_PSTORE_DEFLATE_COMPRESS=y
|
||||
CONFIG_PSTORE_CONSOLE=y
|
||||
CONFIG_PSTORE_PMSG=y
|
||||
CONFIG_PSTORE_RAM=y
|
||||
@@ -0,0 +1,24 @@
|
||||
# flare-edge: fbcon display policy -- keep OUR splash on screen, uninterrupted.
|
||||
#
|
||||
# Two separate problems, both fbcon, both fixed here.
|
||||
#
|
||||
# 1) The generic Linux logo option draws
|
||||
# drivers/video/logo/logo_linux_clut224.ppm whenever fbcon takes over a
|
||||
# framebuffer. This is NOT Rockchip's drm_logo handoff -- it is the
|
||||
# kernel's generic boot-logo feature, and the LuckFox SDK ships that file
|
||||
# replaced with their own fox-head + "LUCKFOX" wordmark. It painted over
|
||||
# our white BlueFlare logo on every boot.
|
||||
#
|
||||
# 2) The takeover itself. Even with no logo to draw, fbcon seizing the
|
||||
# framebuffer destroys the drm_logo image U-Boot handed us -- measured at
|
||||
# 1.895s, only 0.83s after the backlight came on at 1.068s, so the white
|
||||
# logo appeared as a brief flash and then the panel went blank until the
|
||||
# userspace colour splash. DEFERRED_TAKEOVER makes fbcon wait until
|
||||
# something actually writes text to the console before claiming the fb.
|
||||
# Our console is ttyFIQ0 (serial), so in practice nothing ever does, and
|
||||
# the U-Boot logo survives until S09splash draws over it deliberately.
|
||||
#
|
||||
# Deps for DEFERRED_TAKEOVER (FB=y, FRAMEBUFFER_CONSOLE, DUMMY_CONSOLE) are
|
||||
# all already satisfied in this defconfig -- verified before enabling.
|
||||
# CONFIG_LOGO is not set
|
||||
CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y
|
||||
@@ -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
|
||||
@@ -0,0 +1,82 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
index 8c07a90d3..ece8d149f 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -147,3 +158,77 @@ &uart4 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&uart4m0_xfer>;
|
||||
};
|
||||
+
|
||||
+/**********PANEL RESET + BACKLIGHT LINK**********/
|
||||
+/*
|
||||
+ * Restored from the FACTORY device tree (extracted from the stock boot.img of
|
||||
+ * this unit and diffed against current SDK HEAD, which had silently dropped
|
||||
+ * both properties). Without them the panel is never taken out of reset: DRM
|
||||
+ * sets 720x720@48.87Hz, the connector reports "connected", the VOP streams
|
||||
+ * pixels and the PWM backlight lights — but the panel controller is
|
||||
+ * unconfigured, so the screen stays black. Even a `modetest` test pattern is
|
||||
+ * invisible, which is what proved the fault sits BELOW DRM rather than in
|
||||
+ * fbdev or the app.
|
||||
+ *
|
||||
+ * gpio0 RK_PA1 is the same line U-Boot drives via `gpio set 1 1` when
|
||||
+ * CONFIG_LUCKFOX_EXECUTE_CMD is set (rv1106-luckfox-rgb-reset.config) — that
|
||||
+ * "Luckfox Pico RGB MCU reset" is the RGB panel's reset, not an LED.
|
||||
+ *
|
||||
+ * Factory values: reset-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>, reset-delay-ms = 200
|
||||
+ */
|
||||
+&panel {
|
||||
+ /*
|
||||
+ * flare-edge: backlight ONLY. reset-gpios and reset-delay-ms are
|
||||
+ * deliberately absent -- do not "restore" them.
|
||||
+ *
|
||||
+ * GPIO0_A1 is not the panel's reset. The schematic (U6 on
|
||||
+ * Luckfox-Pico-86-Panel.pdf) shows a WCH CH32V003 RISC-V MCU whose sole
|
||||
+ * job is to clock this panel's SPI init sequence into it, and the net
|
||||
+ * RGB_RES ties SoC GPIO0_A1, the panel RESET pin (FPC 6) and the MCU's
|
||||
+ * NRST (pin 1) together. Luckfox's own U-Boot comment says as much:
|
||||
+ * "Luckfox Pico RGB MCU reset gpio".
|
||||
+ *
|
||||
+ * So giving panel-simple this GPIO makes drm_panel_prepare() assert it
|
||||
+ * for reset-delay-ms and release it -- REBOOTING THE INIT MCU while the
|
||||
+ * VOP is already scanning pixels. The panel is then clocked with RGB
|
||||
+ * data before its power/gamma/VCOM registers are written, which is
|
||||
+ * exactly the faint coloured vertical banding seen for ~1-3 s on every
|
||||
+ * boot, and why a GPIO "reset" never cleared it (it re-ran the race).
|
||||
+ *
|
||||
+ * Luckfox removed these two properties in commit e2b0ffa22 for this
|
||||
+ * reason. An earlier revision of this file re-added them, having read
|
||||
+ * the deletion as an accidental regression -- see 40-kernel-stack.md,
|
||||
+ * which recorded them as "silently dropped" by SDK HEAD. They were not
|
||||
+ * dropped; they were the fix.
|
||||
+ *
|
||||
+ * The MCU is released exactly once, early, by U-Boot: board_init()
|
||||
+ * drives GPIO0_A1 high, and luckfox_execute_cmd() does the same again
|
||||
+ * harmlessly. At power-on the pin is input-with-pulldown, so the MCU is
|
||||
+ * held in reset until then, which is the intended sequencing.
|
||||
+ *
|
||||
+ * backlight is kept because U-Boot's rockchip_panel.c takes its
|
||||
+ * backlight handle from this node, and our boot logo needs it.
|
||||
+ */
|
||||
+ backlight = <&backlight>;
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * flare-edge: enable the U-Boot/kernel boot logo route.
|
||||
+ *
|
||||
+ * The whole RGB pipeline (display_subsystem, rgb, rgb_in_vop, vop) is already
|
||||
+ * "okay" in rv1106-luckfox-pico-86panel-ipc.dtsi, and that file also wires
|
||||
+ * logo-memory-region = <&drm_logo>. route_rgb was the only piece left
|
||||
+ * disabled, and without it U-Boot's rockchip_display finds no route and skips
|
||||
+ * drawing entirely.
|
||||
+ *
|
||||
+ * The node itself (rv1106.dtsi) already carries logo,uboot = "logo.bmp",
|
||||
+ * logo,kernel = "logo_kernel.bmp" and logo,mode = "center". Those files come
|
||||
+ * from resource.img, which scripts/mkmultidtb.py builds with
|
||||
+ * `resource_tool logo.bmp logo_kernel.bmp <dtbs>` out of the kernel source
|
||||
+ * directory -- so replacing sysdrv/source/kernel/logo.bmp is what changes the
|
||||
+ * splash. Setting logo,kernel to the same image keeps it on screen from
|
||||
+ * U-Boot through kernel handover until LVGL takes over.
|
||||
+ */
|
||||
+&route_rgb {
|
||||
+ status = "okay";
|
||||
+};
|
||||
@@ -0,0 +1,28 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
index 8c07a90d3..a9eb6c9d0 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -114,6 +114,23 @@ &gmac {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+/**********WATCHDOG (flare-edge: docs/firmware-update.md §6.6 item 4, §6.7)**********/
|
||||
+/*
|
||||
+ * flare-edge: enable the RV1106 designware watchdog.
|
||||
+ *
|
||||
+ * The kernel already builds CONFIG_DW_WATCHDOG, but rv1106.dtsi ships this
|
||||
+ * `wdt` node status = "disabled", so /dev/watchdog never appears. Once it is
|
||||
+ * "okay", warden-flared opens /dev/watchdog, sets a timeout (<= ~89 s on this
|
||||
+ * core) and pets it ONLY while the UI is proven live (ui_alive_fresh), after a
|
||||
+ * short unconditional boot grace. A post-boot hang then stops the pets, the SoC hard-resets,
|
||||
+ * and that reset is another boot U-Boot's bootcount sees -- so a wedged new
|
||||
+ * image converges to bootlimit -> altbootcmd -> recovery, exactly like a kernel
|
||||
+ * panic (docs §6.7). One line; needs a boot.img reflash.
|
||||
+ */
|
||||
+&wdt {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
/**********USB**********/
|
||||
&usbdrd_dwc3 {
|
||||
status = "okay";
|
||||
@@ -0,0 +1,28 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
index 8c07a90d3..efc27c0b8 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -117,8 +117,21 @@ &gmac {
|
||||
/**********USB**********/
|
||||
&usbdrd_dwc3 {
|
||||
status = "okay";
|
||||
- dr_mode = "peripheral";
|
||||
- //dr_mode = "host";
|
||||
+ /*
|
||||
+ * flare-edge: dual-role (OTG), not peripheral-only.
|
||||
+ *
|
||||
+ * router mode switches the port to USB HOST at runtime (S26usbhost writes
|
||||
+ * `host` to the inno-usb2 phy otg_mode) so a USB-Ethernet adapter enumerates
|
||||
+ * as an extra LAN port. With dr_mode = "peripheral" the dwc3 registers the
|
||||
+ * gadget role ONLY -- no xHCI host is instantiated, so `echo host` flips the
|
||||
+ * phy but nothing on the port ever enumerates (a silent no-op). "otg" compiles
|
||||
+ * BOTH roles and keeps the extcon/iddig DRD state machine live, so the runtime
|
||||
+ * host switch actually hosts. It still boots peripheral-by-default (ID floats
|
||||
+ * device until `host` asserts it), so the usb0 RNDIS recovery gadget that
|
||||
+ * client mode + net-flash rely on continues to bind. "host" alone would break
|
||||
+ * that recovery gadget, so "otg" is the correct value.
|
||||
+ */
|
||||
+ dr_mode = "otg";
|
||||
};
|
||||
|
||||
/**********RTC**********/
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/sysdrv/source/kernel/scripts/mkimg
|
||||
+++ b/sysdrv/source/kernel/scripts/mkimg
|
||||
@@ -51,6 +51,11 @@
|
||||
LOGO_KERNEL_PATH=${srctree}/logo_kernel.bmp
|
||||
[ -f ${LOGO_KERNEL_PATH} ] && LOGO_KERNEL=logo_kernel.bmp
|
||||
|
||||
+# flare-edge: USB-recovery splash, drawn by U-Boot's download path
|
||||
+# (cmd/download.c rockchip_show_bmp("logo_recovery.bmp"))
|
||||
+LOGO_RECOVERY_PATH=${srctree}/logo_recovery.bmp
|
||||
+[ -f ${LOGO_RECOVERY_PATH} ] && LOGO_RECOVERY=logo_recovery.bmp
|
||||
+
|
||||
KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
|
||||
KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"
|
||||
if [ "${ARCH}" == "arm" ]; then
|
||||
@@ -243,8 +248,9 @@
|
||||
cp -a ${LOGO_KERNEL_PATH} ${objtree}/;
|
||||
fi
|
||||
fi
|
||||
-scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} >/dev/null
|
||||
-echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL}) is ready"
|
||||
+[ -n "${LOGO_RECOVERY}" ] && cp -f "${LOGO_RECOVERY_PATH}" "${LOGO_RECOVERY}"
|
||||
+scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} >/dev/null
|
||||
+echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY}) is ready"
|
||||
|
||||
if [ -f "${BOOT_IMG}" ]; then
|
||||
if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/sysdrv/source/kernel/scripts/mkimg
|
||||
+++ b/sysdrv/source/kernel/scripts/mkimg
|
||||
@@ -55,7 +55,10 @@
|
||||
# (cmd/download.c rockchip_show_bmp("logo_recovery.bmp"))
|
||||
LOGO_RECOVERY_PATH=${srctree}/logo_recovery.bmp
|
||||
[ -f ${LOGO_RECOVERY_PATH} ] && LOGO_RECOVERY=logo_recovery.bmp
|
||||
+# flare-edge: tapped verbose-boot acknowledgement, selected by U-Boot
|
||||
+LOGO_VERBOSE_PATH=${srctree}/logo_verbose.bmp
|
||||
+[ -f ${LOGO_VERBOSE_PATH} ] && LOGO_VERBOSE=logo_verbose.bmp
|
||||
|
||||
KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
|
||||
KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"
|
||||
if [ "${ARCH}" == "arm" ]; then
|
||||
@@ -248,8 +251,9 @@
|
||||
fi
|
||||
fi
|
||||
[ -n "${LOGO_RECOVERY}" ] && cp -f "${LOGO_RECOVERY_PATH}" "${LOGO_RECOVERY}"
|
||||
-scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} >/dev/null
|
||||
-echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY}) is ready"
|
||||
+[ -n "${LOGO_VERBOSE}" ] && cp -f "${LOGO_VERBOSE_PATH}" "${LOGO_VERBOSE}"
|
||||
+scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} ${LOGO_VERBOSE} >/dev/null
|
||||
+echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} ${LOGO_VERBOSE}) is ready"
|
||||
|
||||
if [ -f "${BOOT_IMG}" ]; then
|
||||
if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
|
||||
@@ -0,0 +1,32 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
index f4e6fb77e..202710496 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
@@ -108,6 +108,27 @@ linux,cma {
|
||||
mmc_ecsd: mmc@3f000 {
|
||||
reg = <0x3f000 0x00001000>;
|
||||
};
|
||||
+
|
||||
+ /*
|
||||
+ * flare-edge: pstore/ramoops persistent crash region. 1 MiB at
|
||||
+ * 240 MiB (of 256 MiB DRAM: reg = <0x0 0x10000000>). Placed HIGH,
|
||||
+ * far above the low kernel-image/DTB/initrd load zone, so this
|
||||
+ * carve-out can only REMOVE RAM from the kernel -- it cannot cause
|
||||
+ * the c8a3-class collision (which was an UN-reserved 0x40000 used
|
||||
+ * by both the boot MCU and the kernel). Kept below the very top of
|
||||
+ * DRAM (U-Boot self-relocates there) so the log is more likely to
|
||||
+ * survive into the recovery boot. console-size captures the kernel
|
||||
+ * console ring (the boot log before a hang); record-size captures
|
||||
+ * oops/panic. No ECC (no reed-solomon dep); no no-map (ramoops
|
||||
+ * memremaps the region itself). See kernel cfg flare-edge.config.
|
||||
+ */
|
||||
+ ramoops@0f000000 {
|
||||
+ compatible = "ramoops";
|
||||
+ reg = <0x0f000000 0x00100000>;
|
||||
+ console-size = <0x00040000>;
|
||||
+ record-size = <0x00020000>;
|
||||
+ pmsg-size = <0x00020000>;
|
||||
+ };
|
||||
};
|
||||
|
||||
acodec_sound: acodec-sound {
|
||||
@@ -0,0 +1,23 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
index f4e6fb77e..dc08f6256 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
@@ -302,3 +302,18 @@ tp_irq: tp-irq {
|
||||
};
|
||||
};
|
||||
};
|
||||
+
|
||||
+/*********************** on-demand MaskRom ************************/
|
||||
+/*
|
||||
+ * flare-edge: let the OS reach TRUE BootROM MaskRom (USB 2207:110c, reliably
|
||||
+ * flashable) via `warden-maskrom maskrom` -> reboot(RESTART2,"maskrom") ->
|
||||
+ * syscon-reboot-mode writes BOOT_BROM_DOWNLOAD to the boot-mode reg 0xff020200.
|
||||
+ * One-shot: a power-on-reset clears the PMU-domain reg. The stock
|
||||
+ * mode-loader/-bootloader only reach U-Boot rockusb "Loader" mode, whose WL is
|
||||
+ * unreliable for multi-partition flashing (writes report 100% but do not
|
||||
+ * persist); this reaches the BootROM proper, where db+wl are reliable.
|
||||
+ * 0xEF08A53C == U-Boot BOOT_BROM_DOWNLOAD (arch-rockchip/boot_mode.h).
|
||||
+ */
|
||||
+&reboot_mode {
|
||||
+ mode-maskrom = <0xEF08A53C>;
|
||||
+};
|
||||
@@ -0,0 +1,55 @@
|
||||
The panel DTS as the SDK actually has it.
|
||||
|
||||
Replaying patches 0001-0006 onto a pristine vendor tree did not reproduce this
|
||||
file: the board model string is "Luckfox Pico 86Panel W" in the SDK, and the
|
||||
watchdog block 0002 adds sits in a different place. Both were hand-edits made
|
||||
directly in the SDK checkout and never captured here, so a rebuild from a clean
|
||||
vendor tree plus this series produced a DTS that differed from the one every
|
||||
shipped image was built with.
|
||||
|
||||
This patch is the remainder, generated by diffing the replayed result against
|
||||
the live SDK. It has no intent of its own beyond making the series faithful.
|
||||
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <dt-bindings/display/media-bus-format.h>
|
||||
|
||||
/ {
|
||||
- model = "Luckfox Pico 86Panel";
|
||||
+ model = "Luckfox Pico 86Panel W";
|
||||
compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106g3";
|
||||
|
||||
restart-poweroff {
|
||||
@@ -134,21 +134,17 @@
|
||||
/**********USB**********/
|
||||
&usbdrd_dwc3 {
|
||||
status = "okay";
|
||||
- /*
|
||||
- * flare-edge: dual-role (OTG), not peripheral-only.
|
||||
- *
|
||||
- * router mode switches the port to USB HOST at runtime (S26usbhost writes
|
||||
- * `host` to the inno-usb2 phy otg_mode) so a USB-Ethernet adapter enumerates
|
||||
- * as an extra LAN port. With dr_mode = "peripheral" the dwc3 registers the
|
||||
- * gadget role ONLY -- no xHCI host is instantiated, so `echo host` flips the
|
||||
- * phy but nothing on the port ever enumerates (a silent no-op). "otg" compiles
|
||||
- * BOTH roles and keeps the extcon/iddig DRD state machine live, so the runtime
|
||||
- * host switch actually hosts. It still boots peripheral-by-default (ID floats
|
||||
- * device until `host` asserts it), so the usb0 RNDIS recovery gadget that
|
||||
- * client mode + net-flash rely on continues to bind. "host" alone would break
|
||||
- * that recovery gadget, so "otg" is the correct value.
|
||||
- */
|
||||
+ /* otg, not host: CONFIG_USB_DWC3_DUAL_ROLE is built in, so the port can
|
||||
+ * still come up as a gadget (usb0) when cabled to a PC while also being
|
||||
+ * able to host a USB Ethernet adapter. host would work for the adapter
|
||||
+ * but would remove the gadget link permanently. */
|
||||
dr_mode = "otg";
|
||||
+ //dr_mode = "peripheral";
|
||||
+ //dr_mode = "host";
|
||||
+ /* flare-edge: set to otg for the host/client live-switch test — a stable
|
||||
+ * network path (onboard eth0) is now in hand, so the usb0-gadget-inconsistency
|
||||
+ * that motivated the earlier peripheral revert no longer blocks us. This
|
||||
+ * matches sdk-patches/kernel/patches/0003-usb-otg-dual-role.patch. */
|
||||
};
|
||||
|
||||
/**********RTC**********/
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
#!/bin/sh
|
||||
# adbd-no-tcp-cases.sh BASE_DIR PATCH_FILE
|
||||
#
|
||||
# Runs test-adbd-no-tcp.sh on the real patch (must PASS), on the unpatched base
|
||||
# (must FAIL), and on four mutants of the patch. Each mutant must FAIL, and its
|
||||
# FAIL line must name the reason given here:
|
||||
# gate-makefile-only ADBD_INPUTS hashes only the Makefile; the patch set and
|
||||
# the gate script are dropped (bfe-core1106-sdk#46)
|
||||
# no-fail-fast the rule ignores failed series, patch and copy steps,
|
||||
# so a failed 0017 hunk still stamps adbd (bfe-core1106-sdk#45)
|
||||
# copy-unchecked only the copy into out/usr/bin is unchecked, so a failed
|
||||
# copy still writes the stamp (bfe-core1106-sdk#45)
|
||||
# gate-no-tarballs ADBD_INPUTS drops the two source tarballs, so a changed
|
||||
# tarball keeps a stale adbd (bfe-core1106-sdk#49)
|
||||
# Usage and layout: see test-adbd-no-tcp.sh.
|
||||
# Exit 0 when every case behaves as expected, 1 otherwise, 2 on usage.
|
||||
set -u
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: $0 BASE_DIR PATCH_FILE" >&2
|
||||
exit 2
|
||||
fi
|
||||
HERE=$(cd "$(dirname "$0")" && pwd) || exit 2
|
||||
TEST=$HERE/test-adbd-no-tcp.sh
|
||||
BASE=$(cd "$1" && pwd) || exit 2
|
||||
PATCH=$(cd "$(dirname "$2")" && pwd)/$(basename "$2") || exit 2
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/adbd-no-tcp-cases.XXXXXX") || exit 2
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
fail=0
|
||||
pass() { echo "PASS $1"; }
|
||||
bad() { echo "FAIL $1"; fail=1; }
|
||||
|
||||
# mutant NAME: writes $WORK/NAME.patch from PATCH with the sed script
|
||||
# $WORK/NAME.sed. Fails when the script changes nothing.
|
||||
mutant() {
|
||||
sed -f "$WORK/$1.sed" "$PATCH" > "$WORK/$1.patch" || return 1
|
||||
if cmp -s "$PATCH" "$WORK/$1.patch"; then return 1; fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# expect WANT LABEL PATCH [REASON]: runs the test on PATCH. The exit status must
|
||||
# be WANT. For a FAIL case, REASON must appear in one of the FAIL lines.
|
||||
expect() {
|
||||
log=$WORK/run-$(echo "$2" | tr -c 'a-zA-Z0-9' '_').log
|
||||
sh "$TEST" "$BASE" "$3" > "$log" 2>&1
|
||||
rc=$?
|
||||
if [ "$rc" != "$1" ]; then
|
||||
bad "$2 (exit $rc, want $1)"
|
||||
return
|
||||
fi
|
||||
if [ -n "${4:-}" ] && ! grep -q "^FAIL.*$4" "$log"; then
|
||||
bad "$2 (exit $rc, no FAIL line names: $4)"
|
||||
return
|
||||
fi
|
||||
pass "$2 (exit $rc)"
|
||||
}
|
||||
|
||||
# The mutant scripts. Each edits only the Makefile hunk of the patch, or the
|
||||
# gate line that carries ADBD_INPUTS.
|
||||
cat > "$WORK/gate-makefile-only.sed" <<'SEDEOF'
|
||||
s#^+ADBD_INPUTS := .*$#+ADBD_INPUTS := $(shell sha256sum $(CURRENT_DIR)/Makefile | cut -c1-64)#
|
||||
SEDEOF
|
||||
cat > "$WORK/no-fail-fast.sed" <<'SEDEOF'
|
||||
/^diff --git a\/sysdrv\/tools\/board\/android-tools\/Makefile /,/^diff --git a\/sysdrv\/tools\/board\/android-tools\/adbd-current.sh /{
|
||||
/^+/{
|
||||
s/ || exit 1//
|
||||
s/\$(SHELL) -e /$(SHELL) /
|
||||
}
|
||||
}
|
||||
SEDEOF
|
||||
cat > "$WORK/copy-unchecked.sed" <<'SEDEOF'
|
||||
/^diff --git a\/sysdrv\/tools\/board\/android-tools\/Makefile /,/^diff --git a\/sysdrv\/tools\/board\/android-tools\/adbd-current.sh /{
|
||||
/^+.*cp -f /s/ || exit 1//
|
||||
}
|
||||
SEDEOF
|
||||
|
||||
cat > "$WORK/gate-no-tarballs.sed" <<'SEDEOF'
|
||||
s#^+ADBD_INPUTS := .*$#+ADBD_INPUTS := $(shell cat $(CURRENT_DIR)/Makefile $(CURRENT_DIR)/adbd-current.sh $(CURRENT_DIR)/$(PKG_PATCHES_ANDROID_TOOLS)/* | sha256sum | cut -d' ' -f1)#
|
||||
SEDEOF
|
||||
|
||||
expect 0 "real patch" "$PATCH"
|
||||
expect 1 "unpatched base" none
|
||||
if mutant gate-makefile-only; then
|
||||
expect 1 "mutant gate-makefile-only" "$WORK/gate-makefile-only.patch" "ADBD_INPUTS is"
|
||||
else
|
||||
bad "mutant gate-makefile-only does not change the patch"
|
||||
fi
|
||||
if mutant no-fail-fast; then
|
||||
expect 1 "mutant no-fail-fast" "$WORK/no-fail-fast.patch" "stops before compile"
|
||||
else
|
||||
bad "mutant no-fail-fast does not change the patch"
|
||||
fi
|
||||
if mutant copy-unchecked; then
|
||||
expect 1 "mutant copy-unchecked" "$WORK/copy-unchecked.patch" "copy into out/usr/bin"
|
||||
else
|
||||
bad "mutant copy-unchecked does not change the patch"
|
||||
fi
|
||||
|
||||
if mutant gate-no-tarballs; then
|
||||
expect 1 "mutant gate-no-tarballs" "$WORK/gate-no-tarballs.patch" "ADBD_INPUTS is"
|
||||
else
|
||||
bad "mutant gate-no-tarballs does not change the patch"
|
||||
fi
|
||||
|
||||
if [ "$fail" = 0 ]; then
|
||||
echo "RESULT PASS"
|
||||
exit 0
|
||||
fi
|
||||
echo "RESULT FAIL"
|
||||
exit 1
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
#!/bin/sh
|
||||
# test-adbd-no-tcp.sh BASE_DIR PATCH_FILE|none
|
||||
#
|
||||
# Regression test for flare-edge#3129 (adbd listened on TCP 5555 and on
|
||||
# 127.0.0.1:5037), bfe-core1106-sdk#44 (a change to the adbd patch set never
|
||||
# reached the image), bfe-core1106-sdk#45 (a failed patch or copy step still
|
||||
# stamped adbd current) and bfe-core1106-sdk#46 (the gate was tested by a copy
|
||||
# of its formula instead of by the Makefile) and bfe-core1106-sdk#49 (a changed
|
||||
# source tarball did not rebuild adbd).
|
||||
#
|
||||
# BASE_DIR holds sysdrv/tools/board/android-tools at the luckfox base commit
|
||||
# 824b817f8, as in the vendor checkout:
|
||||
# git -C <luckfox-sdk> archive 824b817f8 sysdrv/tools/board/android-tools | tar -C BASE_DIR -xf -
|
||||
# PATCH_FILE is luckfox-sdk-patches/board/patches/0015-adbd-no-tcp-listener.patch,
|
||||
# or "none" to check the unpatched base, which must FAIL.
|
||||
#
|
||||
# The android-tools rule of the Makefile runs for real under make, with stub
|
||||
# toolchains, so nothing is compiled: the compiler stub only creates its -o
|
||||
# file. The fail-closed cases each break one step and check that the rule stops
|
||||
# before the stamp is written. tests/adbd-no-tcp-cases.sh runs this test on the
|
||||
# real patch, on the base and on mutants of the patch.
|
||||
# Exit 0 PASS, 1 FAIL, 2 usage or missing input.
|
||||
set -u
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
fail=0
|
||||
pass() { echo "PASS $1"; }
|
||||
bad() { echo "FAIL $1"; fail=1; }
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: $0 BASE_DIR PATCH_FILE|none" >&2
|
||||
exit 2
|
||||
fi
|
||||
BASE=$1
|
||||
PATCH=$2
|
||||
if [ ! -d "$BASE/sysdrv/tools/board/android-tools" ]; then
|
||||
echo "no sysdrv/tools/board/android-tools under $BASE" >&2
|
||||
exit 2
|
||||
fi
|
||||
BASE=$(cd "$BASE" && pwd) || exit 2
|
||||
if [ "$PATCH" != none ]; then
|
||||
[ -f "$PATCH" ] || { echo "no patch file $PATCH" >&2; exit 2; }
|
||||
PATCH=$(cd "$(dirname "$PATCH")" && pwd)/$(basename "$PATCH")
|
||||
fi
|
||||
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/adbd-no-tcp.XXXXXX") || exit 2
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
TREE=$WORK/tree
|
||||
mkdir -p "$TREE/sysdrv/tools/board" || exit 2
|
||||
cp -a "$BASE/sysdrv/tools/board/android-tools" "$TREE/sysdrv/tools/board/" || exit 2
|
||||
AT=$TREE/sysdrv/tools/board/android-tools
|
||||
|
||||
# 1. The board patch applies to the base tree.
|
||||
if [ "$PATCH" != none ]; then
|
||||
if (cd "$TREE" && git apply --check "$PATCH" && git apply "$PATCH") 2>"$WORK/apply.err"; then
|
||||
pass "board patch applies to the base tree"
|
||||
else
|
||||
bad "board patch does not apply to the base tree: $(head -3 "$WORK/apply.err")"
|
||||
echo "RESULT FAIL"; exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Stub toolchain for the rule: the compiler (also CXX and CPP), strip, and the
|
||||
# openssl and zlib sub-makes. The compiler stub logs each run to $STUB_LOG,
|
||||
# creates its -o output, and fails when STUB_CC_FAIL is set.
|
||||
STUB=$WORK/stub
|
||||
mkdir -p "$STUB/dep" || exit 2
|
||||
cat > "$STUB/cross-gcc" <<'STUBEOF'
|
||||
#!/bin/sh
|
||||
[ -n "${STUB_LOG:-}" ] && echo "cc $*" >> "$STUB_LOG"
|
||||
[ -n "${STUB_CC_FAIL:-}" ] && { echo "stub compiler: forced failure" >&2; exit 1; }
|
||||
out=
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "$1" = -o ]; then out=$2; shift; fi
|
||||
shift
|
||||
done
|
||||
[ -n "$out" ] && : > "$out"
|
||||
exit 0
|
||||
STUBEOF
|
||||
cp "$STUB/cross-gcc" "$STUB/cross-g++" || exit 2
|
||||
cp "$STUB/cross-gcc" "$STUB/cross-cpp" || exit 2
|
||||
printf '#!/bin/sh\nexit 0\n' > "$STUB/cross-strip" || exit 2
|
||||
printf 'all:\n\t@true\n' > "$STUB/dep/Makefile" || exit 2
|
||||
chmod 755 "$STUB/cross-gcc" "$STUB/cross-g++" "$STUB/cross-cpp" "$STUB/cross-strip" || exit 2
|
||||
|
||||
# run_make AT_DIR LOG: runs the rule of the Makefile in AT_DIR under make, with
|
||||
# the stubs. Sets RC (make's exit status) and CC_RUNS (compiler runs).
|
||||
run_make() {
|
||||
rm -f "$2.cc"
|
||||
(cd "$1" && STUB_LOG="$2.cc" make -f Makefile SYSDRV_PARAM=/dev/null \
|
||||
SYSDRV_CROSS="$STUB/cross" SYSDRV_JOBS=1 \
|
||||
PKG_DEP_OPENSSL="$STUB/dep" PKG_DEP_ZLIB="$STUB/dep" all) > "$2" 2>&1
|
||||
RC=$?
|
||||
CC_RUNS=0
|
||||
if [ -s "$2.cc" ]; then CC_RUNS=$(wc -l < "$2.cc" | tr -d ' '); fi
|
||||
}
|
||||
|
||||
# case_at NAME: a fresh copy of the patched android-tools tree; prints its path.
|
||||
case_at() {
|
||||
rm -rf "$WORK/case-$1"
|
||||
mkdir -p "$WORK/case-$1/sysdrv/tools/board" || return 1
|
||||
cp -a "$AT" "$WORK/case-$1/sysdrv/tools/board/" || return 1
|
||||
echo "$WORK/case-$1/sysdrv/tools/board/android-tools"
|
||||
}
|
||||
|
||||
# 2. The rule applies every debian series entry and every android-tools.patch.sh
|
||||
# step, builds adbd, and writes the stamp.
|
||||
GOOD=$(case_at good) || exit 2
|
||||
run_make "$GOOD" "$WORK/good.log"
|
||||
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then
|
||||
pass "rule applies the debian series and android-tools.patch.sh, then builds adbd"
|
||||
else
|
||||
bad "rule does not build adbd from the patch set (rc $RC, compiler runs $CC_RUNS): $(grep -m1 -E 'FAILED|No such|Error' "$WORK/good.log")"
|
||||
fi
|
||||
|
||||
# 3. The device half of adb_main(), in the source the rule generated: the TCP
|
||||
# listeners must be gone, and the USB transport must stay.
|
||||
# Comments are stripped first: the source keeps commented-out calls, and a
|
||||
# comment that names a call is not a call.
|
||||
ADB=$GOOD/android-tools/core/adbd/adb.c
|
||||
awk '
|
||||
/^int adb_main\(/ { inmain = 1 }
|
||||
inmain && /^}/ { exit }
|
||||
inmain {
|
||||
if (incom) { if (index($0, "*/")) incom = 0; next }
|
||||
if (index($0, "/*")) { if (!index($0, "*/")) incom = 1; next }
|
||||
line = $0
|
||||
sub(/\/\/.*/, "", line)
|
||||
if (line ~ /^#if ADB_HOST/) { host = 1; next }
|
||||
if (host && line ~ /^#else/) { host = 0; dev = 1; next }
|
||||
if (dev && line ~ /^#endif/) { dev = 0; next }
|
||||
if (dev) print line
|
||||
}' "$ADB" > "$WORK/device-main.txt" 2>/dev/null
|
||||
if [ ! -s "$WORK/device-main.txt" ]; then
|
||||
bad "could not extract the device half of adb_main()"
|
||||
else
|
||||
if grep -q 'local_init' "$WORK/device-main.txt"; then
|
||||
bad "adb_main() device half still calls local_init (TCP 5555 listener)"
|
||||
else
|
||||
pass "adb_main() device half opens no TCP 5555 listener"
|
||||
fi
|
||||
if grep -q 'install_listener' "$WORK/device-main.txt"; then
|
||||
bad "adb_main() device half still installs a smartsocket listener (tcp:5037)"
|
||||
else
|
||||
pass "adb_main() device half installs no smartsocket listener"
|
||||
fi
|
||||
for need in 'usb_init()' 'Using USB' 'init_jdwp()'; do
|
||||
if grep -q "$need" "$WORK/device-main.txt"; then
|
||||
pass "adb_main() device half keeps: $need"
|
||||
else
|
||||
bad "adb_main() device half lost the USB path: $need"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# 4. The gate, as the Makefile evaluates it: ADBD_INPUTS must be the sha256 of
|
||||
# the Makefile, adbd-current.sh, the patch set and the two adbd source
|
||||
# tarballs, the five inputs that the stamp must match.
|
||||
# shellcheck disable=SC2016 # the make text must reach make unexpanded
|
||||
printf '%s\n' '$(info ADBD_INPUTS=$(ADBD_INPUTS))' > "$WORK/probe.mk" || exit 2
|
||||
probe=$(cd "$GOOD" && make -s -f Makefile -f "$WORK/probe.mk" SYSDRV_PARAM=/dev/null no-such-target 2>/dev/null | sed -n 's/^ADBD_INPUTS=//p')
|
||||
want=$(cd "$AT" && cat Makefile adbd-current.sh android-tools-patches/* android-tools_4.2.2+git20130218.orig.tar.xz android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz 2>/dev/null | sha256sum | cut -d' ' -f1)
|
||||
if [ -n "$probe" ] && [ "$probe" = "$want" ]; then
|
||||
pass "ADBD_INPUTS is the sha256 of Makefile, adbd-current.sh, the patch set and the source tarballs"
|
||||
else
|
||||
bad "ADBD_INPUTS is '$probe', want '$want' (sha256 of Makefile, adbd-current.sh, the patch set and the source tarballs)"
|
||||
fi
|
||||
|
||||
# 5. The rule itself: a matching stamp with adbd present skips the build, and a
|
||||
# stale or missing stamp rebuilds it. The stamp must hold ADBD_INPUTS.
|
||||
if [ -n "$probe" ] && [ "$(cat "$GOOD/out/.adbd-inputs" 2>/dev/null)" = "$probe" ]; then
|
||||
pass "rule writes the stamp of its inputs after the build"
|
||||
else
|
||||
bad "rule did not write the stamp of its inputs after the build"
|
||||
fi
|
||||
run_make "$GOOD" "$WORK/skip.log"
|
||||
if [ "$RC" = 0 ] && [ "$CC_RUNS" = 0 ] && [ -n "$probe" ] && [ "$(cat "$GOOD/out/.adbd-inputs" 2>/dev/null)" = "$probe" ]; then
|
||||
pass "rule skips adbd when the stamp matches"
|
||||
else
|
||||
bad "rule did not skip adbd with a matching stamp (rc $RC, compiler runs $CC_RUNS)"
|
||||
fi
|
||||
echo "0000000000000000000000000000000000000000000000000000000000000000" > "$GOOD/out/.adbd-inputs" || exit 2
|
||||
run_make "$GOOD" "$WORK/stale.log"
|
||||
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then
|
||||
pass "rule rebuilds adbd when the stamp is stale"
|
||||
else
|
||||
bad "rule did not rebuild adbd with a stale stamp (rc $RC, compiler runs $CC_RUNS)"
|
||||
fi
|
||||
rm -f "$GOOD/out/.adbd-inputs"
|
||||
run_make "$GOOD" "$WORK/nostamp.log"
|
||||
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then
|
||||
pass "rule rebuilds adbd when there is no stamp"
|
||||
else
|
||||
bad "rule did not rebuild adbd without a stamp (rc $RC, compiler runs $CC_RUNS)"
|
||||
fi
|
||||
|
||||
# 5b. The source tarballs are inputs too: a changed tarball must rebuild adbd
|
||||
# when the Makefile, the gate script and the patch set are unchanged.
|
||||
D=$(case_at tarball) || exit 2
|
||||
run_make "$D" "$WORK/tarball-built.log"
|
||||
first_built=0
|
||||
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then first_built=1; fi
|
||||
t=$D/android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz
|
||||
tb=$WORK/tarball-edit
|
||||
rm -rf "$tb" && mkdir -p "$tb" || exit 2
|
||||
if [ "$first_built" = 1 ] && tar -xzf "$t" -C "$tb" && : > "$tb/debian/.tarball-changed" && tar -czf "$t.new" -C "$tb" debian && mv "$t.new" "$t"; then
|
||||
run_make "$D" "$WORK/tarball.log"
|
||||
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then
|
||||
pass "rule rebuilds adbd when a source tarball changes"
|
||||
else
|
||||
bad "rule did not rebuild adbd after a source tarball change (rc $RC, compiler runs $CC_RUNS)"
|
||||
fi
|
||||
else
|
||||
bad "could not build the tarball case (first build or tarball edit failed)"
|
||||
fi
|
||||
|
||||
# 6. Fail closed. An injected failure must stop the rule with a non-zero status
|
||||
# and leave no stamp. The failures before the compile step must also stop the
|
||||
# rule before the compiler runs.
|
||||
check_closed() { # AT_DIR LOG PRE LABEL
|
||||
run_make "$1" "$2"
|
||||
stamp=absent
|
||||
[ -e "$1/out/.adbd-inputs" ] && stamp=written
|
||||
if [ "$RC" != 0 ] && [ "$stamp" = absent ] && { [ "$3" != pre ] || [ "$CC_RUNS" = 0 ]; }; then
|
||||
pass "$4"
|
||||
else
|
||||
bad "$4 (rc $RC, stamp $stamp, compiler runs $CC_RUNS): $(grep -m1 -E 'FAILED|No such|Error|forced|cannot|Is a directory' "$2")"
|
||||
fi
|
||||
}
|
||||
inject_drift() { # AT_DIR: one removed line of the 0017 hunk stops matching
|
||||
f=$1/android-tools-patches/0017-no-adb-tcp-listener.patch
|
||||
[ -f "$f" ] || return 1
|
||||
awk '{ if ($0 == "- build_local_name(local_name, sizeof(local_name), server_port);") $0 = $0 " /* drift */"; print }' "$f" > "$f.new" || return 1
|
||||
grep -q 'drift' "$f.new" || return 1
|
||||
mv "$f.new" "$f"
|
||||
}
|
||||
inject_middle() { # AT_DIR: a failing patch step ahead of the last step
|
||||
f=$1/android-tools-patches/android-tools.patch.sh
|
||||
[ -f "$f" ] || return 1
|
||||
awk 'NR == 4 { print "patch -p1 < 0000-no-such-patch.patch" } { print }' "$f" > "$f.new" || return 1
|
||||
mv "$f.new" "$f"
|
||||
}
|
||||
inject_series() { # AT_DIR: a debian series entry with no patch file behind it
|
||||
t=$1/android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz
|
||||
d=$WORK/deb-series
|
||||
rm -rf "$d" && mkdir -p "$d" || return 1
|
||||
tar -xzf "$t" -C "$d" || return 1
|
||||
printf '\nno-such-debian-patch.patch\n' >> "$d/debian/patches/series" || return 1
|
||||
tar -czf "$t.new" -C "$d" debian || return 1
|
||||
mv "$t.new" "$t"
|
||||
}
|
||||
|
||||
D=$(case_at drift) || exit 2
|
||||
if inject_drift "$D"; then
|
||||
check_closed "$D" "$WORK/drift.log" pre "rule stops before compile when a 0017 hunk does not apply"
|
||||
else
|
||||
bad "could not inject a 0017 failure (no 0017 patch in the tree)"
|
||||
fi
|
||||
D=$(case_at middle) || exit 2
|
||||
if inject_middle "$D"; then
|
||||
check_closed "$D" "$WORK/middle.log" pre "rule stops before compile when a middle android-tools.patch.sh step fails"
|
||||
else
|
||||
bad "could not inject a failing android-tools.patch.sh step"
|
||||
fi
|
||||
D=$(case_at series) || exit 2
|
||||
if inject_series "$D"; then
|
||||
check_closed "$D" "$WORK/series.log" pre "rule stops before compile when a debian series entry does not apply"
|
||||
else
|
||||
bad "could not inject a failing debian series entry"
|
||||
fi
|
||||
D=$(case_at compile) || exit 2
|
||||
export STUB_CC_FAIL=1
|
||||
check_closed "$D" "$WORK/compile.log" any "rule stops and writes no stamp when the compiler fails"
|
||||
unset STUB_CC_FAIL
|
||||
D=$(case_at copy) || exit 2
|
||||
mkdir -p "$D/out/usr/bin/adbd" || exit 2
|
||||
check_closed "$D" "$WORK/copy.log" any "rule stops and writes no stamp when the copy into out/usr/bin fails"
|
||||
|
||||
# 7. The Makefile still parses (a parse error prints something other than
|
||||
# "No rule to make target").
|
||||
if (cd "$AT" && make -f Makefile SYSDRV_PARAM=/dev/null -n no-such-target 2>&1 | grep -q 'No rule to make target'); then
|
||||
pass "Makefile parses"
|
||||
else
|
||||
bad "Makefile does not parse"
|
||||
fi
|
||||
|
||||
if [ "$fail" = 0 ]; then
|
||||
echo "RESULT PASS"
|
||||
exit 0
|
||||
fi
|
||||
echo "RESULT FAIL"
|
||||
exit 1
|
||||
@@ -0,0 +1,10 @@
|
||||
# flare-edge: A/B slot boot in U-Boot proper.
|
||||
#
|
||||
# Lean port of the vendor SPL A/B engine (common/flare_ab.c): AOSP
|
||||
# AvbABData metadata in one CRC32-protected sector at misc+2048, slot
|
||||
# suffixing hooked into part_get_info_by_name() (covers boot_fit AND the
|
||||
# board_init()-time kernel-DTB/resource load), one tries decrement per
|
||||
# boot attempt while a slot is unconfirmed, recovery-FIT fallback when
|
||||
# both slots are exhausted, MaskRom when even that fails.
|
||||
# Design: docs/decisions/0001-slot-machine.md (flare-edge repo).
|
||||
CONFIG_FLARE_AB=y
|
||||
@@ -0,0 +1,35 @@
|
||||
# flare-edge: the env bootcount escalation layer is RETIRED.
|
||||
#
|
||||
# History: this fragment used to enable U-Boot's env bootcount
|
||||
# options: autoboot.c incremented a counter in the 32 KiB env on
|
||||
# every boot and, once it passed ${bootlimit}, ran ${altbootcmd}=download to
|
||||
# drop into USB download/MaskRom. Two properties made it dangerous:
|
||||
# 1. The counter lived in the env, so it PERSISTED across power cycles.
|
||||
# 2. It escalated to USB download, not to the recovery FIT.
|
||||
# A panel that lost power mid-boot several times therefore walked the counter
|
||||
# past the limit and then booted straight into the USB-download screen on EVERY
|
||||
# power-on, with no way to clear it from the device (issue #123, seen on a real
|
||||
# panel at the warehouse 2026-09-02).
|
||||
#
|
||||
# Replacement: the A/B engine (common/flare_ab.c) now drives boot-failure
|
||||
# escalation from a PMU register (OS_REG4), gated on the CRU reset-status
|
||||
# register. It survives a warm reset (so in-session retries accumulate) but is
|
||||
# cleared by a power-on reset, so escalation is: selected slot for a couple of
|
||||
# attempts, then the other committed slot, then the recovery FIT, then USB
|
||||
# download -- and a POWER CYCLE always restarts at the selected slot. flared
|
||||
# clears OS_REG4 once a boot proves healthy and before a deliberate reboot. No
|
||||
# per-boot flash writes, and no state that can strand a device across a power
|
||||
# cycle. See docs/boot-flow.md and docs/decisions/0001-slot-machine.md.
|
||||
#
|
||||
# The filename is kept so the board makefile fragment-list reference
|
||||
# (sdk-patches/board/patches/0001-86panel-seatbelt-wiring.patch) still resolves.
|
||||
# This fragment is merged last, so it disables bootcount and sets the env
|
||||
# whitelist authoritatively.
|
||||
# CONFIG_BOOTCOUNT is not set
|
||||
# CONFIG_BOOTCOUNT_LIMIT is not set
|
||||
# CONFIG_BOOTCOUNT_ENV is not set
|
||||
# Env whitelist WITHOUT the retired escalation keys (bootcount, bootlimit,
|
||||
# altbootcmd, upgrade_available) -- a stale env carrying them can no longer feed
|
||||
# the retired layer. bootcmd/bootdelay/preboot stay so a provisioned env can
|
||||
# still override the compiled-in boot command.
|
||||
CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved ipaddr serverip netmask gatewayip ethaddr bootcmd bootdelay preboot"
|
||||
@@ -0,0 +1,78 @@
|
||||
# CONFIG_ATMEL_HLCD is not set
|
||||
# CONFIG_BACKLIGHT_GPIO is not set
|
||||
CONFIG_BACKLIGHT_PWM=y
|
||||
# CONFIG_CMD_BMP is not set
|
||||
# CONFIG_CMD_REGULATOR is not set
|
||||
CONFIG_CONSOLE_NORMAL=y
|
||||
# CONFIG_CONSOLE_ROTATION is not set
|
||||
CONFIG_CONSOLE_SCROLL_LINES=1
|
||||
# CONFIG_CONSOLE_TRUETYPE is not set
|
||||
CONFIG_DISPLAY=y
|
||||
CONFIG_DM_PWM=y
|
||||
# CONFIG_DM_REGULATOR_FIXED is not set
|
||||
# CONFIG_DM_REGULATOR_GPIO is not set
|
||||
CONFIG_DM_REGULATOR=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
# CONFIG_DRM_MAXIM_MAX96745 is not set
|
||||
# CONFIG_DRM_MAXIM_MAX96752F is not set
|
||||
# CONFIG_DRM_MAXIM_MAX96755F is not set
|
||||
CONFIG_DRM_MEM_RESERVED_SIZE_MBYTES=32
|
||||
CONFIG_DRM_MIPI_DSI=y
|
||||
# CONFIG_DRM_PANEL_MAXIM_DESERIALIZER is not set
|
||||
# CONFIG_DRM_ROCKCHIP_ANALOGIX_DP is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_DP is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_HDMI is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_HDMI_QP is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI2 is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_HDMI is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_MIPI_PHY is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_VIDEO_COMBO_PHY is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_VIDEO_PHY is not set
|
||||
# CONFIG_DRM_ROCKCHIP_LVDS is not set
|
||||
CONFIG_DRM_ROCKCHIP_PANEL=y
|
||||
CONFIG_DRM_ROCKCHIP_RGB=y
|
||||
# CONFIG_DRM_ROCKCHIP_RK1000 is not set
|
||||
# CONFIG_DRM_ROCKCHIP_RK618 is not set
|
||||
# CONFIG_DRM_ROCKCHIP_SAMSUNG_MIPI_DCPHY is not set
|
||||
CONFIG_DRM_ROCKCHIP=y
|
||||
CONFIG_I2C_EDID=y
|
||||
# CONFIG_NOP_PHY is not set
|
||||
# CONFIG_PHY_ROCKCHIP_SAMSUNG_HDPTX_HDMI is not set
|
||||
CONFIG_PHY=y
|
||||
# CONFIG_PWM_EXYNOS is not set
|
||||
CONFIG_PWM_ROCKCHIP=y
|
||||
# CONFIG_PWM_TEGRA is not set
|
||||
# CONFIG_REGULATOR_FAN53555 is not set
|
||||
# CONFIG_REGULATOR_PWM is not set
|
||||
# CONFIG_REGULATOR_RK860X is not set
|
||||
CONFIG_ROCKCHIP_CUBIC_LUT_SIZE=0
|
||||
# CONFIG_DRM_ROCKCHIP_TVE is not set
|
||||
# CONFIG_ROCKCHIP_INNO_HDMI_PHY is not set
|
||||
# CONFIG_SPL_DM_REGULATOR is not set
|
||||
# CONFIG_VIDCONSOLE_AS_LCD is not set
|
||||
CONFIG_VIDEO_BPP16=y
|
||||
CONFIG_VIDEO_BPP32=y
|
||||
CONFIG_VIDEO_BPP8=y
|
||||
# CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345 is not set
|
||||
# CONFIG_VIDEO_BRIDGE_NXP_PTN3460 is not set
|
||||
# CONFIG_VIDEO_BRIDGE_PARADE_PS862X is not set
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
# CONFIG_VIDEO_ROCKCHIP is not set
|
||||
# CONFIG_VIDEO_TEGRA124 is not set
|
||||
# flare-edge: BMP logo support for the boot splash. The rockchip_display logo
|
||||
# path accepts 16/24/32bpp (display_logo() in drivers/video/drm/rockchip_display.c);
|
||||
# our logo.bmp is 720x720 24bpp uncompressed, which matches the panel exactly.
|
||||
# flare-edge: keep USING_KERNEL_DTB=y (the proven flow: envf import, fixups),
|
||||
# but adopt an EMBEDDED kernel-style DTB instead of the booted slot's one. The
|
||||
# 6.18 slot's mainline-style DTB has no vendor display nodes, which silenced
|
||||
# the boot logo there; embedding the proven 5.10 board DTB (extracted from the
|
||||
# vendor-built boot.img resource) makes U-Boot's own device world -- display
|
||||
# included -- identical on every slot. Each slot's FIT still hands the real
|
||||
# kernel its own fdt; fdt_addr_r stays reserved for it (see kernel_dtb.c).
|
||||
# A DISABLED USING_KERNEL_DTB was tried first and broke the envf whitelist
|
||||
# import (no blkdevparts on the cmdline -> no eMMC partitions -> rootwait
|
||||
# hang on both slots); do not retry that route without fixing envf.
|
||||
CONFIG_EMBED_KERNEL_DTB=y
|
||||
CONFIG_EMBED_KERNEL_DTB_ALWAYS=y
|
||||
CONFIG_EMBED_KERNEL_DTB_PATH="dts/rv1106-warden-kernel.dtb"
|
||||
@@ -0,0 +1,7 @@
|
||||
# flare-edge: build spl_bootrom.o so BOOT_DEVICE_BOOTROM is a registered SPL
|
||||
# load method. Paired with the board_boot_order() change in
|
||||
# arch/arm/mach-rockchip/spl-boot-order.c, this makes a failed U-Boot load drop
|
||||
# to MaskRom instead of hanging. Does NOT set SPL_ROCKCHIP_BACK_TO_BROM: that
|
||||
# would flip SPL_MMC_SUPPORT off (see mach-rockchip/Kconfig) and hand the whole
|
||||
# load path to the BROM, which is a behaviour change we do not want.
|
||||
CONFIG_SPL_BOOTROM_SUPPORT=y
|
||||
@@ -0,0 +1,12 @@
|
||||
# flare-edge: let U-Boot read the panel's touchscreen.
|
||||
#
|
||||
# The verbose-boot choice is made in the bootloader (see
|
||||
# arch/arm/mach-rockchip/flare_touch.c), so it is on the kernel command line
|
||||
# before the kernel prints its first line. That needs I2C, which this board's
|
||||
# U-Boot did not have: only the EDID I2C helper was set, and that is the display
|
||||
# path's EDID parser, not a controller driver.
|
||||
#
|
||||
# The GT911 sits on i2c3 (i2c@ff460000). Both symbols are required: the
|
||||
# Rockchip controller driver depends on the DM I2C uclass.
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_ROCKCHIP=y
|
||||
@@ -0,0 +1,54 @@
|
||||
# flare-edge: USB device-mode recovery from U-Boot (rockusb gadget).
|
||||
#
|
||||
# WHY: the BootROM only self-enters MaskRom when it cannot LOAD idblock/uboot.
|
||||
# A U-Boot that loads but then fails to boot (a bug in our display/FLARE_AB
|
||||
# code, an exhausted A/B set, a corrupt recovery FIT) never reaches Linux, so
|
||||
# the software MaskRom trigger and the rescue-image RNDIS gadget are both
|
||||
# unavailable, leaving only the daughterboard-blocked BOOT button. Enabling
|
||||
# the DWC3 USB gadget + rockusb closes that gap: `download` (which FLARE_AB and
|
||||
# altbootcmd already invoke on failure) runs `rockusb` FROM U-BOOT
|
||||
# (cmd/download.c), exposing the Rockchip flashing protocol on the existing USB
|
||||
# port (2207:110c, same as MaskRom to upgrade_tool). Recover or reflash without
|
||||
# opening the case. Falls through to `rbrom` (BootROM MaskRom) only if the
|
||||
# gadget can't start.
|
||||
#
|
||||
# RV1106 USB = DWC3 (rv1106.dtsi usb@ffb00000 snps,dwc3) + Innosilicon USB2
|
||||
# PHY, dr_mode=otg. Symbols below mirror the vendor rv1106-usb.config /
|
||||
# rv1106-dfu.config references. Fits the 512K uboot partition (A/B layout).
|
||||
CONFIG_USB=y
|
||||
CONFIG_DM_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_DWC3_GENERIC=y
|
||||
CONFIG_USB_DWC3_GADGET=y
|
||||
# dwc3-generic unconditionally compiles its host (xHCI) probe in non-SPL
|
||||
# builds (it calls xhci_register), so the xHCI host core must link even though
|
||||
# we only use gadget mode; the vendor rv1106-usb.config pairs them the same
|
||||
# way. Harmless in peripheral/otg mode; the host driver is simply never probed.
|
||||
CONFIG_USB_HOST=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
|
||||
CONFIG_DM_REGULATOR=y
|
||||
CONFIG_DM_REGULATOR_FIXED=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_DUALSPEED=y
|
||||
CONFIG_USB_GADGET_DOWNLOAD=y
|
||||
# Fastboot is a separate download function whose FASTBOOT_BUF_ADDR symbol has
|
||||
# no default and would make `yes "" | make oldconfig` loop forever (it produced
|
||||
# a 16 GB log). We only want rockusb, so disable fastboot explicitly, exactly
|
||||
# as the vendor rv1106-dfu.config does. rockusb coexists fine without it.
|
||||
# CONFIG_FASTBOOT is not set
|
||||
CONFIG_USB_GADGET_MANUFACTURER="Rockchip"
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x110c
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x2207
|
||||
CONFIG_USB_GADGET_VBUS_DRAW=2
|
||||
# rockusb has no dedicated Kconfig symbol. f_rockusb.c is #include'd by
|
||||
# f_mass_storage.c and gated purely by CMD_ROCKUSB + the UMS/gadget framework
|
||||
# (the mass-storage function, already defined in rv1106_common.h).
|
||||
CONFIG_CMD_ROCKUSB=y
|
||||
# The display stack + this USB gadget push uboot.itb past the old 256K limit
|
||||
# (287K). scripts/fit-core.sh uses SPL_FIT_IMAGE_KB as BOTH the pack ceiling
|
||||
# and how many KB SPL reads for the FIT. Raise it to 512 to match the A/B
|
||||
# layout's 512K `uboot` partition (docs/decisions/0003-partition-layout.md).
|
||||
# This is an SPL/idblock change (self-recovering to MaskRom if wrong), taken in
|
||||
# the same MaskRom re-provision as the repartition.
|
||||
CONFIG_SPL_FIT_IMAGE_KB=512
|
||||
@@ -0,0 +1,12 @@
|
||||
# flare-edge: boot instrumentation.
|
||||
#
|
||||
# Prefixes EVERY U-Boot console line with [ssss.uuuuuu] microseconds since
|
||||
# power-on, using the timestamping puts() that already exists in this Rockchip
|
||||
# fork (common/console.c, guarded by this symbol). Same time base as the
|
||||
# FLARE_TRACE macro and as Rockchip's own "Total: x/y ms" line, so U-Boot,
|
||||
# SPL and the kernel can all be put on one axis.
|
||||
#
|
||||
# Cost is ~15 characters per line. At 115200 baud that is ~1.3 ms per line, so
|
||||
# a verbose boot IS measurably slower than a production one -- read timings
|
||||
# from an instrumented boot as an upper bound, not as production numbers.
|
||||
CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP=y
|
||||
@@ -0,0 +1,49 @@
|
||||
# rv1106-warden-kernel.dtb -- provenance and regeneration
|
||||
|
||||
This binary is U-Boot's embedded control DTB (`CONFIG_EMBED_KERNEL_DTB_PATH`,
|
||||
set in `../configs/flare-display.config`). With `CONFIG_EMBED_KERNEL_DTB_ALWAYS`
|
||||
U-Boot adopts it in `board_init()` instead of reading the booted slot's DTB out
|
||||
of `resource`, so the display bring-up (boot logo included) is identical on
|
||||
every slot regardless of the slot kernel's own device tree.
|
||||
|
||||
## Where this exact blob came from
|
||||
|
||||
Extracted 2026-09-01 from the vendor-built 5.10 firmware image
|
||||
`sdk/output/image/boot.img` (build of 2026-08-24, WardenOS 0.3.x line): the
|
||||
`rk-kernel.dtb` entry of its `resource` sub-image, 73379 bytes, dtb magic
|
||||
`d00dfeed`. That is byte-for-byte the DTB U-Boot's display stack was proven
|
||||
against when it adopted the slot DTB directly.
|
||||
|
||||
## Regenerating after a kernel DTS change
|
||||
|
||||
Run this from a `blueflare/flare-edge` worktree with this SDK checked out at
|
||||
`vendor/warden-sdk` (the normal layout). The 5.10 board DTS is the source of
|
||||
truth (`sdk/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts`
|
||||
plus its ipc dtsi, where `sdk/` is flare-edge's own vendor-SDK checkout, not
|
||||
this repo). After any display-relevant change there, rebuild the firmware
|
||||
once and re-extract:
|
||||
|
||||
```python
|
||||
import struct, subprocess, re
|
||||
fit = open('sdk/output/image/boot.img','rb').read()
|
||||
open('/tmp/fitmeta.dtb','wb').write(fit[:4096])
|
||||
def fdtget(node, prop):
|
||||
r = subprocess.run(['fdtget','-ti','/tmp/fitmeta.dtb',node,prop],
|
||||
capture_output=True, text=True)
|
||||
return int(r.stdout.split()[0])
|
||||
pos, size = fdtget('/images/resource','data-position'), fdtget('/images/resource','data-size')
|
||||
res = fit[pos:pos+size]
|
||||
for m in re.finditer(b'ENTR', res):
|
||||
e = res[m.start():m.start()+272]
|
||||
name = e[4:260].split(b'\0')[0].decode()
|
||||
blk_off, sz = struct.unpack('<II', e[260:268])
|
||||
if name == 'rk-kernel.dtb':
|
||||
open('vendor/warden-sdk/luckfox-sdk-patches/uboot/dts/rv1106-warden-kernel.dtb','wb').write(
|
||||
res[blk_off*512: blk_off*512+sz])
|
||||
```
|
||||
|
||||
Then rebuild U-Boot and confirm the boot log prints
|
||||
`DTB: dts/rv1106-warden-kernel.dtb`. A stale blob here silently diverges from
|
||||
the kernel-side display timings; this file must be regenerated in the same
|
||||
change that edits them. flare-edge's `tools/build-firmware.sh` hard-fails if
|
||||
the file is missing while `EMBED_KERNEL_DTB_ALWAYS` is configured.
|
||||
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* flare-edge: bootloader-side touch probe for the verbose-boot choice.
|
||||
* See arch/arm/mach-rockchip/flare_touch.c for why the decision is made here
|
||||
* rather than in userspace, and why it costs no boot time.
|
||||
*/
|
||||
#ifndef __FLARE_TOUCH_H
|
||||
#define __FLARE_TOUCH_H
|
||||
|
||||
/**
|
||||
* struct flare_touch_state - what the controller said, for the boot report
|
||||
*
|
||||
* @addr: I2C address that answered, or 0 if the controller was never
|
||||
* reached
|
||||
* @status: raw value of the coordinate/status register, sampled at the
|
||||
* read this struct reports (i.e. after the splash appeared)
|
||||
* @arm_status: raw value of the same register, sampled by flare_touch_arm()
|
||||
* before it cleared any power-on report -- lets the two reads be
|
||||
* told apart, one from before the splash and one from after
|
||||
* @armed: whether flare_touch_arm() ran and reached the controller
|
||||
* before this read, so @arm_status can be trusted
|
||||
* @id: product id string the controller reports ("911" on this
|
||||
* panel), NUL-terminated, empty if it could not be read
|
||||
*
|
||||
* A panel in the field has no serial console, so every one of these ends up on
|
||||
* the kernel command line. "No touchscreen", "touchscreen present but silent"
|
||||
* and "not touched" are three different faults that look identical without it.
|
||||
*/
|
||||
struct flare_touch_state {
|
||||
int addr;
|
||||
unsigned char status;
|
||||
unsigned char arm_status;
|
||||
bool armed;
|
||||
char id[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* flare_touch_arm() - discard whatever the controller is holding right now
|
||||
*
|
||||
* Call once, early, as soon as the splash is up. The GT911 publishes a report
|
||||
* when it powers up, so on a COLD boot there is already one waiting before
|
||||
* anybody has touched anything -- and a later read cannot tell that apart from
|
||||
* a tap that has since been released, because both read as "ready, zero
|
||||
* fingers". Clearing here makes the later read mean something precise: a
|
||||
* report that arrived AFTER the splash appeared.
|
||||
*
|
||||
* Costs one I2C transaction and no delay. Safe if the controller is absent.
|
||||
*/
|
||||
void flare_touch_arm(void);
|
||||
|
||||
/**
|
||||
* flare_touch_tapped() - is a touch report waiting?
|
||||
*
|
||||
* ONE I2C read, no polling and no delay. The controller latches a report and
|
||||
* holds it until the host acknowledges it, so a single late read catches a
|
||||
* touch that happened any time earlier in the boot. Watching for a window
|
||||
* would add that window to every boot, touched or not, which is not a price
|
||||
* worth paying for a diagnostic escape hatch.
|
||||
*
|
||||
* Safe on a board with no reachable controller: reports "not touched" rather
|
||||
* than failing, so no boot path depends on the hardware answering.
|
||||
*
|
||||
* @st: filled in with what was observed; may be NULL
|
||||
* @return 1 if a touch was waiting, 0 otherwise
|
||||
*/
|
||||
int flare_touch_tapped(struct flare_touch_state *st);
|
||||
|
||||
#endif /* __FLARE_TOUCH_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* flare-edge boot instrumentation.
|
||||
*
|
||||
* Emits "FLARE-T <microseconds-since-power-on> <label>" on the console at
|
||||
* interesting points in the boot, so tools/boot-trace.py can build a single
|
||||
* timeline spanning BootROM -> SPL -> U-Boot -> kernel -> userspace.
|
||||
*
|
||||
* The time expression is deliberately the same one Rockchip's own
|
||||
* "Total: x/y ms" line uses (arch/arm/lib/bootm.c, common/spl/spl.c): the
|
||||
* secure timer is started in TPL/SPL and free-runs from power-on, so
|
||||
* get_ticks() is ticks-since-power-on and COUNTER_FREQUENCY is 24 MHz.
|
||||
* That makes these values directly comparable to that existing line, and
|
||||
* immune to UART transmit latency (unlike host-side timestamps, which lag
|
||||
* by ~5 ms per line at 115200 and much more when the port is flooded).
|
||||
*
|
||||
* Cost is a handful of printf calls. Note the uboot partition has only
|
||||
* ~12.8 KB spare (see wiki 30-uboot.md), so do not add these liberally.
|
||||
*/
|
||||
#ifndef _FLARE_TRACE_H_
|
||||
#define _FLARE_TRACE_H_
|
||||
|
||||
#define FLARE_USEC() \
|
||||
((ulong)(get_ticks() / (COUNTER_FREQUENCY / 1000000)))
|
||||
|
||||
#define FLARE_TRACE(label) \
|
||||
printf("FLARE-T %lu %s\n", \
|
||||
FLARE_USEC(), label)
|
||||
|
||||
#endif /* _FLARE_TRACE_H_ */
|
||||
@@ -0,0 +1,647 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
index 8821862db..ab2c45239 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
@@ -12,7 +12,34 @@
|
||||
|
||||
chosen {
|
||||
stdout-path = &uart2;
|
||||
- u-boot,spl-boot-order = &sdmmc, &spi_nor, &spi_nand, &emmc;
|
||||
+ /*
|
||||
+ * flare-edge: eMMC first -- it is the only boot medium fitted.
|
||||
+ *
|
||||
+ * Stock order was <&sdmmc, &spi_nor, &spi_nand, &emmc>, i.e. the
|
||||
+ * one device that actually works came last. MEASURED cost of
|
||||
+ * walking the three dead entries first, from the timestamped SPL
|
||||
+ * log: ~212 ms resolving spi_nand (it fails with "unknown raw ID
|
||||
+ * 0 0 0" from drivers/mtd/nand/spi/core.c) plus ~57 ms probing
|
||||
+ * sdmmc twice ("Card did not respond to voltage select",
|
||||
+ * mmc_init: -95). That is ~270 ms of a ~450 ms SPL, spent on
|
||||
+ * hardware this board does not have: sdmmc is wired to the
|
||||
+ * AIC8800 WiFi as SDIO (non-removable, supports-sdio), there is
|
||||
+ * no SD slot, and nothing is fitted on the SFC.
|
||||
+ *
|
||||
+ * Recovery is unaffected. VERIFIED on hardware: BOOT-key recovery
|
||||
+ * runs in U-Boot proper via SARADC at ~1.18 s ("download key
|
||||
+ * pressed... entering download mode"), so it only needs SPL to
|
||||
+ * reach U-Boot -- which is exactly what booting eMMC first does,
|
||||
+ * sooner. If eMMC itself fails, board_boot_order() still appends
|
||||
+ * BOOT_DEVICE_BOOTROM, and a corrupt idblock drops to MaskRom via
|
||||
+ * the BootROM regardless. See 80-open-questions.md §8.
|
||||
+ *
|
||||
+ * NOTE: this dtsi is shared by every rv1106 U-Boot build in this
|
||||
+ * tree. Only the eMMC 86Panel is built here; if an SD- or
|
||||
+ * SPI-NAND-booting variant is ever built, restore the stock order
|
||||
+ * from rv1106-u-boot.dtsi.flare-orig.
|
||||
+ */
|
||||
+ u-boot,spl-boot-order = &emmc;
|
||||
};
|
||||
|
||||
secure-otp@ff3fd8000 {
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
index 067176a9b..25972c645 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <cli.h>
|
||||
#include <clk.h>
|
||||
#include <console.h>
|
||||
+#include <flare_trace.h>
|
||||
#include <debug_uart.h>
|
||||
#include <dm.h>
|
||||
#include <dvfs.h>
|
||||
@@ -461,10 +462,67 @@ static void scan_run_cmd(void)
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: the VOP frame/underrun watcher lived here and has been removed.
|
||||
+ *
|
||||
+ * It enabled the VOP's own interrupt sources and polled them, which is the only
|
||||
+ * way to learn what the display hardware is actually doing rather than when our
|
||||
+ * code ran. Its verdict, MEASURED on hardware: 150 frames in 3.08 s (48.7 Hz,
|
||||
+ * exactly the designed rate) with ZERO bus_error, ZERO win1_empty and ZERO
|
||||
+ * post_buf_empty. So the SoC emits a perfect, never-starved raster from ~0.9 s,
|
||||
+ * and the ~3 s before the panel shows a stable image is the glass failing to
|
||||
+ * lock onto a signal that is already valid -- not anything on our side.
|
||||
+ *
|
||||
+ * It cost exactly its own duration (3 s) in added boot time, because U-Boot is
|
||||
+ * single-threaded and the counters have to be polled. Removed now that it has
|
||||
+ * answered the question.
|
||||
+ *
|
||||
+ * To bring it back, the expensive part is the register map, so it is recorded
|
||||
+ * here. VOP base 0xff990000: INTR_EN 0x34, INTR_CLEAR 0x38, INTR_STATUS 0x3c,
|
||||
+ * all write-masked (value in the low half word, write-enable mask in the high).
|
||||
+ * Bit order is rk3366-lite (= rv1106), and array index IS the hardware bit, per
|
||||
+ * rk3366_vop_lit_intrs[] in the kernel's rockchip_vop_reg.c:
|
||||
+ * bit0 FS (frame start) bit5 BUS_ERROR
|
||||
+ * bit7 WIN1_EMPTY bit11 POST_BUF_EMPTY
|
||||
+ * Poll INTR_STATUS & 0xffff, count set bits, write them back to INTR_CLEAR.
|
||||
+ * See 80-open-questions.md 1f.
|
||||
+ */
|
||||
+
|
||||
int board_late_init(void)
|
||||
{
|
||||
+ FLARE_TRACE("board_late_init entry");
|
||||
#ifdef CONFIG_LUCKFOX_EXECUTE_CMD
|
||||
luckfox_execute_cmd();
|
||||
+ FLARE_TRACE("panel MCU reset released (gpio set 1 1)");
|
||||
+#endif
|
||||
+ /*
|
||||
+ * flare-edge: sample the BOOT key BEFORE the display work.
|
||||
+ *
|
||||
+ * setup_download_mode() is this board's primary recovery path -- it is
|
||||
+ * how a held BOOT key reaches run_command("download") -> rbrom ->
|
||||
+ * MaskRom (VERIFIED on hardware, 80-open-questions.md 8). It is a cheap
|
||||
+ * SARADC read when the key is not pressed.
|
||||
+ *
|
||||
+ * An earlier revision of this reorder put rockchip_show_logo() first and
|
||||
+ * left this call after it, which pushed the key sample from ~1.18 s to
|
||||
+ * ~1.5 s -- and when a 3 s diagnostic briefly sat between them, out past
|
||||
+ * 4 s. A recovery mechanism that silently requires an 8 second hold is a
|
||||
+ * trap, so the safety check goes first and the logo follows it. The logo
|
||||
+ * still runs well before ethaddr/serialno/scan_run_cmd, which is what
|
||||
+ * the reorder was for.
|
||||
+ */
|
||||
+ setup_download_mode();
|
||||
+
|
||||
+ /* Logo as early as possible, but never ahead of the recovery path. */
|
||||
+#ifdef CONFIG_DRM_ROCKCHIP
|
||||
+ if (rockchip_get_boot_mode() != BOOT_MODE_QUIESCENT) {
|
||||
+ FLARE_TRACE("rockchip_show_logo start");
|
||||
+ rockchip_show_logo();
|
||||
+ FLARE_TRACE("rockchip_show_logo done");
|
||||
+ }
|
||||
+#endif
|
||||
+#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
|
||||
+ rockchip_eink_show_uboot_logo();
|
||||
#endif
|
||||
#ifdef CONFIG_ROCKCHIP_SET_ETHADDR
|
||||
rockchip_set_ethaddr();
|
||||
@@ -472,7 +530,6 @@ int board_late_init(void)
|
||||
#ifdef CONFIG_ROCKCHIP_SET_SN
|
||||
rockchip_set_serialno();
|
||||
#endif
|
||||
- setup_download_mode();
|
||||
scan_run_cmd();
|
||||
#ifdef CONFIG_ROCKCHIP_USB_BOOT
|
||||
boot_from_udisk();
|
||||
@@ -485,13 +542,6 @@ int board_late_init(void)
|
||||
rk_minidump_init();
|
||||
#endif
|
||||
|
||||
-#ifdef CONFIG_DRM_ROCKCHIP
|
||||
- if (rockchip_get_boot_mode() != BOOT_MODE_QUIESCENT)
|
||||
- rockchip_show_logo();
|
||||
-#endif
|
||||
-#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
|
||||
- rockchip_eink_show_uboot_logo();
|
||||
-#endif
|
||||
#if (CONFIG_ROCKCHIP_BOOT_MODE_REG > 0)
|
||||
setup_boot_mode();
|
||||
#endif
|
||||
@@ -539,9 +589,52 @@ static void board_debug_init(void)
|
||||
printf("Cmd interface: disabled\n");
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: set once we have released the panel reset ourselves, read by
|
||||
+ * drivers/video/drm/rockchip_panel.c so it does not reset the panel a second
|
||||
+ * time and restart its initialisation.
|
||||
+ */
|
||||
+int flare_panel_reset_early;
|
||||
+
|
||||
+/*
|
||||
+ * flare-edge: release GPIO0_A1 (net RGB_RES) as early as possible.
|
||||
+ *
|
||||
+ * This is NOT simply "the panel reset". Per the 86Panel schematic, RGB_RES
|
||||
+ * ties three things together: SoC GPIO0_A1, the panel's RESET pin (FPC 6),
|
||||
+ * and the NRST of a WCH CH32V003 MCU (U6) whose only wired pins are SPI
|
||||
+ * (CS/SCK/SDI) to that same FPC. That MCU exists to clock the panel's
|
||||
+ * initialisation sequence in; Luckfox's own comment calls it the "RGB MCU".
|
||||
+ *
|
||||
+ * So holding this line low holds the *initialiser* in reset, and the panel
|
||||
+ * cannot come up until it is released and the MCU has run. At power-on the
|
||||
+ * pin is input-with-pulldown, i.e. asserted, so the sooner we drive it high
|
||||
+ * the sooner the panel becomes usable. MEASURED: the glass takes ~2-3 s from
|
||||
+ * release before it displays a stable image, so this is the long pole in the
|
||||
+ * whole boot -- every millisecond of head start counts.
|
||||
+ *
|
||||
+ * A previous revision of this function ASSERTED the line here and held it
|
||||
+ * ~540 ms across init_kernel_dtb(), on the theory that the panel needed a
|
||||
+ * longer reset pulse. That was backwards: it delayed the initialiser by half
|
||||
+ * a second. Do not reintroduce it.
|
||||
+ *
|
||||
+ * Register-level rather than DM/pinctrl because this runs before the kernel
|
||||
+ * DTB is adopted and before most of the driver model exists. RV1106 GPIO v2
|
||||
+ * at 0xff380000: swport_dr_l 0x00, swport_ddr_l 0x08, both write-masked with
|
||||
+ * the enable bits in the upper half word, so only bit 1 is touched.
|
||||
+ */
|
||||
+static void flare_release_panel_reset(void)
|
||||
+{
|
||||
+ writel(0x00020002, (void *)0xff380008); /* bit 1 -> output */
|
||||
+ writel(0x00020002, (void *)0xff380000); /* bit 1 -> high: MCU + panel
|
||||
+ * out of reset */
|
||||
+ flare_panel_reset_early = 1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int board_init(void)
|
||||
{
|
||||
board_debug_init();
|
||||
+ flare_release_panel_reset();
|
||||
#ifdef DEBUG
|
||||
soc_clk_dump();
|
||||
#endif
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/console.c b/sysdrv/source/uboot/u-boot/common/console.c
|
||||
index 629c2a645..bce3e51b6 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/common/console.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/console.c
|
||||
@@ -515,11 +515,72 @@ static inline void pre_console_putc(const char c) {}
|
||||
static inline void print_pre_console_buffer(int flushpoint) {}
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP
|
||||
+/*
|
||||
+ * flare-edge: prefix every console line with "[ s.uuuuuu] ", microseconds
|
||||
+ * since power-on.
|
||||
+ *
|
||||
+ * Hooked into putc() rather than puts() on purpose. With
|
||||
+ * CONFIG_USE_TINY_PRINTF (required for SPL size) printf() emits one character
|
||||
+ * at a time through putc_normal() -> putc() and never calls puts(), so a
|
||||
+ * puts()-level hook is invisible to SPL -- which is precisely the ~0.42 s of
|
||||
+ * boot we most wanted to see. putc() catches both paths.
|
||||
+ *
|
||||
+ * Formatted by hand because tiny printf supports only %c %s %u %d %x: no
|
||||
+ * field width, no zero padding, so "%5lu.%06lu" would not render. get_ticks()
|
||||
+ * is the free-running secure timer started in TPL at 24 MHz, so this shares a
|
||||
+ * clock with Rockchip's own "Total: x/y ms" lines and with FLARE_TRACE.
|
||||
+ */
|
||||
+static int flare_in_ts;
|
||||
+
|
||||
+static void flare_putc_ts(void)
|
||||
+{
|
||||
+ unsigned long ticks = (unsigned long)(get_ticks() / 24ULL);
|
||||
+ unsigned long sec = ticks / 1000000UL;
|
||||
+ unsigned long us = ticks % 1000000UL;
|
||||
+ unsigned long div;
|
||||
+ char d[12];
|
||||
+ int n = 0;
|
||||
+
|
||||
+ putc('[');
|
||||
+ if (!sec) {
|
||||
+ d[n++] = '0';
|
||||
+ } else {
|
||||
+ while (sec) {
|
||||
+ d[n++] = '0' + (char)(sec % 10);
|
||||
+ sec /= 10;
|
||||
+ }
|
||||
+ }
|
||||
+ for (div = n; div < 5; div++)
|
||||
+ putc(' ');
|
||||
+ while (n--)
|
||||
+ putc(d[n]);
|
||||
+ putc('.');
|
||||
+ for (div = 100000UL; div; div /= 10)
|
||||
+ putc('0' + (char)((us / div) % 10));
|
||||
+ putc(']');
|
||||
+ putc(' ');
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
void putc(const char c)
|
||||
{
|
||||
if (!gd || gd->flags & GD_FLG_DISABLE_CONSOLE)
|
||||
return;
|
||||
|
||||
+#ifdef CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP
|
||||
+ if (!flare_in_ts) {
|
||||
+ if (c == '\n') {
|
||||
+ gd->new_line = 1;
|
||||
+ } else if (gd->new_line) {
|
||||
+ gd->new_line = 0;
|
||||
+ flare_in_ts = 1;
|
||||
+ flare_putc_ts();
|
||||
+ flare_in_ts = 0;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
#ifdef CONFIG_PSTORE
|
||||
putc_to_ram(c);
|
||||
#endif
|
||||
@@ -553,51 +614,11 @@ void putc(const char c)
|
||||
}
|
||||
}
|
||||
|
||||
-#if ((!defined(CONFIG_SPL_BUILD) || !defined(CONFIG_USE_TINY_PRINTF)) && \
|
||||
- defined(CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP))
|
||||
-static void vspfunc(char *buf, size_t size, char *format, ...)
|
||||
-{
|
||||
- va_list ap;
|
||||
-
|
||||
- va_start(ap, format);
|
||||
- vsnprintf(buf, size, format, ap);
|
||||
- va_end(ap);
|
||||
-}
|
||||
-
|
||||
-void puts(const char *s)
|
||||
-{
|
||||
- unsigned long ts_sec, ts_msec, ticks;
|
||||
- char pr_timestamp[32], *p;
|
||||
-
|
||||
- while (*s) {
|
||||
- if (*s == '\n') {
|
||||
- gd->new_line = 1;
|
||||
- putc(*s++);
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- if (gd->new_line) {
|
||||
- gd->new_line = 0;
|
||||
- ticks = (get_ticks() / 24ULL);
|
||||
- ts_sec = ticks / 1000000;
|
||||
- ts_msec = ticks % 1000000;
|
||||
- vspfunc(pr_timestamp, sizeof(pr_timestamp),
|
||||
- "[%5lu.%06lu] ", ts_sec, ts_msec);
|
||||
- p = pr_timestamp;
|
||||
- while (*p)
|
||||
- putc(*p++);
|
||||
- }
|
||||
-
|
||||
- putc(*s++);
|
||||
- }
|
||||
-}
|
||||
-#else
|
||||
void puts(const char *s)
|
||||
{
|
||||
while (*s)
|
||||
putc(*s++);
|
||||
}
|
||||
-#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_CONSOLE_RECORD
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c b/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c
|
||||
index a99846f4e..4fc64f33d 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c
|
||||
@@ -976,20 +976,93 @@ static ulong rv1106_vop_set_clk(struct rv1106_clk_priv *priv,
|
||||
sel << ACLK_VOP_SEL_SHIFT);
|
||||
break;
|
||||
case DCLK_VOP_SRC:
|
||||
- case DCLK_VOP:
|
||||
- if ((priv->cpll_hz % rate) == 0) {
|
||||
+ case DCLK_VOP: {
|
||||
+ /*
|
||||
+ * flare-edge: the divider field is 5 bits (DCLK_VOP_DIV_MASK
|
||||
+ * = 0x1f << 3), so the largest divisor the hardware can encode
|
||||
+ * is 32. The original code took DIV_ROUND_UP() of the parent
|
||||
+ * rate and wrote (div - 1) straight into that field with no
|
||||
+ * range check. For this panel -- 30 MHz pixel clock from a
|
||||
+ * 1188 MHz GPLL -- that is a divisor of 40, i.e. 39 = 0b100111
|
||||
+ * written into 5 bits, which truncates to 7. MEASURED result:
|
||||
+ * the VOP ran at 125 MHz instead of 30 MHz, so the panel was
|
||||
+ * fed a signal it cannot lock to and showed coloured vertical
|
||||
+ * lines / black while U-Boot happily turned the backlight on.
|
||||
+ *
|
||||
+ * Neither PLL can actually reach 30 MHz through a /32 divider
|
||||
+ * (1188/32 = 37.125, 1000/32 = 31.25), so clamp to the field
|
||||
+ * maximum and choose whichever parent lands closest to the
|
||||
+ * request rather than silently corrupting the register.
|
||||
+ */
|
||||
+ ulong c_div, g_div, c_rate, g_rate, c_err, g_err;
|
||||
+
|
||||
+ /*
|
||||
+ * flare-edge: if neither PLL can divide down to the requested
|
||||
+ * pixel clock exactly, retune CPLL so that it can.
|
||||
+ *
|
||||
+ * Stock rates give 1188/32 = 37.125 MHz and 1000/32 = 31.25 MHz
|
||||
+ * against the 30 MHz this panel wants, so the best achievable
|
||||
+ * was 4.2% fast. An already-locked panel copes with that --
|
||||
+ * Linux never notices, because it inherits a display U-Boot has
|
||||
+ * already started -- but U-Boot is the ONLY stage that locks the
|
||||
+ * panel from cold, and at 31.25 MHz that took 1-2 seconds of
|
||||
+ * visible coloured banding before the image settled.
|
||||
+ *
|
||||
+ * CPLL is safe to move here: within this driver only the VOP and
|
||||
+ * UART (as a secondary parent) derive from it. The eMMC, peri and
|
||||
+ * bus roots do not, and the debug UART runs from the 24 MHz
|
||||
+ * oscillator, so neither the boot media nor the console is
|
||||
+ * affected. rkclk_init() pins CPLL to CPLL_HZ and has already run
|
||||
+ * by this point, so nothing puts it back underneath us.
|
||||
+ */
|
||||
+ if ((priv->cpll_hz % rate) && (priv->gpll_hz % rate)) {
|
||||
+ ulong want = rate * 32;
|
||||
+
|
||||
+ if (want >= 300 * MHz && want <= 1200 * MHz &&
|
||||
+ !rockchip_pll_set_rate(&rv1106_pll_clks[CPLL],
|
||||
+ priv->cru, CPLL, want)) {
|
||||
+ printf("dclk_vop: cpll %luHz -> %luHz for an exact /32\n",
|
||||
+ priv->cpll_hz, want);
|
||||
+ priv->cpll_hz = want;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ c_div = DIV_ROUND_UP(priv->cpll_hz, rate);
|
||||
+ g_div = DIV_ROUND_UP(priv->gpll_hz, rate);
|
||||
+ if (c_div > 32)
|
||||
+ c_div = 32;
|
||||
+ if (g_div > 32)
|
||||
+ g_div = 32;
|
||||
+ if (c_div < 1)
|
||||
+ c_div = 1;
|
||||
+ if (g_div < 1)
|
||||
+ g_div = 1;
|
||||
+
|
||||
+ c_rate = priv->cpll_hz / c_div;
|
||||
+ g_rate = priv->gpll_hz / g_div;
|
||||
+ c_err = (c_rate > rate) ? (c_rate - rate) : (rate - c_rate);
|
||||
+ g_err = (g_rate > rate) ? (g_rate - rate) : (rate - g_rate);
|
||||
+
|
||||
+ if (c_err <= g_err) {
|
||||
sel = DCLK_VOP_SEL_CPLL;
|
||||
- div = DIV_ROUND_UP(priv->cpll_hz, rate);
|
||||
+ div = c_div;
|
||||
} else {
|
||||
sel = DCLK_VOP_SEL_GPLL;
|
||||
- div = DIV_ROUND_UP(priv->gpll_hz, rate);
|
||||
+ div = g_div;
|
||||
}
|
||||
+
|
||||
+ printf("dclk_vop: want %luHz, cpll=%luHz/%lu=%luHz gpll=%luHz/%lu=%luHz -> %s/%d\n",
|
||||
+ rate, priv->cpll_hz, c_div, c_rate,
|
||||
+ priv->gpll_hz, g_div, g_rate,
|
||||
+ sel == DCLK_VOP_SEL_CPLL ? "cpll" : "gpll", div);
|
||||
+
|
||||
rk_clrsetreg(&cru->clksel_con[23],
|
||||
DCLK_VOP_SEL_MASK |
|
||||
DCLK_VOP_DIV_MASK,
|
||||
sel << DCLK_VOP_SEL_SHIFT |
|
||||
(div - 1) << DCLK_VOP_DIV_SHIFT);
|
||||
break;
|
||||
+ }
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
@@ -1226,10 +1299,17 @@ static ulong rv1106_clk_set_rate(struct clk *clk, ulong rate)
|
||||
case DCLK_VOP:
|
||||
case ACLK_VOP_ROOT:
|
||||
case ACLK_VOP:
|
||||
- rate = rv1106_vop_set_clk(priv, clk->id, rate);
|
||||
+ /* flare-edge: was "rate = ...", but this function returns `ret`,
|
||||
+ * so the actual rate was discarded and clk_set_rate() always
|
||||
+ * reported 0. The hardware was still programmed, which is why
|
||||
+ * this stayed hidden -- but it made the VOP's own
|
||||
+ * "set crtc_clock to 30000KHz, get 0Hz" line useless as a
|
||||
+ * diagnostic, and 0 is indistinguishable from a dead clock when
|
||||
+ * you are trying to work out why a panel shows nothing. */
|
||||
+ ret = rv1106_vop_set_clk(priv, clk->id, rate);
|
||||
break;
|
||||
case DCLK_DECOM:
|
||||
- rate = rv1106_decom_set_clk(priv, rate);
|
||||
+ ret = rv1106_decom_set_clk(priv, rate);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
index 69e9a1dfa..fe09efe09 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
@@ -2106,7 +2106,12 @@ static int rockchip_display_probe(struct udevice *dev)
|
||||
}
|
||||
split_conn = rockchip_get_split_connector(conn);
|
||||
|
||||
- s = malloc(sizeof(*s));
|
||||
+ /* flare-edge: calloc, not malloc -- enabled_at_spl and other fields
|
||||
+ * are only explicitly initialised under CONFIG_SPL_BUILD, which does
|
||||
+ * not apply here (this file runs in U-Boot proper). Uninitialised
|
||||
+ * heap garbage in enabled_at_spl silently skips panel prepare/enable
|
||||
+ * (and therefore backlight_enable) in display_enable() below. */
|
||||
+ s = calloc(1, sizeof(*s));
|
||||
if (!s)
|
||||
continue;
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c
|
||||
index 9ddb4d819..44c31945c 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c
|
||||
@@ -12,6 +12,31 @@
|
||||
#include <malloc.h>
|
||||
#include <video.h>
|
||||
#include <backlight.h>
|
||||
+
|
||||
+/*
|
||||
+ * Milliseconds to wait after the CRTC starts scanning out, before switching
|
||||
+ * the backlight on, when the devicetree gives no enable-delay-ms.
|
||||
+ *
|
||||
+ * This hides the panel's own wake, which is driven by the CH32V003 (U6)
|
||||
+ * clocking the init sequence in over SPI once RGB_RES is released at the top
|
||||
+ * of board_init(). Two artefacts have been seen here with DIFFERENT causes --
|
||||
+ * do not conflate them:
|
||||
+ *
|
||||
+ * coloured vertical banding -- NOT a settle problem. That was Linux
|
||||
+ * rebooting the CH32V003 mid-scanout via reset-gpios on &panel; fixed in
|
||||
+ * the kernel DTS. Raising this constant only ever masked it.
|
||||
+ * inverted image that fades to correct -- the driver IC is still coming up
|
||||
+ * when the backlight lands, so we see the tail of its internal rail ramp.
|
||||
+ * This constant is the right tool for that one.
|
||||
+ *
|
||||
+ * Trade-off is explicit: first light moves later, but what you see first is
|
||||
+ * the logo rather than garbage. The better fix is to release RGB_RES earlier
|
||||
+ * (SPL/TPL) so the initialiser is done before we get here -- same margin,
|
||||
+ * without delaying the logo. That needs an idblock flash, hence not done yet.
|
||||
+ */
|
||||
+#define FLARE_PANEL_SETTLE_MS 250
|
||||
+
|
||||
+extern int flare_panel_reset_early;
|
||||
#include <spi.h>
|
||||
#include <asm/gpio.h>
|
||||
#include <dm/device.h>
|
||||
@@ -302,6 +327,24 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
|
||||
if (priv->prepared)
|
||||
return;
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: force the backlight OFF before touching the panel.
|
||||
+ *
|
||||
+ * The PWM block is not reset by a warm reboot, so after `reboot` from
|
||||
+ * Linux the backlight is still lit from the previous session for the
|
||||
+ * whole of U-Boot. Delaying our own backlight_enable() therefore did
|
||||
+ * nothing -- the lamp was already on, and the panel's 1-2 s cold-lock
|
||||
+ * banding was plainly visible through it. Only a cold power-cycle hid
|
||||
+ * the problem, which is exactly why it looked inconsistent.
|
||||
+ *
|
||||
+ * Explicitly blanking here means the settle happens in the dark on
|
||||
+ * both warm and cold boots, and the first thing the user sees is the
|
||||
+ * finished logo. panel_simple_enable() switches it back on once the
|
||||
+ * panel has locked.
|
||||
+ */
|
||||
+ if (priv->backlight)
|
||||
+ backlight_disable(priv->backlight);
|
||||
+
|
||||
if (priv->power_supply)
|
||||
regulator_set_enable(priv->power_supply, !plat->power_invert);
|
||||
|
||||
@@ -311,6 +354,15 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
|
||||
if (plat->delay.prepare)
|
||||
mdelay(plat->delay.prepare);
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: board_init() asserted this reset back at ~0.47 s and has
|
||||
+ * been holding it ever since, so by the time we get here the panel has
|
||||
+ * already had a ~540 ms low pulse -- far longer than the 200 ms
|
||||
+ * reset-delay-ms below, and the closest we can get to the full
|
||||
+ * power-down that this panel demonstrably needs. Run the normal cycle
|
||||
+ * anyway: it is harmless (the line is already low) and it is what
|
||||
+ * actually releases the reset.
|
||||
+ */
|
||||
if (dm_gpio_is_valid(&priv->reset_gpio))
|
||||
dm_gpio_set_value(&priv->reset_gpio, 1);
|
||||
|
||||
@@ -388,6 +440,26 @@ static void panel_simple_enable(struct rockchip_panel *panel)
|
||||
if (plat->delay.enable)
|
||||
mdelay(plat->delay.enable);
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: this panel needs 1-2 s to lock onto the RGB signal from
|
||||
+ * cold, and until it does it shows faint coloured vertical banding.
|
||||
+ * U-Boot is the only stage that ever starts it from cold -- Linux
|
||||
+ * inherits an already-running display -- so this is the only place the
|
||||
+ * problem appears. Lighting the backlight before the panel has locked
|
||||
+ * just makes the garbage visible.
|
||||
+ *
|
||||
+ * Ruled out as causes, each MEASURED rather than assumed: memory
|
||||
+ * bandwidth contention (the image is rock steady through sustained
|
||||
+ * 8 MB eMMC reads at the U-Boot prompt), and pixel-clock accuracy
|
||||
+ * (retuning CPLL to 960 MHz for an exact 30.000 MHz changed nothing).
|
||||
+ * It is simply the panel's own lock time.
|
||||
+ *
|
||||
+ * Prefer the devicetree's enable-delay-ms above if a value is set;
|
||||
+ * this is the fallback for a DT that specifies none.
|
||||
+ */
|
||||
+ if (!plat->delay.enable)
|
||||
+ mdelay(FLARE_PANEL_SETTLE_MS);
|
||||
+
|
||||
if (priv->backlight)
|
||||
backlight_enable(priv->backlight);
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c
|
||||
index 240910395..675ac1580 100755
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c
|
||||
@@ -4,6 +4,20 @@
|
||||
* Author: Zhang yubing <yubing.zhang@rock-chips.com>
|
||||
*/
|
||||
|
||||
+/*
|
||||
+ * flare-edge: <common.h> must come first.
|
||||
+ *
|
||||
+ * rockchip_post_csc.h pulls in <edid.h>, which includes <i2c.h>
|
||||
+ * unconditionally (edid.h:20). With CONFIG_DM_I2C unset -- which is the case
|
||||
+ * in rv1106_defconfig and ours -- i2c.h takes its legacy branch (i2c.h:554),
|
||||
+ * and those prototypes use `uchar`. That typedef lives in <common.h>, which
|
||||
+ * this file never included, so the prototypes failed to parse and the later
|
||||
+ * inline users of i2c_read()/i2c_write() then became implicit-declaration
|
||||
+ * errors. Including common.h first resolves the whole cascade, and is far
|
||||
+ * cheaper than enabling the DM I2C stack purely to dodge a header ordering
|
||||
+ * bug (the uboot partition is 256K with ~64K spare).
|
||||
+ */
|
||||
+#include <common.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c b/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c
|
||||
index 718b2fd04..83dbd7e56 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <pwm.h>
|
||||
#include <asm/gpio.h>
|
||||
#include <power/regulator.h>
|
||||
+#include <flare_trace.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -66,6 +67,19 @@ static int pwm_backlight_enable(struct udevice *dev)
|
||||
if (dm_gpio_is_valid(&priv->enable))
|
||||
dm_gpio_set_value(&priv->enable, 1);
|
||||
|
||||
+ /*
|
||||
+ * Report the values that actually determine whether the panel lights
|
||||
+ * up, not just "we got here". The previous message claimed "panel now
|
||||
+ * visible", which was untrue for a long time: the PWM was enabled at
|
||||
+ * 99.6%% duty but INVERTED, so the real brightness was ~0.4%% and the
|
||||
+ * screen looked dead. A trace marker that asserts an outcome it cannot
|
||||
+ * observe is worse than no marker at all.
|
||||
+ */
|
||||
+ printf("FLARE-T %lu backlight pwm enabled: duty=%u/%u ns (%lu%%), polarity=%s\n",
|
||||
+ (ulong)(get_ticks() / (COUNTER_FREQUENCY / 1000000)),
|
||||
+ duty_cycle, priv->period_ns,
|
||||
+ priv->period_ns ? (ulong)duty_cycle * 100 / priv->period_ns : 0,
|
||||
+ priv->polarity ? "inverted" : "normal");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -143,7 +157,20 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
|
||||
}
|
||||
priv->channel = args.args[0];
|
||||
priv->period_ns = args.args[1];
|
||||
- priv->polarity = args.args[2];
|
||||
+ /*
|
||||
+ * flare-edge: the third pwm cell is a FLAGS word, not a boolean.
|
||||
+ * Only bit 0 (PWM_POLARITY_INVERTED) selects polarity; the kernel
|
||||
+ * masks it and ignores everything else.
|
||||
+ *
|
||||
+ * This board's DTS carries pwms = <&pwm1 0 100000 50000>. Assigning
|
||||
+ * 50000 straight into a bool made U-Boot invert the PWM while Linux
|
||||
+ * did not, so a 99.6% duty cycle (PERIOD=10000, DUTY=9960) came out
|
||||
+ * as ~0.4% on. MEASURED: PWM_CTRL read back 0x13, i.e. DUTY_NEGATIVE
|
||||
+ * + INACTIVE_POSITIVE. The backlight reported itself enabled and was
|
||||
+ * to the eye completely dark -- while the logo was rendering into the
|
||||
+ * framebuffer perfectly the whole time.
|
||||
+ */
|
||||
+ priv->polarity = args.args[2] & 1;
|
||||
|
||||
index = dev_read_u32_default(dev, "default-brightness-level", 255);
|
||||
cell = dev_read_prop(dev, "brightness-levels", &len);
|
||||
@@ -0,0 +1,108 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c
|
||||
index 3b943079d..bdc6876e0 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c
|
||||
@@ -197,7 +197,28 @@ void board_boot_order(u32 *spl_boot_list)
|
||||
|
||||
/* If we had no matches, fall back to spl_boot_device */
|
||||
if (idx == 0)
|
||||
- spl_boot_list[0] = spl_boot_device();
|
||||
+ spl_boot_list[idx++] = spl_boot_device();
|
||||
+
|
||||
+#ifdef CONFIG_SPL_BOOTROM_SUPPORT
|
||||
+ /*
|
||||
+ * flare-edge: last-resort recovery entry.
|
||||
+ *
|
||||
+ * boot_from_devices() walks this list in order and, if every entry
|
||||
+ * fails, common/spl/spl.c does puts("SPL: failed to boot from all
|
||||
+ * boot devices") followed by hang(). A hung SPL presents nothing on
|
||||
+ * USB, and the BOOT key is sampled by U-Boot proper (SARADC, in
|
||||
+ * board_late_init) -- so it cannot rescue a failure that happens
|
||||
+ * before U-Boot runs. The board would then need hardware recovery.
|
||||
+ *
|
||||
+ * Appending the BROM here costs nothing on a healthy boot (MMC is
|
||||
+ * tried first and succeeds), but turns "unbootable uboot.img" from a
|
||||
+ * hang into an automatic drop to MaskRom, which upgrade_tool can talk
|
||||
+ * to. See board_return_to_bootrom() in mach-rockchip/spl.c: with
|
||||
+ * SPL_ROCKCHIP_BACK_TO_BROM off this issues BROM_BOOT_ENTER_DNL.
|
||||
+ */
|
||||
+ if (idx < 5)
|
||||
+ spl_boot_list[idx++] = BOOT_DEVICE_BOOTROM;
|
||||
+#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
index 9f882ca14..430302c38 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
@@ -31,7 +31,23 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
void board_return_to_bootrom(void)
|
||||
{
|
||||
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
|
||||
+ /* Normal flow: the BROM is expected to load the next stage for us. */
|
||||
back_to_bootrom(BROM_BOOT_NEXTSTAGE);
|
||||
+#else
|
||||
+ /*
|
||||
+ * flare-edge: SPL loads U-Boot from MMC itself, so this is only
|
||||
+ * reached as the final entry of board_boot_order() -- i.e. every real
|
||||
+ * boot device already failed. Asking the BROM to continue the boot
|
||||
+ * sequence would just fail again, so request download mode instead
|
||||
+ * and let MaskRom recovery take over.
|
||||
+ *
|
||||
+ * This file is obj-spl-y only (TPL uses tpl.o), so TPL's own
|
||||
+ * back-to-BROM path, which must stay BROM_BOOT_NEXTSTAGE, is
|
||||
+ * unaffected.
|
||||
+ */
|
||||
+ back_to_bootrom(BROM_BOOT_ENTER_DNL);
|
||||
+#endif
|
||||
}
|
||||
|
||||
__weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
|
||||
diff --git a/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig b/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig
|
||||
index 0fe5c20b3..ac74ec7f1 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig
|
||||
+++ b/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig
|
||||
@@ -78,7 +78,7 @@ CONFIG_OF_LIVE=y
|
||||
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
|
||||
CONFIG_OF_U_BOOT_REMOVE_PROPS="interrupt-parent"
|
||||
CONFIG_ENVF=y
|
||||
-CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved ipaddr serverip netmask gatewayip ethaddr"
|
||||
+CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved ipaddr serverip netmask gatewayip ethaddr bootcmd bootdelay preboot altbootcmd bootlimit bootcount"
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SPL_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig b/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig
|
||||
index c9d627cce..a71a7e421 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig
|
||||
@@ -13,6 +13,28 @@ config BOOTCOUNT
|
||||
|
||||
if BOOTCOUNT
|
||||
|
||||
+config BOOTCOUNT_LIMIT
|
||||
+ bool "Enable boot count limit (altbootcmd fallback)"
|
||||
+ help
|
||||
+ Used by common/autoboot.c: each boot increments the counter and, once
|
||||
+ it exceeds ${bootlimit}, U-Boot runs ${altbootcmd} instead of
|
||||
+ ${bootcmd}. The code has always referenced CONFIG_BOOTCOUNT_LIMIT but
|
||||
+ this tree never declared it in Kconfig, so it could only be set via a
|
||||
+ board config header. Declared here so it can come from a defconfig
|
||||
+ fragment. (flare-edge)
|
||||
+
|
||||
+config BOOTCOUNT_ENV
|
||||
+ bool "Store boot counter in the environment"
|
||||
+ help
|
||||
+ Keeps the counter in the environment (drivers/bootcount/bootcount_env.c).
|
||||
+ Note both load and store are gated on ${upgrade_available}, so the
|
||||
+ counter only runs during an upgrade window -- which is the behaviour we
|
||||
+ want: arm it when flashing, clear it once userspace confirms a good
|
||||
+ boot. Requires an environment backend that implements save(); ENVF does
|
||||
+ (env/envf.c: .save = env_save_ptr(envf_save)). The Makefile already
|
||||
+ builds bootcount_env.o for this symbol; only the Kconfig entry was
|
||||
+ missing. (flare-edge)
|
||||
+
|
||||
config BOOTCOUNT_EXT
|
||||
bool "Boot counter on EXT filesystem"
|
||||
help
|
||||
@@ -0,0 +1,953 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c
|
||||
index 7c5681a02..b8787dda1 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c
|
||||
@@ -10,6 +10,9 @@
|
||||
#include <sysmem.h>
|
||||
#include <asm/arch/fit.h>
|
||||
#include <asm/arch/resource_img.h>
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -145,10 +148,28 @@ static void *fit_get_blob(struct blk_desc *dev_desc,
|
||||
char *part_name = PART_BOOT;
|
||||
void *fit, *fdt;
|
||||
int blk_num;
|
||||
+ __maybe_unused int recovery = 0;
|
||||
|
||||
#ifndef CONFIG_ANDROID_AB
|
||||
- if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY)
|
||||
+ if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY) {
|
||||
+ part_name = PART_RECOVERY;
|
||||
+ recovery = 1;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * BCB-commanded recovery (above) and no-bootable-slot fallback
|
||||
+ * both boot the shared recovery FIT; either way the A/B layer
|
||||
+ * must know, so it stops decrementing slot tries and escalates
|
||||
+ * to MaskRom if the recovery FIT itself will not boot.
|
||||
+ */
|
||||
+ if (!recovery && flare_ab_enabled() && !flare_ab_have_bootable()) {
|
||||
part_name = PART_RECOVERY;
|
||||
+ recovery = 1;
|
||||
+ }
|
||||
+ if (recovery)
|
||||
+ flare_ab_set_recovery_mode();
|
||||
#endif
|
||||
|
||||
if (part_get_info_by_name(dev_desc, part_name, &part) < 0) {
|
||||
diff --git a/sysdrv/source/uboot/u-boot/cmd/bootfit.c b/sysdrv/source/uboot/u-boot/cmd/bootfit.c
|
||||
index 3a8b75bf7..6335cbf39 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/cmd/bootfit.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/cmd/bootfit.c
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <malloc.h>
|
||||
#include <sysmem.h>
|
||||
#include <asm/arch/fit.h>
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -69,6 +72,20 @@ static int do_boot_fit(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
|
||||
printf("## Booting FIT Image ");
|
||||
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * Count this boot attempt against the selected slot BEFORE trying
|
||||
+ * to load its FIT (the SPL engine's "decrease before load" rule):
|
||||
+ * a slot whose FIT is corrupt must still burn tries on every failed
|
||||
+ * attempt, or the failure path below would reset forever without
|
||||
+ * ever falling back to the other slot. Writes one sector, and only
|
||||
+ * while the slot is not yet marked successful; no-op in recovery
|
||||
+ * fallback mode (the earlier kernel-DTB load already resolved it).
|
||||
+ */
|
||||
+ if (argc == 1)
|
||||
+ flare_ab_boot_attempt();
|
||||
+#endif
|
||||
+
|
||||
if (argc == 1)
|
||||
fit = do_boot_fit_storage(&size);
|
||||
else
|
||||
@@ -120,8 +137,24 @@ static int do_boot_fit(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
goto out;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ if (ret && argc == 1)
|
||||
+ goto out;
|
||||
+#endif
|
||||
+
|
||||
return CMD_RET_SUCCESS;
|
||||
out:
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * A storage boot that reached this point failed to load or boot
|
||||
+ * the selected slot's FIT. On an A/B layout this resets so the
|
||||
+ * next boot makes progress (retries burn down, then the other
|
||||
+ * slot, then recovery, then MaskRom); on a legacy layout it
|
||||
+ * returns and stock behavior continues.
|
||||
+ */
|
||||
+ if (argc == 1)
|
||||
+ flare_ab_boot_failed();
|
||||
+#endif
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/Kconfig b/sysdrv/source/uboot/u-boot/common/Kconfig
|
||||
index c276f701a..31b5c712d 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/common/Kconfig
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/Kconfig
|
||||
@@ -620,6 +620,21 @@ config ANDROID_AB
|
||||
allows a bootloader to try a new version of the system but roll back
|
||||
to previous version if the new one didn't boot all the way.
|
||||
|
||||
+config FLARE_AB
|
||||
+ bool "flare-edge A/B slot boot (lean, misc-based, no libavb)"
|
||||
+ depends on !ANDROID_AB
|
||||
+ default n
|
||||
+ help
|
||||
+ A/B slot selection for U-Boot proper using the same AOSP
|
||||
+ AvbABData metadata (single CRC32-protected sector at
|
||||
+ misc + 2048 bytes) as the vendor SPL A/B engine, without the
|
||||
+ libavb stack CONFIG_ANDROID_AB pulls in. Slot suffixing hooks
|
||||
+ part_get_info_by_name(), so boot_a/boot_b (and the early
|
||||
+ kernel-DTB/resource load) resolve transparently; tries are
|
||||
+ decremented once per boot attempt only while a slot is not yet
|
||||
+ marked successful; with no bootable slot the recovery FIT is
|
||||
+ booted, and failing that the board drops to MaskRom.
|
||||
+
|
||||
config ANDROID_WRITE_KEYBOX
|
||||
bool "Support Write Keybox"
|
||||
default y
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/Makefile b/sysdrv/source/uboot/u-boot/common/Makefile
|
||||
index 52cd612d1..a81071566 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/common/Makefile
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/Makefile
|
||||
@@ -12,6 +12,7 @@ obj-$(CONFIG_SUPPORT_USBPLUG) += usbplug/
|
||||
|
||||
obj-y += main.o
|
||||
obj-y += exports.o
|
||||
+obj-$(CONFIG_FLARE_AB) += flare_ab.o
|
||||
obj-$(CONFIG_HASH) += hash.o
|
||||
obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
|
||||
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
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/flare_ab.c
|
||||
@@ -0,0 +1,642 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0+
|
||||
+/*
|
||||
+ * flare-edge A/B slot boot for U-Boot proper.
|
||||
+ *
|
||||
+ * Core metadata engine adapted from the vendor's common/spl/spl_ab.c
|
||||
+ * (Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd) so U-Boot
|
||||
+ * proper and SPL agree byte-for-byte on the AvbABData struct at
|
||||
+ * `misc` + AB_METADATA_OFFSET blocks, without pulling in libavb.
|
||||
+ *
|
||||
+ * Semantics (AOSP A/B, unchanged from the SPL engine):
|
||||
+ * - a slot is bootable iff priority>0 && (successful_boot || tries>0)
|
||||
+ * - selection prefers the higher-priority bootable slot
|
||||
+ * - one tries_remaining decrement per boot attempt, ONLY while the
|
||||
+ * slot is not yet successful; metadata is written only if changed,
|
||||
+ * so a confirmed steady-state device never writes flash at boot
|
||||
+ * - corrupt metadata self-reinitializes (both slots bootable, A first)
|
||||
+ * - when no slot is bootable, selection falls back to last_boot and
|
||||
+ * fit_get_blob() redirects to the recovery FIT instead
|
||||
+ */
|
||||
+
|
||||
+#include <common.h>
|
||||
+#include <asm/io.h>
|
||||
+#include <blk.h>
|
||||
+#include <boot_rkimg.h>
|
||||
+#include <command.h>
|
||||
+#include <malloc.h>
|
||||
+#include <part.h>
|
||||
+#include <flare_ab.h>
|
||||
+#include <android_avb/avb_ab_flow.h>
|
||||
+
|
||||
+/*
|
||||
+ * Per-power-session boot-attempt escalation (warehouse deployment).
|
||||
+ *
|
||||
+ * The AvbABData tries above are PERSISTENT (in the misc sector) and exist for
|
||||
+ * the UPDATE case: a freshly written slot gets a tries budget, and a bad update
|
||||
+ * burns it down and reverts to the other slot even across power cycles (a bad
|
||||
+ * image must not come back after a brownout). That is correct for updates and
|
||||
+ * is left unchanged.
|
||||
+ *
|
||||
+ * The STEADY-STATE case (both slots already committed, no update in flight) has
|
||||
+ * a different requirement: retry the selected slot a couple of times, then the
|
||||
+ * other slot, then recovery -- and RESET on every power cycle, so a device that
|
||||
+ * merely lost power mid-boot always comes back up on its selected slot instead
|
||||
+ * of walking itself into recovery. A persistent counter cannot express "reset
|
||||
+ * on power cycle"; this needs a store that survives a WARM reset (so in-session
|
||||
+ * escalation accumulates) but is cleared by a power-on reset.
|
||||
+ *
|
||||
+ * Two PMU-domain registers give exactly that, both hardware-validated on a real
|
||||
+ * 86-panel 2026-09-02:
|
||||
+ * - CRU glb_rst_st (0xff3b0c04): reads 0 after a power-on reset, nonzero
|
||||
+ * (bit0 set) after a warm/software reset. It survives the boot chain into
|
||||
+ * Linux and no vendor code clears it, so U-Boot can read it as the
|
||||
+ * cold-vs-warm discriminator.
|
||||
+ * - PMU GRF OS_REG4 (0xff020210): a free scratch register (OS_REG2/3 hold DDR
|
||||
+ * info, OS_REG8+ are used by the PM code, OS_REG0/1 are boot-mode/chip-ver).
|
||||
+ * It survives a warm reset (the attempt count accumulates) and, being in the
|
||||
+ * always-on PMU domain like the boot-mode register, is cleared by a power-on
|
||||
+ * reset. We additionally gate on glb_rst_st, so a power cycle restarts the
|
||||
+ * count even if the register somehow retained a value.
|
||||
+ *
|
||||
+ * flared clears OS_REG4 once a boot proves healthy (UI live for a sustained
|
||||
+ * hold) and before any deliberate reboot -- the same discipline the retired env
|
||||
+ * bootcount used, moved to a register that costs no flash wear and resets for
|
||||
+ * free on power loss. So only CONSECUTIVE unhealthy boots within one power
|
||||
+ * session escalate; a healthy boot, or a power cycle, restarts at the selected
|
||||
+ * slot.
|
||||
+ */
|
||||
+#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 */
|
||||
+/*
|
||||
+ * Attempts on the selected committed slot before failing over to the other
|
||||
+ * committed slot; the other slot then gets the same budget before recovery.
|
||||
+ * Keep in sync with the runbook and flared's docs.
|
||||
+ */
|
||||
+#define FLARE_AB_SLOT_TRIES 2
|
||||
+/* Clamp against a garbage register value (validated free, so belt-only). */
|
||||
+#define FLARE_AB_MAX_SESSION 250
|
||||
+
|
||||
+static u32 flare_ab_reg_read(u32 addr)
|
||||
+{
|
||||
+ return readl((void __iomem *)(uintptr_t)addr);
|
||||
+}
|
||||
+
|
||||
+static void flare_ab_reg_write(u32 addr, u32 val)
|
||||
+{
|
||||
+ writel(val, (void __iomem *)(uintptr_t)addr);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Slot selection is resolved once per boot and memoized: the first
|
||||
+ * caller is init_kernel_dtb() at board_init() time (via the part-name
|
||||
+ * hook), and the per-attempt decrement must never flip the selection
|
||||
+ * mid-boot (the "boundary problem" the SPL engine documents).
|
||||
+ *
|
||||
+ * cached state: -1 unknown, -2 no A/B layout, 0 slot A, 1 slot B
|
||||
+ */
|
||||
+static int flare_ab_cached_slot = -1;
|
||||
+static int flare_ab_recovery;
|
||||
+
|
||||
+/*
|
||||
+ * Set during slot selection when the per-power-session escalation has burned
|
||||
+ * through both committed slots and the boot must fall to the recovery FIT.
|
||||
+ * Resolved once (inside ab_select_slot, via the flare_ab_cached_slot memo) and
|
||||
+ * read by flare_ab_have_bootable()/boot_attempt()/update_root_partition(), so
|
||||
+ * every consumer agrees for the whole boot. Distinct from flare_ab_recovery,
|
||||
+ * which fit_get_blob sets once it has actually redirected to the recovery FIT.
|
||||
+ */
|
||||
+static int flare_ab_force_recovery;
|
||||
+
|
||||
+/*
|
||||
+ * The serialized metadata must fit in the single 512-byte sector we read and
|
||||
+ * write. This is a build invariant, not a runtime condition (the struct is a
|
||||
+ * fixed 32 bytes), so assert it at compile time instead of branching on it.
|
||||
+ */
|
||||
+_Static_assert(sizeof(AvbABData) <= 512, "AvbABData must fit in one sector");
|
||||
+
|
||||
+/*
|
||||
+ * Whether any slot is bootable is resolved once per boot and memoized, exactly
|
||||
+ * like the slot selection above: fit_get_blob() reads it BOTH at the early
|
||||
+ * kernel-DTB load and again at the FIT load, and flare_ab_boot_attempt()'s
|
||||
+ * tries decrement runs between those two reads. An uncached re-read could flip
|
||||
+ * on the last-try boot (tries 1->0) and source U-Boot's own control FDT from a
|
||||
+ * slot we then abandon for the recovery FIT. -1 unknown, 0 none, 1 bootable.
|
||||
+ */
|
||||
+static int flare_ab_cached_bootable = -1;
|
||||
+
|
||||
+static uint32_t flare_htobe32(uint32_t in)
|
||||
+{
|
||||
+ union {
|
||||
+ uint32_t word;
|
||||
+ uint8_t bytes[4];
|
||||
+ } ret;
|
||||
+
|
||||
+ ret.bytes[0] = (in >> 24) & 0xff;
|
||||
+ ret.bytes[1] = (in >> 16) & 0xff;
|
||||
+ ret.bytes[2] = (in >> 8) & 0xff;
|
||||
+ ret.bytes[3] = in & 0xff;
|
||||
+
|
||||
+ return ret.word;
|
||||
+}
|
||||
+
|
||||
+static uint32_t flare_be32toh(uint32_t in)
|
||||
+{
|
||||
+ uint8_t *d = (uint8_t *)∈
|
||||
+ uint32_t ret;
|
||||
+
|
||||
+ ret = ((uint32_t)d[0]) << 24;
|
||||
+ ret |= ((uint32_t)d[1]) << 16;
|
||||
+ ret |= ((uint32_t)d[2]) << 8;
|
||||
+ ret |= ((uint32_t)d[3]);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static bool ab_data_verify_and_byteswap(const AvbABData *src, AvbABData *dest)
|
||||
+{
|
||||
+ if (memcmp(src->magic, AVB_AB_MAGIC, AVB_AB_MAGIC_LEN) != 0) {
|
||||
+ printf("FLARE-AB: magic is incorrect\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(dest, src, sizeof(AvbABData));
|
||||
+ dest->crc32 = flare_be32toh(dest->crc32);
|
||||
+
|
||||
+ if (dest->version_major > AVB_AB_MAJOR_VERSION) {
|
||||
+ printf("FLARE-AB: no support for given major version\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (dest->crc32 != crc32(0, (const uint8_t *)dest,
|
||||
+ sizeof(AvbABData) - sizeof(uint32_t))) {
|
||||
+ printf("FLARE-AB: CRC32 does not match\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static void ab_data_update_crc_and_byteswap(const AvbABData *src,
|
||||
+ AvbABData *dest)
|
||||
+{
|
||||
+ memcpy(dest, src, sizeof(AvbABData));
|
||||
+ dest->crc32 = flare_htobe32(crc32(0, (const uint8_t *)dest,
|
||||
+ sizeof(AvbABData) - sizeof(uint32_t)));
|
||||
+}
|
||||
+
|
||||
+static void ab_data_init(AvbABData *data)
|
||||
+{
|
||||
+ memset(data, '\0', sizeof(AvbABData));
|
||||
+ memcpy(data->magic, AVB_AB_MAGIC, AVB_AB_MAGIC_LEN);
|
||||
+ data->version_major = AVB_AB_MAJOR_VERSION;
|
||||
+ data->version_minor = AVB_AB_MINOR_VERSION;
|
||||
+ data->last_boot = 0;
|
||||
+ data->slots[0].priority = AVB_AB_MAX_PRIORITY;
|
||||
+ data->slots[0].tries_remaining = AVB_AB_MAX_TRIES_REMAINING;
|
||||
+ data->slots[0].successful_boot = 0;
|
||||
+ data->slots[1].priority = AVB_AB_MAX_PRIORITY - 1;
|
||||
+ data->slots[1].tries_remaining = AVB_AB_MAX_TRIES_REMAINING;
|
||||
+ data->slots[1].successful_boot = 0;
|
||||
+}
|
||||
+
|
||||
+static int ab_read_metadata(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ disk_partition_t part_info;
|
||||
+ char temp[512];
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!dev_desc || !ab_data)
|
||||
+ return -EFAULT;
|
||||
+
|
||||
+ /*
|
||||
+ * Strict lookup: "misc" must never itself be slot-suffixed, and
|
||||
+ * this path is re-entered from the part-name hook.
|
||||
+ */
|
||||
+ if (part_get_info_by_name_strict(dev_desc, PART_MISC, &part_info) < 0)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ ret = blk_dread(dev_desc, part_info.start + AB_METADATA_OFFSET, 1,
|
||||
+ temp);
|
||||
+ if (ret != 1)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ memcpy(ab_data, temp, sizeof(AvbABData));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ab_write_metadata(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ disk_partition_t part_info;
|
||||
+ char temp[512];
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!dev_desc || !ab_data)
|
||||
+ return -EFAULT;
|
||||
+
|
||||
+ memset(temp, 0, sizeof(temp));
|
||||
+ memcpy(temp, ab_data, sizeof(AvbABData));
|
||||
+ if (part_get_info_by_name_strict(dev_desc, PART_MISC, &part_info) < 0)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ ret = blk_dwrite(dev_desc, part_info.start + AB_METADATA_OFFSET, 1,
|
||||
+ temp);
|
||||
+ if (ret != 1)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ab_data_write(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ AvbABData serialized;
|
||||
+
|
||||
+ ab_data_update_crc_and_byteswap(ab_data, &serialized);
|
||||
+
|
||||
+ return ab_write_metadata(dev_desc, &serialized);
|
||||
+}
|
||||
+
|
||||
+static int ab_data_read(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ AvbABData serialized;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = ab_read_metadata(dev_desc, &serialized);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (!ab_data_verify_and_byteswap(&serialized, ab_data)) {
|
||||
+ printf("FLARE-AB: invalid metadata, resetting to defaults\n");
|
||||
+ ab_data_init(ab_data);
|
||||
+ ab_data_write(dev_desc, ab_data);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static bool slot_is_bootable(AvbABSlotData *slot)
|
||||
+{
|
||||
+ return slot->priority > 0 &&
|
||||
+ (slot->successful_boot || (slot->tries_remaining > 0));
|
||||
+}
|
||||
+
|
||||
+static void slot_set_unbootable(AvbABSlotData *slot)
|
||||
+{
|
||||
+ slot->priority = 0;
|
||||
+ slot->tries_remaining = 0;
|
||||
+ slot->successful_boot = 0;
|
||||
+}
|
||||
+
|
||||
+static void slot_normalize(AvbABSlotData *slot)
|
||||
+{
|
||||
+ if (slot->priority > 0) {
|
||||
+ if (slot->tries_remaining == 0 && !slot->successful_boot)
|
||||
+ slot_set_unbootable(slot);
|
||||
+ if (slot->tries_remaining > 0 && slot->successful_boot)
|
||||
+ slot_set_unbootable(slot);
|
||||
+ } else {
|
||||
+ slot_set_unbootable(slot);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * This power session's boot-attempt number against the selected slot (>=1).
|
||||
+ * glb_rst_st==0 (a power-on reset) restarts the count; a warm reset carries the
|
||||
+ * prior value forward. Writes the incremented value back to OS_REG4 so the next
|
||||
+ * warm reset escalates. Called exactly once per boot (from ab_select_slot, which
|
||||
+ * itself runs once behind the flare_ab_cached_slot memo).
|
||||
+ */
|
||||
+static int flare_ab_bump_session(void)
|
||||
+{
|
||||
+ u32 prior;
|
||||
+
|
||||
+ if (flare_ab_reg_read(FLARE_AB_GLB_RST_ST) == 0)
|
||||
+ prior = 0;
|
||||
+ else
|
||||
+ prior = flare_ab_reg_read(FLARE_AB_SESSION_REG);
|
||||
+
|
||||
+ if (prior > FLARE_AB_MAX_SESSION)
|
||||
+ prior = FLARE_AB_MAX_SESSION;
|
||||
+
|
||||
+ prior += 1;
|
||||
+ flare_ab_reg_write(FLARE_AB_SESSION_REG, prior);
|
||||
+
|
||||
+ return (int)prior;
|
||||
+}
|
||||
+
|
||||
+static int ab_select_slot(void)
|
||||
+{
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ AvbABData ab_data;
|
||||
+ int pref, other, session;
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return -2;
|
||||
+
|
||||
+ if (ab_data_read(dev_desc, &ab_data))
|
||||
+ return -2; /* no misc partition: legacy single-slot layout */
|
||||
+
|
||||
+ if (slot_is_bootable(&ab_data.slots[0]) &&
|
||||
+ slot_is_bootable(&ab_data.slots[1])) {
|
||||
+ if (ab_data.slots[1].priority > ab_data.slots[0].priority)
|
||||
+ pref = 1;
|
||||
+ else
|
||||
+ pref = 0;
|
||||
+ } else if (slot_is_bootable(&ab_data.slots[0])) {
|
||||
+ pref = 0;
|
||||
+ } else if (slot_is_bootable(&ab_data.slots[1])) {
|
||||
+ pref = 1;
|
||||
+ } else {
|
||||
+ /*
|
||||
+ * No bootable slot at all (an exhausted update). Keep a
|
||||
+ * deterministic answer (last_boot) so partition lookups still
|
||||
+ * resolve; the boot path falls back to the recovery FIT instead
|
||||
+ * (fit_get_blob checks flare_ab_have_bootable). Session
|
||||
+ * escalation does not apply here -- persistent tries already
|
||||
+ * decided this -- so leave OS_REG4 alone.
|
||||
+ */
|
||||
+ printf("FLARE-AB: no bootable slot, lastboot=%d\n",
|
||||
+ ab_data.last_boot);
|
||||
+ return ab_data.last_boot ? 1 : 0;
|
||||
+ }
|
||||
+
|
||||
+ other = 1 - pref;
|
||||
+
|
||||
+ if (!ab_data.slots[pref].successful_boot) {
|
||||
+ /*
|
||||
+ * UPDATE regime: the preferred bootable slot is an unconfirmed
|
||||
+ * update. The persistent per-attempt tries decrement (in
|
||||
+ * flare_ab_boot_attempt) drives the revert, and it must survive
|
||||
+ * power cycles so a bad update cannot return after a brownout.
|
||||
+ * The session counter plays no part here; clear it so that once
|
||||
+ * the update resolves to a committed steady state the escalation
|
||||
+ * starts fresh at the selected slot.
|
||||
+ */
|
||||
+ flare_ab_reg_write(FLARE_AB_SESSION_REG, 0);
|
||||
+ printf("FLARE-AB: slot %s (update in flight), tries-remain=%d\n",
|
||||
+ pref ? "_b" : "_a",
|
||||
+ ab_data.slots[pref].tries_remaining);
|
||||
+ return pref;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * STEADY-STATE regime: the selected slot is committed. Escalate per
|
||||
+ * power session -- selected slot for FLARE_AB_SLOT_TRIES attempts, then
|
||||
+ * the other slot if it too is committed, then the recovery FIT. A power
|
||||
+ * cycle (glb_rst_st==0) restarts at the selected slot.
|
||||
+ */
|
||||
+ session = flare_ab_bump_session();
|
||||
+
|
||||
+ if (session <= FLARE_AB_SLOT_TRIES) {
|
||||
+ printf("FLARE-AB: slot %s (attempt %d/%d this power session)\n",
|
||||
+ pref ? "_b" : "_a", session, FLARE_AB_SLOT_TRIES);
|
||||
+ return pref;
|
||||
+ }
|
||||
+
|
||||
+ if (session <= 2 * FLARE_AB_SLOT_TRIES &&
|
||||
+ slot_is_bootable(&ab_data.slots[other]) &&
|
||||
+ ab_data.slots[other].successful_boot) {
|
||||
+ printf("FLARE-AB: slot %s failed %d attempts this session, trying %s\n",
|
||||
+ pref ? "_b" : "_a", FLARE_AB_SLOT_TRIES,
|
||||
+ other ? "_b" : "_a");
|
||||
+ return other;
|
||||
+ }
|
||||
+
|
||||
+ printf("FLARE-AB: both committed slots failed this power session, recovery\n");
|
||||
+ flare_ab_force_recovery = 1;
|
||||
+ return pref;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_enabled(void)
|
||||
+{
|
||||
+ if (flare_ab_cached_slot == -1)
|
||||
+ flare_ab_cached_slot = ab_select_slot();
|
||||
+
|
||||
+ return flare_ab_cached_slot >= 0;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_get_current_slot(char *slot)
|
||||
+{
|
||||
+ if (!flare_ab_enabled())
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ memcpy(slot, flare_ab_cached_slot ? "_b" : "_a", 2);
|
||||
+ slot[2] = '\0';
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_append_part_slot(struct blk_desc *dev_desc,
|
||||
+ const char *part_name, char *new_name)
|
||||
+{
|
||||
+ char slot_suffix[3] = {0};
|
||||
+
|
||||
+ /*
|
||||
+ * Never suffix the slot-metadata carrier itself (also breaks
|
||||
+ * the re-entrancy from ab_read_metadata), nor the shared
|
||||
+ * recovery FIT.
|
||||
+ */
|
||||
+ if (!strcmp(part_name, PART_MISC) ||
|
||||
+ !strcmp(part_name, PART_RECOVERY)) {
|
||||
+ strcat(new_name, part_name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (flare_ab_get_current_slot(slot_suffix)) {
|
||||
+ /* No A/B layout: behave exactly like stock. */
|
||||
+ strcat(new_name, part_name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ strcpy(new_name, part_name);
|
||||
+ strcat(new_name, slot_suffix);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_have_bootable(void)
|
||||
+{
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ AvbABData ab_data;
|
||||
+
|
||||
+ /*
|
||||
+ * Resolve selection first: the per-power-session escalation can decide
|
||||
+ * both committed slots are exhausted and force the recovery FIT even
|
||||
+ * though the persistent metadata still marks a slot bootable. In that
|
||||
+ * case there is no bootable NORMAL slot for this boot.
|
||||
+ */
|
||||
+ flare_ab_enabled();
|
||||
+ if (flare_ab_force_recovery)
|
||||
+ return 0;
|
||||
+
|
||||
+ /*
|
||||
+ * Memoized for the whole boot (see flare_ab_cached_bootable): the two
|
||||
+ * fit_get_blob() reads straddle the per-attempt tries decrement, so an
|
||||
+ * uncached answer could disagree with itself on the last-try boot.
|
||||
+ */
|
||||
+ if (flare_ab_cached_bootable != -1)
|
||||
+ return flare_ab_cached_bootable;
|
||||
+
|
||||
+ flare_ab_cached_bootable = 0;
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (ab_data_read(dev_desc, &ab_data))
|
||||
+ return 0;
|
||||
+
|
||||
+ flare_ab_cached_bootable = slot_is_bootable(&ab_data.slots[0]) ||
|
||||
+ slot_is_bootable(&ab_data.slots[1]);
|
||||
+ return flare_ab_cached_bootable;
|
||||
+}
|
||||
+
|
||||
+void flare_ab_set_recovery_mode(void)
|
||||
+{
|
||||
+ if (!flare_ab_recovery) {
|
||||
+ printf("FLARE-AB: recovery FIT selected\n");
|
||||
+ /*
|
||||
+ * One-shot, like the BCB clear RkLunch-recovery.sh does on
|
||||
+ * entry to the rescue ramdisk: the per-power-session
|
||||
+ * escalation has done its job (or was bypassed by a BCB
|
||||
+ * command) once we are here, so reset it. Without this,
|
||||
+ * OS_REG4 keeps carrying the count that forced recovery, and
|
||||
+ * this SoC's `reboot` only works via the CRU global-reset
|
||||
+ * poke (docs/boot-flow.md) -- itself a WARM reset -- so any
|
||||
+ * reboot issued from inside recovery would re-escalate
|
||||
+ * straight back into recovery on the next boot, stranding
|
||||
+ * the operator until someone cycles power at the unit. This
|
||||
+ * one hook covers every path that reaches PART_RECOVERY (BCB
|
||||
+ * command, no-bootable-slot fallback, and this session
|
||||
+ * escalation alike).
|
||||
+ */
|
||||
+ flare_ab_reg_write(FLARE_AB_SESSION_REG, 0);
|
||||
+ }
|
||||
+ flare_ab_recovery = 1;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_in_recovery(void)
|
||||
+{
|
||||
+ return flare_ab_recovery;
|
||||
+}
|
||||
+
|
||||
+void flare_ab_boot_attempt(void)
|
||||
+{
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ AvbABData ab_data, ab_data_orig;
|
||||
+ int slot_index;
|
||||
+
|
||||
+ if (!flare_ab_enabled() || flare_ab_recovery || flare_ab_force_recovery)
|
||||
+ return;
|
||||
+
|
||||
+ slot_index = flare_ab_cached_slot;
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return;
|
||||
+
|
||||
+ if (ab_data_read(dev_desc, &ab_data))
|
||||
+ return;
|
||||
+
|
||||
+ memcpy(&ab_data_orig, &ab_data, sizeof(AvbABData));
|
||||
+
|
||||
+ slot_normalize(&ab_data.slots[0]);
|
||||
+ slot_normalize(&ab_data.slots[1]);
|
||||
+
|
||||
+ if (!ab_data.slots[slot_index].successful_boot &&
|
||||
+ ab_data.slots[slot_index].tries_remaining > 0)
|
||||
+ ab_data.slots[slot_index].tries_remaining -= 1;
|
||||
+
|
||||
+ ab_data.last_boot = slot_index;
|
||||
+
|
||||
+ /*
|
||||
+ * Single-sector write, and only while an update window is open
|
||||
+ * (an unsuccessful slot): a confirmed device's ordinary boots
|
||||
+ * and power cycles never write flash here.
|
||||
+ */
|
||||
+ if (memcmp(&ab_data, &ab_data_orig, sizeof(AvbABData)))
|
||||
+ ab_data_write(dev_desc, &ab_data);
|
||||
+}
|
||||
+
|
||||
+void flare_ab_boot_failed(void)
|
||||
+{
|
||||
+ if (!flare_ab_enabled())
|
||||
+ return;
|
||||
+
|
||||
+ if (flare_ab_recovery) {
|
||||
+ /*
|
||||
+ * Both slots AND the recovery FIT are gone. Escalate to USB
|
||||
+ * download: `download` runs `rockusb` FROM U-BOOT when
|
||||
+ * CONFIG_CMD_ROCKUSB is built (flare-usb-gadget.config), so a
|
||||
+ * bad-boot device is reflashable over USB with no MaskRom
|
||||
+ * button / disassembly; if rockusb is absent it falls through
|
||||
+ * to `rbrom` (BootROM MaskRom). Either way the host can recover
|
||||
+ * it over the existing USB port.
|
||||
+ */
|
||||
+ printf("FLARE-AB: recovery FIT unbootable, entering USB download\n");
|
||||
+ run_command("download", 0);
|
||||
+ hang();
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * A storage-slot boot failed to load its FIT. Reset so the next boot
|
||||
+ * makes forward progress. This is a WARM reset, so glb_rst_st stays
|
||||
+ * nonzero and OS_REG4 carries the attempt count: the next boot
|
||||
+ * escalates -- retry the same committed slot up to FLARE_AB_SLOT_TRIES,
|
||||
+ * then the other committed slot, then the recovery FIT, then USB
|
||||
+ * download. In the update regime the per-attempt persistent-tries
|
||||
+ * decrement (flare_ab_boot_attempt) has already run, so the same reset
|
||||
+ * drives the persistent revert to the other slot. A power cycle
|
||||
+ * (glb_rst_st==0) restarts at the selected slot -- no failure state is
|
||||
+ * written to flash for a committed slot.
|
||||
+ */
|
||||
+ printf("FLARE-AB: slot boot failed, resetting\n");
|
||||
+ do_reset(NULL, 0, 0, NULL);
|
||||
+ hang();
|
||||
+}
|
||||
+
|
||||
+void flare_ab_update_root_partition(void)
|
||||
+{
|
||||
+ disk_partition_t part_info;
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ char arg[64];
|
||||
+ char slot_suffix[3] = {0};
|
||||
+ int part_num;
|
||||
+
|
||||
+ if (!flare_ab_enabled())
|
||||
+ return;
|
||||
+
|
||||
+ if (flare_ab_recovery || flare_ab_force_recovery) {
|
||||
+ /*
|
||||
+ * Recovery boots from its own initramfs; publish the
|
||||
+ * marker and leave root= alone (unused under rdinit).
|
||||
+ * flare_ab_force_recovery is set by the session escalation at
|
||||
+ * selection time, before fit_get_blob has set flare_ab_recovery,
|
||||
+ * so it must be honored here too.
|
||||
+ */
|
||||
+ env_update("bootargs", "warden.recovery=1");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return;
|
||||
+
|
||||
+ /* Auto-suffixed by the part-name hook: resolves rootfs_a/_b. */
|
||||
+ part_num = part_get_info_by_name(dev_desc, "rootfs", &part_info);
|
||||
+ if (part_num < 0) {
|
||||
+ printf("FLARE-AB: no rootfs slot partition\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (dev_desc->if_type != IF_TYPE_MMC)
|
||||
+ return;
|
||||
+
|
||||
+ snprintf(arg, sizeof(arg), "root=/dev/mmcblk0p%d", part_num);
|
||||
+ env_update("bootargs", arg);
|
||||
+
|
||||
+ flare_ab_get_current_slot(slot_suffix);
|
||||
+ snprintf(arg, sizeof(arg), "warden.slot=%s", slot_suffix);
|
||||
+ env_update("bootargs", arg);
|
||||
+}
|
||||
diff --git a/sysdrv/source/uboot/u-boot/configs/flare-ab.config b/sysdrv/source/uboot/u-boot/configs/flare-ab.config
|
||||
new file mode 100644
|
||||
index 000000000..1404655c0
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/configs/flare-ab.config
|
||||
@@ -0,0 +1,10 @@
|
||||
+# flare-edge: A/B slot boot in U-Boot proper.
|
||||
+#
|
||||
+# Lean port of the vendor SPL A/B engine (common/flare_ab.c): AOSP
|
||||
+# AvbABData metadata in one CRC32-protected sector at misc+2048, slot
|
||||
+# suffixing hooked into part_get_info_by_name() (covers boot_fit AND the
|
||||
+# board_init()-time kernel-DTB/resource load), one tries decrement per
|
||||
+# boot attempt while a slot is unconfirmed, recovery-FIT fallback when
|
||||
+# both slots are exhausted, MaskRom when even that fails.
|
||||
+# Design: docs/decisions/0001-slot-machine.md (flare-edge repo).
|
||||
+CONFIG_FLARE_AB=y
|
||||
diff --git a/sysdrv/source/uboot/u-boot/disk/part.c b/sysdrv/source/uboot/u-boot/disk/part.c
|
||||
index 182c03771..ad73662eb 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/disk/part.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/disk/part.c
|
||||
@@ -14,6 +14,9 @@
|
||||
#ifdef CONFIG_SPL_AB
|
||||
#include <spl_ab.h>
|
||||
#endif
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
#include <ubifs_uboot.h>
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
#include <android_avb/avb_ops_user.h>
|
||||
@@ -700,7 +703,8 @@ static int part_get_info_by_name_option(struct blk_desc *dev_desc,
|
||||
}
|
||||
|
||||
/* 1. Query partition with A/B slot suffix */
|
||||
-#if defined(CONFIG_ANDROID_AB) || defined(CONFIG_SPL_AB)
|
||||
+#if defined(CONFIG_ANDROID_AB) || defined(CONFIG_SPL_AB) || \
|
||||
+ defined(CONFIG_FLARE_AB)
|
||||
char *slot = (char *)name + strlen(name) - 2;
|
||||
|
||||
if (!strcmp(slot, "_a") || !strcmp(slot, "_b"))
|
||||
@@ -710,6 +714,10 @@ static int part_get_info_by_name_option(struct blk_desc *dev_desc,
|
||||
if (rk_avb_append_part_slot(name, name_slot))
|
||||
return -1;
|
||||
full_name = name_slot;
|
||||
+#elif defined(CONFIG_FLARE_AB) && !defined(CONFIG_SPL_BUILD)
|
||||
+ if (flare_ab_append_part_slot(dev_desc, name, name_slot))
|
||||
+ return -1;
|
||||
+ full_name = name_slot;
|
||||
#elif defined(CONFIG_SPL_AB) && defined(CONFIG_SPL_BUILD)
|
||||
if (spl_ab_append_part_slot(dev_desc, name, name_slot))
|
||||
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
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/flare_ab.h
|
||||
@@ -0,0 +1,73 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
+/*
|
||||
+ * flare-edge A/B slot boot for U-Boot proper.
|
||||
+ *
|
||||
+ * A lean, libavb-free port of the vendor SPL A/B engine
|
||||
+ * (common/spl/spl_ab.c) so the same AOSP AvbABData metadata (one
|
||||
+ * CRC32-protected 32-byte struct in a single 512-byte sector at
|
||||
+ * `misc` + AB_METADATA_OFFSET blocks) drives slot selection in U-Boot
|
||||
+ * proper: boot_a/boot_b via the part_get_info_by_name() suffix hook,
|
||||
+ * 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
|
||||
+ * this metadata from userspace (CI-enforced).
|
||||
+ */
|
||||
+
|
||||
+#ifndef _FLARE_AB_H_
|
||||
+#define _FLARE_AB_H_
|
||||
+
|
||||
+#include <blk.h>
|
||||
+
|
||||
+/* Same on-disk location as the vendor SPL engine (spl_ab.h). */
|
||||
+#ifndef AB_METADATA_OFFSET
|
||||
+#define AB_METADATA_OFFSET 4
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * True when an A/B layout is present (a `misc` partition with valid or
|
||||
+ * initializable metadata). On a legacy single-slot layout every hook
|
||||
+ * below degrades to stock behavior.
|
||||
+ */
|
||||
+int flare_ab_enabled(void);
|
||||
+
|
||||
+/* Memoized for the whole boot: "_a"/"_b" into slot[3]. 0 on success. */
|
||||
+int flare_ab_get_current_slot(char *slot);
|
||||
+
|
||||
+/* part_get_info_by_name() hook: append the active slot suffix. */
|
||||
+int flare_ab_append_part_slot(struct blk_desc *dev_desc,
|
||||
+ const char *part_name, char *new_name);
|
||||
+
|
||||
+/* Any slot with priority>0 and (successful || tries>0)? */
|
||||
+int flare_ab_have_bootable(void);
|
||||
+
|
||||
+/*
|
||||
+ * 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).
|
||||
+ * No-op in recovery fallback mode or on a non-A/B layout.
|
||||
+ */
|
||||
+void flare_ab_boot_attempt(void);
|
||||
+
|
||||
+/*
|
||||
+ * Storage boot failed (FIT unreadable/unbootable). On an A/B layout:
|
||||
+ * reset so the next boot re-selects (per-attempt decrement guarantees
|
||||
+ * progress); once no slot is bootable the next boot falls back to the
|
||||
+ * recovery FIT; if that also failed, drop to MaskRom (`download`).
|
||||
+ * Returns (doing nothing) on a non-A/B layout.
|
||||
+ */
|
||||
+void flare_ab_boot_failed(void);
|
||||
+
|
||||
+/* fit_get_blob() fell back to (or was commanded into) the recovery FIT. */
|
||||
+void flare_ab_set_recovery_mode(void);
|
||||
+int flare_ab_in_recovery(void);
|
||||
+
|
||||
+/*
|
||||
+ * bootargs fixup, mirrors ab_update_root_partition(): key-replace
|
||||
+ * root= with the active slot's rootfs partition and publish
|
||||
+ * warden.slot=_x (and warden.recovery=1 in recovery fallback) for
|
||||
+ * userspace (oem mount, slotctl).
|
||||
+ */
|
||||
+void flare_ab_update_root_partition(void);
|
||||
+
|
||||
+#endif /* _FLARE_AB_H_ */
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
@@ -16,6 +16,9 @@
|
||||
#include <cli.h>
|
||||
#include <clk.h>
|
||||
#include <console.h>
|
||||
#include <flare_trace.h>
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
#include <debug_uart.h>
|
||||
#include <dm.h>
|
||||
@@ -1340,9 +1343,19 @@
|
||||
static void bootargs_add_android(bool verbose)
|
||||
{
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
ab_update_root_partition();
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * Runs after bootargs_add_partition() merged sys_bootargs, so
|
||||
+ * the env_update() here key-replaces any build-time root= with
|
||||
+ * the active slot's rootfs partition (and publishes warden.slot
|
||||
+ * for userspace).
|
||||
+ */
|
||||
+ flare_ab_update_root_partition();
|
||||
+#endif
|
||||
+
|
||||
/* Android header v4+ need this handle */
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
struct andr_img_hdr *hdr;
|
||||
@@ -0,0 +1,35 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/cmd/download.c b/sysdrv/source/uboot/u-boot/cmd/download.c
|
||||
index 528501305..77f56ea12 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/cmd/download.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/cmd/download.c
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <console.h>
|
||||
+#if defined(CONFIG_DRM_ROCKCHIP) && defined(CONFIG_FLARE_AB)
|
||||
+#include <video_rockchip.h>
|
||||
+#endif
|
||||
|
||||
__weak void do_board_download(void)
|
||||
{
|
||||
@@ -17,6 +20,20 @@ static int do_download(cmd_tbl_t *cmdtp, int flag,
|
||||
{
|
||||
disable_ctrlc(1);
|
||||
|
||||
+#if defined(CONFIG_DRM_ROCKCHIP) && defined(CONFIG_FLARE_AB)
|
||||
+ /*
|
||||
+ * flare-edge: paint the "connect USB to recover" splash before entering
|
||||
+ * download mode. Reached on every download trigger — FLARE_AB slot/
|
||||
+ * recovery exhaustion, altbootcmd=download, the BOOT key, Ctrl+D. The
|
||||
+ * VOP keeps scanning out this framebuffer while rockusb (below) serves
|
||||
+ * from U-Boot WITHOUT a reset, so the image PERSISTS on screen the whole
|
||||
+ * time the device is USB-flashable. (On the rbrom fallback a CRU reset
|
||||
+ * clears it — BootROM has no display — but rockusb is the primary path.)
|
||||
+ * logo_recovery.bmp is packed into resource.img (kernel scripts/mkimg).
|
||||
+ */
|
||||
+ rockchip_show_bmp("logo_recovery.bmp");
|
||||
+#endif
|
||||
+
|
||||
/* Allow board specific download, maybe noreturn */
|
||||
do_board_download();
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
diff -ruN a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi 2026-09-01 15:32:39.100121610 -0600
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi 2026-09-01 15:32:39.056121549 -0600
|
||||
@@ -93,7 +93,14 @@
|
||||
|
||||
&sdmmc {
|
||||
u-boot,dm-spl;
|
||||
- pwr-en-gpios = <&gpio0 RK_PA1 GPIO_ACTIVE_LOW>;
|
||||
+ /* flare-edge: the EVB's SD-slot power enable was <&gpio0 RK_PA1
|
||||
+ * GPIO_ACTIVE_LOW> -- on the 86-Panel that pin is RGB_RES, the
|
||||
+ * CH32V003 panel-init MCU's reset (schematic-confirmed net). The
|
||||
+ * sdmmc probe was driving it low in SPL on every boot, holding the
|
||||
+ * panel initialiser in reset until board_init re-released it at
|
||||
+ * ~0.55 s and restarting its measured, fixed 4.89 s init -- the
|
||||
+ * single longest pole in time-to-first-image. The 86-Panel's SD slot
|
||||
+ * has no switched rail on this line; drop the property. */
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
diff -ruN a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c 2026-09-01 15:32:39.100121610 -0600
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c 2026-09-01 15:32:39.040121527 -0600
|
||||
@@ -216,6 +216,23 @@
|
||||
#endif
|
||||
gd->flags = dummy;
|
||||
rockchip_stimer_init();
|
||||
+#if defined(CONFIG_ROCKCHIP_RV1106)
|
||||
+ /*
|
||||
+ * flare-edge: release GPIO0_A1 (net RGB_RES) at the earliest possible
|
||||
+ * moment. The net holds the 86-Panel's CH32V003 init MCU (and the
|
||||
+ * panel's own reset pin) in reset via the pin's power-on pulldown, and
|
||||
+ * the MCU takes a MEASURED, fixed 4.89 s from release to first photons
|
||||
+ * (its SPI init of the NV3052 controller) regardless of anything the
|
||||
+ * SoC does. Every millisecond the release moves earlier is a
|
||||
+ * millisecond off time-to-first-image, so it happens here in SPL
|
||||
+ * (~0.03 s) rather than U-Boot proper's board_init() (~0.45 s), which
|
||||
+ * keeps its own idempotent release as a fallback. Raw writels because
|
||||
+ * no driver model exists yet: RV1106 GPIO0 v2 @0xff380000,
|
||||
+ * swport_dr_l 0x00 / swport_ddr_l 0x08, write-masked upper half word.
|
||||
+ */
|
||||
+ writel(0x00020002, (void *)0xff380008); /* GPIO0_A1 -> output */
|
||||
+ writel(0x00020002, (void *)0xff380000); /* GPIO0_A1 -> high */
|
||||
+#endif
|
||||
#define EARLY_UART
|
||||
#if defined(EARLY_UART) && defined(CONFIG_DEBUG_UART)
|
||||
/*
|
||||
@@ -230,6 +247,14 @@
|
||||
!(gd->flags & GD_FLG_DISABLE_CONSOLE))
|
||||
debug_uart_init();
|
||||
printascii("U-Boot SPL board init");
|
||||
+#if defined(CONFIG_ROCKCHIP_RV1106)
|
||||
+ /* flare-edge: diagnose the early GPIO0_A1 release -- print DR+DDR. */
|
||||
+ printascii(" [RGB_RES dr=");
|
||||
+ printhex8(readl((void *)0xff380000));
|
||||
+ printascii(" ddr=");
|
||||
+ printhex8(readl((void *)0xff380008));
|
||||
+ printascii("] ");
|
||||
+#endif
|
||||
#endif
|
||||
gd->sys_start_tick = get_ticks();
|
||||
#ifdef CONFIG_SPL_PCIE_EP_SUPPORT
|
||||
@@ -0,0 +1,109 @@
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
@@ -246,3 +246,106 @@
|
||||
u-boot,dm-pre-reloc;
|
||||
status = "okay";
|
||||
};
|
||||
+
|
||||
+/*
|
||||
+ * flare-edge: the 86-Panel display graph, kept in U-Boot's OWN device tree.
|
||||
+ *
|
||||
+ * DORMANT in the shipped configuration: flare-display.config keeps
|
||||
+ * CONFIG_USING_KERNEL_DTB=y and embeds a kernel-style control DTB
|
||||
+ * (CONFIG_EMBED_KERNEL_DTB_ALWAYS, dts/rv1106-warden-kernel.dtb), which
|
||||
+ * board_init() adopts BEFORE any display bring-up -- so these nodes are not
|
||||
+ * consulted at runtime today. They are kept as the complete, board-correct
|
||||
+ * display graph for a future own-control-DTB configuration, copied verbatim
|
||||
+ * from the proven 5.10 kernel DTS (rv1106-luckfox-pico-86panel-ipc.dtsi).
|
||||
+ *
|
||||
+ * Do NOT enable such a configuration by setting
|
||||
+ * "CONFIG_USING_KERNEL_DTB is not set": that path was tried 2026-09-01 and
|
||||
+ * silently breaks the ENVF whitelist import -- blkdevparts= disappears from
|
||||
+ * the kernel cmdline and, with no partition table outside the cmdline, BOTH
|
||||
+ * slots hang in rootwait (see flare-display.config for the full account).
|
||||
+ * The logo BMPs always come from the booted slot's resource.img.
|
||||
+ */
|
||||
+/ {
|
||||
+ backlight: backlight {
|
||||
+ compatible = "pwm-backlight";
|
||||
+ pwms = <&pwm1 0 100000 50000>;
|
||||
+ };
|
||||
+
|
||||
+ panel: panel {
|
||||
+ compatible = "simple-panel";
|
||||
+ backlight = <&backlight>;
|
||||
+ bus-format = <0x1009>; /* MEDIA_BUS_FMT_RGB666_1X18 */
|
||||
+ width-mm = <85>;
|
||||
+ height-mm = <85>;
|
||||
+
|
||||
+ display-timings {
|
||||
+ native-mode = <&timing0>;
|
||||
+
|
||||
+ timing0: timing0 {
|
||||
+ clock-frequency = <30000000>;
|
||||
+ hactive = <720>;
|
||||
+ vactive = <720>;
|
||||
+ hback-porch = <44>;
|
||||
+ hfront-porch = <46>;
|
||||
+ vback-porch = <18>;
|
||||
+ vfront-porch = <16>;
|
||||
+ hsync-len = <2>;
|
||||
+ vsync-len = <2>;
|
||||
+ hsync-active = <0>;
|
||||
+ vsync-active = <0>;
|
||||
+ de-active = <0>;
|
||||
+ pixelclk-active = <0>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port {
|
||||
+ panel_in_rgb: endpoint {
|
||||
+ remote-endpoint = <&rgb_out_panel>;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&display_subsystem {
|
||||
+ status = "okay";
|
||||
+
|
||||
+ route {
|
||||
+ route_rgb: route-rgb {
|
||||
+ status = "okay";
|
||||
+ logo,uboot = "logo.bmp";
|
||||
+ logo,kernel = "logo_kernel.bmp";
|
||||
+ logo,mode = "center";
|
||||
+ charge_logo,mode = "center";
|
||||
+ connect = <&vop_out_rgb>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&pwm1 {
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pwm1m2_pins>;
|
||||
+};
|
||||
+
|
||||
+&rgb {
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&lcd_pins>;
|
||||
+
|
||||
+ ports {
|
||||
+ rgb_out: port@1 {
|
||||
+ reg = <1>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ rgb_out_panel: endpoint@0 {
|
||||
+ reg = <0>;
|
||||
+ remote-endpoint = <&panel_in_rgb>;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&vop {
|
||||
+ status = "okay";
|
||||
+};
|
||||
@@ -0,0 +1,36 @@
|
||||
diff -ruN a/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h b/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h
|
||||
--- a/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h 2026-09-01 16:48:53.948824814 -0600
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h 2026-09-01 16:48:53.936824778 -0600
|
||||
@@ -68,18 +68,26 @@
|
||||
#define ENV_MEM_LAYOUT_SETTINGS CONFIG_ENV_MEM_LAYOUT_SETTINGS
|
||||
#else
|
||||
/*
|
||||
+ * flare-edge layout (2026-09-01): the vendor put fdt at 12M and ramdisk at
|
||||
+ * 14M, which capped the zImage (loaded at 0x8000) at ~11.95MB -- sysmem
|
||||
+ * rejects the boot with "slot boot failed" the moment the kernel grows past
|
||||
+ * the fdt region, which our gzip-compressed 6.18 (12.25MB) did. Move fdt to
|
||||
+ * 128M (matching the load address our external-data FITs already carry) and
|
||||
+ * ramdisk above it; a 256MB board has the room, and the kernel can now grow
|
||||
+ * to ~120MB before this bites again.
|
||||
+ *
|
||||
* Image: 0 - 8M
|
||||
- * zImage: 8 - 12M
|
||||
- * fdt: 12 - 13M
|
||||
- * ramdisk: 14 ...
|
||||
+ * zImage: 8 - ...
|
||||
+ * fdt: 128M
|
||||
+ * ramdisk: 132M ...
|
||||
*/
|
||||
#define ENV_MEM_LAYOUT_SETTINGS \
|
||||
"scriptaddr=0x00b00000\0" \
|
||||
- "pxefile_addr_r=0x00c00000\0" \
|
||||
- "fdt_addr_r=0x00c00000\0" \
|
||||
+ "pxefile_addr_r=0x08000000\0" \
|
||||
+ "fdt_addr_r=0x08000000\0" \
|
||||
"kernel_addr_c=0x00808000\0" \
|
||||
"kernel_addr_r=0x00008000\0" \
|
||||
- "ramdisk_addr_r=0x000e00000\0"
|
||||
+ "ramdisk_addr_r=0x008400000\0"
|
||||
#endif
|
||||
|
||||
#define CONFIG_EXTRA_ENV_SETTINGS \
|
||||
@@ -0,0 +1,503 @@
|
||||
flare-edge: decide the verbose boot in U-Boot, from a press on the splash.
|
||||
|
||||
See arch/arm/mach-rockchip/flare_touch.c for the measurements behind the
|
||||
sampling design (issues #140, #143).
|
||||
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <clk.h>
|
||||
#include <console.h>
|
||||
#include <flare_trace.h>
|
||||
+#include <flare_touch.h>
|
||||
#ifdef CONFIG_FLARE_AB
|
||||
#include <flare_ab.h>
|
||||
#endif
|
||||
@@ -519,9 +520,28 @@
|
||||
/* Logo as early as possible, but never ahead of the recovery path. */
|
||||
#ifdef CONFIG_DRM_ROCKCHIP
|
||||
if (rockchip_get_boot_mode() != BOOT_MODE_QUIESCENT) {
|
||||
+ char ubt[64];
|
||||
+ ulong t0, t1;
|
||||
+
|
||||
FLARE_TRACE("rockchip_show_logo start");
|
||||
+ t0 = FLARE_USEC();
|
||||
rockchip_show_logo();
|
||||
+ t1 = FLARE_USEC();
|
||||
FLARE_TRACE("rockchip_show_logo done");
|
||||
+ /* Milliseconds since power-on, entering and leaving the logo
|
||||
+ * call. Reported on the kernel command line because that is the
|
||||
+ * only place a panel with no serial console can be asked
|
||||
+ * afterwards how long its splash really took. */
|
||||
+ snprintf(ubt, sizeof(ubt), "warden.ubt=%lu,%lu",
|
||||
+ t0 / 1000, t1 / 1000);
|
||||
+ env_set("flare_ubt", ubt);
|
||||
+
|
||||
+ /*
|
||||
+ * From here on, anything the touch controller reports is
|
||||
+ * something that happened while the splash was on screen.
|
||||
+ */
|
||||
+ flare_touch_arm();
|
||||
+
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
|
||||
@@ -676,6 +696,49 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: swap the splash mark and ask for a verbose boot, if the panel
|
||||
+ * was tapped.
|
||||
+ *
|
||||
+ * The splash's bottom-right mark reads GRAPHIC. A tap swaps it for the
|
||||
+ * otherwise identical VERBOSE image and puts warden.verbose=1 on the kernel
|
||||
+ * command line, so what the operator is shown matches the boot they get.
|
||||
+ *
|
||||
+ * BOTH image calls are needed. rockchip_show_bmp() repaints what U-Boot is
|
||||
+ * showing now; rockchip_set_kernel_logo() changes the separate image handed to
|
||||
+ * the kernel at the display handoff. Without the second, the kernel logo
|
||||
+ * paints GRAPHIC back over the first a few milliseconds later and the tap
|
||||
+ * looks ignored.
|
||||
+ *
|
||||
+ * warden.touch is reported on EVERY boot, tapped or not. Without it, "no
|
||||
+ * controller", "controller present but silent" and "not touched" are the same
|
||||
+ * silence on a panel with no serial console.
|
||||
+ */
|
||||
+static void flare_verbose_check(void)
|
||||
+{
|
||||
+ struct flare_touch_state st;
|
||||
+ char buf[80];
|
||||
+ int tapped, shown, kset;
|
||||
+
|
||||
+ tapped = flare_touch_tapped(&st);
|
||||
+
|
||||
+ snprintf(buf, sizeof(buf), "warden.touch=0x%x,%d,%s,arm%d:0x%02x,rd0x%02x",
|
||||
+ st.addr, tapped, st.id[0] ? st.id : "none",
|
||||
+ st.armed, st.arm_status, st.status);
|
||||
+ env_set("flare_touch", buf);
|
||||
+ FLARE_TRACE(buf);
|
||||
+
|
||||
+ if (!tapped)
|
||||
+ return;
|
||||
+
|
||||
+ shown = rockchip_show_bmp("logo_verbose.bmp");
|
||||
+ kset = rockchip_set_kernel_logo("logo_verbose.bmp");
|
||||
+ snprintf(buf, sizeof(buf), "warden.vmark=%d,%d", shown, kset);
|
||||
+ env_set("flare_vmark", buf);
|
||||
+ env_set("flare_verbose", "1");
|
||||
+ FLARE_TRACE("verbose boot selected by touch");
|
||||
+}
|
||||
+
|
||||
int board_fdt_fixup(void *blob)
|
||||
{
|
||||
/*
|
||||
@@ -684,6 +747,23 @@
|
||||
*/
|
||||
rk_board_dm_fdt_fixup(blob);
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: the verbose-boot tap.
|
||||
+ *
|
||||
+ * Sampled HERE, and deliberately not earlier. The controller latches a
|
||||
+ * touch report and holds it until acknowledged, so one read at this
|
||||
+ * point catches a tap made at any time during the splash -- without
|
||||
+ * watching for a window, which would add that window to every boot
|
||||
+ * whether or not anyone touched the panel. An escape hatch is not worth
|
||||
+ * paying for on boots that never use it.
|
||||
+ *
|
||||
+ * This is the last moment both halves can still be changed: it runs
|
||||
+ * before rockchip_display_fixup() below loads the kernel logo, and
|
||||
+ * arch_fixup_fdt() runs before fdt_chosen(), so the command line built
|
||||
+ * by board_fdt_chosen_bootargs() still picks up what is set here.
|
||||
+ */
|
||||
+ flare_verbose_check();
|
||||
+
|
||||
/* Common fixup for DRM */
|
||||
#ifdef CONFIG_DRM_ROCKCHIP
|
||||
rockchip_display_fixup(blob);
|
||||
@@ -1475,6 +1555,29 @@
|
||||
bootargs_add_fwver(verbose);
|
||||
bootargs_add_android(verbose);
|
||||
|
||||
+ /* flare-edge: the splash tap, carried to the kernel. Added here rather
|
||||
+ * than where it is sampled because sys_bootargs is merged into bootargs
|
||||
+ * after board_late_init, and an earlier append does not survive it. */
|
||||
+ {
|
||||
+ const char *ub = env_get("flare_ubt");
|
||||
+ const char *ft = env_get("flare_touch");
|
||||
+
|
||||
+ if (ub)
|
||||
+ env_update("bootargs", ub);
|
||||
+ const char *fv = env_get("flare_verbose");
|
||||
+
|
||||
+ if (ft)
|
||||
+ env_update("bootargs", ft);
|
||||
+
|
||||
+ if (fv && !strcmp(fv, "1")) {
|
||||
+ const char *vm = env_get("flare_vmark");
|
||||
+
|
||||
+ env_update("bootargs", "warden.verbose=1");
|
||||
+ if (vm)
|
||||
+ env_update("bootargs", vm);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Initrd fixup: remove unused "initrd=0x...,0x...",
|
||||
* this for compatible with legacy parameter.txt
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/Makefile
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/Makefile
|
||||
@@ -37,6 +37,7 @@
|
||||
obj-y += boot_mode.o
|
||||
obj-y += boot_rkimg.o
|
||||
obj-y += board.o
|
||||
+obj-y += flare_touch.o
|
||||
obj-y += iomem.o
|
||||
obj-y += memblk.o
|
||||
obj-$(CONFIG_ROCKCHIP_HOTKEY) += hotkey.o
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
@@ -52,7 +52,22 @@
|
||||
#define RK_BLK_SIZE 512
|
||||
#define BMP_PROCESSED_FLAG 8399
|
||||
#define BYTES_PER_PIXEL sizeof(uint32_t)
|
||||
-#define MAX_IMAGE_BYTES (8 * 1024 * 1024)
|
||||
+/*
|
||||
+ * flare-edge: 8 MB was too large to ask for twice.
|
||||
+ *
|
||||
+ * This is the transient scratch buffer a single image load takes, and it is
|
||||
+ * held while the decoded bitmap (~2 MB for this panel) is also live. Against
|
||||
+ * CONFIG_SYS_MALLOC_LEN of 16 MB the first load fits, but by the second the
|
||||
+ * heap can no longer satisfy another 8 MB contiguous request and the load
|
||||
+ * fails with -ENOMEM. That is invisible on a panel: rockchip_show_bmp() went
|
||||
+ * on to report success, so a second image simply never appeared.
|
||||
+ *
|
||||
+ * The panel's own logos are 720x720x3 plus header = 1,555,254 bytes, so 4 MB
|
||||
+ * is still 2.6x the largest image this board can display while being small
|
||||
+ * enough to allocate repeatedly. An image larger than this reads short and is
|
||||
+ * then rejected by the decoder rather than shown corrupt.
|
||||
+ */
|
||||
+#define MAX_IMAGE_BYTES (4 * 1024 * 1024)
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
static LIST_HEAD(rockchip_display_list);
|
||||
@@ -1549,7 +1564,15 @@
|
||||
|
||||
list_for_each_entry(s, &rockchip_display_list, head) {
|
||||
s->logo.mode = s->charge_logo_mode;
|
||||
- if (load_bmp_logo(&s->logo, bmp))
|
||||
+ /*
|
||||
+ * flare-edge: report the load failure instead of swallowing it.
|
||||
+ * `ret` starts at 0 and this loop used to `continue` past a
|
||||
+ * failed load, so a call that displayed nothing at all still
|
||||
+ * returned success -- which sent a whole debugging round after
|
||||
+ * a display that had never been given an image.
|
||||
+ */
|
||||
+ ret = load_bmp_logo(&s->logo, bmp);
|
||||
+ if (ret)
|
||||
continue;
|
||||
ret = display_logo(s);
|
||||
}
|
||||
@@ -1557,6 +1580,36 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: change which image the KERNEL is handed at the display handoff.
|
||||
+ *
|
||||
+ * rockchip_show_bmp() only repaints what U-Boot itself is showing. The image
|
||||
+ * the kernel keeps on screen is a separate one, loaded from klogo_name into
|
||||
+ * the rockchip,drm-logo reserved memory during rockchip_display_fixup(), and
|
||||
+ * it is painted over whatever U-Boot drew moments earlier. So swapping the
|
||||
+ * splash for a tap without also swapping this one shows the new image for a
|
||||
+ * few milliseconds and then reverts, which reads on the panel as the tap
|
||||
+ * having done nothing at all.
|
||||
+ */
|
||||
+int rockchip_set_kernel_logo(const char *bmp)
|
||||
+{
|
||||
+ struct display_state *s;
|
||||
+ int found = 0;
|
||||
+
|
||||
+ if (!bmp)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ list_for_each_entry(s, &rockchip_display_list, head) {
|
||||
+ if (strlen(bmp) >= sizeof(s->klogo_name))
|
||||
+ return -ENAMETOOLONG;
|
||||
+ memset(s->klogo_name, 0, sizeof(s->klogo_name));
|
||||
+ memcpy(s->klogo_name, bmp, strlen(bmp));
|
||||
+ found++;
|
||||
+ }
|
||||
+
|
||||
+ return found ? 0 : -ENODEV;
|
||||
+}
|
||||
+
|
||||
int rockchip_show_logo(void)
|
||||
{
|
||||
struct display_state *s;
|
||||
--- a/sysdrv/source/uboot/u-boot/include/video_rockchip.h
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/video_rockchip.h
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
int rockchip_show_bmp(const char *bmp);
|
||||
int rockchip_show_logo(void);
|
||||
+int rockchip_set_kernel_logo(const char *bmp);
|
||||
void rockchip_display_fixup(void *blob);
|
||||
|
||||
#endif
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/flare_touch.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/flare_touch.c
|
||||
@@ -0,0 +1,252 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0+
|
||||
+/*
|
||||
+ * flare-edge: read the panel's touchscreen from U-Boot, so the choice between
|
||||
+ * the graphic splash and a verbose boot is made BEFORE the kernel starts.
|
||||
+ *
|
||||
+ * WHY THIS LIVES IN THE BOOTLOADER. The same decision used to be made in
|
||||
+ * userspace, by S09splash watching the evdev node. That could only ever cover
|
||||
+ * the part of the boot that had already happened by the time an init script
|
||||
+ * ran, and it was fragile for a second reason: the window was expressed as an
|
||||
+ * absolute uptime, and once the splash started later than that deadline the
|
||||
+ * probe ended on its first iteration and the feature was silently dead
|
||||
+ * (issue #143). Deciding here removes both problems -- the flag is on the
|
||||
+ * kernel command line before the kernel prints its first line, and there is no
|
||||
+ * race with when an init script happens to run.
|
||||
+ *
|
||||
+ * THE PANEL'S CONTROLLER. A Goodix GT911 on i2c3 (i2c@ff460000). Its I2C
|
||||
+ * address is selected by the INT pin level while RESET is released: high
|
||||
+ * selects 0x14, low selects 0x5d. U-Boot drives RESET (it is in the DT as
|
||||
+ * reset-gpios) but NOT INT (the DT describes INT as an interrupt, not a gpio),
|
||||
+ * so the address after our reset is whatever INT floats to. Rather than fight
|
||||
+ * that, both addresses are probed and the one that answers is used. The kernel
|
||||
+ * driver re-runs its own reset sequence later regardless, so leaving the
|
||||
+ * controller in either state is safe.
|
||||
+ *
|
||||
+ * COST. Everything here is bounded and skipped entirely when the controller
|
||||
+ * does not answer, so a panel with no touchscreen, or one whose controller is
|
||||
+ * held in reset, adds only the probe attempt to boot -- not the poll window.
|
||||
+ */
|
||||
+#include <common.h>
|
||||
+#include <dm.h>
|
||||
+#include <i2c.h>
|
||||
+#include <asm/gpio.h>
|
||||
+#include <dm/ofnode.h>
|
||||
+#include <linux/libfdt.h>
|
||||
+#include <asm/global_data.h>
|
||||
+#include <flare_trace.h>
|
||||
+#include <flare_touch.h>
|
||||
+
|
||||
+DECLARE_GLOBAL_DATA_PTR;
|
||||
+
|
||||
+#define GT911_I2C_BUS 3
|
||||
+#define GT911_ADDR_INT_HIGH 0x14
|
||||
+#define GT911_ADDR_INT_LOW 0x5d
|
||||
+
|
||||
+/*
|
||||
+ * Coordinate/status register. Bit 7 is "a fresh report is ready"; the low
|
||||
+ * nibble counts the touch points in it. The controller does not clear this
|
||||
+ * itself -- the reader must write 0 back, or the same report is returned for
|
||||
+ * ever and a single stale touch would look like a finger held down.
|
||||
+ */
|
||||
+#define GT911_REG_STATUS 0x814e
|
||||
+#define GT911_STATUS_READY 0x80
|
||||
+#define GT911_STATUS_NTOUCH 0x0f
|
||||
+
|
||||
+/* Datasheet: >=10 ms asserted, and the controller needs ~50 ms after release
|
||||
+ * before it answers on I2C. The margins here are deliberately generous: this
|
||||
+ * runs once per boot and a retry costs more than the wait it saves. */
|
||||
+#define GT911_RESET_HOLD_MS 20
|
||||
+#define GT911_RESET_SETTLE_MS 60
|
||||
+
|
||||
+/* Product id lives here: four ASCII bytes, "911" on this panel. Reading it is
|
||||
+ * how we tell a real controller from an address that merely ACKs. */
|
||||
+#define GT911_REG_ID 0x8140
|
||||
+
|
||||
+/*
|
||||
+ * Release the controller from reset, if the DT tells us which pin that is.
|
||||
+ * Only used when nothing answered on either address: the reset latches the
|
||||
+ * I2C address from the INT level, which U-Boot does not drive, so it is a last
|
||||
+ * resort rather than routine initialisation.
|
||||
+ *
|
||||
+ * Returns 0 when the line was driven, or a negative errno when the node or the
|
||||
+ * property is missing.
|
||||
+ */
|
||||
+static int gt911_release_reset(void)
|
||||
+{
|
||||
+ struct gpio_desc reset;
|
||||
+ int node, ret;
|
||||
+
|
||||
+ node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "goodix,gt911");
|
||||
+ if (node < 0)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "reset-gpios",
|
||||
+ 0, &reset, GPIOD_IS_OUT);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Asserted, then released. dm_gpio_set_value() takes the LOGICAL level,
|
||||
+ * so the DT's active-low flag is already accounted for here. */
|
||||
+ dm_gpio_set_value(&reset, 1);
|
||||
+ mdelay(GT911_RESET_HOLD_MS);
|
||||
+ dm_gpio_set_value(&reset, 0);
|
||||
+ mdelay(GT911_RESET_SETTLE_MS);
|
||||
+
|
||||
+ dm_gpio_free(NULL, &reset);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* The address the controller answered on, for the boot report. */
|
||||
+static int gt911_addr;
|
||||
+
|
||||
+/* Find the controller at whichever address it is currently on. */
|
||||
+static struct udevice *gt911_probe(void)
|
||||
+{
|
||||
+ static const int addrs[] = { GT911_ADDR_INT_HIGH, GT911_ADDR_INT_LOW };
|
||||
+ struct udevice *dev;
|
||||
+ u8 status;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(addrs); i++) {
|
||||
+ if (i2c_get_chip_for_busnum(GT911_I2C_BUS, addrs[i], 2, &dev))
|
||||
+ continue;
|
||||
+ /* A successful read is the only proof the chip is really there:
|
||||
+ * i2c_get_chip_for_busnum() will hand back a device for an
|
||||
+ * address nothing answers on. */
|
||||
+ if (dm_i2c_read(dev, GT911_REG_STATUS, &status, 1))
|
||||
+ continue;
|
||||
+ gt911_addr = addrs[i];
|
||||
+ return dev;
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+/* Probe, resetting only if nothing answers on either address. */
|
||||
+static struct udevice *gt911_get(bool *did_reset)
|
||||
+{
|
||||
+ struct udevice *dev = gt911_probe();
|
||||
+
|
||||
+ if (!dev) {
|
||||
+ gt911_release_reset();
|
||||
+ if (did_reset)
|
||||
+ *did_reset = true;
|
||||
+ dev = gt911_probe();
|
||||
+ }
|
||||
+
|
||||
+ return dev;
|
||||
+}
|
||||
+
|
||||
+/* What arm() found and cleared, for the boot report. */
|
||||
+static u8 gt911_arm_status;
|
||||
+static bool gt911_armed;
|
||||
+
|
||||
+void flare_touch_arm(void)
|
||||
+{
|
||||
+ struct udevice *dev = gt911_get(NULL);
|
||||
+ u8 status = 0;
|
||||
+ u8 clear = 0;
|
||||
+
|
||||
+ if (!dev)
|
||||
+ return;
|
||||
+
|
||||
+ if (dm_i2c_read(dev, GT911_REG_STATUS, &status, 1))
|
||||
+ return;
|
||||
+
|
||||
+ gt911_arm_status = status;
|
||||
+ gt911_armed = true;
|
||||
+
|
||||
+ if (status & GT911_STATUS_READY) {
|
||||
+ dm_i2c_write(dev, GT911_REG_STATUS, &clear, 1);
|
||||
+ FLARE_TRACE("touch: cleared the power-on report");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int flare_touch_tapped(struct flare_touch_state *st)
|
||||
+{
|
||||
+ struct udevice *dev;
|
||||
+ bool did_reset = false;
|
||||
+ u8 status = 0;
|
||||
+ u8 clear = 0;
|
||||
+
|
||||
+ if (st) {
|
||||
+ st->addr = 0;
|
||||
+ st->status = 0;
|
||||
+ st->armed = false;
|
||||
+ st->arm_status = 0;
|
||||
+ st->id[0] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Probe BEFORE resetting. The controller is normally already running by
|
||||
+ * the time U-Boot gets here, and resetting a working one is not free:
|
||||
+ * its I2C address is latched from the INT level while RESET is released,
|
||||
+ * and U-Boot does not drive INT, so a reset can move the chip to the
|
||||
+ * other address or leave it mid-init. Only reset when nothing answers.
|
||||
+ */
|
||||
+ dev = gt911_get(&did_reset);
|
||||
+ if (!dev) {
|
||||
+ FLARE_TRACE("touch: no GT911 on i2c3");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (st) {
|
||||
+ st->armed = gt911_armed;
|
||||
+ st->arm_status = gt911_arm_status;
|
||||
+ st->addr = gt911_addr;
|
||||
+ if (dm_i2c_read(dev, GT911_REG_ID, (u8 *)st->id, 4) == 0)
|
||||
+ st->id[4] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * A single read. The report is latched: bit 7 stays set until the host
|
||||
+ * writes the register back to 0, so this sees a touch that happened at
|
||||
+ * any point since the controller came up, without watching for one.
|
||||
+ */
|
||||
+ if (dm_i2c_read(dev, GT911_REG_STATUS, &status, 1))
|
||||
+ return 0;
|
||||
+ if (st)
|
||||
+ st->status = status;
|
||||
+
|
||||
+ if (!(status & GT911_STATUS_READY))
|
||||
+ return 0;
|
||||
+
|
||||
+ /*
|
||||
+ * A report we produced ourselves is not a tap.
|
||||
+ *
|
||||
+ * Bringing the controller out of reset makes it publish a report, so on
|
||||
+ * a panel whose GT911 does not answer until we reset it, EVERY boot
|
||||
+ * latches one and every boot would come up verbose. MEASURED on the
|
||||
+ * bench panel: it answers only at 0x5d after a reset, and reported
|
||||
+ * status 0x80 on a boot nobody touched.
|
||||
+ *
|
||||
+ * Acknowledge it and report untouched. A panel in this state cannot
|
||||
+ * report a tap made before we woke its controller either -- there was
|
||||
+ * nothing listening to record it.
|
||||
+ */
|
||||
+ if (did_reset) {
|
||||
+ dm_i2c_write(dev, GT911_REG_STATUS, &clear, 1);
|
||||
+ FLARE_TRACE("touch: report discarded, we caused it");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Acknowledge, so the same report cannot be read again next boot. */
|
||||
+ dm_i2c_write(dev, GT911_REG_STATUS, &clear, 1);
|
||||
+
|
||||
+ /*
|
||||
+ * A finger must be ON THE GLASS right now. The ready bit is not enough.
|
||||
+ *
|
||||
+ * MEASURED on the bench panel across cold boots nobody touched: the
|
||||
+ * controller had a report waiting when the splash appeared (arm 0x80,
|
||||
+ * cleared), and had published ANOTHER by the time this read ran
|
||||
+ * (rd 0x80). It re-arms on its own, so "a report exists" is true on
|
||||
+ * every boot and cannot mean "someone touched it". Only the point count
|
||||
+ * distinguishes a finger from the controller talking to itself.
|
||||
+ *
|
||||
+ * The cost is that the touch has to be HELD across this sample rather
|
||||
+ * than tapped and released, because catching a release would mean
|
||||
+ * watching for one, and watching means adding that time to every boot.
|
||||
+ * A press held through the splash is the reliable, free signal.
|
||||
+ */
|
||||
+ return (status & GT911_STATUS_NTOUCH) ? 1 : 0;
|
||||
+}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c
|
||||
index 276fc6017..b9a66c416 100755
|
||||
--- a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c
|
||||
+++ b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c
|
||||
@@ -76,7 +76,7 @@ int cmd_mgr_queue_force_defer(struct rwnx_cmd_mgr *cmd_mgr,
|
||||
spin_lock_bh(&cmd_mgr->lock);
|
||||
|
||||
if (cmd_mgr->state == RWNX_CMD_MGR_STATE_CRASHED) {
|
||||
- printk(KERN_CRIT "cmd queue crashed\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd queue crashed\n");
|
||||
cmd->result = -EPIPE;
|
||||
spin_unlock_bh(&cmd_mgr->lock);
|
||||
return -EPIPE;
|
||||
@@ -168,7 +168,7 @@ static int cmd_mgr_queue(struct rwnx_cmd_mgr *cmd_mgr, struct rwnx_cmd *cmd)
|
||||
}
|
||||
|
||||
if (cmd_mgr->state == RWNX_CMD_MGR_STATE_CRASHED) {
|
||||
- printk(KERN_CRIT "cmd queue crashed\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd queue crashed\n");
|
||||
cmd->result = -EPIPE;
|
||||
spin_unlock_bh(&cmd_mgr->lock);
|
||||
return -EPIPE;
|
||||
@@ -260,10 +260,17 @@ static int cmd_mgr_queue(struct rwnx_cmd_mgr *cmd_mgr, struct rwnx_cmd *cmd)
|
||||
/* TODO: kill the cmd at fw level */
|
||||
}
|
||||
#else
|
||||
+ /* flare-edge: queue_sz must never scale this to zero. A zero
|
||||
+ * timeout makes wait_for_completion_timeout() return
|
||||
+ * immediately, so the "timeout" path runs without ever
|
||||
+ * waiting -- measured as ~2000 "cmd timed-out" per second
|
||||
+ * (668349 in 319s), which saturates the console and takes the
|
||||
+ * whole system down with it. Clamp to at least one. */
|
||||
unsigned long tout = msecs_to_jiffies(
|
||||
- RWNX_80211_CMD_TIMEOUT_MS * cmd_mgr->queue_sz);
|
||||
+ RWNX_80211_CMD_TIMEOUT_MS *
|
||||
+ max_t(u32, cmd_mgr->queue_sz, 1));
|
||||
if (!wait_for_completion_timeout(&cmd->complete, tout)) {
|
||||
- printk(KERN_CRIT "cmd timed-out\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd timed-out\n");
|
||||
#ifdef AICWF_SDIO_SUPPORT
|
||||
ret = aicwf_sdio_writeb(
|
||||
sdiodev, sdiodev->sdio_reg.wakeup_reg, 2);
|
||||
@@ -395,11 +402,12 @@ void cmd_mgr_task_process(struct work_struct *work)
|
||||
#endif
|
||||
kfree(next->a2e_msg);
|
||||
|
||||
+ /* flare-edge: see above -- never a zero timeout */
|
||||
tout = msecs_to_jiffies(RWNX_80211_CMD_TIMEOUT_MS *
|
||||
- cmd_mgr->queue_sz);
|
||||
+ max_t(u32, cmd_mgr->queue_sz, 1));
|
||||
if (!wait_for_completion_timeout(&next->complete,
|
||||
tout)) {
|
||||
- printk(KERN_CRIT "cmd timed-out\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd timed-out\n");
|
||||
#ifdef AICWF_SDIO_SUPPORT
|
||||
if (aicwf_sdio_writeb(
|
||||
sdiodev,
|
||||
@@ -0,0 +1,73 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c
|
||||
index 13005ac68..d28b7127a 100755
|
||||
--- a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c
|
||||
+++ b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c
|
||||
@@ -1356,6 +1356,8 @@ int aicwf_sdio_wakeup(struct aic_sdio_dev *sdiodev)
|
||||
}
|
||||
|
||||
if (sdiodev->state == SDIO_SLEEP_ST) {
|
||||
+ int woke = 0;
|
||||
+
|
||||
AICWFDBG(LOGSDPWRC, "%s w\n", __func__);
|
||||
|
||||
//rwnx_pm_stay_awake(sdiodev);
|
||||
@@ -1379,21 +1381,53 @@ int aicwf_sdio_wakeup(struct aic_sdio_dev *sdiodev)
|
||||
txrx_err(
|
||||
"sdio wakeup read fail\n");
|
||||
else if ((val & 0x1) == 0) {
|
||||
+ woke = 1;
|
||||
break;
|
||||
}
|
||||
read_retry--;
|
||||
- udelay(200);
|
||||
+ /*
|
||||
+ * flare-edge: sleep, do NOT udelay()
|
||||
+ * here. This is a sleepable context
|
||||
+ * (reached only under pwrctl_wakeup_sema
|
||||
+ * from the bustx kthread), and that
|
||||
+ * thread re-enters this path on every
|
||||
+ * TX. A busy-wait therefore pins the
|
||||
+ * single Cortex-A7 core whenever the
|
||||
+ * SDIO link wedges, starving the UI
|
||||
+ * render loop -- the "extremely laggy"
|
||||
+ * failure. Sleeping frees the core.
|
||||
+ */
|
||||
+ usleep_range(200, 400);
|
||||
}
|
||||
- if (read_retry != 0)
|
||||
+ if (woke)
|
||||
break;
|
||||
}
|
||||
sdio_dbg("write retry: %d \n", write_retry);
|
||||
write_retry--;
|
||||
- udelay(100);
|
||||
+ if (write_retry)
|
||||
+ usleep_range(100, 200);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * flare-edge: never fake SDIO_ACTIVE_ST on a failed wake. The
|
||||
+ * stock driver advanced state unconditionally, so a wedged link
|
||||
+ * looked "awake" and every later TX hammered a dead chip forever
|
||||
+ * with no recovery. Advance state only when the chip actually
|
||||
+ * acknowledged; otherwise stay SLEEP and report the error so the
|
||||
+ * caller (and the reset-recovery path added in a later patch)
|
||||
+ * can act on it.
|
||||
+ */
|
||||
+ if (woke) {
|
||||
+ sdiodev->state = SDIO_ACTIVE_ST;
|
||||
+ aicwf_sdio_pwrctl_timer(sdiodev,
|
||||
+ sdiodev->active_duration);
|
||||
+ ret = 0;
|
||||
+ } else {
|
||||
+ printk_ratelimited(
|
||||
+ KERN_WARNING
|
||||
+ "aic8800: SDIO wakeup failed; chip may be wedged\n");
|
||||
+ ret = -1;
|
||||
}
|
||||
-
|
||||
- sdiodev->state = SDIO_ACTIVE_ST;
|
||||
- aicwf_sdio_pwrctl_timer(sdiodev, sdiodev->active_duration);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/insmod_wifi.sh b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
index f34ae1581..c70664564 100755
|
||||
--- a/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
+++ b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
@@ -124,8 +124,23 @@ if [ -n "$(cat /proc/device-tree/model | grep "W")" ] || \
|
||||
fi
|
||||
|
||||
#start wifi app
|
||||
+#
|
||||
+# flare-edge: rkwifi_server is deliberately NOT started. WardenOS owns wlan0
|
||||
+# through warden-ui, which runs its own wpa_supplicant against
|
||||
+# /userdata/warden/wpa_supplicant.conf.
|
||||
+#
|
||||
+# rkwifi_server starts "wpa_supplicant -B -i wlan0 -c /data/wpa_supplicant.conf"
|
||||
+# using the stock config, whose network block is the vendor placeholder
|
||||
+# ssid="Your wifi ssid". The radio then scans forever for a network that does
|
||||
+# not exist while the real one sits at -50 dBm.
|
||||
+#
|
||||
+# warden-ui already does "killall rkwifi_server" before taking over, but that
|
||||
+# does not kill the wpa_supplicant rkwifi_server spawned, and the UI guards its
|
||||
+# own launch with `if ! pidof wpa_supplicant`. So the orphan survives, the
|
||||
+# guard sees it, the UI never starts its own, and the saved credentials are
|
||||
+# never used. Not starting the daemon removes the race entirely.
|
||||
+#
|
||||
+# Re-enable only if something other than warden-ui needs to own wlan0.
|
||||
if ifconfig wlan0 2>&1 | grep -q "not found"; then
|
||||
- echo "wlan0 not found. Stop run rkwifi_server."
|
||||
-else
|
||||
- rkwifi_server start >/dev/null 2>&1 &
|
||||
+ echo "wlan0 not found."
|
||||
fi
|
||||
@@ -0,0 +1,59 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/insmod_wifi.sh b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
--- a/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
+++ b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
@@ -33,7 +33,26 @@
|
||||
if [ $? -eq 0 ]; then
|
||||
insmod cfg80211.ko
|
||||
insmod aic_load_fw.ko aic_fw_path=/oem/usr/ko/
|
||||
- insmod aic8800_fdrv.ko
|
||||
+ # flare-edge: he_on=0 -- do NOT let this radio negotiate 802.11ax (HE).
|
||||
+ #
|
||||
+ # The AIC8800DC associates fine in HE and negotiates high HE-MCS rates, then
|
||||
+ # silently loses the unicast path while every local indicator still reads
|
||||
+ # healthy (wpa_state=COMPLETED, carrier 1, lease BOUND, strong signal). Only
|
||||
+ # beacons and broadcast keep arriving. See flare-edge issue #156.
|
||||
+ #
|
||||
+ # Measured on warden-c8a3 against an 802.11ax AP: with HE on, the driver
|
||||
+ # deinit/reconnect cycle fired every ~965 s indefinitely
|
||||
+ # ("deinit:macaddr" -> "rwnx_send_sm_connect_req", 154 times in 2.8 days).
|
||||
+ # he_on=0 makes the chip advertise HT/VHT only (phy reports "HE supp 0") and
|
||||
+ # the cycle stops.
|
||||
+ #
|
||||
+ # This costs Wi-Fi 6 rates, which the radio was never actually delivering
|
||||
+ # usable throughput at anyway, and costs no compatibility: 802.11ax APs serve
|
||||
+ # n/ac clients normally, so the panel still joins modern networks.
|
||||
+ #
|
||||
+ # Remove only when the HE path is actually fixed in the driver or the AIC
|
||||
+ # firmware blob, and re-verify with a multi-hour soak against an ax AP.
|
||||
+ insmod aic8800_fdrv.ko he_on=0
|
||||
insmod bcmdhd.ko
|
||||
fi
|
||||
|
||||
@@ -117,7 +136,26 @@
|
||||
insmod aes_generic.ko
|
||||
insmod aic8800_bsp.ko
|
||||
sleep 0.2
|
||||
- insmod aic8800_fdrv.ko
|
||||
+ # flare-edge: he_on=0 -- do NOT let this radio negotiate 802.11ax (HE).
|
||||
+ #
|
||||
+ # The AIC8800DC associates fine in HE and negotiates high HE-MCS rates, then
|
||||
+ # silently loses the unicast path while every local indicator still reads
|
||||
+ # healthy (wpa_state=COMPLETED, carrier 1, lease BOUND, strong signal). Only
|
||||
+ # beacons and broadcast keep arriving. See flare-edge issue #156.
|
||||
+ #
|
||||
+ # Measured on warden-c8a3 against an 802.11ax AP: with HE on, the driver
|
||||
+ # deinit/reconnect cycle fired every ~965 s indefinitely
|
||||
+ # ("deinit:macaddr" -> "rwnx_send_sm_connect_req", 154 times in 2.8 days).
|
||||
+ # he_on=0 makes the chip advertise HT/VHT only (phy reports "HE supp 0") and
|
||||
+ # the cycle stops.
|
||||
+ #
|
||||
+ # This costs Wi-Fi 6 rates, which the radio was never actually delivering
|
||||
+ # usable throughput at anyway, and costs no compatibility: 802.11ax APs serve
|
||||
+ # n/ac clients normally, so the panel still joins modern networks.
|
||||
+ #
|
||||
+ # Remove only when the HE path is actually fixed in the driver or the AIC
|
||||
+ # firmware blob, and re-verify with a multi-hour soak against an ax AP.
|
||||
+ insmod aic8800_fdrv.ko he_on=0
|
||||
sleep 2
|
||||
insmod aic8800_btlpm.ko
|
||||
sleep 0.1
|
||||
@@ -33,7 +33,7 @@ new file mode 100644
|
||||
index 000000000..b44eeeadd
|
||||
--- /dev/null
|
||||
+++ b/drivers/clk/rockchip/clk-rv1106.c
|
||||
@@ -0,0 +1,1299 @@
|
||||
@@ -0,0 +1,1303 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2022 Rockchip Electronics Co. Ltd.
|
||||
@@ -373,7 +373,11 @@ index 000000000..b44eeeadd
|
||||
+ /* PD_CORE */
|
||||
+ GATE(CLK_PVTM_CORE, "clk_pvtm_core", "xin24m", 0,
|
||||
+ RV1106_CORECLKGATE_CON(0), 14, GFLAGS),
|
||||
+ GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", 0,
|
||||
+ /* clk_core_mcu_rtc is the 24 MHz mtime of the HPMCU, kept up for the
|
||||
+ * mtime safety tick. Nothing in Linux claims it, so clk_disable_unused()
|
||||
+ * would gate it after boot; IGNORE_UNUSED keeps it running, like
|
||||
+ * clk_core_mcu below (rebuild M0, SCH-01). */
|
||||
+ GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", CLK_IGNORE_UNUSED,
|
||||
+ RV1106_CORECLKGATE_CON(1), 6, GFLAGS),
|
||||
+ COMPOSITE(HCLK_CPU, "hclk_cpu", mux_gpll_24m_p, CLK_IS_CRITICAL,
|
||||
+ RV1106_CORECLKSEL_CON(2), 5, 1, MFLAGS, 0, 5, DFLAGS,
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
@@ -247,6 +247,7 @@
|
||||
struct device *dev;
|
||||
struct regmap *grf;
|
||||
struct regmap *usbgrf;
|
||||
+ void __iomem *phy_base;
|
||||
struct clk_bulk_data *clks;
|
||||
struct clk *clk480m;
|
||||
struct clk_hw clk480m_hw;
|
||||
@@ -1417,6 +1418,19 @@
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * RV1106 tunes signal quality through the PHY's own register block, which
|
||||
+ * is this node's "reg" resource and is distinct from the GRF regmap above.
|
||||
+ * Map it only where a tuning callback needs it; every other SoC here tunes
|
||||
+ * through the GRF and must keep working with phy_base left NULL.
|
||||
+ */
|
||||
+ if (of_device_is_compatible(np, "rockchip,rv1106-usb2phy")) {
|
||||
+ rphy->phy_base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(rphy->phy_base))
|
||||
+ return dev_err_probe(dev, PTR_ERR(rphy->phy_base),
|
||||
+ "failed to map phy registers\n");
|
||||
+ }
|
||||
+
|
||||
rphy->phy_reset = devm_reset_control_get_optional(dev, "phy");
|
||||
if (IS_ERR(rphy->phy_reset))
|
||||
return PTR_ERR(rphy->phy_reset);
|
||||
@@ -1506,6 +1520,30 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Direct PHY-register accessors. Most SoCs here tune through the GRF regmap,
|
||||
+ * but the RV1106's signal-quality registers live in the PHY's own block, which
|
||||
+ * is mapped separately into rphy->phy_base.
|
||||
+ */
|
||||
+static inline void phy_update_bits(void __iomem *reg, u32 mask, u32 val)
|
||||
+{
|
||||
+ u32 tmp = readl(reg);
|
||||
+
|
||||
+ tmp &= ~mask;
|
||||
+ tmp |= val & mask;
|
||||
+ writel(tmp, reg);
|
||||
+}
|
||||
+
|
||||
+static inline void phy_set_bits(void __iomem *reg, u32 bits)
|
||||
+{
|
||||
+ writel(readl(reg) | bits, reg);
|
||||
+}
|
||||
+
|
||||
+static inline void phy_clear_bits(void __iomem *reg, u32 bits)
|
||||
+{
|
||||
+ writel(readl(reg) & ~bits, reg);
|
||||
+}
|
||||
+
|
||||
static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy)
|
||||
{
|
||||
/* Turn off differential receiver in suspend mode */
|
||||
@@ -2291,10 +2329,65 @@
|
||||
* iddig_output/iddig_en/bvalid_grf_sel are dropped). Signal-quality phy_tuning is
|
||||
* left off for now (guarded, so NULL is safe) — the phy is functional without it.
|
||||
*/
|
||||
+/*
|
||||
+ * RV1106 USB2 PHY signal-quality tuning, ported from the vendor 5.10 driver
|
||||
+ * (drivers/phy/rockchip/phy-rockchip-inno-usb2.c, rv1106_usb2phy_tuning).
|
||||
+ *
|
||||
+ * The 6.18 forward-port originally omitted this ("the phy is functional without
|
||||
+ * it"). It is functional, but not reliable: with these registers left at reset
|
||||
+ * defaults the HS link is electrically marginal under sustained traffic. On a
|
||||
+ * bench panel a USB-Ethernet dongle would stall a bulk transfer after a few
|
||||
+ * minutes; the r8152 Tx-timeout recovery then issues an xHCI Stop Endpoint
|
||||
+ * command which the controller never answers, and xhci-hcd declares the
|
||||
+ * controller dead and tears the bus down (flare-edge issue #160). Measured
|
||||
+ * carrier-on to death across four runs: 14s, 519s, 521s, 584s -- a stochastic
|
||||
+ * spread, not a timer, which is what marginal signalling looks like.
|
||||
+ *
|
||||
+ * Pre-emphasis strength is silicon-revision dependent. The vendor driver picks
|
||||
+ * it from rockchip_get_cpu_version(), which does not exist in mainline; it
|
||||
+ * derives from RV1106_OS_REG1 (0xff020204) & 0x7. Our panels read 1, i.e. the
|
||||
+ * non-zero branch, so 3'b001 is pinned here. If a board ever reports version 0
|
||||
+ * it wants 3'b011 instead -- see the vendor driver.
|
||||
+ */
|
||||
+static int rv1106_usb2phy_tuning(struct rockchip_usb2phy *rphy)
|
||||
+{
|
||||
+ /* Mapped only for this compatible; refuse to poke a NULL base. */
|
||||
+ if (!rphy->phy_base)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ /* Always enable pre-emphasis in SOF & EOP & chirp & non-chirp state */
|
||||
+ phy_update_bits(rphy->phy_base + 0x30, GENMASK(2, 0), 0x07);
|
||||
+
|
||||
+ /* Set Tx HS pre_emphasize strength to 3'b001 (cpu_version != 0) */
|
||||
+ phy_update_bits(rphy->phy_base + 0x40, GENMASK(5, 3), (0x01 << 3));
|
||||
+
|
||||
+ /* Set RX Squelch trigger point configure to 4'b0000(112.5 mV) */
|
||||
+ phy_update_bits(rphy->phy_base + 0x64, GENMASK(6, 3), (0x00 << 3));
|
||||
+
|
||||
+ /* Turn off differential receiver by default to save power */
|
||||
+ phy_clear_bits(rphy->phy_base + 0x100, BIT(6));
|
||||
+
|
||||
+ /* Set 45ohm HS ODT value to 5'b10111 to increase driver strength */
|
||||
+ phy_update_bits(rphy->phy_base + 0x11c, GENMASK(4, 0), 0x17);
|
||||
+
|
||||
+ /* Set Tx HS eye height tuning to 3'b011(462 mV) */
|
||||
+ phy_update_bits(rphy->phy_base + 0x124, GENMASK(4, 2), (0x03 << 2));
|
||||
+
|
||||
+ /* Bypass Squelch detector calibration */
|
||||
+ phy_update_bits(rphy->phy_base + 0x1a4, GENMASK(7, 4), (0x01 << 4));
|
||||
+ phy_update_bits(rphy->phy_base + 0x1b4, GENMASK(7, 4), (0x01 << 4));
|
||||
+
|
||||
+ /* Set HS disconnect detect mode to single ended detect mode */
|
||||
+ phy_set_bits(rphy->phy_base + 0x70, BIT(2));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static const struct rockchip_usb2phy_cfg rv1106_phy_cfgs[] = {
|
||||
{
|
||||
.reg = 0xff3e0000,
|
||||
.num_ports = 1,
|
||||
+ .phy_tuning = rv1106_usb2phy_tuning,
|
||||
.clkout_ctl = { 0x0058, 4, 4, 1, 0 },
|
||||
.port_cfgs = {
|
||||
[USB2PHY_PORT_OTG] = {
|
||||
@@ -0,0 +1,136 @@
|
||||
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
|
||||
@@ -203,6 +203,7 @@
|
||||
* @event_nb: hold event notification callback.
|
||||
* @state: define OTG enumeration states before device reset.
|
||||
* @mode: the dr_mode of the controller.
|
||||
+ * @host_mode: the port is currently acting as a USB host.
|
||||
*/
|
||||
struct rockchip_usb2phy_port {
|
||||
struct phy *phy;
|
||||
@@ -222,6 +223,7 @@
|
||||
struct notifier_block event_nb;
|
||||
enum usb_otg_state state;
|
||||
enum usb_dr_mode mode;
|
||||
+ bool host_mode;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -239,6 +241,8 @@
|
||||
* @dcd_retries: The retry count used to track Data contact
|
||||
* detection process.
|
||||
* @edev: extcon device for notification registration
|
||||
+ * @edev_self_allocated: no extcon phandle in DT, so the OTG state machine
|
||||
+ * has no external role signal at all
|
||||
* @irq: muxed interrupt for single irq configuration
|
||||
* @phy_cfg: phy register configuration, assigned by driver data.
|
||||
* @ports: phy port instance.
|
||||
@@ -257,6 +261,7 @@
|
||||
enum power_supply_type chg_type;
|
||||
u8 dcd_retries;
|
||||
struct extcon_dev *edev;
|
||||
+ bool edev_self_allocated;
|
||||
int irq;
|
||||
const struct rockchip_usb2phy_cfg *phy_cfg;
|
||||
struct rockchip_usb2phy_port ports[USB2PHY_NUM_PORTS];
|
||||
@@ -459,6 +464,14 @@
|
||||
if (ret)
|
||||
return dev_err_probe(rphy->dev, ret,
|
||||
"failed to register extcon device\n");
|
||||
+
|
||||
+ /*
|
||||
+ * Nothing external drives the role on this board. The extcon
|
||||
+ * below is ours, and no code ever sets a cable state on it, so
|
||||
+ * the OTG state machine's view of the world is permanently
|
||||
+ * blank rather than merely stale.
|
||||
+ */
|
||||
+ rphy->edev_self_allocated = true;
|
||||
}
|
||||
|
||||
rphy->edev = edev;
|
||||
@@ -649,11 +662,52 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * The OTG port's state machines only make sense while the port is a
|
||||
+ * peripheral. In host role their inputs are meaningless on a board with no
|
||||
+ * ID source: charger detection drives the analog front end of a port that is
|
||||
+ * already enumerating a device, and its DCP verdict ends in
|
||||
+ * rockchip_usb2phy_power_off(), which suspends the phy and drops the 480M
|
||||
+ * clkout that the host controller's core runs on. The controller then stops
|
||||
+ * clocking with its registers still readable, so it reports itself healthy
|
||||
+ * while no transfer ever completes.
|
||||
+ *
|
||||
+ * dwc3 already calls phy_set_mode() on every role change, but this driver
|
||||
+ * implemented no .set_mode, so the phy never learned the role. Track it and
|
||||
+ * keep both state machines out of host role.
|
||||
+ */
|
||||
+static int rockchip_usb2phy_set_mode(struct phy *phy, enum phy_mode mode,
|
||||
+ int submode)
|
||||
+{
|
||||
+ struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
|
||||
+
|
||||
+ if (rport->port_id != USB2PHY_PORT_OTG)
|
||||
+ return 0;
|
||||
+
|
||||
+ switch (mode) {
|
||||
+ case PHY_MODE_USB_HOST:
|
||||
+ if (!rport->host_mode) {
|
||||
+ rport->host_mode = true;
|
||||
+ cancel_delayed_work_sync(&rport->otg_sm_work);
|
||||
+ cancel_delayed_work_sync(&rport->chg_work);
|
||||
+ }
|
||||
+ break;
|
||||
+ case PHY_MODE_USB_DEVICE:
|
||||
+ rport->host_mode = false;
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static const struct phy_ops rockchip_usb2phy_ops = {
|
||||
.init = rockchip_usb2phy_init,
|
||||
.exit = rockchip_usb2phy_exit,
|
||||
.power_on = rockchip_usb2phy_power_on,
|
||||
.power_off = rockchip_usb2phy_power_off,
|
||||
+ .set_mode = rockchip_usb2phy_set_mode,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
@@ -667,6 +721,15 @@
|
||||
unsigned long delay;
|
||||
bool vbus_attach, sch_work, notify_charger;
|
||||
|
||||
+ /*
|
||||
+ * This machine can only get the answer wrong here. In host role its
|
||||
+ * verdict suspends a phy that is enumerating a device (#160); with a
|
||||
+ * self-allocated extcon it has no role signal in EITHER direction, and
|
||||
+ * in device role it strands the gadget the same way (#168).
|
||||
+ */
|
||||
+ if (rport->host_mode || rphy->edev_self_allocated)
|
||||
+ return;
|
||||
+
|
||||
vbus_attach = property_enabled(rphy->grf,
|
||||
&rport->port_cfg->utmi_bvalid);
|
||||
|
||||
@@ -825,6 +888,15 @@
|
||||
bool is_dcd, tmout, vout, vbus_attach;
|
||||
unsigned long delay;
|
||||
|
||||
+ /*
|
||||
+ * Never probe the front end of a port that is hosting a device, and
|
||||
+ * never at all on a board whose bvalid is pinned high by the VBUS
|
||||
+ * bypass: charger detection cannot be meaningful there, and its DCP
|
||||
+ * verdict powers the phy off underneath a working link (#160, #168).
|
||||
+ */
|
||||
+ if (rport->host_mode || rphy->edev_self_allocated)
|
||||
+ return;
|
||||
+
|
||||
vbus_attach = property_enabled(rphy->grf, &rport->port_cfg->utmi_bvalid);
|
||||
|
||||
dev_dbg(&rport->phy->dev, "chg detection work state = %d\n",
|
||||
@@ -0,0 +1,62 @@
|
||||
diff --git a/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts b/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts
|
||||
--- a/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts
|
||||
+++ b/arch/arm/boot/dts/rockchip/rv1106-warden-m2.dts
|
||||
@@ -74,6 +74,15 @@
|
||||
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
|
||||
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
|
||||
clock-frequency = <24000000>;
|
||||
+ /*
|
||||
+ * The boot firmware does not enter the kernel in HYP mode and leaves
|
||||
+ * CNTVOFF non-zero (bfe-core1106-sdk#35): the virtual counter the
|
||||
+ * arm32 vDSO reads runs a fixed offset away from the physical one
|
||||
+ * the kernel keeps time on. This keeps the kernel on the physical
|
||||
+ * timer and drops the vDSO clock calls, so clock_gettime() uses the
|
||||
+ * syscall and agrees with every kernel deadline.
|
||||
+ */
|
||||
+ arm,cpu-registers-not-fw-configured;
|
||||
};
|
||||
|
||||
gic: interrupt-controller@ff1f0000 {
|
||||
diff --git a/arch/arm/boot/dts/rockchip/rv1106.dtsi b/arch/arm/boot/dts/rockchip/rv1106.dtsi
|
||||
--- a/arch/arm/boot/dts/rockchip/rv1106.dtsi
|
||||
+++ b/arch/arm/boot/dts/rockchip/rv1106.dtsi
|
||||
@@ -417,6 +417,15 @@
|
||||
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>,
|
||||
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
|
||||
clock-frequency = <24000000>;
|
||||
+ /*
|
||||
+ * The boot firmware does not enter the kernel in HYP mode and leaves
|
||||
+ * CNTVOFF non-zero (bfe-core1106-sdk#35): the virtual counter the
|
||||
+ * arm32 vDSO reads runs a fixed offset away from the physical one
|
||||
+ * the kernel keeps time on. This keeps the kernel on the physical
|
||||
+ * timer and drops the vDSO clock calls, so clock_gettime() uses the
|
||||
+ * syscall and agrees with every kernel deadline.
|
||||
+ */
|
||||
+ arm,cpu-registers-not-fw-configured;
|
||||
};
|
||||
|
||||
grf: syscon@ff000000 {
|
||||
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
|
||||
--- a/drivers/clocksource/arm_arch_timer.c
|
||||
+++ b/drivers/clocksource/arm_arch_timer.c
|
||||
@@ -933,6 +933,20 @@ static void __init arch_counter_register(void)
|
||||
arch_timer_read_counter = rd;
|
||||
clocksource_counter.vdso_clock_mode = vdso_default;
|
||||
|
||||
+ /*
|
||||
+ * The arm32 vDSO always reads the virtual counter. A kernel that keeps
|
||||
+ * time on the physical counter and was not entered in HYP mode never
|
||||
+ * had CNTVOFF zeroed by the hyp stub, so the vDSO clock may sit a fixed
|
||||
+ * offset away from the kernel's and absolute deadlines taken from it
|
||||
+ * expire late. Fall back to the syscall then.
|
||||
+ */
|
||||
+ if (IS_ENABLED(CONFIG_ARM) && arch_timer_uses_ppi != ARCH_TIMER_VIRT_PPI &&
|
||||
+ !is_hyp_mode_available() &&
|
||||
+ clocksource_counter.vdso_clock_mode != VDSO_CLOCKMODE_NONE) {
|
||||
+ clocksource_counter.vdso_clock_mode = VDSO_CLOCKMODE_NONE;
|
||||
+ pr_info("physical counter without HYP: vDSO clock disabled\n");
|
||||
+ }
|
||||
+
|
||||
width = arch_counter_get_width();
|
||||
clocksource_counter.mask = CLOCKSOURCE_MASK(width);
|
||||
cyclecounter.mask = CLOCKSOURCE_MASK(width);
|
||||
@@ -0,0 +1,25 @@
|
||||
Remove the DRM_MSM_VALIDATE_XML Kconfig symbol (rebuild M0, bfe-core1106-sdk#19).
|
||||
|
||||
Its dependency $(success,$(PYTHON3) -c "import lxml") makes the expanded .config differ by host: with
|
||||
python3-lxml importable the file gains '# CONFIG_DRM_MSM_VALIDATE_XML is not set', without it the line is
|
||||
absent, so KCONFIG_SHA256 was not reproducible across hosts. The symbol only validates Qualcomm GPU register
|
||||
XML for DRM MSM developers; the panel has no Qualcomm GPU. No binary changes.
|
||||
|
||||
diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
|
||||
--- a/drivers/gpu/drm/msm/Kconfig
|
||||
+++ b/drivers/gpu/drm/msm/Kconfig
|
||||
@@ -50,14 +50,6 @@
|
||||
Only use this if you are a driver developer. This should *not*
|
||||
be enabled for production kernels. If unsure, say N.
|
||||
|
||||
-config DRM_MSM_VALIDATE_XML
|
||||
- bool "Validate XML register files against schema"
|
||||
- depends on DRM_MSM && EXPERT
|
||||
- depends on $(success,$(PYTHON3) -c "import lxml")
|
||||
- help
|
||||
- Validate XML files with register definitions against rules-fd schema.
|
||||
- This option is mostly targeting DRM MSM developers. If unsure, say N.
|
||||
-
|
||||
config DRM_MSM_KMS
|
||||
def_bool n
|
||||
depends on DRM_MSM
|
||||
+7
-2
@@ -1,8 +1,9 @@
|
||||
# The Kernel Patch Series
|
||||
|
||||
The delta that forward-ports the vendor Rockchip 5.10.160 RV1106 support onto a
|
||||
pristine upstream **linux-6.18.46**, as a reviewable, subsystem-split series. Every
|
||||
patch applies cleanly onto pristine 6.18.46 (`git apply --check`), and the whole set
|
||||
pristine upstream **linux-6.18.46**, as a reviewable, subsystem-split series. The
|
||||
series applies cleanly, in order, onto pristine 6.18.46 (`git apply --check`; a fix
|
||||
patch such as 82 edits files that an earlier patch adds), and the whole set
|
||||
reproduces the 223-file / ~136K-line delta that boots and is hardware-verified on
|
||||
`warden-c8a3` (see `../kernel/rv1106-enablement/`).
|
||||
|
||||
@@ -18,6 +19,8 @@ with `../build/warden_defconfig` -> `zImage` + `rv1106-warden.dtb`).
|
||||
| `15-pinctrl.patch` | `pinctrl-rockchip` RV1106 iomux |
|
||||
| `20-arch-dts-bindings.patch` | `arch/arm` DTs (`rv1106.dtsi`, `rv1106-warden.dts`, pinctrl), mach, configs, `include/dt-bindings` |
|
||||
| `25-usb-phy.patch` | inno-usb2 phy |
|
||||
| `27-usb-phy-tuning.patch` | inno-usb2 phy: RV1106 signal-quality register tuning |
|
||||
| `29-usb2phy-no-blind-otg-sm.patch` | inno-usb2 phy: stop the OTG/charger state machines running blind |
|
||||
| `30-drm-vop-panel-rgb.patch` | VOP (`rgb_dclk_pol`=0 + WIN1 scanout), panel-simple bus-format, rockchip_rgb |
|
||||
| `35-mailbox-hpmcu.patch` | rockchip-mailbox (rv1106 num_chans=1) |
|
||||
| `40-pvtm-soc.patch` | PVTM (core+pmu) + `include/soc/rockchip/pvtm.h` |
|
||||
@@ -26,6 +29,8 @@ with `../build/warden_defconfig` -> `zImage` + `rv1106-warden.dtb`).
|
||||
| `60-wifi-aic8800.patch` | out-of-tree AIC8800 wifi/BT (the 88.5K-line vendor blob) |
|
||||
| `70-audio-codec.patch` | `rv1106_codec` + I2S wiring |
|
||||
| `80-misc-thermal-rtc-adc.patch` | tsadc, rtc-rockchip, saradc, trng, otp, gmac, goodix touch |
|
||||
| `82-arch-timer-vdso-phys-counter.patch` | arch timer: keep the arm32 vDSO clock off the virtual counter while the kernel times on the physical one (CNTVOFF left non-zero by the boot firmware, #35); checked by `tests/arch-timer/check-vdso-counter.py` |
|
||||
| `90-kconfig-no-python-symbol.patch` | drops `DRM_MSM_VALIDATE_XML` so the expanded `.config` (and `KCONFIG_SHA256`) does not depend on the host python (#19) |
|
||||
|
||||
## License
|
||||
|
||||
|
||||
+47
-1
@@ -54,7 +54,8 @@ screenshot from here is not evidence about a 5.10 panel's Wi-Fi page.
|
||||
WORK=$HOME/kbuild-out CROSS_COMPILE=arm-linux-gnueabihf- \
|
||||
WARDEN_KCONFIG_FRAGMENT=qemu/configs/virt.fragment bash build/build-kernel.sh
|
||||
|
||||
# 2. initramfs (sha256-pinned static busybox + qemu/rootfs/) and A/B disk
|
||||
# 2. initramfs (sha256-pinned static busybox + qemu/rootfs/) and A/B disk;
|
||||
# RIG_BUSYBOX=panel builds the image's own BusyBox instead (qemu/busybox/)
|
||||
bash qemu/mkinitramfs.sh
|
||||
bash qemu/mkimage.sh # options: --portal-url --state K=V --fw-version
|
||||
|
||||
@@ -73,6 +74,20 @@ daemons a bench panel already runs: flare-edge `tools/rig-pull-daemons.sh
|
||||
chardev without `--rs485`), so `warden-modbus` polls a port with nothing on
|
||||
it, as on a panel with an empty header, and never the control channel.
|
||||
|
||||
A `mosquitto` in the payload starts the panel's device bus first (socket
|
||||
`/run/warden/bus/bus.sock`, one credential file per bus user under
|
||||
`/run/warden/bus/cred/`), as S10bus does before every bus client on a panel;
|
||||
see `payload/README.md`. The rig broker takes any user and loads no plugin.
|
||||
With a test-flavor `warden-ui` and `wthctl` (flare-edge `tools/wthctl.c`, the
|
||||
test hook client) in the payload as well, a flow's `override` step pins a
|
||||
state document inside the UI: qmp.py hands the request to the control bridge
|
||||
(`@hookdoc` pieces, then `@hook override`), which sends it to `test/req/ui`
|
||||
as bus user `testhook` and answers the hook's reply. The run's first hook
|
||||
request waits until the hook answers a `ping` (retried while the bridge
|
||||
reports no answer, up to `HOOK_READY_S`): right after boot the UI is still
|
||||
taking the broker's retained replay, and an override sent then was lost
|
||||
(flare-edge #2602).
|
||||
|
||||
The VT cursor is kept off (`vt.global_cursor_default=0`): fbcon shares the
|
||||
virtio-gpu framebuffer with warden-ui and its blinking cursor would otherwise
|
||||
show up in screendumps at random (issue #18).
|
||||
@@ -85,6 +100,28 @@ does on a panel instead of rejecting every attempt. `qemu_stage_rootfs()`
|
||||
the executable bit, so the checked-out source file's own mode depends on the
|
||||
checking-out umask and cannot be trusted to arrive non-world-readable.
|
||||
|
||||
`--append warden.initchain` boots the UI the way a panel does (flare-edge
|
||||
#2210). The caller lays the panel's own scripts over the rootfs with
|
||||
`ROOTFS_OVERLAY=<dir> mkimage.sh` (only `etc/` and `usr/` at its top, no
|
||||
symlinks). Stage-2 init then starts `/etc/init.d/S00`-`S09` with `start`
|
||||
before the bus (S03warden-accounts creates the platform accounts, and the
|
||||
bus hands `cred/ui` to `warden-ui`), and `S10`-`S99` after the payload
|
||||
daemons in place of its direct root start of `warden-ui`. S99lvgl then runs
|
||||
`warden-ui-run`, which drops the UI to its account and respawns it. Rig
|
||||
differences: the splash handover is marked done (no S09splash) and
|
||||
warden-ui-run passes `-b fbdev`, not the panel's `-b drm`. A chain boot
|
||||
with no script prints `WARDEN-QEMU-INITCHAIN-EMPTY` and starts no UI.
|
||||
`tests/ui-drive.sh --init-chain <dir>` does both steps, and the drive verb
|
||||
`assert_ui_chain` judges the result: one `warden-ui` and one `warden-ui-run`,
|
||||
the UI's four uids all `warden-ui`'s, no safe-mode flag, and no exit or
|
||||
refusal in `/tmp/warden-ui.log`. `tests/scripts/init-chain-ui.txt` runs the
|
||||
check at about T+120 s.
|
||||
|
||||
A flow seed may contain `qemu-flow-setup.sh`. Stage-2 init runs it inside the
|
||||
disposable guest after mounting userdata and before starting daemons or the
|
||||
UI. A nonzero exit stops the boot. Use it only for test devices and commands
|
||||
that the virt machine does not provide.
|
||||
|
||||
## Scenarios
|
||||
|
||||
All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
|
||||
@@ -93,6 +130,7 @@ All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
|
||||
|---|---|---|
|
||||
| `stage-rootfs-perms.sh` | - | offline, no VM: `qemu_stage_rootfs()` always lands `etc/shadow` at 0600, even staged from a source copy deliberately left 0644 |
|
||||
| `seed-dir.sh` | - | offline, no VM: `mkimage.sh`'s `SEED_DIR` hook lands every seeded file under userdata/warden with its original mode (a 0600 secret included), a seeded file beats a same-named `--state` value, a `SEED_DIR` that isn't a directory fails closed, and so does an individual entry that is a symlink, a subdirectory, or named outside `[A-Za-z0-9_.-]+` -- a hyphenated key such as `gas-plant.devices` still seeds cleanly |
|
||||
| `payload-dir.sh` | - | offline, no VM: `mkimage.sh`'s `PAYLOAD_DIR` hook puts the run's own payload set (symlinked entries included, as regular 0755 files; its README.md skipped) into `/usr/bin` of both slots and nothing from `qemu/payload`, the default still reads `qemu/payload`, a `PAYLOAD_DIR` that is not a directory fails closed, and `ui-drive.sh` looks for `warden-ui` in the same directory |
|
||||
| `boot-smoke.sh` | - | sentinel-asserting boot; runs in CI inside kernel-build |
|
||||
| `portal-scenario.sh` | `FLARE_EDGE` | real flared against the desk mock portal: authenticated check-in, desired-state pull, signed tier-1 `.wfw` download; verify/stage/APPLYING as a dry run (no `WARDEN_FW_ALLOW_APPLY`) |
|
||||
| `ota-apply.sh` | `FLARE_EDGE` | the FULL apply: the `.wfw`'s bootable rootfs payload is written to rootfs_b (`run.sh --allow-apply` gates it per boot), the AvbABData in `misc` flips, and slot `_b` boots the applied version |
|
||||
@@ -100,7 +138,15 @@ All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
|
||||
| `ui-drive.sh <script>` | - | the same rig for a SEQUENCE: boots once, runs a `qmp.py drive` script of taps/swipes/screenshots in panel pixels, and FAILS if warden-ui died on the way (stage-2 init announces the exit on the console). `tests/scripts/nav-stress.txt` is the navigation regression: it reproduces the s_row_left overflow that segfaulted the UI on returning to Settings > Apps; `tests/scripts/home-leaves-fullscreen.txt` proves the `home` verb clears dashboard fullscreen, the state a hardware wake tap leaves behind (flare-edge #176); `tests/scripts/fullscreen-toggle-tracks-real-state.txt` proves a `fullscreen toggle` right after `home` (or a real tap) reads the dashboard's actual state rather than a belief `home` bypassed -- `test_qmp_drive.py`'s `FullscreenToggleTracksRealState` pins the same contract offline |
|
||||
| `real-image-boot.sh` | matched `rootfs.img` + `oem.img` | an ACTUAL flare-edge build (placed by `mkimage.sh --rootfs-image/--oem-image`) boots its own init chain to getty; binaries predating known fixes reproduce their bugs faithfully, a time machine for field issues |
|
||||
| `test-ui-drive-rs485.sh` | - | offline, no VM: a fake `run.sh` and (for one case) a fake `socat` stand in so `ui-drive.sh --rs485-devices`'s startup fails closed instead of printing a false "== rs485 simulator: ..." over a bus nothing is serving, for each of a qemu rs.sock that never appears, a socat that never links rs.pty, and an mbsim.py that dies before opening rs.ctl; also proves `cleanup()` escalates to SIGKILL for a sim process that ignores SIGTERM |
|
||||
| `rootfs-overlay.sh` | - | offline, no VM: `mkimage.sh`'s `ROOTFS_OVERLAY` hook lays a directory of panel files (flare-edge's S03warden-accounts, S99lvgl, warden-ui-run) over the rootfs of both slots with their modes kept, beside the skeleton's own files; without it there is no `/etc/init.d`; an overlay that is not a directory, names anything but `etc/` and `usr/` at its top, or holds a symlink fails closed and writes no image; `ui-drive.sh --init-chain` refuses a missing directory or one without `etc/init.d/S99lvgl` before boot |
|
||||
| `init-chain-test.sh` | - | offline, no VM: `warden_init_chain` (rootfs/etc/warden-lib.sh) starts the executable `S<NN>*` scripts of a number range in name order, names a failing one and goes on, and counts them; `warden_rig_bus_owners` hands a bus credential to its account only when the rootfs has it; sbin/init runs S00-S09 before the bus and S10-S99 instead of the direct UI start on a `warden.initchain` boot (flare-edge #2210) |
|
||||
| `run-sh-args-test.sh` | - | offline, no VM: a fake `qemu-system-arm` captures run.sh's own argv and pins the ctl/rs485 pci-serial ordering contract rootfs/sbin/init's ttyS0-vs-ttyS1 alias depends on -- the ctl device always enumerates before rs485, warden.ctl only lands on the cmdline when --ctl is given, and an rs485 pci-serial device (real or null-backed) is always present so the port count never shifts |
|
||||
| `busybox-panel-test.sh` | - | offline, no VM: the panel BusyBox inputs (qemu/busybox/). panel.config carries every setting of the image's applet patch, rig.fragment changes only STATIC, USE_BB_PWD_GRP and USE_BB_SHADOW, a Kconfig rewrite of any setting and an applet the panel lacks fail the build, applets.txt and help.txt agree, and RIG_BUSYBOX refuses an unknown value, and accepts a prebuilt panel `BUSYBOX` only when its `.inputs` match this tree (flare-edge#2210) |
|
||||
| `busybox-panel-help.sh [BIN]` | an ARM runner (binfmt or `QEMU_USER=qemu-arm`) | the built panel BusyBox against the bench capture: its applet list and every applet's `--help` equal the panel's own binary's. CI runs it in qemu-tools after `build-busybox.sh` |
|
||||
| `console-shell-test.sh` | - | offline, no VM: `warden_console_shell` (warden.shell) runs `setsid cttyhack sh` where cttyhack exists, else `setsid -c sh` on the console tty read from sysfs (the panel BusyBox has no cttyhack), else a plain sh. CI runs it under bash's `sh` and busybox `sh` |
|
||||
| `ctl-bridge-test.sh` | - | offline, no VM: runs the control bridge (`warden_ctl_bridge` in rootfs/etc/warden-lib.sh) against a fake warden-ui that answers some commands late. A reply slower than the old 5 s bound still arrives (the bound is now 30 s, `WARDEN_CTL_WAIT_S`), a timeout answers `bridge: no reply from warden-ui ...` (qmp.py raises it as a rig fault), and a timed-out command's late reply is drained instead of being read as the next command's answer (flare-edge #1448). A fake `wthctl` stands in for the hook client behind `@hookdoc`/`@hook` (flare-edge #2054): the pieces join into one request whose args are used once, only plain words reach the client, and a missing client or a request with no reply answers a `bridge:` line. CI runs it under bash's `sh` and busybox `sh` |
|
||||
| `init-rig-bus-test.sh` | - | offline, no VM: `warden_rig_bus` in rootfs/etc/warden-lib.sh against stub brokers. No broker in the payload creates nothing; a broker that listens gets the panel's layout (the `bus.sock` link, a 0400 64-hex credential per bus user, a config without password file, ACL or plugin); a broker that exits or never listens is reported within the bound; init starts the bus before the payload daemons. `WARDEN_TEST_MOSQUITTO_DIR` adds a real mosquitto carrying one message between two users logged in by credential file (flare-edge #1754) |
|
||||
| `agent-test.sh` | - | offline, no VM: the rig agent (`warden_agent` in rootfs/etc/warden-lib.sh, armed by `run.sh --agent` and `warden.agent`) answers `@run ID SECS B64` with `<<BEGIN ID>>`, the base64 of the script's output and `<<END ID RC>>`; `@chunk` pieces join into one script used once; a script past its deadline is killed with its process group and answers 124; a malformed request answers one `<<ERR ...>>` line and runs nothing; init puts the agent's port after ctl and RS485. It is the guest shell of flare-edge `tools/soak/rig-qemu.py` (M9 soak-lite). CI runs it under bash's `sh` and busybox `sh` |
|
||||
| watchdog (`run.sh --watchdog`) | - | arm `/dev/watchdog`, don't pet: the VM resets ~30 s later (verified) |
|
||||
|
||||
Scenario fine print:
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the rig's panel BusyBox: the image's BusyBox version with the image's
|
||||
# applet config, linked static for the rig's initramfs (flare-edge#2210).
|
||||
#
|
||||
# build-busybox.sh
|
||||
#
|
||||
# Env:
|
||||
# OUT output dir (default qemu/out); the binary lands at
|
||||
# $OUT/busybox-armv7l-panel, its rebuild key (.key) and its
|
||||
# source inputs (.inputs, see qemu_busybox_panel_inputs in
|
||||
# lib.sh) next to it
|
||||
# CROSS_COMPILE cross toolchain prefix (default arm-linux-gnueabihf-)
|
||||
# BB_SRC_TARBALL a local busybox-$BB_SRC_VER.tar.bz2 (skips the download;
|
||||
# still verified against BB_SRC_SHA256)
|
||||
# JOBS make -j (default: nproc, at most 4)
|
||||
#
|
||||
# The inputs are pinned, not the output: the source tarball by sha256 and the
|
||||
# configuration by the committed files in qemu/busybox/. Compilers differ
|
||||
# between hosts, so one host's binary hash means nothing on another; the
|
||||
# output is checked by its applet list instead (qemu/busybox/applets.txt, the
|
||||
# same list as flare-edge tests/fixtures/panel-busybox-applets.txt). A rebuild
|
||||
# is skipped when the input key (tarball, config files, compiler version)
|
||||
# matches the cached binary's.
|
||||
#
|
||||
# FAILS CLOSED: no cross compiler, a bad tarball, a configuration that the
|
||||
# BusyBox Kconfig rewrites (a symbol the version does not know), an applet
|
||||
# list that differs, or a dynamically linked result is an error, never a
|
||||
# fallback to the multiarch binary.
|
||||
set -euo pipefail
|
||||
|
||||
QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BB_DIR="$QEMU_DIR/busybox"
|
||||
|
||||
# The source pin (BB_SRC_VER, BB_SRC_URL, BB_SRC_SHA256) lives in lib.sh,
|
||||
# beside qemu_busybox_panel_inputs, which a prebuilt binary is checked by.
|
||||
# shellcheck source=qemu/lib.sh disable=SC1091
|
||||
. "$QEMU_DIR/lib.sh"
|
||||
|
||||
# Write the panel config with every fragment line applied: the symbol's old
|
||||
# setting (set or "is not set") is dropped and the fragment's line appended.
|
||||
# Usage: bb_apply_fragment PANEL_CONFIG FRAGMENT > .config
|
||||
bb_apply_fragment() {
|
||||
local panel="$1" frag="$2" line sym pat=""
|
||||
while IFS= read -r line; do
|
||||
case "$line" in ''|'#'*) continue ;; esac
|
||||
sym="${line%%=*}"
|
||||
case "$sym" in
|
||||
CONFIG_*) ;;
|
||||
*) echo "FATAL: bad fragment line: '$line'" >&2; return 1 ;;
|
||||
esac
|
||||
pat="${pat}|^${sym}=|^# ${sym} is not set\$"
|
||||
done < "$frag"
|
||||
if [ -n "$pat" ]; then
|
||||
grep -Ev "${pat#|}" "$panel" || true
|
||||
else
|
||||
cat "$panel"
|
||||
fi
|
||||
grep -Ev '^(#|$)' "$frag"
|
||||
}
|
||||
|
||||
# The settings of a config file, one per line, sorted: "SYM=value" for a set
|
||||
# symbol and "SYM is not set" for an unset one. Comments and the header are
|
||||
# dropped, so two configs compare by what they configure.
|
||||
bb_settings() {
|
||||
sed -n -e 's/^\(CONFIG_[A-Za-z0-9_]*=.*\)$/\1/p' \
|
||||
-e 's/^# \(CONFIG_[A-Za-z0-9_]*\) is not set$/\1 is not set/p' "$1" | LC_ALL=C sort
|
||||
}
|
||||
|
||||
# Fail when Kconfig changed any setting of the config it was given (WANT)
|
||||
# while writing GOT: a symbol this BusyBox version does not know, or one whose
|
||||
# dependencies are unmet, would otherwise be dropped without a word.
|
||||
bb_check_config() {
|
||||
local want="$1" got="$2" d
|
||||
if ! d="$(diff <(bb_settings "$want") <(bb_settings "$got"))"; then
|
||||
echo "FATAL: the BusyBox $BB_SRC_VER Kconfig rewrote the panel config (< given, > written):" >&2
|
||||
printf '%s\n' "$d" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Compare the applet names in a busybox.links file (one install path per line)
|
||||
# with the committed list. Usage: bb_check_applets LINKS APPLETS_TXT
|
||||
bb_check_applets() {
|
||||
local links="$1" want="$2" d
|
||||
if ! d="$(diff <(LC_ALL=C sort -u "$want") <(sed 's|.*/||' "$links" | LC_ALL=C sort -u))"; then
|
||||
echo "FATAL: the built BusyBox applet list differs from $want (< want, > built):" >&2
|
||||
printf '%s\n' "$d" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# The cache key: everything the binary is built from.
|
||||
bb_input_key() {
|
||||
local cc="$1"
|
||||
{
|
||||
qemu_busybox_panel_inputs
|
||||
echo "$cc"
|
||||
"${cc}gcc" --version | head -n 1
|
||||
} | sha256sum | awk '{print $1}'
|
||||
}
|
||||
|
||||
bb_main() {
|
||||
local out="${OUT:-$QEMU_DIR/out}" cc="${CROSS_COMPILE:-arm-linux-gnueabihf-}"
|
||||
local jobs="${JOBS:-}" bin key src scratch tar
|
||||
bin="$out/busybox-armv7l-panel"
|
||||
command -v "${cc}gcc" >/dev/null || {
|
||||
echo "FATAL: no ${cc}gcc on PATH (apt-get install gcc-arm-linux-gnueabihf, or set CROSS_COMPILE)" >&2
|
||||
exit 1
|
||||
}
|
||||
if [ -z "$jobs" ]; then
|
||||
jobs="$(nproc)"; [ "$jobs" -le 4 ] || jobs=4
|
||||
fi
|
||||
mkdir -p "$out"
|
||||
key="$(bb_input_key "$cc")"
|
||||
if [ -f "$bin" ] && [ "$(cat "$bin.key" 2>/dev/null)" = "$key" ]; then
|
||||
qemu_busybox_panel_inputs > "$bin.inputs"
|
||||
qemu_log "panel busybox up to date ($bin)"
|
||||
return
|
||||
fi
|
||||
# A stale .inputs must never vouch for a binary while it is rebuilt.
|
||||
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"
|
||||
|
||||
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
|
||||
# Expanded now on purpose: the trap must remove this run's directory.
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$scratch'" EXIT
|
||||
tar -xjf "$tar" -C "$scratch"
|
||||
src="$scratch/busybox-${BB_SRC_VER}"
|
||||
[ -d "$src" ] || { echo "FATAL: $tar has no busybox-${BB_SRC_VER}/" >&2; exit 1; }
|
||||
# Buildroot's patches for this version, as the image applies them.
|
||||
local p
|
||||
for p in "$BB_DIR"/patches/*.patch; do
|
||||
patch -d "$src" -p1 -s --no-backup-if-mismatch < "$p" || {
|
||||
echo "FATAL: $p does not apply to busybox $BB_SRC_VER" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
bb_apply_fragment "$BB_DIR/panel.config" "$BB_DIR/rig.fragment" > "$scratch/want.config"
|
||||
cp "$scratch/want.config" "$src/.config"
|
||||
# Fixed time stamps so two builds with one compiler give one binary.
|
||||
export SOURCE_DATE_EPOCH=0 KCONFIG_NOTIMESTAMP=1 KBUILD_BUILD_TIMESTAMP="1970-01-01"
|
||||
export KBUILD_BUILD_USER=warden KBUILD_BUILD_HOST=rig
|
||||
# oldconfig with no terminal: a symbol missing from the config would stop
|
||||
# at a prompt and read EOF; the settings check below names it either way.
|
||||
make -C "$src" -s CROSS_COMPILE="$cc" oldconfig </dev/null >"$scratch/oldconfig.log" 2>&1 || {
|
||||
cat "$scratch/oldconfig.log" >&2
|
||||
echo "FATAL: make oldconfig failed" >&2
|
||||
exit 1
|
||||
}
|
||||
bb_check_config "$scratch/want.config" "$src/.config"
|
||||
qemu_log "building busybox $BB_SRC_VER (panel config, static, ${cc}gcc, -j$jobs)"
|
||||
make -C "$src" -s -j"$jobs" CROSS_COMPILE="$cc" busybox busybox.links >"$scratch/make.log" 2>&1 || {
|
||||
tail -n 40 "$scratch/make.log" >&2
|
||||
echo "FATAL: busybox build failed" >&2
|
||||
exit 1
|
||||
}
|
||||
bb_check_applets "$src/busybox.links" "$BB_DIR/applets.txt"
|
||||
if "${cc}readelf" -l "$src/busybox" | grep -q 'INTERP'; then
|
||||
echo "FATAL: the built busybox is dynamically linked (CONFIG_STATIC not applied)" >&2
|
||||
exit 1
|
||||
fi
|
||||
"${cc}readelf" -h "$src/busybox" | grep -q 'Machine:.*ARM' || {
|
||||
echo "FATAL: the built busybox is not an ARM binary" >&2
|
||||
exit 1
|
||||
}
|
||||
install -m 0755 "$src/busybox" "$bin.tmp"
|
||||
mv -f "$bin.tmp" "$bin"
|
||||
printf '%s\n' "$key" > "$bin.key"
|
||||
# For a job without the cross compiler: qemu_get_busybox accepts this
|
||||
# binary as BUSYBOX under RIG_BUSYBOX=panel when the inputs match its tree.
|
||||
qemu_busybox_panel_inputs > "$bin.inputs"
|
||||
qemu_log "panel busybox: $bin ($(sha256sum "$bin" | awk '{print $1}'))"
|
||||
}
|
||||
|
||||
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
||||
bb_main "$@"
|
||||
fi
|
||||
@@ -0,0 +1,36 @@
|
||||
# The panel's BusyBox, for the rig
|
||||
|
||||
`RIG_BUSYBOX=panel` (qemu/lib.sh) makes the rig run the image's own BusyBox
|
||||
instead of the busybox.net 1.31.0 multiarch binary, so a script that calls an
|
||||
applet or option the panel lacks fails in the rig as it fails on a panel
|
||||
(flare-edge#2210; #1903 `setpriv --reuid`, #2002 `stat`, #1349 `flock -w`).
|
||||
`qemu/build-busybox.sh` builds it; the default stays `multiarch` until the
|
||||
flare-edge QEMU jobs switch over.
|
||||
|
||||
| File | What it is |
|
||||
|---|---|
|
||||
| `panel.config` | The image's BusyBox 1.37.0 configuration. Made from Buildroot 2025.02.8 `package/busybox/busybox.config` (the vendor SDK's base; its header matches the `a/` side of the applet patch), with `luckfox-sdk-patches/buildroot/patches/0001-busybox-applets.patch` applied and then `yes "" \| make oldconfig` in busybox-1.37.0, as Buildroot does for a config written for an older version (it adds TIME64, GETFATTR, FIND_EXEC_OK, IP_LINK_CAN and UDHCPD_BOOTP at their defaults and drops ASH_SLEEP). The time stamp line is dropped. |
|
||||
| `rig.fragment` | The rig's only differences: a static link, and BusyBox's own passwd, group and shadow readers (a static glibc binary cannot load NSS modules). Neither adds or removes an applet or option. |
|
||||
| `patches/` | Buildroot 2025.02.8's `package/busybox/*.patch`, applied in order like the image build does (one of them is what makes `tc` build with current kernel headers). Commit-message text was changed to ASCII; the diffs are unchanged. |
|
||||
| `applets.txt` | `busybox --list` of the panel (bench a, image 417a66b), the same as flare-edge `tests/fixtures/panel-busybox-applets.txt`. The build fails when its applet list differs. |
|
||||
| `help.txt` | `busybox <applet> --help` of every applet of the panel, the same as flare-edge `tests/fixtures/panel-busybox-help.txt` (flare-edge `tools/bench/busybox-help/capture.sh`). `qemu/tests/busybox-panel-help.sh` compares the built binary with it. |
|
||||
|
||||
The Buildroot fixups in `busybox.mk` that depend on the image's Buildroot
|
||||
options (mdev, init, watchdog, less flags, crypt SHA) are not applied here;
|
||||
the applet list and the per-applet help check would show any of them that
|
||||
changed an applet or an option. When the image's BusyBox changes, update
|
||||
`panel.config` and `patches/` the same way and re-capture `applets.txt` and
|
||||
`help.txt` from a panel.
|
||||
|
||||
The inputs are pinned (source tarball sha256, these files); the output is not,
|
||||
because each host's compiler gives a different binary. The cache key in
|
||||
`$OUT/busybox-armv7l-panel.key` covers the tarball, these files and the
|
||||
compiler version.
|
||||
|
||||
A job without the cross compiler (a flare-edge flow job, given the binary its
|
||||
image build job made) sets `RIG_BUSYBOX=panel BUSYBOX=<binary>`. The build
|
||||
writes `<binary>.inputs` next to it: one sha256 over the source pin and these
|
||||
files, without the compiler (`qemu_busybox_panel_inputs` in qemu/lib.sh).
|
||||
`qemu_get_busybox` takes the prebuilt binary only when that file equals the
|
||||
value for its own tree, so a binary built from another config is refused
|
||||
rather than booted.
|
||||
@@ -0,0 +1,282 @@
|
||||
[
|
||||
[[
|
||||
addgroup
|
||||
adduser
|
||||
ar
|
||||
arch
|
||||
arp
|
||||
arping
|
||||
ascii
|
||||
ash
|
||||
awk
|
||||
base32
|
||||
base64
|
||||
basename
|
||||
bc
|
||||
blkid
|
||||
bunzip2
|
||||
bzcat
|
||||
cat
|
||||
chattr
|
||||
chgrp
|
||||
chmod
|
||||
chown
|
||||
chroot
|
||||
chrt
|
||||
chvt
|
||||
cksum
|
||||
clear
|
||||
cmp
|
||||
cp
|
||||
cpio
|
||||
crc32
|
||||
crond
|
||||
crontab
|
||||
cut
|
||||
date
|
||||
dc
|
||||
dd
|
||||
deallocvt
|
||||
delgroup
|
||||
deluser
|
||||
devmem
|
||||
df
|
||||
diff
|
||||
dirname
|
||||
dmesg
|
||||
dnsd
|
||||
dnsdomainname
|
||||
dos2unix
|
||||
du
|
||||
dumpkmap
|
||||
echo
|
||||
egrep
|
||||
eject
|
||||
env
|
||||
ether-wake
|
||||
expr
|
||||
factor
|
||||
fallocate
|
||||
false
|
||||
fbset
|
||||
fdflush
|
||||
fdformat
|
||||
fdisk
|
||||
fgrep
|
||||
find
|
||||
flock
|
||||
fold
|
||||
free
|
||||
freeramdisk
|
||||
fsck
|
||||
fsfreeze
|
||||
fstrim
|
||||
fuser
|
||||
getfattr
|
||||
getopt
|
||||
getty
|
||||
grep
|
||||
gunzip
|
||||
gzip
|
||||
halt
|
||||
hdparm
|
||||
head
|
||||
hexdump
|
||||
hexedit
|
||||
hostid
|
||||
hostname
|
||||
hwclock
|
||||
i2cdetect
|
||||
i2cdump
|
||||
i2cget
|
||||
i2cset
|
||||
i2ctransfer
|
||||
id
|
||||
ifconfig
|
||||
ifdown
|
||||
ifup
|
||||
inetd
|
||||
init
|
||||
insmod
|
||||
install
|
||||
ip
|
||||
ipaddr
|
||||
ipcrm
|
||||
ipcs
|
||||
iplink
|
||||
ipneigh
|
||||
iproute
|
||||
iprule
|
||||
iptunnel
|
||||
kill
|
||||
killall
|
||||
killall5
|
||||
klogd
|
||||
last
|
||||
less
|
||||
link
|
||||
linux32
|
||||
linux64
|
||||
linuxrc
|
||||
ln
|
||||
loadfont
|
||||
loadkmap
|
||||
logger
|
||||
login
|
||||
logname
|
||||
losetup
|
||||
ls
|
||||
lsattr
|
||||
lsmod
|
||||
lsof
|
||||
lspci
|
||||
lsscsi
|
||||
lsusb
|
||||
lzcat
|
||||
lzma
|
||||
lzopcat
|
||||
makedevs
|
||||
md5sum
|
||||
mdev
|
||||
mesg
|
||||
microcom
|
||||
mim
|
||||
mkdir
|
||||
mkdosfs
|
||||
mke2fs
|
||||
mkfifo
|
||||
mknod
|
||||
mkpasswd
|
||||
mkswap
|
||||
mktemp
|
||||
modprobe
|
||||
more
|
||||
mount
|
||||
mountpoint
|
||||
mt
|
||||
mv
|
||||
nameif
|
||||
netstat
|
||||
nice
|
||||
nl
|
||||
nohup
|
||||
nologin
|
||||
nproc
|
||||
nslookup
|
||||
nuke
|
||||
od
|
||||
openvt
|
||||
partprobe
|
||||
passwd
|
||||
paste
|
||||
patch
|
||||
pidof
|
||||
ping
|
||||
pipe_progress
|
||||
pivot_root
|
||||
poweroff
|
||||
printenv
|
||||
printf
|
||||
ps
|
||||
pwd
|
||||
rdate
|
||||
readlink
|
||||
readprofile
|
||||
realpath
|
||||
reboot
|
||||
renice
|
||||
reset
|
||||
resize
|
||||
resume
|
||||
rfkill
|
||||
rm
|
||||
rmdir
|
||||
rmmod
|
||||
route
|
||||
run-init
|
||||
run-parts
|
||||
runlevel
|
||||
sed
|
||||
seedrng
|
||||
seq
|
||||
setarch
|
||||
setconsole
|
||||
setfattr
|
||||
setkeycodes
|
||||
setlogcons
|
||||
setpriv
|
||||
setserial
|
||||
setsid
|
||||
sh
|
||||
sha1sum
|
||||
sha256sum
|
||||
sha3sum
|
||||
sha512sum
|
||||
shred
|
||||
sleep
|
||||
sort
|
||||
start-stop-daemon
|
||||
strings
|
||||
stty
|
||||
su
|
||||
sulogin
|
||||
svc
|
||||
svok
|
||||
swapoff
|
||||
swapon
|
||||
switch_root
|
||||
sync
|
||||
sysctl
|
||||
syslogd
|
||||
tail
|
||||
tar
|
||||
tc
|
||||
tee
|
||||
telnet
|
||||
telnetd
|
||||
test
|
||||
tftp
|
||||
time
|
||||
top
|
||||
touch
|
||||
tr
|
||||
traceroute
|
||||
tree
|
||||
true
|
||||
truncate
|
||||
ts
|
||||
tsort
|
||||
tty
|
||||
ubirename
|
||||
udhcpc
|
||||
uevent
|
||||
umount
|
||||
uname
|
||||
uniq
|
||||
unix2dos
|
||||
unlink
|
||||
unlzma
|
||||
unlzop
|
||||
unxz
|
||||
unzip
|
||||
uptime
|
||||
usleep
|
||||
uudecode
|
||||
uuencode
|
||||
vconfig
|
||||
vi
|
||||
vlock
|
||||
w
|
||||
watch
|
||||
watchdog
|
||||
wc
|
||||
wget
|
||||
which
|
||||
who
|
||||
whoami
|
||||
xargs
|
||||
xxd
|
||||
xz
|
||||
xzcat
|
||||
yes
|
||||
zcat
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
From e1690453cd84c798ca88cc4370710f65da86d986 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
Date: Sat, 5 Oct 2013 15:55:06 +0200
|
||||
Subject: [PATCH] networking/libiproute: use <linux/if_packet.h> instead of
|
||||
<net/if_packet.h>
|
||||
|
||||
The musl C library doesn't provide the <net/if_packet.h> since the
|
||||
corresponding kernel headers <linux/if_packet.h> already provides the
|
||||
necessary definitions. Replacing <net/if_packet.h> by
|
||||
<linux/if_packet.h> also removes the need to include
|
||||
<netpacket/packet.h>
|
||||
|
||||
This commit fixes the build of iplink with the musl C library.
|
||||
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
[Gustavo: update for busybox 1.22.0]
|
||||
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
|
||||
---
|
||||
networking/libiproute/iplink.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
|
||||
index 37ed114bc..bc526d89c 100644
|
||||
--- a/networking/libiproute/iplink.c
|
||||
+++ b/networking/libiproute/iplink.c
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
#include <net/if.h>
|
||||
/*#include <net/if_packet.h> - not needed? */
|
||||
-#include <netpacket/packet.h>
|
||||
+#include <linux/if_packet.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
||||
#include <linux/if_vlan.h>
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From df20ae1280a2601a4c233ec12372d1e17db21e96 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
Date: Mon, 25 Nov 2013 22:51:53 +0100
|
||||
Subject: [PATCH] Makefile.flags: strip non -l arguments returned by pkg-config
|
||||
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
[yann.morin.1998@free.fr: refresh for 1.29.0]
|
||||
[petr.vorel@gmail.com: refresh for 1.32.0]
|
||||
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
|
||||
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
|
||||
---
|
||||
Makefile.flags | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile.flags b/Makefile.flags
|
||||
index 97cb4dca2..92a9063d9 100644
|
||||
--- a/Makefile.flags
|
||||
+++ b/Makefile.flags
|
||||
@@ -181,7 +181,9 @@ ifeq ($(CONFIG_SELINUX),y)
|
||||
SELINUX_PC_MODULES = libselinux libsepol
|
||||
$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
|
||||
CPPFLAGS += $(SELINUX_CFLAGS)
|
||||
-LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
|
||||
+LDLIBS += $(if $(SELINUX_LIBS),\
|
||||
+ $(patsubst -l%,%,$(filter -l%,$(SELINUX_LIBS))),\
|
||||
+ $(SELINUX_PC_MODULES:lib%=%))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y)
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
From 68eaf20d86d4fe0f16a914817217f386155157cc Mon Sep 17 00:00:00 2001
|
||||
From: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Date: Mon, 19 Sep 2022 14:15:12 +0200
|
||||
Subject: [PATCH] libbb: sockaddr2str: ensure only printable characters are
|
||||
returned for the hostname part
|
||||
|
||||
CVE: CVE-2022-28391
|
||||
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Tested-by: Radoslav Kolev <radoslav.kolev@suse.com>
|
||||
Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089796.html
|
||||
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
|
||||
---
|
||||
libbb/xconnect.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
|
||||
index 0e0b247b8..02c061e67 100644
|
||||
--- a/libbb/xconnect.c
|
||||
+++ b/libbb/xconnect.c
|
||||
@@ -497,8 +497,9 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
|
||||
);
|
||||
if (rc)
|
||||
return NULL;
|
||||
+ /* ensure host contains only printable characters */
|
||||
if (flags & IGNORE_PORT)
|
||||
- return xstrdup(host);
|
||||
+ return xstrdup(printable_string(host));
|
||||
#if ENABLE_FEATURE_IPV6
|
||||
if (sa->sa_family == AF_INET6) {
|
||||
if (strchr(host, ':')) /* heh, it's not a resolved hostname */
|
||||
@@ -509,7 +510,7 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
|
||||
#endif
|
||||
/* For now we don't support anything else, so it has to be INET */
|
||||
/*if (sa->sa_family == AF_INET)*/
|
||||
- return xasprintf("%s:%s", host, serv);
|
||||
+ return xasprintf("%s:%s", printable_string(host), serv);
|
||||
/*return xstrdup(host);*/
|
||||
}
|
||||
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
From 56b84c6efb9a06ae294eb92cf9634f70af443b0a Mon Sep 17 00:00:00 2001
|
||||
From: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Date: Mon, 19 Sep 2022 14:15:12 +0200
|
||||
Subject: [PATCH] nslookup: sanitize all printed strings with printable_string
|
||||
|
||||
Otherwise, terminal sequences can be injected, which enables various terminal injection
|
||||
attacks from DNS results.
|
||||
|
||||
CVE: CVE-2022-28391
|
||||
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
|
||||
Tested-by: Radoslav Kolev <radoslav.kolev@suse.com>
|
||||
Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089795.html
|
||||
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
|
||||
---
|
||||
networking/nslookup.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/networking/nslookup.c b/networking/nslookup.c
|
||||
index b67d354f7..79412477c 100644
|
||||
--- a/networking/nslookup.c
|
||||
+++ b/networking/nslookup.c
|
||||
@@ -784,7 +784,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
//printf("Unable to uncompress domain: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
- printf(format, ns_rr_name(rr), dname);
|
||||
+ printf(format, ns_rr_name(rr), printable_string(dname));
|
||||
break;
|
||||
|
||||
case ns_t_mx:
|
||||
@@ -799,7 +799,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
//printf("Cannot uncompress MX domain: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
- printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, dname);
|
||||
+ printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, printable_string(dname));
|
||||
break;
|
||||
|
||||
case ns_t_txt:
|
||||
@@ -811,7 +811,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
if (n > 0) {
|
||||
memset(dname, 0, sizeof(dname));
|
||||
memcpy(dname, ns_rr_rdata(rr) + 1, n);
|
||||
- printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), dname);
|
||||
+ printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), printable_string(dname));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -831,7 +831,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
}
|
||||
|
||||
printf("%s\tservice = %u %u %u %s\n", ns_rr_name(rr),
|
||||
- ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), dname);
|
||||
+ ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), printable_string(dname));
|
||||
break;
|
||||
|
||||
case ns_t_soa:
|
||||
@@ -860,7 +860,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- printf("\tmail addr = %s\n", dname);
|
||||
+ printf("\tmail addr = %s\n", printable_string(dname));
|
||||
cp += n;
|
||||
|
||||
printf("\tserial = %lu\n", ns_get32(cp));
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
From 9fed109be1f811069cb2f727e04c6996cd44b017 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= <raphael.melotte@mind.be>
|
||||
Date: Tue, 18 Apr 2023 15:54:43 +0200
|
||||
Subject: [PATCH] seedrng: fix getrandom() detection for non-glibc libc
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
glibc <= 2.24 does not provide getrandom(). A check for it has been
|
||||
added in 200a9669fbf6f06894e4243cccc9fc11a1a6073a and fixed in
|
||||
cb57abb46f06f4ede8d9ccbdaac67377fdf416cf.
|
||||
|
||||
However, building with a libc other than glibc can lead to the same
|
||||
problem as not every other libc has getrandom() either:
|
||||
|
||||
- uClibc provides it from v1.0.2 onwards, but requires to define
|
||||
_GNU_SOURCE (all versions - we already define it by default), and
|
||||
stddef to be included first (when using uClibc < 1.0.35 - we already
|
||||
include it through libbb.h).
|
||||
|
||||
- musl libc has getrandom(), but only from version 1.1.20 onwards. As
|
||||
musl does not provide __MUSL__ or version information, it's not
|
||||
possible to check for it like we did for glibc.
|
||||
|
||||
All of this makes it difficult (or impossible in case of musl) to
|
||||
check what we need to do to have getrandom() based on each libc
|
||||
versions.
|
||||
|
||||
On top of that, getrandom() is also not available on older kernels. As
|
||||
an example, when using a 3.10 kernel with uClibc 1.0.26, getrandom()
|
||||
is declared so compiling works, but it fails at link time because
|
||||
getrandom() is not defined.
|
||||
|
||||
To make it easier, take a similar approach to what was done for the
|
||||
crypt library: try to build a sample program to see if we have
|
||||
getrandom(). To keep it compatible with different versions of
|
||||
make (for reference see [1]), a variable for '#' is also introduced.
|
||||
|
||||
Based on the new Makefile variable, we now either use the
|
||||
libc-provided getrandom() when it's available, or use our own
|
||||
implementation when it's not (like it was the case already for glibc <
|
||||
2.25).
|
||||
|
||||
This should fix compiling with many libc/kernel combinations.
|
||||
|
||||
[1]: https://git.savannah.gnu.org/cgit/make.git/commit/?id=c6966b323811c37acedff05b576b907b06aea5f4
|
||||
|
||||
Signed-off-by: Raphael Melotte <raphael.melotte@mind.be>
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2023-May/090317.html
|
||||
---
|
||||
Makefile.flags | 12 ++++++++++++
|
||||
miscutils/seedrng.c | 8 ++++----
|
||||
2 files changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Makefile.flags b/Makefile.flags
|
||||
index 92a9063d9..c8f601308 100644
|
||||
--- a/Makefile.flags
|
||||
+++ b/Makefile.flags
|
||||
@@ -162,6 +162,18 @@ ifeq ($(RT_AVAILABLE),y)
|
||||
LDLIBS += rt
|
||||
endif
|
||||
|
||||
+# GNU Make version 4.2.1 and earlier require number signs ('#')
|
||||
+# inside function invocations to be escaped, while versions 4.3+
|
||||
+# require them to be unescaped. Use a variable for it so that it works
|
||||
+# for both versions:
|
||||
+C := \#
|
||||
+# Not all libc versions have getrandom, so check for it:
|
||||
+HAVE_GETRANDOM := $(shell printf '$Cdefine _GNU_SOURCE\n$Cinclude <stddef.h>\n$Cinclude <sys/random.h>\nint main(void){char buf[256];\ngetrandom(buf,sizeof(buf),0);}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c)
|
||||
+
|
||||
+ifeq ($(HAVE_GETRANDOM),y)
|
||||
+CFLAGS += -DHAVE_GETRANDOM
|
||||
+endif
|
||||
+
|
||||
# libpam may use libpthread, libdl and/or libaudit.
|
||||
# On some platforms that requires an explicit -lpthread, -ldl, -laudit.
|
||||
# However, on *other platforms* it fails when some of those flags
|
||||
diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
|
||||
index 7a2331cb1..ba98f4d19 100644
|
||||
--- a/miscutils/seedrng.c
|
||||
+++ b/miscutils/seedrng.c
|
||||
@@ -44,8 +44,10 @@
|
||||
#include <linux/random.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
-/* Fix up glibc <= 2.24 not having getrandom() */
|
||||
-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24
|
||||
+/* Fix up some libc (e.g. glibc <= 2.24) not having getrandom() */
|
||||
+#if defined HAVE_GETRANDOM
|
||||
+#include <sys/random.h>
|
||||
+#else /* No getrandom */
|
||||
#include <sys/syscall.h>
|
||||
static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
|
||||
{
|
||||
@@ -56,8 +58,6 @@ static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
|
||||
return -1;
|
||||
# endif
|
||||
}
|
||||
-#else
|
||||
-#include <sys/random.h>
|
||||
#endif
|
||||
|
||||
/* Apparently some headers don't ship with this yet. */
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
From 7f0bb7f69f38298971aa8153d3fbe9b1fdda8ae7 Mon Sep 17 00:00:00 2001
|
||||
From: ctxnop <ctxnop@gmail.com>
|
||||
Date: Sun, 26 Jan 2025 20:59:20 +0100
|
||||
Subject: [PATCH] menuconfig: GCC failing saying ncurses is not found
|
||||
|
||||
Newer GCC increased diagnostics levels resulting in considering the
|
||||
test code to be invalid. The resulting message was misleading, saying
|
||||
that ncurses was not found, while the check failed for an unrelated
|
||||
reason which was hidden because GCC stderr was redirected to
|
||||
/dev/null.
|
||||
|
||||
Signed-off-by: ctxnop <ctxnop@gmail.com>
|
||||
Upstream: http://lists.busybox.net/pipermail/busybox/2024-July/090840.html
|
||||
[Fiona: rephrased commit message for clarity]
|
||||
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
|
||||
---
|
||||
scripts/kconfig/lxdialog/check-lxdialog.sh | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
|
||||
index 5075ebf2d..08e4da3de 100755
|
||||
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
|
||||
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
|
||||
@@ -45,9 +45,9 @@ trap "rm -f $tmp" 0 1 2 3 15
|
||||
|
||||
# Check if we can link to ncurses
|
||||
check() {
|
||||
- $cc -x c - -o $tmp 2>/dev/null <<'EOF'
|
||||
+ $cc -x c - -o $tmp <<'EOF'
|
||||
#include CURSES_LOC
|
||||
-main() {}
|
||||
+int main() { return 0; }
|
||||
EOF
|
||||
if [ $? != 0 ]; then
|
||||
echo " *** Unable to find the ncurses libraries or the" 1>&2
|
||||
--
|
||||
2.48.1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user