diff --git a/local/scripts/build-redbear.sh b/local/scripts/build-redbear.sh index 794100f1..a4063235 100755 --- a/local/scripts/build-redbear.sh +++ b/local/scripts/build-redbear.sh @@ -2,14 +2,12 @@ # build-redbear.sh — Build Red Bear OS from upstream base + Red Bear overlay # # Usage: -# ./local/scripts/build-redbear.sh # Default: redbear-kde -# ./local/scripts/build-redbear.sh redbear-minimal # 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 integration target -# ./local/scripts/build-redbear.sh redbear-wayland # Bounded Wayland runtime validation profile -# ./local/scripts/build-redbear.sh redbear-kde # Tracked KWin Wayland desktop target -# ./local/scripts/build-redbear.sh redbear-live # Live ISO variant -# ./local/scripts/build-redbear.sh --upstream redbear-kde # Allow Redox/upstream recipe refresh +# ./local/scripts/build-redbear.sh # Default: redbear-full +# ./local/scripts/build-redbear.sh redbear-mini # Minimal validation baseline +# ./local/scripts/build-redbear.sh redbear-full # Full Red Bear desktop/session target +# ./local/scripts/build-redbear.sh redbear-live-mini # Live ISO for minimal target +# ./local/scripts/build-redbear.sh redbear-live-full # Live ISO for full target +# ./local/scripts/build-redbear.sh --upstream redbear-full # Allow Redox/upstream recipe refresh # APPLY_PATCHES=0 ./local/scripts/build-redbear.sh # Skip patch application # # This script assumes the Red Bear overlay model: @@ -21,7 +19,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" -CONFIG="redbear-kde" +CONFIG="redbear-full" JOBS="${JOBS:-$(nproc)}" APPLY_PATCHES="${APPLY_PATCHES:-1}" ALLOW_UPSTREAM=0 @@ -37,8 +35,7 @@ Options: -h, --help Show this help Configs: - redbear-desktop, redbear-minimal, redbear-bluetooth-experimental, - redbear-full, redbear-wayland, redbear-kde, redbear-live + redbear-mini, redbear-live-mini, redbear-full, redbear-live-full EOF } @@ -73,11 +70,17 @@ fi [ ${#POSITIONAL[@]} -eq 1 ] && CONFIG="${POSITIONAL[0]}" 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 "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 ;; esac @@ -109,6 +112,31 @@ stash_nested_repo_if_dirty() { 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 if [ "$APPLY_PATCHES" = "1" ]; then echo ">>> Applying local patches..." @@ -172,6 +200,10 @@ if [ ! -f "target/release/repo" ]; then cargo build --release fi +if [ "$CONFIG" = "redbear-full" ] || [ "$CONFIG" = "redbear-live-full" ]; then + ensure_relibc_desktop_surface +fi + # Step 2: Check firmware FW_AMD_DIR="$PROJECT_ROOT/local/firmware/amdgpu" if [ "$CONFIG" != "redbear-minimal" ]; then diff --git a/local/scripts/test-usb-maturity-qemu.sh b/local/scripts/test-usb-maturity-qemu.sh index 64ab915d..b4c15c04 100755 --- a/local/scripts/test-usb-maturity-qemu.sh +++ b/local/scripts/test-usb-maturity-qemu.sh @@ -10,10 +10,11 @@ usage() { Usage: test-usb-maturity-qemu.sh [config] 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: - xHCI interrupt mode + - xHCI device lifecycle hotplug proof - full USB stack proof - USB storage bounded readback proof USAGE @@ -28,11 +29,18 @@ for arg in "$@"; do esac done -config="${1:-redbear-desktop}" +config="${1:-redbear-mini}" + +if [[ "$config" == "redbear-mini" ]]; then + config="redbear-minimal" +fi echo ">>> Running xHCI interrupt proof" 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" bash "$SCRIPT_DIR/test-usb-qemu.sh" --check "$config" diff --git a/local/scripts/test-usb-qemu.sh b/local/scripts/test-usb-qemu.sh index ed2debfc..e45d45a8 100755 --- a/local/scripts/test-usb-qemu.sh +++ b/local/scripts/test-usb-qemu.sh @@ -50,7 +50,7 @@ usage() { Usage: test-usb-qemu.sh [--check] [config] 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: 1. xHCI controller initializes and reports interrupt mode @@ -63,7 +63,7 @@ USAGE } check_mode=0 -config="redbear-desktop" +config="redbear-mini" for arg in "$@"; do case "$arg" in --help|-h|help) @@ -79,6 +79,10 @@ for arg in "$@"; do esac done +if [[ "$config" == "redbear-mini" ]]; then + config="redbear-minimal" +fi + firmware="$(find_uefi_firmware)" || { echo "ERROR: no usable x86_64 UEFI firmware found" >&2 exit 1 @@ -112,38 +116,40 @@ sleep 1 rm -f "$log_file" set +e -timeout 120s 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 \ - -device nvme,drive=drv0,serial=NVME_SERIAL \ - -drive file="$extra",format=raw,if=none,id=drv1 \ - -device nvme,drive=drv1,serial=NVME_EXTRA \ - -drive file="$usb_img",format=raw,if=none,id=usbdisk \ - -device usb-storage,bus=xhci.0,drive=usbdisk \ - -device usb-kbd,bus=xhci.0 \ - -device usb-tablet,bus=xhci.0 \ - -enable-kvm -cpu host \ - > "$log_file" 2>&1 +expect </dev/null || true + failures=0 echo "--- USB Stack Validation: $config ---" # 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" else echo " [FAIL] xHCI did not report interrupt-driven mode" >&2 @@ -151,7 +157,7 @@ else fi # 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" else echo " [FAIL] USB HID driver did not spawn" >&2 @@ -159,44 +165,56 @@ else fi # 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" else echo " [FAIL] USB SCSI driver did not spawn" >&2 failures=$((failures + 1)) 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" 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)) fi # 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" -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)" else echo " [WARN] No BOS descriptor log output found" fi # 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 failures=$((failures + 1)) else echo " [PASS] No crash-class errors detected" fi -# Check 6: Hub driver (if hub detected) -if grep -q "USB HUB driver spawned" "$log_file"; then +# Check 6: Boot progressed far enough to reach the guest shell +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" else echo " [INFO] No hub driver spawn (expected for direct-attached devices)" 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 ---" if [[ "$failures" -gt 0 ]]; then diff --git a/local/scripts/test-xhci-irq-qemu.sh b/local/scripts/test-xhci-irq-qemu.sh index b2bc83e8..d429ba47 100644 --- a/local/scripts/test-xhci-irq-qemu.sh +++ b/local/scripts/test-xhci-irq-qemu.sh @@ -28,11 +28,12 @@ usage() { Usage: test-xhci-irq-qemu.sh [--check] [config] 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 } check_mode=0 -config="redbear-desktop" +config="redbear-mini" for arg in "$@"; do case "$arg" in --help|-h|help) @@ -48,6 +49,10 @@ for arg in "$@"; do esac done +if [[ "$config" == "redbear-mini" ]]; then + config="redbear-minimal" +fi + firmware="$(find_uefi_firmware)" || { echo "ERROR: no usable x86_64 UEFI firmware found" >&2 exit 1 @@ -76,7 +81,9 @@ if [[ "$check_mode" -eq 1 ]]; then set +e timeout 90s qemu-system-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 \ -m 2048 \ -bios "$firmware" \ @@ -89,25 +96,29 @@ if [[ "$check_mode" -eq 1 ]]; then -netdev user,id=net0 \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -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 \ - -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 \ -enable-kvm -cpu host \ > "$log_file" 2>&1 status=$? 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 exit 1 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" exit 0 fi exec qemu-system-x86_64 \ -name "Red Bear OS x86_64" \ - -device qemu-xhci \ + -device qemu-xhci,id=xhci \ -smp 4 \ -m 2048 \ -bios "$firmware" \ @@ -120,8 +131,8 @@ exec qemu-system-x86_64 \ -netdev user,id=net0 \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -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 \ - -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 \ -enable-kvm -cpu host