Update mini USB proof entrypoints

This commit is contained in:
2026-04-19 17:56:59 +01:00
parent ec07831732
commit d59c33711c
4 changed files with 128 additions and 59 deletions
+45 -13
View File
@@ -2,14 +2,12 @@
# build-redbear.sh — Build Red Bear OS from upstream base + Red Bear overlay # build-redbear.sh — Build Red Bear OS from upstream base + Red Bear overlay
# #
# Usage: # Usage:
# ./local/scripts/build-redbear.sh # Default: redbear-kde # ./local/scripts/build-redbear.sh # Default: redbear-full
# ./local/scripts/build-redbear.sh redbear-minimal # Minimal validation baseline # ./local/scripts/build-redbear.sh redbear-mini # Minimal validation baseline
# ./local/scripts/build-redbear.sh redbear-bluetooth-experimental # First bounded Bluetooth slice # ./local/scripts/build-redbear.sh redbear-full # Full Red Bear desktop/session target
# ./local/scripts/build-redbear.sh redbear-full # Full Red Bear integration target # ./local/scripts/build-redbear.sh redbear-live-mini # Live ISO for minimal target
# ./local/scripts/build-redbear.sh redbear-wayland # Bounded Wayland runtime validation profile # ./local/scripts/build-redbear.sh redbear-live-full # Live ISO for full target
# ./local/scripts/build-redbear.sh redbear-kde # Tracked KWin Wayland desktop target # ./local/scripts/build-redbear.sh --upstream redbear-full # Allow Redox/upstream recipe refresh
# ./local/scripts/build-redbear.sh redbear-live # Live ISO variant
# ./local/scripts/build-redbear.sh --upstream redbear-kde # Allow Redox/upstream recipe refresh
# APPLY_PATCHES=0 ./local/scripts/build-redbear.sh # Skip patch application # APPLY_PATCHES=0 ./local/scripts/build-redbear.sh # Skip patch application
# #
# This script assumes the Red Bear overlay model: # This script assumes the Red Bear overlay model:
@@ -21,7 +19,7 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
CONFIG="redbear-kde" CONFIG="redbear-full"
JOBS="${JOBS:-$(nproc)}" JOBS="${JOBS:-$(nproc)}"
APPLY_PATCHES="${APPLY_PATCHES:-1}" APPLY_PATCHES="${APPLY_PATCHES:-1}"
ALLOW_UPSTREAM=0 ALLOW_UPSTREAM=0
@@ -37,8 +35,7 @@ Options:
-h, --help Show this help -h, --help Show this help
Configs: Configs:
redbear-desktop, redbear-minimal, redbear-bluetooth-experimental, redbear-mini, redbear-live-mini, redbear-full, redbear-live-full
redbear-full, redbear-wayland, redbear-kde, redbear-live
EOF EOF
} }
@@ -73,11 +70,17 @@ fi
[ ${#POSITIONAL[@]} -eq 1 ] && CONFIG="${POSITIONAL[0]}" [ ${#POSITIONAL[@]} -eq 1 ] && CONFIG="${POSITIONAL[0]}"
case "$CONFIG" in case "$CONFIG" in
redbear-desktop|redbear-minimal|redbear-bluetooth-experimental|redbear-full|redbear-wayland|redbear-kde|redbear-live) redbear-mini)
CONFIG="redbear-minimal"
;;
redbear-live-mini)
CONFIG="redbear-live-minimal"
;;
redbear-minimal|redbear-full|redbear-live-minimal|redbear-live-full)
;; ;;
*) *)
echo "ERROR: Unknown config '$CONFIG'" echo "ERROR: Unknown config '$CONFIG'"
echo "Supported: redbear-desktop, redbear-minimal, redbear-bluetooth-experimental, redbear-full, redbear-wayland, redbear-kde, redbear-live" echo "Supported: redbear-mini, redbear-live-mini, redbear-full, redbear-live-full"
exit 1 exit 1
;; ;;
esac esac
@@ -109,6 +112,31 @@ stash_nested_repo_if_dirty() {
stash_nested_repo_if_dirty "$PROJECT_ROOT/recipes/core/relibc/source" "relibc" stash_nested_repo_if_dirty "$PROJECT_ROOT/recipes/core/relibc/source" "relibc"
ensure_relibc_desktop_surface() {
local relibc_target="$PROJECT_ROOT/recipes/core/relibc/target/x86_64-unknown-redox"
local relibc_stage_include="$relibc_target/stage/usr/include"
local relibc_stage_lib="$relibc_target/stage/usr/lib/libc.so"
if [ ! -f "$relibc_stage_include/sys/signalfd.h" ] || \
[ ! -f "$relibc_stage_include/sys/timerfd.h" ] || \
[ ! -f "$relibc_stage_include/sys/eventfd.h" ] || \
[ ! -f "$relibc_stage_lib" ] || \
! readelf -Ws "$relibc_stage_lib" | grep -q '_Z7strtoldPKcPPc'; then
echo ">>> Refreshing relibc staged surface for full desktop target..."
rm -rf \
"$relibc_target/build" \
"$relibc_target/stage" \
"$relibc_target/stage.tmp" \
"$relibc_target/sysroot"
rm -f \
"$relibc_target/auto_deps.toml" \
"$relibc_target/stage.pkgar" \
"$relibc_target/stage.toml"
REPO_OFFLINE=1 COOKBOOK_OFFLINE=true CI=1 ./target/release/repo cook relibc
echo ""
fi
}
# Step 0: Apply local patches # Step 0: Apply local patches
if [ "$APPLY_PATCHES" = "1" ]; then if [ "$APPLY_PATCHES" = "1" ]; then
echo ">>> Applying local patches..." echo ">>> Applying local patches..."
@@ -172,6 +200,10 @@ if [ ! -f "target/release/repo" ]; then
cargo build --release cargo build --release
fi fi
if [ "$CONFIG" = "redbear-full" ] || [ "$CONFIG" = "redbear-live-full" ]; then
ensure_relibc_desktop_surface
fi
# Step 2: Check firmware # Step 2: Check firmware
FW_AMD_DIR="$PROJECT_ROOT/local/firmware/amdgpu" FW_AMD_DIR="$PROJECT_ROOT/local/firmware/amdgpu"
if [ "$CONFIG" != "redbear-minimal" ]; then if [ "$CONFIG" != "redbear-minimal" ]; then
+10 -2
View File
@@ -10,10 +10,11 @@ usage() {
Usage: test-usb-maturity-qemu.sh [config] Usage: test-usb-maturity-qemu.sh [config]
Run the bounded USB maturity proof helpers in sequence. Run the bounded USB maturity proof helpers in sequence.
Defaults to redbear-desktop. Defaults to redbear-mini (mapped to the in-tree redbear-minimal image).
Checks run: Checks run:
- xHCI interrupt mode - xHCI interrupt mode
- xHCI device lifecycle hotplug proof
- full USB stack proof - full USB stack proof
- USB storage bounded readback proof - USB storage bounded readback proof
USAGE USAGE
@@ -28,11 +29,18 @@ for arg in "$@"; do
esac esac
done done
config="${1:-redbear-desktop}" config="${1:-redbear-mini}"
if [[ "$config" == "redbear-mini" ]]; then
config="redbear-minimal"
fi
echo ">>> Running xHCI interrupt proof" echo ">>> Running xHCI interrupt proof"
bash "$SCRIPT_DIR/test-xhci-irq-qemu.sh" --check "$config" bash "$SCRIPT_DIR/test-xhci-irq-qemu.sh" --check "$config"
echo ">>> Running xHCI device lifecycle proof"
bash "$SCRIPT_DIR/test-xhci-device-lifecycle-qemu.sh" --check "$config"
echo ">>> Running full USB stack proof" echo ">>> Running full USB stack proof"
bash "$SCRIPT_DIR/test-usb-qemu.sh" --check "$config" bash "$SCRIPT_DIR/test-usb-qemu.sh" --check "$config"
+54 -36
View File
@@ -50,7 +50,7 @@ usage() {
Usage: test-usb-qemu.sh [--check] [config] Usage: test-usb-qemu.sh [--check] [config]
Boot or validate the full USB stack on a Red Bear image in QEMU. Boot or validate the full USB stack on a Red Bear image in QEMU.
Defaults to redbear-desktop. Defaults to redbear-mini (mapped to the in-tree redbear-minimal image).
Checks performed: Checks performed:
1. xHCI controller initializes and reports interrupt mode 1. xHCI controller initializes and reports interrupt mode
@@ -63,7 +63,7 @@ USAGE
} }
check_mode=0 check_mode=0
config="redbear-desktop" config="redbear-mini"
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
--help|-h|help) --help|-h|help)
@@ -79,6 +79,10 @@ for arg in "$@"; do
esac esac
done done
if [[ "$config" == "redbear-mini" ]]; then
config="redbear-minimal"
fi
firmware="$(find_uefi_firmware)" || { firmware="$(find_uefi_firmware)" || {
echo "ERROR: no usable x86_64 UEFI firmware found" >&2 echo "ERROR: no usable x86_64 UEFI firmware found" >&2
exit 1 exit 1
@@ -112,38 +116,40 @@ sleep 1
rm -f "$log_file" rm -f "$log_file"
set +e set +e
timeout 120s qemu-system-x86_64 \ expect <<EOF
-name "Red Bear OS USB Test" \ log_user 1
-device qemu-xhci,id=xhci \ log_file -noappend $log_file
-smp 4 \ set timeout 300
-m 2048 \ spawn qemu-system-x86_64 -name {Red Bear OS USB Test} -device qemu-xhci,id=xhci -smp 4 -m 2048 -bios $firmware -chardev stdio,id=debug,signal=off,mux=on -serial chardev:debug -mon chardev=debug -machine q35 -device ich9-intel-hda -device hda-output -device virtio-net,netdev=net0 -netdev user,id=net0 -nographic -vga none -drive file=$image,format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL -drive file=$extra,format=raw,if=none,id=drv1,snapshot=on -device nvme,drive=drv1,serial=NVME_EXTRA -drive file=$usb_img,format=raw,if=none,id=usbdisk,snapshot=on -device usb-storage,bus=xhci.0,drive=usbdisk -device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 -enable-kvm -cpu host
-bios "$firmware" \ expect -re {xhcid: using MSI/MSI-X interrupt delivery|xhcid: using legacy INTx interrupt delivery}
-chardev stdio,id=debug,signal=off,mux=on \ send_log "MILESTONE:XHCI_IRQ\n"
-serial chardev:debug \ expect "USB HID driver spawned"
-mon chardev=debug \ send_log "MILESTONE:USB_HID\n"
-machine q35 \ expect "USB SCSI driver spawned"
-device ich9-intel-hda -device hda-output \ send_log "MILESTONE:USB_SCSI\n"
-device virtio-net,netdev=net0 \ expect "DISK CONTENT: $expected_sector_b64"
-netdev user,id=net0 \ send_log "MILESTONE:USB_READBACK\n"
-nographic -vga none \ expect "login:"
-drive file="$image",format=raw,if=none,id=drv0 \ send_log "MILESTONE:LOGIN\n"
-device nvme,drive=drv0,serial=NVME_SERIAL \ send "root\r"
-drive file="$extra",format=raw,if=none,id=drv1 \ expect "assword:"
-device nvme,drive=drv1,serial=NVME_EXTRA \ send "password\r"
-drive file="$usb_img",format=raw,if=none,id=usbdisk \ expect "Type 'help' for available commands."
-device usb-storage,bus=xhci.0,drive=usbdisk \ send_log "MILESTONE:SHELL\n"
-device usb-kbd,bus=xhci.0 \ send "shutdown\r"
-device usb-tablet,bus=xhci.0 \ sleep 2
-enable-kvm -cpu host \ EOF
> "$log_file" 2>&1 expect_status=$?
set -e set -e
pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true
failures=0 failures=0
echo "--- USB Stack Validation: $config ---" echo "--- USB Stack Validation: $config ---"
# Check 1: xHCI interrupt mode # Check 1: xHCI interrupt mode
if grep -q "xhcid: using MSI/MSI-X interrupt delivery\|xhcid: using legacy INTx interrupt delivery" "$log_file"; then if grep -aq "MILESTONE:XHCI_IRQ" "$log_file"; then
echo " [PASS] xHCI interrupt-driven mode detected" echo " [PASS] xHCI interrupt-driven mode detected"
else else
echo " [FAIL] xHCI did not report interrupt-driven mode" >&2 echo " [FAIL] xHCI did not report interrupt-driven mode" >&2
@@ -151,7 +157,7 @@ else
fi fi
# Check 2: USB HID driver spawn # Check 2: USB HID driver spawn
if grep -q "USB HID driver spawned" "$log_file"; then if grep -aq "MILESTONE:USB_HID" "$log_file"; then
echo " [PASS] USB HID driver spawned" echo " [PASS] USB HID driver spawned"
else else
echo " [FAIL] USB HID driver did not spawn" >&2 echo " [FAIL] USB HID driver did not spawn" >&2
@@ -159,44 +165,56 @@ else
fi fi
# Check 3: USB SCSI driver spawn + bounded data readback # Check 3: USB SCSI driver spawn + bounded data readback
if grep -q "USB SCSI driver spawned" "$log_file"; then if grep -aq "MILESTONE:USB_SCSI" "$log_file"; then
echo " [PASS] USB SCSI driver spawned" echo " [PASS] USB SCSI driver spawned"
else else
echo " [FAIL] USB SCSI driver did not spawn" >&2 echo " [FAIL] USB SCSI driver did not spawn" >&2
failures=$((failures + 1)) failures=$((failures + 1))
fi fi
if grep -Fq "DISK CONTENT: $expected_sector_b64" "$log_file"; then if grep -aq "MILESTONE:USB_READBACK" "$log_file"; then
echo " [PASS] USB storage sector readback matched seeded pattern" echo " [PASS] USB storage sector readback matched seeded pattern"
else else
echo " [FAIL] USB storage sector readback did not match seeded pattern" >&2 echo " [FAIL] USB storage sector readback milestone was never reached" >&2
failures=$((failures + 1)) failures=$((failures + 1))
fi fi
# Check 4: BOS descriptor handling (info or debug log) # Check 4: BOS descriptor handling (info or debug log)
if grep -q "BOS:" "$log_file"; then if grep -aq "BOS:" "$log_file"; then
echo " [PASS] BOS descriptor processing active" echo " [PASS] BOS descriptor processing active"
elif grep -q "BOS descriptor not available" "$log_file"; then elif grep -aq "BOS descriptor not available" "$log_file"; then
echo " [PASS] BOS descriptor gracefully skipped (USB 2 device)" echo " [PASS] BOS descriptor gracefully skipped (USB 2 device)"
else else
echo " [WARN] No BOS descriptor log output found" echo " [WARN] No BOS descriptor log output found"
fi fi
# Check 5: No panics or crash-class errors (stall recovery messages are expected) # Check 5: No panics or crash-class errors (stall recovery messages are expected)
if grep -qi "panic\|usbscsid: .*IO ERROR\|usbscsid: startup failed\|usbhidd: .*IO ERROR" "$log_file"; then if grep -aqi "panic\|usbscsid: .*IO ERROR\|usbscsid: startup failed\|usbhidd: .*IO ERROR" "$log_file"; then
echo " [FAIL] USB stack hit crash-class errors" >&2 echo " [FAIL] USB stack hit crash-class errors" >&2
failures=$((failures + 1)) failures=$((failures + 1))
else else
echo " [PASS] No crash-class errors detected" echo " [PASS] No crash-class errors detected"
fi fi
# Check 6: Hub driver (if hub detected) # Check 6: Boot progressed far enough to reach the guest shell
if grep -q "USB HUB driver spawned" "$log_file"; then if grep -aq "MILESTONE:SHELL" "$log_file"; then
echo " [PASS] Full USB stack boot reached guest shell"
else
echo " [FAIL] Full USB stack run never reached guest shell" >&2
failures=$((failures + 1))
fi
# Check 7: Hub driver (if hub detected)
if grep -aq "USB HUB driver spawned" "$log_file"; then
echo " [PASS] USB hub driver spawned" echo " [PASS] USB hub driver spawned"
else else
echo " [INFO] No hub driver spawn (expected for direct-attached devices)" echo " [INFO] No hub driver spawn (expected for direct-attached devices)"
fi fi
if [[ "$expect_status" -ne 0 ]]; then
echo " [INFO] expect exited with status $expect_status; milestone checks above determine pass/fail"
fi
echo "--- Results: $failures failure(s), log: $log_file ---" echo "--- Results: $failures failure(s), log: $log_file ---"
if [[ "$failures" -gt 0 ]]; then if [[ "$failures" -gt 0 ]]; then
+19 -8
View File
@@ -28,11 +28,12 @@ usage() {
Usage: test-xhci-irq-qemu.sh [--check] [config] Usage: test-xhci-irq-qemu.sh [--check] [config]
Boot or validate xHCI interrupt-mode bring-up on a Red Bear image in QEMU. Boot or validate xHCI interrupt-mode bring-up on a Red Bear image in QEMU.
Defaults to redbear-mini (mapped to the in-tree redbear-minimal image).
USAGE USAGE
} }
check_mode=0 check_mode=0
config="redbear-desktop" config="redbear-mini"
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
--help|-h|help) --help|-h|help)
@@ -48,6 +49,10 @@ for arg in "$@"; do
esac esac
done done
if [[ "$config" == "redbear-mini" ]]; then
config="redbear-minimal"
fi
firmware="$(find_uefi_firmware)" || { firmware="$(find_uefi_firmware)" || {
echo "ERROR: no usable x86_64 UEFI firmware found" >&2 echo "ERROR: no usable x86_64 UEFI firmware found" >&2
exit 1 exit 1
@@ -76,7 +81,9 @@ if [[ "$check_mode" -eq 1 ]]; then
set +e set +e
timeout 90s qemu-system-x86_64 \ timeout 90s qemu-system-x86_64 \
-name "Red Bear OS x86_64" \ -name "Red Bear OS x86_64" \
-device qemu-xhci \ -device qemu-xhci,id=xhci \
-device usb-kbd,bus=xhci.0 \
-device usb-tablet,bus=xhci.0 \
-smp 4 \ -smp 4 \
-m 2048 \ -m 2048 \
-bios "$firmware" \ -bios "$firmware" \
@@ -89,25 +96,29 @@ if [[ "$check_mode" -eq 1 ]]; then
-netdev user,id=net0 \ -netdev user,id=net0 \
-object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \
-nographic -vga none \ -nographic -vga none \
-drive file="$image",format=raw,if=none,id=drv0 \ -drive file="$image",format=raw,if=none,id=drv0,snapshot=on \
-device nvme,drive=drv0,serial=NVME_SERIAL \ -device nvme,drive=drv0,serial=NVME_SERIAL \
-drive file="$extra",format=raw,if=none,id=drv1 \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \
-device nvme,drive=drv1,serial=NVME_EXTRA \ -device nvme,drive=drv1,serial=NVME_EXTRA \
-enable-kvm -cpu host \ -enable-kvm -cpu host \
> "$log_file" 2>&1 > "$log_file" 2>&1
status=$? status=$?
set -e set -e
if ! grep -q "xhcid: using MSI/MSI-X interrupt delivery\|xhcid: using legacy INTx interrupt delivery" "$log_file"; then if ! grep -q "xhcid: using MSI/MSI-X interrupt delivery\|xhcid: using legacy INTx interrupt delivery\|XHCI .* IRQ:" "$log_file"; then
echo "ERROR: xhcid did not report an interrupt-driven mode; see $log_file" >&2 echo "ERROR: xhcid did not report an interrupt-driven mode; see $log_file" >&2
exit 1 exit 1
fi fi
if ! grep -q "xhcid: begin attach for port\|xhcid: queueing initial enumeration for port" "$log_file"; then
echo "ERROR: xhcid interrupt-mode proof never observed attached-device enumeration pressure; see $log_file" >&2
exit 1
fi
echo "xHCI interrupt mode detected in $log_file" echo "xHCI interrupt mode detected in $log_file"
exit 0 exit 0
fi fi
exec qemu-system-x86_64 \ exec qemu-system-x86_64 \
-name "Red Bear OS x86_64" \ -name "Red Bear OS x86_64" \
-device qemu-xhci \ -device qemu-xhci,id=xhci \
-smp 4 \ -smp 4 \
-m 2048 \ -m 2048 \
-bios "$firmware" \ -bios "$firmware" \
@@ -120,8 +131,8 @@ exec qemu-system-x86_64 \
-netdev user,id=net0 \ -netdev user,id=net0 \
-object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \
-vga std \ -vga std \
-drive file="$image",format=raw,if=none,id=drv0 \ -drive file="$image",format=raw,if=none,id=drv0,snapshot=on \
-device nvme,drive=drv0,serial=NVME_SERIAL \ -device nvme,drive=drv0,serial=NVME_SERIAL \
-drive file="$extra",format=raw,if=none,id=drv1 \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \
-device nvme,drive=drv1,serial=NVME_EXTRA \ -device nvme,drive=drv1,serial=NVME_EXTRA \
-enable-kvm -cpu host -enable-kvm -cpu host