Compare commits

...
Author SHA1 Message Date
NoahandClaude Sonnet 5.5 35dc64714e kernel: probe V3 passed, the hardware RNG symbols are required
ci / qemu-tools (pull_request) Successful in 50s
ci / patches-apply (pull_request) Successful in 26s
ci / mcdc (push) Successful in 18s
ci / patches-apply (push) Successful in 24s
ci / test (push) Successful in 11s
ci / bench (push) Successful in 8s
ci / qemu-tools (push) Successful in 50s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / kernel-symbols (push) Successful in 2m21s
ci / test (pull_request) Successful in 12s
ci / quality (push) Successful in 33s
ci / badges (push) Skipped
ci / mcdc (pull_request) Successful in 17s
ci / bench (pull_request) Successful in 7s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 34s
ci / badges (pull_request) Skipped
ci / kernel-symbols (pull_request) Successful in 2m20s
Probe V3 (d09 T14, AT-M0-33) on the bench panel with the batch kernel: /dev/hwrng from the
rockchip-rng driver, a 2.6 MB read in 2.4 s (1058 KiB/s) without blocking, and 1 FIPS 140-2 failure
in 1000 blocks (limit 3). CONFIG_HW_RANDOM and CONFIG_HW_RANDOM_ROCKCHIP move from probe-symbols.txt
to required-symbols.txt; the probe list is now empty, which build-kernel.sh accepts (it skips an
empty probe list; the required list may never be empty). The config does not change: the defconfig
already built both in, and the digest stays ec276f77.

Regression tests (run-required-symbols-tests.sh): both symbols asserted and built in, a config
without either is refused by name, the probe list may be empty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 19:17:57 -06:00
NoahandClaude Sonnet 5.5 cf72a6dcbc kernel: make KCONFIG_SHA256 independent of the host python (bfe-core1106-sdk#19)
DRM_MSM_VALIDATE_XML depended on `$(PYTHON3) -c "import lxml"`, so the expanded .config gained a
line on hosts where python3 could import lxml and the whole-file digest differed (the flashed image
ec276f77 against e8e9ef1c from a config-only run on the same tree). Drop the unused Qualcomm symbol
with a one-block Kconfig patch; the digest is now ec276f77 everywhere and equals the flashed one.

Regression test: tests/required-symbols/run-config-determinism-tests.sh runs the config-only
expansion with a python3 whose import lxml works and one where it fails and requires the same
digest; it is proven red on a copy of the tree without the patch. The kernel-symbols CI job runs it.

Fixes #19.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 19:17:57 -06:00
NoahandClaude Sonnet 5.5 0589829619 qemu init: read the command line without for-in-cat (blueflare/bfe-core1106-sdk#18)
ci / test (push) Canceled after 0s
ci / mcdc (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / bench (pull_request) Canceled after 0s
ci / qemu-tools (pull_request) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / kernel-symbols (pull_request) Canceled after 0s
ci / badges (push) Canceled after 0s
ci / prune-artifacts (pull_request) Canceled after 0s
ci / badges (pull_request) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / kernel-symbols (push) Canceled after 0s
ci / test (pull_request) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / mcdc (pull_request) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / patches-apply (pull_request) Canceled after 0s
ci / kernel-build (pull_request) Canceled after 0s
ci / quality (pull_request) Canceled after 0s
shellcheck 0.9 in the qemu-tools CI job reports SC2013 for
`for w in $(cat /proc/cmdline)` and exits non-zero, which kept CI red on the M0 kernel
branch since the warden.run entry was added. Read /proc/cmdline into a variable and loop
over its words.

Regression test: tests/qemu-init/run-init-shellcheck-tests.sh (run by the qemu-tools job)
shellchecks the rootfs scripts and proves the old form red on a doctored copy.

Fixes #18.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 18:42:13 -06:00
NoahandClaude Sonnet 5.5 8615f7c13a kernel: turn CONFIG_SUSPEND off (rebuild M0)
ci / test (pull_request) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / bench (pull_request) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / qemu-tools (pull_request) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / badges (push) Canceled after 0s
ci / quality (pull_request) Canceled after 0s
ci / test (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / kernel-symbols (push) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / mcdc (pull_request) Canceled after 0s
ci / kernel-symbols (pull_request) Canceled after 0s
ci / patches-apply (pull_request) Canceled after 0s
ci / prune-artifacts (pull_request) Canceled after 0s
ci / kernel-build (pull_request) Canceled after 0s
ci / badges (pull_request) Canceled after 0s
ci / mcdc (push) Canceled after 0s
The panel is wall powered and never sleeps the SoC. SUSPEND defaults to y, so the
defconfig carries an explicit unset, and required-symbols.txt asserts SUSPEND and
PM_SLEEP unset against the final .config. Kconfig then drops PM_SLEEP, PM_SLEEP_SMP,
SUSPEND_FREEZER, FREEZER, PM_GENERIC_DOMAINS_SLEEP, FW_CACHE and VT_CONSOLE_SLEEP; as
PM_SLEEP_SMP was the only thing selecting HOTPLUG_CPU on this one-core SoC, HOTPLUG_CPU,
KEXEC and CRASH_DUMP go with it. PM, PM_CLK and runtime PM stay.

Regression test: tests/required-symbols asserts both lines, refuses a config that turns
either back on, and fails when the defconfig loses the explicit unset (proven red).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 18:31:08 -06:00
NoahandClaude Sonnet 5.5 469f31c278 buildroot: nftables cgroupv2 patch reads the handle with the raw syscall (uClibc has no wrapper)
ci / test (push) Successful in 19s
ci / mcdc (push) Successful in 18s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Failing after 13s
ci / kernel-symbols (push) Successful in 1m24s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / badges (push) Skipped
ci / patches-apply (push) Successful in 17s
ci / quality (push) Successful in 1m2s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 11:21:17 -06:00
NoahandClaude Sonnet 5.5 aa6956f595 buildroot: patch nftables so socket cgroupv2 matches on 32-bit kernels
ci / test (push) Canceled after 0s
ci / mcdc (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / kernel-symbols (push) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / badges (push) Canceled after 0s
nftables 1.1.0 builds the id of "socket cgroupv2 level N <path>" from st_ino, which
is the 64-bit kernfs id only on 64-bit kernels. On armv7 the id is
(generation << 32) | ino and st_ino carries the low half, so the rule loaded and
never matched: byte metering per service counted nothing (found by the M0 counting
test in QEMU on the 6.18.46 kernel). The patch takes the id from the directory's file
handle, in both the parse and the listing path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 10:58:38 -06:00
NoahandClaude Sonnet 5.5 445b2082f5 qemu: check the kernel contract at boot and run a staged script (warden.run)
ci / test (push) Canceled after 0s
ci / mcdc (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / kernel-symbols (push) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / badges (push) Canceled after 0s
init verifies build/required-symbols.txt against the guest's /proc/config.gz,
the cgroup v2 controllers and PSI and prints markers; boot-smoke.sh fails when a
marker is missing. mkinitramfs.sh stages the list and merges EXTRA_DIR; run.sh
--append passes warden.run=<path>, which init runs before powering off (used by the
flare-edge M0 limit tests). README notes the symbol lists.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 10:45:22 -06:00
NoahandClaude Sonnet 5.5 0360b8dc46 kernel: single M0 batch (cgroups, namespaces, PSI, raw table, nftables) with a symbol list and clock keep-alive
ci / test (push) Successful in 18s
ci / mcdc (push) Successful in 19s
ci / bench (push) Successful in 9s
ci / qemu-tools (push) Successful in 53s
ci / prune-artifacts (push) Skipped
ci / quality (push) Successful in 46s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 1m25s
ci / patches-apply (push) Successful in 21s
ci / kernel-build (push) Skipped
One kernel flash for everything later work needs (rebuild M0, d09 M0-2):

- warden_defconfig: cgroup v2 controllers (MEMCG, CGROUP_PIDS, CGROUP_SCHED,
  FAIR_GROUP_SCHED, CFS_BANDWIDTH), the byte-metering match symbols
  (XT_MATCH_CGROUP, XT_CONNMARK, XT_MARK, IP6_NF_MANGLE), IKCONFIG and
  IKCONFIG_PROC, XT_MATCH_OWNER, the raw tables and the CT target (the
  NOTRACK for flare-edge#537), NAMESPACES with its five sub-options
  (USER_NS stays closed at boot by a sysctl), PSI, and the nftables set
  (NF_TABLES, ip and ip6 families, NFT_CT, NFT_MASQ, NFT_NAT, NFT_LIMIT,
  NFT_SOCKET, NFT_REJECT). TIME_NS and RT_GROUP_SCHED are explicitly unset.
  HW_RANDOM_ROCKCHIP is built in as a probe for the hardware RNG.
- build/required-symbols.txt and probe-symbols.txt are the source of record;
  build-kernel.sh asserts both against the final .config instead of a
  hand-written list (olddefconfig drops an unknown or unsatisfied symbol
  without a word).
- WARDEN_CONFIG_ONLY=1 stops after that assertion (a seconds-long CI gate) and,
  like a full build, writes the final .config and its sha256 (CONFIG_OUT),
  the digest firmware images record as KCONFIG_SHA256.
- clk_core_mcu_rtc gets CLK_IGNORE_UNUSED like clk_core_mcu, in the patch and in
  the enablement source it documents, so 6.18 keeps the HPMCU mtime clock up.
- CI: a kernel-symbols job expands the real configuration and asserts the lists
  on every push; offline tests prove the assertion fires for every failure shape.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-09 10:12:15 -06:00
noah d22c900fb6 Merge pull request 'kernel: build in IPv6 netfilter (flare-edge#533)' (#15) from fix-533-ipv6-netfilter into flare-edge-next
ci / test (push) Successful in 13s
ci / mcdc (push) Successful in 13s
ci / bench (push) Successful in 5s
ci / patches-apply (push) Successful in 15s
ci / quality (push) Successful in 27s
ci / badges (push) Skipped
ci / qemu-tools (push) Successful in 44s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
2026-10-08 07:56:51 -06:00
NoahandClaude Sonnet 5.5 b7125fc4a7 kernel: correct IPv6 netfilter defconfig comment (flare-edge#533)
ci / badges (push) Skipped
ci / mcdc (push) Successful in 13s
ci / test (push) Successful in 15s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 29s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Successful in 44s
ci / patches-apply (push) Successful in 16s
ci / quality (pull_request) Successful in 27s
ci / badges (pull_request) Skipped
ci / test (pull_request) Successful in 14s
ci / bench (pull_request) Successful in 6s
ci / mcdc (pull_request) Successful in 12s
ci / patches-apply (pull_request) Successful in 14s
ci / qemu-tools (pull_request) Successful in 43s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
The icmp6 match is part of the ip6_tables core (IP6_NF_IPTABLES), not
xt_tcpudp. Comment only; the symbol set is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-07 14:35:09 -06:00
NoahandClaude Sonnet 5.5 35f3ca10eb kernel: build in IPv6 netfilter (flare-edge#533)
The panel kernel had no ip6tables filter table, so the IPv4 default-drop
firewall never applied to IPv6 and dropbear and telnetd were reachable over
::. Enable the ip6tables core (legacy flavour, matching the userland), the
filter table, and IPv6 defrag for conntrack, all built in because the panel
has no /lib/modules:

  CONFIG_NF_DEFRAG_IPV6=y
  CONFIG_IP6_NF_IPTABLES=y
  CONFIG_IP6_NF_IPTABLES_LEGACY=y
  CONFIG_IP6_NF_FILTER=y

No new match symbols: icmp6 lives in xt_tcpudp, and state, limit and
conntrack are family-agnostic and already enabled.

build-kernel.sh now asserts these four are =y in the final .config, because
olddefconfig drops an unmet-dependency line silently and the loss would only
show as an unfiltered IPv6 stack in the field.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk
2026-10-07 13:16:08 -06:00
noah 8212bf5feb Merge pull request 'QEMU: allow seeded flow setup' (#14) from qemu-bt-flow-fixture into flare-edge-next
ci / mcdc (push) Successful in 13s
ci / bench (push) Successful in 5s
ci / test (push) Successful in 12s
ci / qemu-tools (push) Successful in 44s
ci / patches-apply (push) Successful in 14s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 29s
ci / badges (push) Skipped
2026-10-04 21:09:36 -06:00
BFE Engineering 8c4870c6fb Allow seeded QEMU flow setup
ci / mcdc (pull_request) Successful in 12s
ci / bench (pull_request) Successful in 3s
ci / qemu-tools (pull_request) Successful in 42s
ci / patches-apply (pull_request) Successful in 15s
ci / test (push) Successful in 13s
ci / test (pull_request) Successful in 12s
ci / mcdc (push) Successful in 11s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Successful in 43s
ci / patches-apply (push) Successful in 18s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 30s
ci / badges (push) Skipped
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 1m39s
ci / badges (pull_request) Skipped
2026-10-04 18:29:49 -06:00
noah 92d601f585 Merge pull request 'qemu: seed installed RS485 profiles through SEED_DIR' (#13) from qemu-seed-profiles into flare-edge-next
ci / test (push) Successful in 18s
ci / mcdc (push) Successful in 19s
ci / bench (push) Successful in 9s
ci / qemu-tools (push) Successful in 55s
ci / patches-apply (push) Successful in 22s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 36s
ci / badges (push) Skipped
2026-10-03 03:05:49 -06:00
NoahandClaude Opus 5.5 65a6800228 qemu: seed installed RS485 profiles through SEED_DIR
ci / patches-apply (push) Successful in 21s
ci / qemu-tools (push) Successful in 49s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 29s
ci / badges (push) Skipped
ci / patches-apply (pull_request) Successful in 19s
ci / qemu-tools (pull_request) Successful in 46s
ci / bench (push) Successful in 6s
ci / test (pull_request) Successful in 13s
ci / mcdc (pull_request) Successful in 14s
ci / bench (pull_request) Successful in 6s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 28s
ci / badges (pull_request) Skipped
ci / test (push) Successful in 15s
ci / mcdc (push) Successful in 12s
A flow can now boot the rig with a .w485p profile already installed:
SEED_DIR may hold profiles/rs485/<slug>.w485p (plain files, lower-case
slug names, nothing else under profiles/), copied to
/userdata/warden/profiles/rs485/ where warden-modbus keeps them. Every
other subdirectory, symlink or name still fails closed. Needed for
flare-edge#387 (a flow whose undos stay pending needs the profile
installed at boot; the rig cannot reboot within a flow).

seed-dir.sh scenarios 7 and 8 cover the allowed path and five refused
ones.

Refs blueflare/flare-edge#387.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-10-03 01:16:03 -06:00
noah d01add5646 Merge pull request 'qemu: start warden-modbus before warden-automation' (#12) from qemu-init-modbus-order into flare-edge-next
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 28s
ci / badges (push) Skipped
ci / test (push) Successful in 18s
ci / mcdc (push) Successful in 18s
ci / patches-apply (push) Successful in 17s
ci / bench (push) Successful in 8s
ci / qemu-tools (push) Successful in 46s
2026-10-02 23:05:17 -06:00
NoahandClaude Opus 5.5 a828667b0f qemu: start warden-modbus before warden-automation in the rig init
ci / quality (push) Successful in 40s
ci / badges (push) Skipped
ci / mcdc (pull_request) Successful in 17s
ci / qemu-tools (pull_request) Successful in 47s
ci / test (pull_request) Successful in 19s
ci / bench (pull_request) Successful in 8s
ci / patches-apply (pull_request) Successful in 21s
ci / test (push) Successful in 17s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 39s
ci / badges (pull_request) Skipped
ci / mcdc (push) Successful in 19s
ci / bench (push) Successful in 9s
ci / patches-apply (push) Successful in 22s
ci / qemu-tools (push) Successful in 46s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
flare-edge#348 moves the panel's warden-modbus to S21modbus and
warden-automation to S22automation, right after S20linkmount, so a held
relay closes about 9 s sooner at boot. An automation's device command
goes through warden-modbus (flare-edge#331), so modbus starts first. The
rig's init starts the same daemons in the panel's S-number order and
listed automation before modbus (S93, S94); it now matches the panel.

init-daemon-order-test.sh reads the start loop and pins the order; it
fails on the old list. Wired into CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-10-02 21:25:03 -06:00
noah 45569611da Merge pull request 'relays: refuse a WARDEN_GPIO_ROOT too long for PATH_MAX' (#11) from fix-10-relay-path-bound into flare-edge-next
ci / quality (push) Successful in 29s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Successful in 42s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / badges (push) Skipped
ci / test (push) Successful in 13s
ci / mcdc (push) Successful in 10s
ci / patches-apply (push) Successful in 16s
2026-10-02 12:14:29 -06:00
BFE EngineeringandClaude Opus 5.5 b18ed3888b relays: refuse a WARDEN_GPIO_ROOT too long for PATH_MAX
ci / test (push) Successful in 16s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / bench (push) Successful in 11s
ci / patches-apply (push) Successful in 22s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 37s
ci / badges (push) Skipped
ci / qemu-tools (pull_request) Successful in 45s
ci / qemu-tools (push) Successful in 49s
ci / test (pull_request) Successful in 17s
ci / mcdc (pull_request) Successful in 19s
ci / bench (pull_request) Successful in 8s
ci / mcdc (push) Successful in 23s
ci / patches-apply (pull_request) Successful in 22s
ci / quality (pull_request) Successful in 34s
ci / badges (pull_request) Skipped
Sysfs paths were built in fixed 80/96-byte stack buffers with unchecked
snprintf, so a root longer than about 70 bytes was truncated and both relays
silently read as unavailable.

Each operation now formats all of its paths up front into PATH_MAX buffers
and checks every snprintf return. A root whose longest path does not fit is
refused with a stderr line and the call reports unavailable, off or no-op;
nothing is ever truncated. The export argument comes from a constant table
instead of runtime formatting.

Regression tests: a 200-byte root through the fake io (full path reaches
the backend), the exact PATH_MAX boundary, one byte over (refused and logged
on available, get and set, io untouched), and a real scratch tree under a
root over 200 bytes. MC/DC stays at 100% (50/50 conditions).

Fixes #10

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-10-02 11:01:40 -06:00
noah d746ceba6d Merge pull request 'S50usbdevice: an unset USB role is client (flare-edge#278)' (#9) from fix-278-s50-role-default into flare-edge-next
ci / quality (push) Successful in 39s
ci / patches-apply (push) Successful in 26s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / test (push) Successful in 17s
ci / mcdc (push) Successful in 24s
ci / bench (push) Successful in 8s
ci / qemu-tools (push) Successful in 46s
ci / badges (push) Skipped
2026-10-01 16:04:39 -06:00
NoahandClaude Opus 5.5 5f3db8453b S50usbdevice: an unset USB role is client
ci / bench (push) Successful in 6s
ci / mcdc (push) Successful in 12s
ci / patches-apply (push) Successful in 15s
ci / test (pull_request) Successful in 14s
ci / quality (push) Successful in 29s
ci / badges (push) Skipped
ci / test (push) Successful in 13s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / qemu-tools (push) Successful in 42s
ci / patches-apply (pull_request) Successful in 16s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 27s
ci / badges (pull_request) Skipped
ci / bench (pull_request) Successful in 4s
ci / mcdc (pull_request) Successful in 14s
ci / qemu-tools (pull_request) Successful in 41s
0004's gate read a missing /userdata/warden/role as router, so a fresh
store never composed the gadget and the panel had no usb0 until its
second boot (flare-edge#278). Every other role reader defaults unset to
client. 0014 changes the gate to match.

A new patch rather than an edit to 0004: build-firmware.sh skips an
edited, already-applied 0004 as inconclusive, so the runner SDK would
keep the old gate. 0014 applies on a pristine replay and on a tree that
already carries 0004 and 0008.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-10-01 15:19:12 -06:00
noah 85dc1ee04d Merge pull request 'qemu: a reboot tap may lose the control channel; expect_reboot looks back one step' (#8) from qemu-reboot-tap-race into flare-edge-next
ci / bench (push) Successful in 6s
ci / qemu-tools (push) Successful in 41s
ci / patches-apply (push) Successful in 15s
ci / prune-artifacts (push) Skipped
ci / quality (push) Successful in 26s
ci / test (push) Successful in 13s
ci / mcdc (push) Successful in 9s
ci / kernel-build (push) Skipped
ci / badges (push) Skipped
2026-09-28 21:23:10 -06:00
NoahandClaude Opus 5.5 6576a4a506 qemu: a reboot tap may lose the control channel; expect_reboot looks back one step
ci / test (pull_request) Successful in 13s
ci / mcdc (pull_request) Successful in 13s
ci / bench (pull_request) Successful in 6s
ci / qemu-tools (pull_request) Successful in 40s
ci / patches-apply (push) Successful in 15s
ci / qemu-tools (push) Successful in 42s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 15s
ci / test (push) Successful in 12s
ci / quality (pull_request) Successful in 28s
ci / badges (pull_request) Skipped
ci / mcdc (push) Successful in 13s
ci / bench (push) Successful in 6s
ci / quality (push) Successful in 1m5s
ci / badges (push) Skipped
A tap whose outcome is a reboot races init tearing warden-ui down: the
control channel can close while the tap's press/release counts are still
polled, which made the tap FATAL, and a fast guest can print its restart
line before expect_reboot starts, which expect_reboot then ignored.
flare-edge's Reboot flow passed about half its rig runs (flare-edge#233).

drive() now tells each step the next command and the console size when the
previous step began. A tap followed by expect_reboot that loses the channel
after its press went out is ok; expect_reboot reads the console from the
start of the step before it. Anything earlier still does not count.

Tests: RebootTapRace (3 cases) in test_qmp_drive.py; the old driver fails
the main one. Rig: settings/system-reboot-restarts 4/4 sequential passes,
each through the channel-close path (next: 2/4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-09-28 20:30:57 -06:00
noah 9b0659d30c Merge pull request 'Make the patch series reproduce the SDK from a clean vendor checkout' (#7) from sdk4-reproducible into flare-edge-next
ci / quality (push) Successful in 28s
ci / badges (push) Skipped
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / test (push) Successful in 20s
ci / mcdc (push) Successful in 12s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Successful in 40s
ci / patches-apply (push) Successful in 15s
2026-09-28 14:04:32 -06:00
noah 317ae087fd Merge pull request 'qemu: rig init honours reboot, poweroff and halt' (#6) from qemu-init-reboot into flare-edge-next
ci / test (push) Canceled after 0s
ci / mcdc (push) Canceled after 0s
ci / bench (push) Canceled after 0s
ci / qemu-tools (push) Canceled after 0s
ci / patches-apply (push) Canceled after 0s
ci / prune-artifacts (push) Canceled after 0s
ci / kernel-build (push) Canceled after 0s
ci / quality (push) Canceled after 0s
ci / badges (push) Canceled after 0s
2026-09-28 13:07:21 -06:00
NoahandClaude Opus 5.5 07db1b9ec0 qemu: rig init honours reboot, poweroff and halt
ci / test (push) Successful in 13s
ci / bench (push) Successful in 5s
ci / mcdc (push) Successful in 15s
ci / patches-apply (push) Successful in 22s
ci / qemu-tools (push) Successful in 46s
ci / qemu-tools (pull_request) Successful in 42s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 37s
ci / badges (push) Skipped
ci / test (pull_request) Successful in 13s
ci / mcdc (pull_request) Successful in 11s
ci / bench (pull_request) Successful in 5s
ci / patches-apply (pull_request) Successful in 16s
ci / quality (pull_request) Successful in 27s
ci / badges (pull_request) Skipped
The stage-2 init is a busybox sh script running as PID 1. Busybox reboot,
poweroff and halt only signal PID 1 (TERM, USR2, USR1), and the kernel
drops a signal PID 1 has no handler for, so a plain reboot did nothing on
the rig while a panel's busybox init honours it. Settings > System >
Reboot hit exactly that (flare-edge#96).

warden_trap_power_signals performs the -f action after a sync, and
warden_idle_forever idles with sleep & wait so the trap runs at once
instead of after an hour-long foreground sleep.

Test: qemu/tests/init-power-signals-test.sh runs the real helpers in sh
with stub commands and sends each signal; it fails without the traps and
with a foreground sleep, and cannot hang on failure.

Fixes #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-09-28 11:17:07 -06:00
NoahandClaude Opus 5.5 67da1141a0 build: unpack the pinned Buildroot tree into the vendor SDK
ci / badges (push) Skipped
ci / mcdc (push) Successful in 18s
ci / test (push) Successful in 17s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Successful in 41s
ci / patches-apply (push) Successful in 20s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 31s
ci / test (pull_request) Successful in 15s
ci / mcdc (pull_request) Successful in 13s
ci / bench (pull_request) Successful in 5s
ci / qemu-tools (pull_request) Successful in 39s
ci / patches-apply (pull_request) Successful in 14s
ci / kernel-build (pull_request) Skipped
ci / prune-artifacts (pull_request) Skipped
ci / quality (pull_request) Successful in 27s
ci / badges (pull_request) Skipped
build/unpack-buildroot.sh fetches buildroot-2025.02.8 through
fetch-buildroot-tarball.sh (sha256-pinned) and unpacks it to
sysdrv/source/buildroot/buildroot-2025.02.8, the tree the patched
project/build.sh and sysdrv/Makefile select. It refuses an SDK whose
selectors are not patched, leaves an existing tree alone, and never leaves a
partial tree at the final path. flare-edge's build-firmware.sh calls it right
after applying luckfox-sdk-patches/.

Offline regression tests cover the fresh unpack, the existing-tree no-op and
every refusal path; the qemu-tools job runs and shellchecks them.

Refs #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-09-28 11:10:53 -06:00
NoahandClaude Opus 5.5 5f36beb44a luckfox-sdk-patches: capture the SDK deltas that lived only in one tree
A clean vendor checkout plus this series could not build WardenOS: the
workstation SDK that CI copies carried tracked changes and two untracked
kernel fragments that no patch recorded (#4).

- board/0009: sysdrv/Makefile selects buildroot-2025.02.8 and relaxes the
  vendor unpack fallback's cp lines.
- board/0010: removes the five 2023-era busybox/hcitool package patches.
- board/0011: flare_minimize strips camera/ISP payload from /oem.
- board/0012: removes the generic S50sshd init script.
- board/0013: e2fsprogs BUILD_CFLAGS for gcc 14 host helpers.
- kernel/configs: flare-wireguard.config and rv1106-usb-host-ethernet.config,
  which the 86Panel board .mk names for the vendor 5.10 kernel.

Every hunk is git diff output against 824b817f8, byte for byte.

Refs #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01441BzdGcvQmXkiN2qDjfZg
2026-09-28 11:10:53 -06:00
noah eb0691d84f Merge pull request 'Clear the shellcheck findings that would fail qemu-tools' (#3) from sdk-shellcheck into flare-edge-next
ci / kernel-build (push) Skipped
ci / test (push) Successful in 17s
ci / mcdc (push) Successful in 18s
ci / bench (push) Successful in 8s
ci / patches-apply (push) Successful in 16s
ci / prune-artifacts (push) Skipped
ci / qemu-tools (push) Successful in 39s
ci / quality (push) Successful in 26s
ci / badges (push) Skipped
2026-09-28 03:30:57 -06:00
49 changed files with 5038 additions and 68 deletions
+72 -1
View File
@@ -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/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,6 +151,10 @@ 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: 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
@@ -166,6 +173,11 @@ jobs:
# Retry-on-mismatch, cleanup, and the already-verified
# short-circuit, against a fake curl on PATH: no network.
run: bash tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh
- name: unpack-buildroot regression tests
# Fresh unpack, leave-existing-tree-alone, and every refusal path
# (unpatched selectors, bad tarball, half-present tree, failed
# fetch), against a stub fetch script: no network (issue #4).
run: bash tests/unpack-buildroot/run-unpack-buildroot-tests.sh
- name: mk-bootimg boot.img validation regression tests
# Guards issue #22 (a missing/erroring fdtget silently skipping the
# data-position check) plus the FIT metadata and per-image
@@ -191,6 +203,65 @@ jobs:
- name: build A/B disk image
run: bash qemu/mkimage.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.
runs-on: ubuntu-latest
+7
View File
@@ -47,6 +47,13 @@ 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 |
+53
View File
@@ -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"
+3 -7
View File
@@ -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
+54
View File
@@ -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"
}
+7
View File
@@ -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.
+83
View File
@@ -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
+81
View File
@@ -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"
+2 -1
View File
@@ -17,7 +17,8 @@
# release tarball has no commit to name:
#
# linux-6.18.46 build/fetch-kernel-tarball.sh
# buildroot-2025.02.8 build/fetch-buildroot-tarball.sh
# buildroot-2025.02.8 build/fetch-buildroot-tarball.sh (unpacked into the
# vendor SDK by build/unpack-buildroot.sh)
#
# The buildroot one matters more than it looks. The firmware builds against
# sysdrv/source/buildroot/buildroot-2025.02.8 inside the vendor SDK, and the
+121
View File
@@ -1372,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
+1 -1
View File
@@ -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
View File
@@ -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. |
+4 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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");
}
+4
View File
@@ -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
+126 -5
View File
@@ -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)
+11 -2
View File
@@ -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,
+51 -1
View File
@@ -57,7 +57,9 @@ luckfox-sdk-patches/uboot/include/ new source files
luckfox-sdk-patches/kernel/patches/ diffs against sysdrv/source/kernel/
luckfox-sdk-patches/kernel/configs/ new kernel config fragments
luckfox-sdk-patches/wifi/patches/ diffs against sysdrv/drv_ko/wifi/ (out-of-tree modules)
luckfox-sdk-patches/board/patches/ diffs against project/ (board .mk + the build driver)
luckfox-sdk-patches/board/patches/ diffs against project/ and sysdrv/ build files (board .mk,
build drivers, Makefiles, init overlays); may delete files
luckfox-sdk-patches/buildroot/ our delta on the Buildroot tree (see "Buildroot" below)
```
Paths inside each patch are relative to the vendor SDK root, so apply with
@@ -87,6 +89,29 @@ skipped; else if `git apply --check` succeeds it is applied; else it is a hand-
patched SDK carrying an equivalent (or a genuine conflict) and the script warns
and continues rather than aborting the build.
## Buildroot
The vendor checkout ships buildroot-2023.02.6; WardenOS builds against
buildroot-2025.02.8, which is not in the vendor checkout.
`board/patches/0006-buildroot-2025.patch` (project/build.sh) and
`board/patches/0009-sysdrv-buildroot-2025.patch` (sysdrv/Makefile) select it,
and `../build/unpack-buildroot.sh` puts the pristine tree at
`sysdrv/source/buildroot/buildroot-2025.02.8`: it fetches the tarball with
`../build/fetch-buildroot-tarball.sh` (sha256-pinned) and leaves an existing
tree alone. flare-edge's `tools/build-firmware.sh` runs it right after
applying the patches, then stages `buildroot/files/` and applies
`buildroot/patches/` onto the tree (issue #4).
## Completeness check
flare-edge's `tools/verify-sdk-patches.sh` replays this series onto the vendor
base and compares the result with an SDK checkout. It also fails when the SDK
has a tracked change (edit or deletion) that no patch, no fragment and no
entry in flare-edge's `tools/sdk-delta-allowlist.txt` accounts for, and when
the 86Panel board config names a kernel or U-Boot config fragment that
neither the vendor base nor this directory provides. Before that check, five
real deltas lived only in copies of one SDK tree (issue #4).
## What each patch does
### `uboot/patches/0001-display-and-boot-timing.patch`
@@ -269,6 +294,29 @@ had masked it (the reproducibility gap `tools/build-firmware.sh` exists to close
`sysdrv/source/uboot/u-boot/configs/` (it is a whole new file, not a diff);
the board `.mk` patch is what references it by name.
### `board/patches/0009` to `0013` (issue #4)
Deltas that lived only in the workstation SDK until issue #4. Each patch
header explains its change.
| patch | file | what it does |
|---|---|---|
| `0009-sysdrv-buildroot-2025.patch` | `sysdrv/Makefile` | `BUILDROOT_VER` to 2025.02.8 (the tree the `buildroot` target builds); relaxes the vendor unpack fallback's `cp` lines |
| `0010-drop-2023-buildroot-package-patches.patch` | `sysdrv/tools/board/buildroot/{busybox,hcitool}_patch/` | deletes five 2023-era package patches the fallback would copy into Buildroot |
| `0011-oem-flare-minimize.patch` | `project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh` | `flare_minimize`: strips camera/ISP files and modules from /oem |
| `0012-drop-s50sshd.patch` | `overlay-luckfox-buildroot-init/etc/init.d/S50sshd` | deletes the generic sshd starter; dropbear provides SSH |
| `0013-e2fsprogs-build-cflags.patch` | `sysdrv/tools/board/e2fsprogs/Makefile` | `BUILD_CFLAGS` so the host helpers build with gcc 14 |
### `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 |
@@ -278,6 +326,8 @@ had masked it (the reproducibility gap `tools/build-firmware.sh` exists to close
| `uboot/flare-bootcount.config` | boot-failure fallback to `altbootcmd=download` -> MaskRom |
| `uboot/flare-spl-brom.config` | builds `spl_bootrom.o`; does *not* set `SPL_ROCKCHIP_BACK_TO_BROM`, which would flip `SPL_MMC_SUPPORT` off |
| `kernel/flare-backlight.config` | `CONFIG_BACKLIGHT_PWM=y`. As `=m` the backlight class device does not exist until userspace `insmod`s it at ~3.3-3.7 s, which is when the logo is being replaced anyway |
| `kernel/flare-wireguard.config` | `CONFIG_WIREGUARD=y` for the vendor 5.10 kernel, which builds the recovery image. Named by the 86Panel board `.mk`; untracked in the workstation SDK until issue #4 |
| `kernel/rv1106-usb-host-ethernet.config` | USB-Ethernet class drivers (with the `USB_NET_DRIVERS` menu gate) for the vendor 5.10 kernel. Same history as `flare-wireguard.config` |
| `kernel/flare-fbcon.config` | `# CONFIG_LOGO is not set` (the SDK ships the LuckFox fox-head over our logo) plus `FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y` (fbcon seizing the fb destroyed the `drm_logo` image U-Boot handed over) |
## Measured boot timeline
@@ -0,0 +1,65 @@
Build buildroot-2025.02.8 from sysdrv/Makefile too.
0006-buildroot-2025.patch points project/build.sh at buildroot-2025.02.8, but
sysdrv/Makefile has its own default, BUILDROOT_VER, and that is the one the
`buildroot` target actually builds. Left at the vendor's 2023.02.6, a clean
checkout configures and builds the old tree.
The same Makefile carries the vendor's fallback that unpacks
tools/board/buildroot/$(BUILDROOT_VER).tar.gz when the tree is missing and
copies the vendor defconfigs and package patches into it. Two relaxations
keep that fallback usable with 2025.02.8:
- `*_defconfig` instead of only luckfox_pico_w_defconfig, so any defconfig
staged beside the vendor ones is copied too.
- `|| true` on the busybox and hcitool patch copies, because
0010-drop-2023-buildroot-package-patches.patch empties those directories.
The WardenOS build does not use the fallback: flare-edge's
tools/build-firmware.sh unpacks the pinned, sha256-verified tarball with
build/unpack-buildroot.sh before the SDK build runs, so the Makefile's
`test -d` finds the tree and skips its own unpack and copies.
diff --git a/sysdrv/Makefile b/sysdrv/Makefile
index 5edb8f875..c173c219e 100644
--- a/sysdrv/Makefile
+++ b/sysdrv/Makefile
@@ -281,7 +281,7 @@ BUSYBOX_DIR := $(SYSDRV_DIR)/source/busybox
SYSDRV_BUSYBOX_OBJS_OUTPUT_DIR ?= $(BUSYBOX_DIR)/objs_$(BUSYBOX_CFG)
BUILDROOT_CFG ?= config_normal
-BUILDROOT_VER ?= buildroot-2023.02.6
+BUILDROOT_VER ?= buildroot-2025.02.8
BUILDROOT_DIR := $(SYSDRV_DIR)/source/buildroot
CUSTOM_VER ?= custom
@@ -599,11 +599,11 @@ buildroot_create:
mkdir -p $(BUILDROOT_DIR)
tar xzf $(SYSDRV_DIR)/tools/board/buildroot/$(BUILDROOT_VER).tar.gz -C $(BUILDROOT_DIR)
cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/
- cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_w_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/
+ cp $(SYSDRV_DIR)/tools/board/buildroot/*_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/
cp $(SYSDRV_DIR)/tools/board/buildroot/busybox.config $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/
- cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/
+ cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/ || true
cp ${MPV_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/mpv/
- cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/
+ cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ || true
buildroot: prepare
@echo -e "$(C_GREEN) ==sysdrv== build buildroot $(C_NORMAL)"
@@ -611,11 +611,11 @@ buildroot: prepare
mkdir -p $(BUILDROOT_DIR) ;\
tar xzf $(SYSDRV_DIR)/tools/board/buildroot/$(BUILDROOT_VER).tar.gz -C $(BUILDROOT_DIR) ;\
cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
- cp $(SYSDRV_DIR)/tools/board/buildroot/luckfox_pico_w_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
+ cp $(SYSDRV_DIR)/tools/board/buildroot/*_defconfig $(BUILDROOT_DIR)/$(BUILDROOT_VER)/configs/ ;\
cp $(SYSDRV_DIR)/tools/board/buildroot/busybox.config $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ ;\
- cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/ ;\
+ cp ${HCITOOL_TOOL_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/bluez5_utils/ || true ;\
cp ${MPV_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/mpv/ ;\
- cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ ;\
+ cp ${BUSYBOX_PATCH_PATH}/*.patch $(BUILDROOT_DIR)/$(BUILDROOT_VER)/package/busybox/ || true ;\
);
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) $(BUILDROOT_DEFCONFIG) -C $(BUILDROOT_DIR)/$(BUILDROOT_VER)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,55 @@
Strip camera and ISP payload from /oem.
luckfox-buildroot-oem-pre.sh runs over the OEM staging tree before it is
packed. flare_minimize() removes what WardenOS never uses because no image
sensor is fitted: the ISP tuning files (about 32 MB), the rkaiq 3A library
and servers, the camera capture kernel modules, and the camera and MPI
sample binaries.
NPU, video codec, RGA and rockit are kept on purpose. WiFi/BT, touch and the
insmod scripts are not touched.
diff --git a/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh b/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh
index 4187457d4..de2bf74e6 100755
--- a/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh
+++ b/project/cfg/BoardConfig_IPC/luckfox-buildroot-oem-pre.sh
@@ -46,4 +46,37 @@ function remove_data()
#=========================
# run
#=========================
-remove_data
\ No newline at end of file
+remove_data
+#=========================
+# flare-edge: drop camera / ISP from /oem
+#
+# Camera is out of scope for the Warden gateway role (no sensor attached).
+# NPU, video codec, RGA and rockit are KEPT deliberately - they are onboard
+# hardware we chose to retain. WiFi/BT (aic8800*), touch (goodix) and the
+# insmod scripts are never touched here.
+#=========================
+function flare_minimize()
+{
+ KO=$RK_PROJECT_PACKAGE_OEM_DIR/usr/ko
+
+ # ISP tuning data - by far the biggest item in /oem (~32MB)
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/share/iqfiles
+
+ # ISP 3A library and its servers
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/lib/librkaiq*
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/rkaiq_3A_server
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/rkaiq_tool_server
+
+ # camera capture path: ISP, CIF, MIPI CSI-2 D-PHY, and the sensor drivers
+ lf_rm $KO/video_rkisp.ko $KO/video_rkcif.ko
+ lf_rm $KO/phy-rockchip-csi2-dphy.ko $KO/phy-rockchip-csi2-dphy-hw.ko
+ lf_rm $KO/sc3336.ko $KO/mis5001.ko $KO/gspca_main.ko
+
+ # camera/ISP demo + sample binaries (keep luckfox_*_test and modetest:
+ # those are the GPIO/UART/I2C/SPI/PWM/display bring-up tools we want)
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/sample_*
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/rk_mpi_*
+ lf_rm $RK_PROJECT_PACKAGE_OEM_DIR/usr/bin/simple_*
+}
+
+flare_minimize
@@ -0,0 +1,65 @@
Remove the generic S50sshd init script.
overlay-luckfox-buildroot-init is in the 86Panel board's RK_POST_OVERLAY.
Its S50sshd runs `ssh-keygen -A` inline. With no hardware RNG and no saved
seed on a freshly written rootfs, getrandom() blocks, and rcS is sequential,
so every init script sorting after it (S50usbdevice among them) never ran
and the board came up with no reachable interface.
WardenOS gets its SSH server from Buildroot's dropbear package, selected by
flare_warden_defconfig, which installs its own init script.
diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S50sshd b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S50sshd
deleted file mode 100755
index e5b9c4451..000000000
--- a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-init/etc/init.d/S50sshd
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-#
-# sshd Starts sshd.
-#
-
-# Make sure the ssh-keygen progam exists
-[ -f /usr/bin/ssh-keygen ] || exit 0
-
-umask 077
-
-start() {
- chown root:root /var/empty/
- # Create any missing keys
- /usr/bin/ssh-keygen -A
-
- printf "Starting sshd: "
- /usr/sbin/sshd
- touch /var/lock/sshd
- echo "OK"
-}
-stop() {
- printf "Stopping sshd: "
- killall sshd
- rm -f /var/lock/sshd
- echo "OK"
-}
-restart() {
- stop
- start
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- restart
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
-esac
-
-exit $?
-
@@ -0,0 +1,21 @@
Build e2fsprogs host helpers with gcc 14.
The vendor's e2fsprogs 1.43.9 compiles a few helper programs for the build
host (BUILD_CC) while cross-building the target tools. That source relies on
implicit function declarations and implicit int, which gcc 14 turns into
errors, so the host helper build fails. BUILD_CFLAGS demotes those two back
to warnings for the host helpers only; the target CFLAGS are unchanged.
diff --git a/sysdrv/tools/board/e2fsprogs/Makefile b/sysdrv/tools/board/e2fsprogs/Makefile
index 14ab9e503..baa541093 100644
--- a/sysdrv/tools/board/e2fsprogs/Makefile
+++ b/sysdrv/tools/board/e2fsprogs/Makefile
@@ -20,7 +20,7 @@ all:
mkdir -p $(CURRENT_DIR)/$(PKG_BIN)/usr/; \
pushd $(CURRENT_DIR)/$(PKG_NAME)/; \
./configure --host=$(SYSDRV_CROSS) --target=$(SYSDRV_CROSS) CFLAGS="$(SYSDRV_CROSS_CFLAGS)" \
- LDFLAGS="$(SYSDRV_CROSS_CFLAGS)" --prefix=$(CURRENT_DIR)/$(PKG_BIN) \
+ LDFLAGS="$(SYSDRV_CROSS_CFLAGS)" BUILD_CFLAGS="-Wno-implicit-function-declaration -Wno-implicit-int" --prefix=$(CURRENT_DIR)/$(PKG_BIN) \
--disable-nls \
--disable-debugfs --disable-imager --disable-defrag --enable-fsck --enable-resizer \
--disable-testio-debug --disable-rpath --enable-symlink-install --disable-fuse2fs; \
@@ -0,0 +1,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,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,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
+6 -2
View File
@@ -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,
+25
View File
@@ -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
+1
View File
@@ -28,6 +28,7 @@ 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 |
| `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
+5
View File
@@ -85,6 +85,11 @@ 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.
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.
+25 -2
View File
@@ -106,8 +106,9 @@ if [ -n "${SEED_DIR:-}" ]; then
# on the first bad entry the same way --state fails closed above, rather
# than copy it into the image and let it surface as a confusing read
# later. Only a top-level plain file matches "one file per settings key"
# (the Env note above) -- seed-fixtures.py never nests a subdirectory, and
# neither should anything else pointed at this hook.
# (the Env note above), with one exception, profiles/rs485/<slug>.w485p
# (installed device profiles, checked below); seed-fixtures.py nests
# nothing else, and neither should anything else pointed at this hook.
#
# Charset is seed-fixtures.py's KEY_RE, not --state's stricter
# [A-Za-z0-9_.]+ above: seed-fixtures.py deliberately also allows '-' for
@@ -126,6 +127,28 @@ if [ -n "${SEED_DIR:-}" ]; then
echo "FATAL: SEED_DIR entry '$base' is a symlink (refusing to copy it into userdata verbatim)" >&2
exit 1
fi
# The one directory allowed: installed RS485 device profiles, as
# warden-modbus keeps them (/userdata/warden/profiles/rs485/<slug>.w485p),
# so a flow can boot with a profile already installed (flare-edge#387).
# Nothing in it but plain <slug>.w485p files directly under rs485/.
if [ "$base" = profiles ] && [ -d "$entry" ]; then
while IFS= read -r -d '' p; do
rel="${p#"$entry"/}"
if [ "$rel" = rs485 ] && [ -d "$p" ] && [ ! -L "$p" ]; then continue; fi
case "$rel" in
rs485/*/*) ok=0 ;;
rs485/*.w485p) ok=1 ;;
*) ok=0 ;;
esac
name="${rel#rs485/}"
case "${name%.w485p}" in ''|*[!a-z0-9-]*) ok=0 ;; esac
if [ "$ok" -ne 1 ] || [ -L "$p" ] || [ ! -f "$p" ]; then
echo "FATAL: SEED_DIR entry 'profiles/$rel' is not a plain profiles/rs485/<slug>.w485p file" >&2
exit 1
fi
done < <(find "$entry" -mindepth 1 -print0)
continue
fi
[ -f "$entry" ] || {
echo "FATAL: SEED_DIR entry '$base' is not a plain file (refusing to copy it into userdata verbatim)" >&2
exit 1
+8
View File
@@ -6,6 +6,8 @@
# Env:
# BUSYBOX path to a local busybox binary (skips the download; still verified)
# OUT output dir (default: qemu/out); initramfs at $OUT/initramfs.cpio.gz
# EXTRA_DIR a directory merged into the initramfs root (a test's scripts and
# static binaries; init runs one on warden.run=<path>)
set -euo pipefail
QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -20,6 +22,12 @@ qemu_get_busybox
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/warden-qemu-initramfs.XXXXXX")"
trap 'rm -rf "$SCRATCH"' EXIT
qemu_stage_rootfs "$SCRATCH/root"
# The kernel symbol list, so init can check it against /proc/config.gz.
install -D -m 0644 "$QEMU_DIR/../build/required-symbols.txt" "$SCRATCH/root/etc/required-symbols.txt"
if [ -n "${EXTRA_DIR:-}" ]; then
[ -d "$EXTRA_DIR" ] || { echo "FATAL: EXTRA_DIR is not a directory: $EXTRA_DIR" >&2; exit 1; }
cp -a "$EXTRA_DIR/." "$SCRATCH/root/"
fi
# Pack (newc cpio, gzip). No device nodes required: /init mounts devtmpfs and
# reopens the console itself, so the archive builds unprivileged.
+21
View File
@@ -41,3 +41,24 @@ warden_slot() {
esac
echo "$slot"
}
# PID 1 must answer busybox's reboot/poweroff/halt itself: they only signal
# PID 1 (TERM, USR2, USR1), and the kernel drops any signal PID 1 has no
# handler for. A panel's busybox init handles them; without this the rig
# ignored a plain `reboot` (bfe-core1106-sdk#5). The -f forms skip init, and
# the kernel still prints its orderly "reboot: Restarting system" line.
# WARDEN_REBOOT_CMD / WARDEN_POWEROFF_CMD exist for the host test only.
warden_trap_power_signals() {
trap 'echo "init: reboot requested"; sync; ${WARDEN_REBOOT_CMD:-reboot -f}' TERM
trap 'echo "init: poweroff requested"; sync; ${WARDEN_POWEROFF_CMD:-poweroff -f}' USR2
trap 'echo "init: halt requested"; sync; ${WARDEN_POWEROFF_CMD:-poweroff -f}' USR1
}
# Idle forever in a way a trapped signal interrupts at once: a foreground
# `sleep` would hold the trap until it returned, up to an hour later.
warden_idle_forever() {
while :; do
sleep 3600 &
wait $!
done
}
+47
View File
@@ -18,6 +18,53 @@ mount -t sysfs sysfs /sys
echo "WARDEN-QEMU-BOOT-OK"
# Kernel contract (rebuild M0): every symbol of build/required-symbols.txt (staged
# as /etc/required-symbols.txt by mkinitramfs.sh) is in the running kernel's
# /proc/config.gz, the cgroup v2 controllers the platform limits with are there,
# and pressure stall information is on. boot-smoke.sh greps these markers.
if [ -r /etc/required-symbols.txt ]; then
if [ -e /proc/config.gz ] && zcat /proc/config.gz > /config.run 2>/dev/null; then
miss=""; nsym=0
while read -r line; do
case "$line" in
CONFIG_*=*)
nsym=$((nsym + 1))
grep -qxF "$line" /config.run || miss="$miss $line" ;;
"# CONFIG_"*" is not set")
sym="${line#\# }"; sym="${sym% is not set}"; nsym=$((nsym + 1))
grep -q "^$sym=" /config.run && miss="$miss ${sym}(set)" ;;
esac
done < /etc/required-symbols.txt
if [ -z "$miss" ]; then echo "WARDEN-QEMU-SYMBOLS-OK $nsym"
else echo "WARDEN-QEMU-SYMBOLS-MISSING$miss"; fi
else
echo "WARDEN-QEMU-SYMBOLS-MISSING /proc/config.gz"
fi
mkdir -p /sys/fs/cgroup
mount -t cgroup2 none /sys/fs/cgroup 2>/dev/null
echo "WARDEN-QEMU-CGROUP-CONTROLLERS $(cat /sys/fs/cgroup/cgroup.controllers 2>/dev/null)"
psi_missing=""
for f in cpu memory io; do [ -r "/proc/pressure/$f" ] || psi_missing="$psi_missing $f"; done
if [ -z "$psi_missing" ]; then echo "WARDEN-QEMU-PSI-OK"; else echo "WARDEN-QEMU-PSI-MISSING$psi_missing"; fi
fi
# warden.run=<path>: run a script that mkinitramfs.sh staged from EXTRA_DIR, then
# power off. Used by the M0 limit tests (tools/m0/limits-test.sh in flare-edge).
read -r CMDLINE < /proc/cmdline
for w in $CMDLINE; do
case "$w" in warden.run=*) RUN_SCRIPT="${w#warden.run=}" ;; esac
done
if [ -n "${RUN_SCRIPT:-}" ]; then
if [ -x "$RUN_SCRIPT" ]; then
echo "WARDEN-QEMU-RUN-BEGIN $RUN_SCRIPT"
"$RUN_SCRIPT"
echo "WARDEN-QEMU-RUN-END rc=$?"
else
echo "WARDEN-QEMU-RUN-MISSING $RUN_SCRIPT"
fi
poweroff -f
fi
# With a virtio disk attached, hand over to the stage-1 rc (by-name symlinks,
# slot select, switch_root). It only returns on failure; then fall through to
# the diskless shell/poweroff behavior below.
+18 -6
View File
@@ -57,6 +57,16 @@ mount_fatal userdata /userdata
mount_fatal "oem${slot}" /oem
mkdir -p /userdata/warden
# A flow may seed an opt-in guest fixture before the UI and payload daemons
# start. The file lives only in this disposable QEMU disk image. Fail the
# boot if setup fails so a flow cannot pass against an unprepared guest.
if [ -f /userdata/warden/qemu-flow-setup.sh ]; then
if ! /bin/busybox sh /userdata/warden/qemu-flow-setup.sh; then
echo "FATAL: QEMU flow setup failed"
poweroff -f
fi
fi
# RS485: warden-modbus hardcodes /dev/ttyS4 at compile time; alias it to the
# VM's RS485 pci-serial UART (needs the virt.fragment kernel). run.sh lists
# the control channel's port first when there is one (warden.ctl on the
@@ -105,14 +115,14 @@ if grep -qw warden.fwapply /proc/cmdline; then
echo "init: OTA APPLY ENABLED (warden.fwapply)"
fi
# The same daemons the panel's SysV scripts start, in their S-number order
# (S92 ai, S93 automation, S94 modbus, S95 mikrotik, S96 asic/starlink/
# stratum, S97 flared), each with no arguments and no environment, exactly
# as start-stop-daemon runs them there. A daemon that cannot live on -M virt
# (S21 modbus, S22 automation, S92 ai, S95 mikrotik, S96 asic/starlink/
# stratum, S97 flared; flare-edge#348), each with no arguments and no
# environment, exactly as start-stop-daemon runs them there. A daemon that cannot live on -M virt
# (warden-ai wants the NPU) exits into its log and the UI shows the same
# "not running" it would show on a panel whose daemon died; that is the
# panel's behaviour, not a rig substitute for it. warden-watchdog stays out:
# it and a payload flared do not mix (README).
for d in /usr/bin/warden-ai /usr/bin/warden-automation /usr/bin/warden-modbus \
for d in /usr/bin/warden-modbus /usr/bin/warden-automation /usr/bin/warden-ai \
/usr/bin/warden-mikrotik /usr/bin/warden-asic /usr/bin/warden-starlink \
/usr/bin/warden-stratum /usr/bin/warden-flared; do
if [ -x "$d" ]; then
@@ -239,5 +249,7 @@ if grep -qw warden.shell /proc/cmdline; then
poweroff -f
fi
# Hold: daemons run, console idles, scenarios drive the VM from outside.
while :; do sleep 3600; done
# Hold: daemons run, console idles, scenarios drive the VM from outside. As
# PID 1 this shell must honour reboot/poweroff/halt itself (#5).
warden_trap_power_signals
warden_idle_forever
+6
View File
@@ -25,6 +25,9 @@
# --http-port N hostfwd 127.0.0.1:N -> guest :80 (default 8080; 0 disables)
# --api-port N hostfwd 127.0.0.1:N -> guest :28443 (default 28443; 0 disables)
# --shell interactive shell in the guest instead of daemon hold
# --append STR extra kernel command line words (for example
# warden.run=/m0/limits-test.sh: init runs that script from
# the initramfs and powers off)
# --allow-apply let flared ACTUALLY apply OTA firmware (writes rootfs_b
# inside disk.img, safe in the VM, never the default)
set -euo pipefail
@@ -38,6 +41,7 @@ KERNEL="" INITRD="$OUT/initramfs.cpio.gz" DISK="" NO_DISK=0 SLOT="_a"
RTC="" RS485="" CTL="" WATCHDOG=0 QMP="" DISPLAY_MODE="off" SHELL_FLAG=0 ALLOW_APPLY=0
SSH_PORT=2222 HTTP_PORT=8080 API_PORT=28443
EXTRA=()
EXTRA_APPEND=""
while [ $# -gt 0 ]; do
case "$1" in
@@ -56,6 +60,7 @@ while [ $# -gt 0 ]; do
--http-port) HTTP_PORT="${2:?}"; shift 2 ;;
--api-port) API_PORT="${2:?}"; shift 2 ;;
--shell) SHELL_FLAG=1; shift ;;
--append) EXTRA_APPEND="${2:?}"; shift 2 ;;
--allow-apply) ALLOW_APPLY=1; shift ;;
--) shift; EXTRA=("$@"); break ;;
*) echo "FATAL: unknown argument '$1' (see header of $0)" >&2; exit 1 ;;
@@ -111,6 +116,7 @@ if [ -n "$DISK" ] && [ "$NO_DISK" -eq 0 ]; then
-device "virtio-blk-device,drive=vd0" )
fi
[ "$SHELL_FLAG" -eq 1 ] && APPEND="$APPEND warden.shell"
[ -n "$EXTRA_APPEND" ] && APPEND="$APPEND $EXTRA_APPEND"
# Tells init the FIRST 8250 is the control bridge. Without this marker init
# bridges nothing, so a VM launched with --rs485 alone never has its Modbus
# wire mistaken for the debug channel.
+17 -1
View File
@@ -44,4 +44,20 @@ grep -q "WARDEN-QEMU-BOOT-OK" "$LOG" || {
echo "FATAL: boot sentinel WARDEN-QEMU-BOOT-OK not found in console log" >&2
exit 1
}
echo "boot smoke OK"
# Kernel contract (rebuild M0): init checked build/required-symbols.txt against the
# running kernel's /proc/config.gz, the cgroup v2 controllers and PSI. A missing
# marker is as fatal as a MISSING one: the check must have run.
grep -q "^WARDEN-QEMU-SYMBOLS-OK " "$LOG" || {
echo "FATAL: the required-symbols check did not pass: $(grep -E 'WARDEN-QEMU-SYMBOLS' "$LOG" | head -1)" >&2
exit 1
}
ctl="$(sed -n 's/^WARDEN-QEMU-CGROUP-CONTROLLERS //p' "$LOG" | head -1 | tr -d '\r')"
for c in cpu memory pids; do
case " $ctl " in *" $c "*) ;; *)
echo "FATAL: cgroup v2 controller '$c' missing in the guest (have: '$ctl')" >&2; exit 1 ;; esac
done
grep -q "^WARDEN-QEMU-PSI-OK" "$LOG" || {
echo "FATAL: pressure stall information is not available: $(grep -E 'WARDEN-QEMU-PSI' "$LOG" | head -1)" >&2
exit 1
}
echo "boot smoke OK (symbols, cgroup controllers [$ctl], PSI)"
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# The rig's /sbin/init starts the Warden daemons in the panel's S-number
# order (flare-edge#348): warden-modbus (S21modbus) before warden-automation
# (S22automation), since an automation's device command goes through
# warden-modbus, and both before the other app backends and flared. Reads
# the daemon list from the init script's own start loop.
set -uo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
INIT="$HERE/../rootfs/sbin/init"
FAIL=0
order=$(awk '
/^for d in \/usr\/bin\/warden-/ { on = 1 }
on {
last = ($0 ~ /; do$/)
for (i = 1; i <= NF; i++) if ($i ~ /^\/usr\/bin\/warden-/) { w = $i; sub(/;$/, "", w); print w }
if (last) exit
}' "$INIT")
want="/usr/bin/warden-modbus
/usr/bin/warden-automation
/usr/bin/warden-ai
/usr/bin/warden-mikrotik
/usr/bin/warden-asic
/usr/bin/warden-starlink
/usr/bin/warden-stratum
/usr/bin/warden-flared"
if [ "$order" = "$want" ]; then
echo "PASS: rig init starts the daemons in the panel's S-number order"
else
echo "FAIL: rig init daemon order differs from the panel's S-number order"
diff <(printf '%s\n' "$want") <(printf '%s\n' "$order")
FAIL=1
fi
exit "$FAIL"
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Regression test for bfe-core1106-sdk#5: the rig's PID 1 script ignored
# busybox reboot/poweroff/halt, which only signal PID 1. Runs the real
# helpers from qemu/rootfs/etc/warden-lib.sh in a plain sh with stub
# commands, idles it the way /sbin/init does, sends each signal and requires
# the matching action within two seconds.
set -uo pipefail
# Job control: each case's shell leads its own process group, so cleanup can
# kill the whole group. An orphaned `sleep 3600` would otherwise keep this
# script's output pipe open for an hour when a case fails.
set -m
HERE="$(cd "$(dirname "$0")" && pwd)"
LIB="$HERE/../rootfs/etc/warden-lib.sh"
SH="${WARDEN_TEST_SH:-sh}"
WORK="$(mktemp -d)" || exit 1
trap 'rm -rf "$WORK"' EXIT
FAIL=0
run_case() { # run_case <signal> <expected marker> <label>
local sig="$1" want="$2" label="$3" out="$WORK/$1.out"
: > "$out"
WARDEN_REBOOT_CMD="eval echo reboot >> $out; exit 0" \
WARDEN_POWEROFF_CMD="eval echo poweroff >> $out; exit 0" \
"$SH" -c ". '$LIB'; warden_trap_power_signals; warden_idle_forever" &
local pid=$!
sleep 0.5
kill -"$sig" "$pid"
local n=0
while ! grep -qx "$want" "$out" && [ "$n" -lt 20 ]; do
sleep 0.1; n=$((n + 1))
done
if grep -qx "$want" "$out"; then
echo "[PASS] $label"
else
echo "[FAIL] $label (got: $(tr '\n' ' ' < "$out"))"; FAIL=1
fi
kill -KILL -- "-$pid" 2>/dev/null
wait "$pid" 2>/dev/null
}
run_case TERM reboot "SIGTERM (busybox reboot) reboots at once"
run_case USR2 poweroff "SIGUSR2 (busybox poweroff) powers off at once"
run_case USR1 poweroff "SIGUSR1 (busybox halt) powers off at once"
exit "$FAIL"
+37 -7
View File
@@ -244,6 +244,7 @@ def do_observed_tap(ctx, ax, ay):
return True
send_events(ctx.s, ctx.f, [abs_ev("x", ax), abs_ev("y", ay), btn_ev(True)])
ctx.tap_sent = True
pressed = False
try:
pressed = wait_input_count(ctx, "presses", before.get("presses"))
@@ -728,6 +729,10 @@ class Ctx:
self.rs485_control = rs485_control
self.outdir = outdir
self.script_path = script_path
# Set by drive() before each step: the command after this one, and the
# console size when the step before this one began (flare-edge#233).
self.next_cmd = None
self.prev_step_console = 0
def need_ctl(self, lineno, cmd):
if self.ctl is None:
@@ -786,7 +791,19 @@ def verb_shot(ctx, lineno, cmd, args, line):
def verb_tap(ctx, lineno, cmd, args, line):
x, y = int(args[0]), int(args[1])
observed = do_observed_tap(ctx, to_axis(x, ctx.size), to_axis(y, ctx.size))
ctx.tap_sent = False
try:
observed = do_observed_tap(ctx, to_axis(x, ctx.size), to_axis(y, ctx.size))
except (RuntimeError, OSError):
# A tap whose correct outcome is a reboot (the next step is
# expect_reboot) can lose the control channel while its press/release
# counts are still being polled: init tears warden-ui down first. Once
# the press went out that is the tap working, not failing; the reboot
# step judges the outcome (flare-edge#233). Anywhere else, or before
# anything was sent, it stays a fatal step.
if ctx.next_cmd == "expect_reboot" and ctx.tap_sent:
return "ok", "tap sent; the control channel closed as the guest went down"
raise
return (("ok", "") if observed else
("fail", "input press or release was not consumed within 2 seconds"))
@@ -829,10 +846,11 @@ def verb_expect_reboot(ctx, lineno, cmd, args, line):
timeout = float(args[0])
if not ctx.console_path:
sys.exit(f"FATAL: {ctx.script_path}:{lineno}: '{cmd}' needs --console")
try:
start = os.path.getsize(ctx.console_path)
except OSError:
start = 0
# From the start of the step BEFORE this one, not this one: the action
# that reboots (a tap, usually) runs in that step, and a fast guest can
# print its restart line before expect_reboot even begins (flare-edge#233).
# A line from any earlier step still does not count.
start = ctx.prev_step_console
deadline = time.monotonic() + timeout
def console_since_start():
@@ -1182,12 +1200,24 @@ def drive(s, f, script_path, outdir, size, ctl_path=None, console_path=None, ref
console_path)
console = ConsoleWatch(console_path)
def console_size():
try:
return os.path.getsize(console_path) if console_path else 0
except OSError:
return 0
steps = []
for lineno, raw in enumerate(lines, 1):
line = raw.split("#", 1)[0].strip()
if not line:
continue
if line:
steps.append((lineno, line))
step_console = console_size()
for i, (lineno, line) in enumerate(steps):
parts = line.split()
cmd, args = parts[0], parts[1:]
ctx.next_cmd = steps[i + 1][1].split()[0] if i + 1 < len(steps) else None
ctx.prev_step_console, step_console = step_console, console_size()
handler = VERBS.get(cmd)
if handler is None:
+37
View File
@@ -186,5 +186,42 @@ else
fail "SEED_DIR: mkimage.sh rejected a valid hyphenated key (see $SCRATCH/mkimage6.log)"
fi
# --- scenario 7: an installed RS485 profile, profiles/rs485/<slug>.w485p,
# seeds into userdata/warden/profiles/rs485/ (flare-edge#387) ---
SEED7="$SCRATCH/seed7"
mkdir -p "$SEED7/profiles/rs485"
printf '{"w485p_version":1}\n' > "$SEED7/profiles/rs485/acme-gen-ctl.w485p"
OUT7="$SCRATCH/out7"
if OUT="$OUT7" BUSYBOX="$BUSYBOX_BIN" SEED_DIR="$SEED7" \
bash "$QEMU_DIR/mkimage.sh" > "$SCRATCH/mkimage7.log" 2>&1; then
UIMG7="$SCRATCH/userdata7.img"
extract_userdata "$OUT7/disk.img" "$UIMG7"
prof="$(debugfs -R "cat /warden/profiles/rs485/acme-gen-ctl.w485p" "$UIMG7" 2>/dev/null)"
if [ "$prof" = '{"w485p_version":1}' ]; then
pass "SEED_DIR: an installed profile seeds into profiles/rs485/"
else
fail "SEED_DIR: profiles/rs485/acme-gen-ctl.w485p = '$prof'"
fi
else
fail "SEED_DIR: mkimage.sh rejected a profiles/rs485/<slug>.w485p seed (see $SCRATCH/mkimage7.log)"
fi
# --- scenario 8: anything else under profiles/ fails closed ---
for bad in "rs485/x.json" "rs485/Bad.w485p" "other/x.w485p" "rs485/sub/x.w485p" "rs485/link.w485p"; do
SEED8="$SCRATCH/seed8"
rm -rf "$SEED8"
mkdir -p "$SEED8/profiles/$(dirname "$bad")"
if [ "$bad" = rs485/link.w485p ]; then ln -s /etc/passwd "$SEED8/profiles/$bad"; else printf 'x\n' > "$SEED8/profiles/$bad"; fi
OUT8="$SCRATCH/out8"
rm -rf "$OUT8"
err8="$(OUT="$OUT8" BUSYBOX="$BUSYBOX_BIN" SEED_DIR="$SEED8" bash "$QEMU_DIR/mkimage.sh" 2>&1 1>/dev/null)"
rc8=$?
if [ "$rc8" -ne 0 ] && printf '%s' "$err8" | grep -qF "is not a plain profiles/rs485/<slug>.w485p file"; then
pass "SEED_DIR: profiles/$bad fails closed"
else
fail "SEED_DIR: profiles/$bad gave rc=$rc8, stderr='$err8'"
fi
done
[ "$FAIL" -eq 0 ] && echo "ALL SEED_DIR TESTS PASSED" || echo "SEED_DIR TESTS FAILED"
[ "$FAIL" -eq 0 ]
+62
View File
@@ -924,6 +924,68 @@ class ExpectReboot(unittest.TestCase):
self.assertIn("without the kernel's orderly restart line", rows[-1]["detail"])
class RebootTapRace(unittest.TestCase):
"""flare-edge#233: a tap whose outcome is a reboot races init tearing
warden-ui down. The control channel can close while the tap's press and
release counts are still being polled, and the guest can print its restart
line before expect_reboot starts. Both are the tap working."""
CONSOLE_LINE = b"init: reboot requested\n[ 17.8] reboot: Restarting system\n"
def run_race(self, script, console_before=b""):
d = tempfile.mkdtemp(prefix="console.")
console = os.path.join(d, "console.log")
with open(console, "wb") as fh:
fh.write(console_before)
line = self.CONSOLE_LINE
class RebootingCtl(FakeCtl):
"""First stats answers (the tap's baseline); the next one, the
press poll, finds the guest already going down: the restart line
is on the console and the channel is closed."""
def send(self, cmd):
if cmd == "stats" and self.stats_calls >= 1:
with open(console, "ab") as fh:
fh.write(line)
raise RuntimeError("control channel closed")
return super().send(cmd)
def rpc(sock, sock_file, obj):
if obj.get("execute") == "query-status":
raise RuntimeError("QMP connection closed")
return fake_rpc(sock, sock_file, obj)
return run_script(script, ctl_cls=RebootingCtl, rpc_fn=rpc, console_path=console)
def test_reboot_tap_losing_the_channel_then_expect_reboot_passes(self):
rc, by, rows = self.run_race("tap 10 10\nexpect_reboot 2\n")
self.assertIsNone(rc, rows)
self.assertEqual([r["status"] for r in rows], ["ok", "ok"], rows)
self.assertIn("control channel closed", rows[0]["detail"])
def test_the_same_channel_loss_before_any_other_step_is_still_fatal(self):
rc, by, rows = self.run_race("tap 10 10\nsleep 0\n")
self.assertEqual(rows[0]["status"], "fatal", rows)
def test_a_restart_line_from_two_steps_back_still_does_not_count(self):
# The restart line is already on the console before the script; the
# reboot step may look back one step, not to the start of the run.
d = tempfile.mkdtemp(prefix="console.")
console = os.path.join(d, "console.log")
with open(console, "wb") as fh:
fh.write(b"reboot: Restarting system\n")
def rpc(sock, sock_file, obj):
if obj.get("execute") == "query-status":
raise RuntimeError("QMP connection closed")
return fake_rpc(sock, sock_file, obj)
rc, by, rows = run_script("sleep 0\nexpect_reboot 1\n", rpc_fn=rpc,
console_path=console)
self.assertEqual(rc, 1)
self.assertIn("without the kernel's orderly restart line", rows[-1]["detail"])
class FullscreenToggleTracksRealState(unittest.TestCase):
"""qemu/tests/scripts/fullscreen-toggle-tracks-real-state.txt, offline:
`home` clears the dashboard's real fullscreen state directly, and a
+1
View File
@@ -37,6 +37,7 @@ scripts=(
"qemu/tests/stage-rootfs-perms.sh"
"tests/fetch-vendor/run-fetch-vendor-tests.sh"
"tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh"
"tests/unpack-buildroot/run-unpack-buildroot-tests.sh"
"tests/mk-bootimg/run-boot-img-validate-tests.sh"
"tests/mk-bootimg/run-help-tests.sh"
"tests/mk-bootimg/run-ci-wiring-tests.sh"
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Offline test: the QEMU initramfs scripts pass the same shellcheck the qemu-tools CI job runs
# (issue #18: `for w in $(cat /proc/cmdline)` failed it with SC2013), and the check really fires.
# Skips with a notice when shellcheck is not installed (CI installs it).
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
FAIL=0
ok() { printf '[PASS] %s\n' "$1"; }
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
if ! command -v shellcheck >/dev/null 2>&1; then
echo "[SKIP] shellcheck is not installed"; exit 0
fi
cd "$REPO" || exit 1
if shellcheck -x qemu/rootfs/init qemu/rootfs/etc/rc qemu/rootfs/sbin/init > "$TMP/out" 2>&1; then
ok "qemu/rootfs scripts pass shellcheck"
else
bad "qemu/rootfs scripts fail shellcheck"; head -20 "$TMP/out"
fi
if grep -q 'read -r CMDLINE < /proc/cmdline' qemu/rootfs/init; then
ok "init reads /proc/cmdline into a variable"
else
bad "init no longer reads /proc/cmdline into a variable"
fi
# the old form must be red
# shellcheck disable=SC2016 # the text is the literal old source line
old_loop='for w in $(cat /proc/cmdline); do'
sed -e '/^read -r CMDLINE < \/proc\/cmdline$/d' -e "s|^for w in \\\$CMDLINE; do\$|$old_loop|" qemu/rootfs/init > "$TMP/init-old"
grep -qF "$old_loop" "$TMP/init-old" || bad "the doctored copy was not built"
out="$(shellcheck -x "$TMP/init-old" 2>&1 || true)"
if printf '%s' "$out" | grep -q 'SC2013'; then
ok "doctored: the cat-in-a-for-loop form is reported as SC2013"
else
bad "doctored: the old form was not caught"
fi
if [ "$FAIL" -eq 0 ]; then echo "ALL QEMU-INIT SHELLCHECK TESTS PASSED"; else echo "QEMU-INIT SHELLCHECK TESTS FAILED"; fi
exit $FAIL
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# The final kernel .config, and so KCONFIG_SHA256, must not depend on the host's python (issue #19):
# DRM_MSM_VALIDATE_XML used to be visible only where python3 could import lxml, adding one line to the
# file. Runs the config-only expansion twice, once with a python3 whose `import lxml` works and once with
# one where it fails, and requires the same digest. Proven red on a copy of the tree without
# patches/90-kconfig-no-python-symbol.patch (when this host's python3 has lxml; otherwise the red case
# is skipped with a notice). Needs the pinned kernel tarball: KERNEL_TARBALL=<path>, or skipped.
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
FAIL=0
ok() { printf '[PASS] %s\n' "$1"; }
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
if [ -z "${KERNEL_TARBALL:-}" ] || [ ! -f "$KERNEL_TARBALL" ]; then
echo "[SKIP] set KERNEL_TARBALL to the pinned linux-6.18.46.tar.xz"; exit 0
fi
command -v python >/dev/null || { echo "[SKIP] needs 'python' on PATH (SDK quirk)"; exit 0; }
REAL_PY="$(command -v python3)"
# a python3 on which `import lxml` fails, everything else passes through
mkdir -p "$TMP/nolxml"
cat > "$TMP/nolxml/python3" <<PYEOF
#!/bin/sh
case "\$*" in *"import lxml"*) exit 1 ;; esac
exec "$REAL_PY" "\$@"
PYEOF
chmod +x "$TMP/nolxml/python3"
# and one where it succeeds even if lxml is not installed
mkdir -p "$TMP/lxml"
cat > "$TMP/lxml/python3" <<PYEOF
#!/bin/sh
case "\$*" in *"import lxml"*) exit 0 ;; esac
exec "$REAL_PY" "\$@"
PYEOF
chmod +x "$TMP/lxml/python3"
digest() { # digest <tree root> <path prefix dir>
local root="$1" pfx="$2" work
work="$(mktemp -d "$TMP/w.XXXXXX")"
PATH="$pfx:$PATH" KERNEL_TARBALL="$KERNEL_TARBALL" WORK="$work" WARDEN_CONFIG_ONLY=1 \
CONFIG_OUT="$work/final.config" CROSS_COMPILE="${CROSS_COMPILE:-arm-linux-gnueabihf-}" \
bash "$root/build/build-kernel.sh" > "$work/log" 2>&1 || { tail -5 "$work/log" >&2; echo FAILED; return; }
cat "$work/final.config.sha256"
}
a="$(digest "$REPO" "$TMP/lxml")"; b="$(digest "$REPO" "$TMP/nolxml")"
if [ "$a" != FAILED ] && [ "$a" = "$b" ]; then ok "the config digest is the same with and without a working import lxml ($a)"
else bad "the config digest depends on the host python: with lxml $a, without $b"; fi
# red case: a tree without the patch
mkdir -p "$TMP/old/patches"
cp -r "$REPO/build" "$TMP/old/build"
for p in "$REPO"/patches/*.patch; do [ "$(basename "$p")" = 90-kconfig-no-python-symbol.patch ] || cp "$p" "$TMP/old/patches/"; done
oa="$(digest "$TMP/old" "$TMP/lxml")"; ob="$(digest "$TMP/old" "$TMP/nolxml")"
if [ "$oa" = FAILED ] || [ "$ob" = FAILED ]; then bad "the doctored tree did not expand"
elif [ "$oa" != "$ob" ]; then ok "doctored: without the patch the digests differ ($oa vs $ob), so this test can fail"
else bad "doctored: the digests are equal even without the patch; the test proves nothing on this tarball"; fi
if [ "$FAIL" -eq 0 ]; then echo "ALL CONFIG-DETERMINISM TESTS PASSED"; else echo "CONFIG-DETERMINISM TESTS FAILED"; fi
exit $FAIL
+127
View File
@@ -0,0 +1,127 @@
#!/usr/bin/env bash
# Offline tests for the required-symbols mechanism (rebuild M0):
# build/lib-required-symbols.sh, the symbol lists, and build-kernel.sh's
# WARDEN_CONFIG_ONLY entry checks. No kernel tarball, no compiler.
#
# What a regression here costs: olddefconfig drops a defconfig line whose symbol
# or dependencies are missing without a word (flare-edge#533 shipped a firewall
# that quietly skipped IPv6 that way), so the assertion against the final
# .config is the only thing between a dropped symbol and a panel. This proves the
# assertion itself fires, on fake .config files, for every failure shape.
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
LIB="$REPO/build/lib-required-symbols.sh"
REQ="$REPO/build/required-symbols.txt"
PROBE="$REPO/build/probe-symbols.txt"
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
FAIL=0
ok() { printf '[PASS] %s\n' "$1"; }
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
# shellcheck source=build/lib-required-symbols.sh
. "$LIB"
# A .config that satisfies a list: every =y line verbatim, every unset line
# absent (Kconfig writes "# CONFIG_X is not set" for those).
mkconfig() { # <list> <out>
{ req_assertions "$1" | grep -v '^# '
req_assertions "$1" | grep '^# '
echo 'CONFIG_SOMETHING_ELSE=y'; } > "$2"
}
# The probe list may be empty once every probe has passed (build-kernel.sh then skips it);
# PROBES is the list to pass along: the probe list when it holds assertions, nothing otherwise.
PROBES=(); [ -n "$(req_assertions "$PROBE")" ] && PROBES=("$PROBE")
mkconfig "$REQ" "$TMP/good-req"; : > "$TMP/good-probe"; [ "${#PROBES[@]}" = 0 ] || mkconfig "$PROBE" "$TMP/good-probe"; cat "$TMP/good-req" "$TMP/good-probe" > "$TMP/good"
req_assert_config "$TMP/good" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 \
&& ok "a config that satisfies both lists passes" || bad "a satisfying config was refused"
n=$(req_assertions "$REQ" | wc -l)
[ "$n" -ge 40 ] && ok "required-symbols.txt holds $n assertions" || bad "required-symbols.txt holds only $n assertions"
# every =y assertion must be refused when its line is missing, one at a time
missing_ok=0; missing_bad=0
while IFS= read -r line; do
case "$line" in CONFIG_*=y) ;; *) continue ;; esac
grep -vxF "$line" "$TMP/good" > "$TMP/cfg-missing"
if req_assert_config "$TMP/cfg-missing" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1; then missing_bad=$((missing_bad+1)); echo " not caught: $line"
else missing_ok=$((missing_ok+1)); fi
done < <(req_assertions "$REQ"; req_assertions "$PROBE")
[ "$missing_bad" = 0 ] && ok "dropping any one of $missing_ok =y assertions fails the check" || bad "$missing_bad dropped symbols were not caught"
# =m is not =y
sed 's/^CONFIG_NFT_CT=y$/CONFIG_NFT_CT=m/' "$TMP/good" > "$TMP/cfg-m"
req_assert_config "$TMP/cfg-m" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 && bad "a modular symbol was accepted" || ok "a symbol built as a module is refused"
# unset assertions: a live value fails, absence and 'is not set' pass
for sym in $(req_assertions "$REQ" | sed -n 's/^# \(CONFIG_[A-Z0-9_]*\) is not set$/\1/p'); do
{ cat "$TMP/good"; echo "$sym=y"; } > "$TMP/cfg-set"
req_assert_config "$TMP/cfg-set" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 && bad "$sym=y was accepted although it must stay unset" || ok "$sym=y is refused (must stay unset)"
grep -vF "$sym" "$TMP/good" > "$TMP/cfg-absent"
req_assert_config "$TMP/cfg-absent" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 && ok "$sym absent from the config is accepted" || bad "$sym absent from the config was refused"
done
# No suspend (Noah 2026-10-09): CONFIG_SUSPEND and CONFIG_PM_SLEEP are asserted unset, the
# defconfig carries the explicit unset (SUSPEND defaults to y), and a config that
# turns either back on is refused by name.
DEFCONFIG="$REPO/build/warden_defconfig"
for sym in CONFIG_SUSPEND CONFIG_PM_SLEEP; do
req_assertions "$REQ" | grep -qxF "# $sym is not set" \
&& ok "required-symbols.txt asserts $sym unset" || bad "required-symbols.txt does not assert $sym unset"
{ cat "$TMP/good"; echo "$sym=y"; } > "$TMP/cfg-suspend"
out=$(req_assert_config "$TMP/cfg-suspend" "$REQ" ${PROBES[@]+"${PROBES[@]}"} 2>&1) && bad "$sym=y was accepted" \
|| { printf '%s' "$out" | grep -q "$sym" && ok "$sym=y is refused naming $sym" || bad "$sym=y was refused without naming it"; }
done
grep -qxF '# CONFIG_SUSPEND is not set' "$DEFCONFIG" \
&& ok "warden_defconfig carries the explicit # CONFIG_SUSPEND is not set" \
|| bad "warden_defconfig lost the explicit # CONFIG_SUSPEND is not set (the Kconfig default is y)"
grep -qE '^CONFIG_SUSPEND=' "$DEFCONFIG" && bad "warden_defconfig sets CONFIG_SUSPEND" || ok "warden_defconfig does not set CONFIG_SUSPEND"
# Probe V3 passed (2026-10-09): the hardware RNG symbols are required, the probe list is empty, and
# the config digest does not move because the defconfig already built them in.
for sym in CONFIG_HW_RANDOM CONFIG_HW_RANDOM_ROCKCHIP; do
req_assertions "$REQ" | grep -qxF "$sym=y" && ok "required-symbols.txt asserts $sym=y (V3 passed)" || bad "required-symbols.txt lost $sym=y"
grep -qxF "$sym=y" "$DEFCONFIG" && ok "warden_defconfig builds $sym in" || bad "warden_defconfig does not set $sym=y"
{ cat "$TMP/good"; } | grep -vxF "$sym=y" > "$TMP/cfg-norng"
out=$(req_assert_config "$TMP/cfg-norng" "$REQ" 2>&1) && bad "a config without $sym was accepted" \
|| { printf '%s' "$out" | grep -q "$sym" && ok "a config without $sym is refused naming it" || bad "refusal did not name $sym"; }
done
[ -z "$(req_assertions "$PROBE")" ] && ok "probe-symbols.txt is empty: every probe has passed" \
|| ok "probe-symbols.txt holds $(req_assertions "$PROBE" | wc -l) pending probe symbol(s)"
# fail-closed shapes
: > "$TMP/empty"
req_assert_config "$TMP/empty" "$REQ" >/dev/null 2>&1 && bad "an empty config was accepted" || ok "an empty config is refused"
req_assert_config "$TMP/good" "$TMP/no-such-list" >/dev/null 2>&1 && bad "a missing list was accepted" || ok "a missing symbol list is refused"
printf '## only comments\n# a comment\n' > "$TMP/no-assertions"
req_assert_config "$TMP/good" "$TMP/no-assertions" >/dev/null 2>&1 && bad "a list with no assertions was accepted" || ok "a list with no assertions is refused"
# comment handling: a prose line starting "# CONFIG_" without "is not set" is a comment
printf '## c\n# CONFIG_PROSE is the name of a thing\nCONFIG_REAL=y\n' > "$TMP/prose"
[ "$(req_assertions "$TMP/prose")" = "CONFIG_REAL=y" ] && ok "a prose comment is not an assertion" || bad "a prose comment was parsed as an assertion"
# the lists: a symbol is asserted once, in one list
dups=$( { req_assertions "$REQ"; req_assertions "$PROBE"; } | sed 's/^# //; s/ is not set//; s/=.*//' | sort | uniq -d | tr '\n' ' ')
# a symbol that passed its probe moves to the required list; it must not stay in both
[ -z "$dups" ] && ok "no symbol is asserted twice across the lists" || bad "symbols asserted twice: $dups"
# build-kernel.sh entry checks (they run before the tarball is touched)
BK="$REPO/build/build-kernel.sh"
out=$(WARDEN_CONFIG_ONLY=2 bash "$BK" 2>&1); rc=$?
[ "$rc" != 0 ] && printf '%s' "$out" | grep -q 'WARDEN_CONFIG_ONLY must be 0 or 1' \
&& ok "WARDEN_CONFIG_ONLY=2 is refused" || bad "WARDEN_CONFIG_ONLY=2 was not refused"
mkdir -p "$TMP/bin"; printf '#!/bin/sh\nexit 0\n' > "$TMP/bin/python"; chmod +x "$TMP/bin/python"
out=$(env -u WORK -u CONFIG_OUT PATH="$TMP/bin:$PATH" WARDEN_CONFIG_ONLY=1 bash "$BK" 2>&1); rc=$?
[ "$rc" != 0 ] && printf '%s' "$out" | grep -q 'needs CONFIG_OUT' \
&& ok "config-only with a scratch WORK and no CONFIG_OUT is refused (the result would be deleted)" \
|| bad "config-only without CONFIG_OUT was not refused: $out"
# wiring text
grep -q 'req_assert_config "\$SRC/.config" "\$REQ_SYMBOLS" \${PROBE_LISTS' "$BK" \
&& ok "build-kernel.sh asserts both lists" || bad "build-kernel.sh does not assert the lists"
grep -q 'for sym in CONFIG_' "$BK" && bad "build-kernel.sh has a hand-written symbol list again" || ok "build-kernel.sh has no hand-written list"
if [ "$FAIL" -eq 0 ]; then echo "ALL REQUIRED-SYMBOLS TESTS PASSED"; else echo "REQUIRED-SYMBOLS TESTS FAILED"; fi
exit $FAIL
+138
View File
@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# Regression tests for build/unpack-buildroot.sh (blueflare/bfe-core1106-sdk#4).
#
# A clean vendor checkout plus luckfox-sdk-patches/ could not build WardenOS
# because nothing put buildroot-2025.02.8 where the SDK builds it. The unpack
# script is now the thing that does, and the persistent CI SDK depends on it
# leaving an existing tree alone. These cases pin both halves: a fresh SDK
# gets a complete tree, an existing tree is never touched or re-fetched, and
# every refusal (unpatched selectors, a bad tarball, a half-present tree, a
# failed fetch) leaves no tree and no scratch directory behind.
#
# Runs the real script, copied beside a stub fetch-buildroot-tarball.sh that
# copies a local fixture tarball instead of downloading. No network, no SDK.
set -uo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
SCRIPT="$HERE/../../build/unpack-buildroot.sh"
[ -f "$SCRIPT" ] || { echo "FAIL: script not found at $SCRIPT"; exit 1; }
FAIL=0
ok() { printf '[PASS] %s\n' "$1"; }
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
TMP="$(mktemp -d)" || { echo "FAIL: mktemp -d failed"; exit 1; }
[ -d "$TMP" ] || { echo "FAIL: mktemp -d failed"; exit 1; }
trap 'rm -rf "$TMP"' EXIT
VER=2025.02.8
# Fixture tarballs: a minimal Buildroot-shaped tree, and one without Makefile.
mk_tarball() { # mk_tarball <out.tar.xz> <with-makefile:0|1>
local out="$1" mf="$2" src
src="$(mktemp -d "$TMP/src.XXXXXX")"
mkdir -p "$src/buildroot-$VER/configs" "$src/buildroot-$VER/package/busybox"
printf 'CONFIG\n' > "$src/buildroot-$VER/package/busybox/busybox.config"
[ "$mf" = 1 ] && printf 'all:\n' > "$src/buildroot-$VER/Makefile"
tar -cJf "$out" -C "$src" "buildroot-$VER"
}
mk_tarball "$TMP/good.tar.xz" 1
mk_tarball "$TMP/nomakefile.tar.xz" 0
# setup <case> <tarball-or-FAIL> -> fixture dir holding build/ and sdk/
setup() {
local dir="$TMP/$1" src="$2"
mkdir -p "$dir/build" "$dir/sdk/project" "$dir/sdk/sysdrv/source/buildroot"
cp "$SCRIPT" "$dir/build/unpack-buildroot.sh"
{
echo '#!/usr/bin/env bash'
echo "BRVER=$VER"
echo "echo fetch-called >> \"$dir/fetch-calls\""
if [ "$src" = FAIL ]; then echo 'exit 1'; else echo "cp \"$src\" \"\$1\""; fi
} > "$dir/build/fetch-buildroot-tarball.sh"
# shellcheck disable=SC2016 # build.sh carries the literal text
printf 'BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-%s\n' "$VER" \
> "$dir/sdk/project/build.sh"
printf 'BUILDROOT_VER ?= buildroot-%s\n' "$VER" > "$dir/sdk/sysdrv/Makefile"
printf '%s' "$dir"
}
run() { # run <dir> -> $OUT, $RC
OUT="$(bash "$1/build/unpack-buildroot.sh" "$1/sdk" 2>&1)"; RC=$?
}
tree() { printf '%s' "$1/sdk/sysdrv/source/buildroot/buildroot-$VER"; }
fetches() { [ -f "$1/fetch-calls" ] && wc -l < "$1/fetch-calls" || echo 0; }
no_scratch() { ! compgen -G "$1/sdk/sysdrv/source/buildroot/.unpack-buildroot.*" >/dev/null; }
# A. Fresh SDK: fetched once, unpacked to the selected path, no scratch left.
d="$(setup fresh "$TMP/good.tar.xz")"; run "$d"
if [ "$RC" -eq 0 ] && [ -f "$(tree "$d")/Makefile" ] && [ -f "$(tree "$d")/package/busybox/busybox.config" ] \
&& [ "$(fetches "$d")" -eq 1 ] && no_scratch "$d"; then
ok "fresh SDK: tree unpacked, one fetch, no scratch left"
else
bad "fresh SDK: tree unpacked, one fetch, no scratch left (rc=$RC, out=$OUT)"
fi
# B. Rerun on that SDK: already present, no second fetch, content untouched.
printf 'LOCAL\n' > "$(tree "$d")/package/busybox/busybox.config"
run "$d"
if [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'tree already present' \
&& [ "$(fetches "$d")" -eq 1 ] && grep -qx LOCAL "$(tree "$d")/package/busybox/busybox.config"; then
ok "existing tree: left alone, not re-fetched"
else
bad "existing tree: left alone, not re-fetched (rc=$RC, out=$OUT)"
fi
# C. project/build.sh still selects the vendor tree: refuse, fetch nothing.
d="$(setup unpatched-build "$TMP/good.tar.xz")"
# shellcheck disable=SC2016 # build.sh carries the literal text
printf 'BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2023.02.6\n' > "$d/sdk/project/build.sh"
run "$d"
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'project/build.sh selects' \
&& [ "$(fetches "$d")" -eq 0 ] && [ ! -e "$(tree "$d")" ]; then
ok "unpatched project/build.sh: refused before fetching"
else
bad "unpatched project/build.sh: refused before fetching (rc=$RC, out=$OUT)"
fi
# D. sysdrv/Makefile still selects the vendor tree: refuse, fetch nothing.
d="$(setup unpatched-make "$TMP/good.tar.xz")"
printf 'BUILDROOT_VER ?= buildroot-2023.02.6\n' > "$d/sdk/sysdrv/Makefile"
run "$d"
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'sysdrv/Makefile selects' \
&& [ "$(fetches "$d")" -eq 0 ] && [ ! -e "$(tree "$d")" ]; then
ok "unpatched sysdrv/Makefile: refused before fetching"
else
bad "unpatched sysdrv/Makefile: refused before fetching (rc=$RC, out=$OUT)"
fi
# E. Tarball without a Buildroot Makefile: refuse, no tree, no scratch.
d="$(setup bad-tarball "$TMP/nomakefile.tar.xz")"; run "$d"
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'did not contain' \
&& [ ! -e "$(tree "$d")" ] && no_scratch "$d"; then
ok "tarball without Makefile: refused, nothing left behind"
else
bad "tarball without Makefile: refused, nothing left behind (rc=$RC, out=$OUT)"
fi
# F. A half-present tree (an interrupted hand unpack): refuse, keep it as is.
d="$(setup half-tree "$TMP/good.tar.xz")"
mkdir -p "$(tree "$d")/output"; printf 'keep\n' > "$(tree "$d")/output/marker"
run "$d"
if [ "$RC" -ne 0 ] && printf '%s' "$OUT" | grep -q 'not a complete Buildroot tree' \
&& [ -f "$(tree "$d")/output/marker" ] && [ "$(fetches "$d")" -eq 0 ]; then
ok "half-present tree: refused and left untouched"
else
bad "half-present tree: refused and left untouched (rc=$RC, out=$OUT)"
fi
# G. Fetch fails (network down, sha256 mismatch): nonzero, no tree.
d="$(setup fetch-fails FAIL)"; run "$d"
if [ "$RC" -ne 0 ] && [ ! -e "$(tree "$d")" ] && no_scratch "$d"; then
ok "failed fetch: nonzero, no tree"
else
bad "failed fetch: nonzero, no tree (rc=$RC, out=$OUT)"
fi
if [ "$FAIL" -eq 0 ]; then echo "ALL UNPACK-BUILDROOT TESTS PASSED"; else echo "UNPACK-BUILDROOT TESTS FAILED"; fi
exit "$FAIL"