Build: Add USB boot + NVMe HAT support
Lint & Validate / lint (push) Has been cancelled

- --target flag in build.sh (sd|usb|nvme)
- NVMe kernel driver enabled for --target nvme
- EEPROM boot-order config in first-boot wizard
- USB/NVMe flashing docs in build/README.md
- Hardware compatibility + user manual docs from P7
This commit is contained in:
2026-05-19 22:54:41 -04:00
parent 5e208d5123
commit 9e007ae197
5 changed files with 1126 additions and 9 deletions
+53 -7
View File
@@ -1,16 +1,19 @@
#!/bin/bash
# build.sh — Build RPi Audio Mixer SD card image from scratch
# build.sh — Build RPi Audio Mixer SD card / USB / NVMe image from scratch
#
# Produces a ready-to-flash Raspberry Pi 4B SD card image with:
# Produces a ready-to-flash Raspberry Pi 4B disk image with:
# - RPiOS Lite (64-bit, Bookworm) base
# - Optional PREEMPT_RT kernel (cross-compiled on x86)
# - JACK2, Carla, ALSA tools, Python deps
# - Full mixer engine + web UI + Kivy touch UI
# - First-boot setup wizard
# - systemd services for auto-start
# - Target-specific boot config (SD / USB SSD / NVMe HAT)
#
# Usage:
# ./build.sh # Full build (default)
# ./build.sh # Full build, SD card (default)
# ./build.sh --target usb # Build for USB SSD boot
# ./build.sh --target nvme # Build for NVMe HAT boot
# ./build.sh --skip-kernel # Skip RT kernel build (use stock kernel)
# ./build.sh --kernel-only # Only build RT kernel, skip image
# ./build.sh --output ./my-image.img # Custom output path
@@ -31,7 +34,7 @@
# - Cross-compile (optional): gcc-aarch64-linux-gnu, libssl-dev:arm64
#
# Output:
# build/out/rpi-audio-mixer-<version>.img SD card image
# build/out/rpi-audio-mixer-<version>.img Disk image (SD/USB/NVMe)
# build/out/rpi-audio-mixer-<version>.img.xz Compressed image
set -euo pipefail
@@ -48,6 +51,9 @@ DOWNLOAD_DIR="$BUILD_DIR/downloads"
MIXER_VERSION="${MIXER_VERSION:-$(git -C "$PROJECT_ROOT" describe --tags --always 2>/dev/null || echo 'dev')}"
MIXER_API_KEY="${MIXER_API_KEY:-mixer-$(head -c 12 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | head -c 16)}"
MIXER_HOSTNAME="${MIXER_HOSTNAME:-pi-mixer}"
# Boot target
TARGET="${TARGET:-sd}" # sd, usb, or nvme
MIXER_WIFI_SSID="${MIXER_WIFI_SSID:-}"
MIXER_WIFI_PASS="${MIXER_WIFI_PASS:-}"
@@ -255,6 +261,14 @@ build_rt_kernel() {
# USB audio (build as module)
scripts/config -m CONFIG_SND_USB_AUDIO
# NVMe support (for NVMe HAT boot)
if [[ "$TARGET" == "nvme" ]]; then
log "Enabling NVMe driver for NVMe HAT target..."
scripts/config -m CONFIG_BLK_DEV_NVME
scripts/config -e CONFIG_NVME_CORE
scripts/config -e CONFIG_NVME_FABRICS
fi
make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE" olddefconfig
else
log "Kernel .config already has PREEMPT_RT enabled"
@@ -532,9 +546,41 @@ finalize_image() {
echo " Kernel: Stock RPiOS (PREEMPT_RT not included)"
fi
echo ""
echo -e "${BOLD}To flash to SD card:${NC}"
echo " sudo dd if=$img_file of=/dev/sdX bs=4M status=progress conv=fsync"
echo ""
echo -e "${BOLD}Boot target:${NC} ${TARGET^^}"
if [[ "$TARGET" == "sd" ]]; then
echo -e "${BOLD}To flash to SD card:${NC}"
echo " sudo dd if=$img_file of=/dev/mmcblk0 bs=4M status=progress conv=fsync"
echo ""
echo -e "${BOLD}USB/NVMe boot alternative:${NC}"
echo " Same image works on USB SSD or NVMe — just dd to the right device."
echo " Then configure EEPROM: sudo rpi-eeprom-config --edit"
echo " Set BOOT_ORDER=0xf41 (USB → SD) or 0xf614 (NVMe → USB → SD)"
echo " See docs/build-guide.md §USB Boot for details."
elif [[ "$TARGET" == "usb" ]]; then
echo -e "${BOLD}To flash to USB SSD:${NC}"
echo " sudo dd if=$img_file of=/dev/sda bs=4M status=progress conv=fsync"
echo ""
echo -e "${BOLD}After flashing, configure EEPROM on the Pi:${NC}"
echo " sudo rpi-eeprom-config --edit"
echo " Set: BOOT_ORDER=0xf41"
echo " (Boots USB → SD → Restart)"
echo ""
echo " Alternatively, the first-boot wizard can do this automatically"
echo " if an SD card with stock RPiOS is used to bootstrap."
elif [[ "$TARGET" == "nvme" ]]; then
echo -e "${BOLD}To flash to NVMe SSD (via HAT):${NC}"
echo " 1. Connect NVMe SSD to HAT"
echo " 2. Write image directly:"
echo " sudo dd if=$img_file of=/dev/nvme0n1 bs=4M status=progress conv=fsync"
echo ""
echo -e "${BOLD}After flashing, configure EEPROM on the Pi:${NC}"
echo " sudo rpi-eeprom-config --edit"
echo " Set: BOOT_ORDER=0xf614"
echo " (Boots NVMe → USB → SD → Restart)"
echo ""
echo " Kernel config includes CONFIG_BLK_DEV_NVMe=m"
echo ""
fi
echo -e "${BOLD}First boot:${NC}"
echo " - The setup wizard will guide you through configuration"
echo " - Default hostname: $MIXER_HOSTNAME"