#!/usr/bin/env bash # Fetch bounded GPU firmware blobs from linux-firmware repository. # AMD remains the larger set; Intel support here is intentionally limited to # display-critical DMC blobs for the current bounded startup manifest. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" LINUX_FIRMWARE_REPO="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" TEMP_DIR=$(mktemp -d) VENDOR="amd" SUBSET="all" usage() { cat </dev/null | wc -l) firmware blobs" echo "=== Verifying firmware selection ===" if [ "$SUBSET" = "rdna" ]; then if ls "$FIRMWARE_DIR"/gc_10_3_*.bin "$FIRMWARE_DIR"/gc_11_0_*.bin >/dev/null 2>&1; then echo "Verified RDNA graphics firmware families (gfx10.3/gfx11) are present" else echo "ERROR: Missing RDNA2/RDNA3 graphics firmware blobs" exit 1 fi if ls "$FIRMWARE_DIR"/psp_13_*_sos.bin >/dev/null 2>&1; then echo "Verified PSP SOS firmware is present" else echo "ERROR: Missing PSP SOS firmware blobs" exit 1 fi non_rdna_count=0 for blob in "$FIRMWARE_DIR"/*.bin; do base="$(basename "$blob")" case "$base" in psp_13_*|gc_10_3_*|gc_11_0_*|sdma_5_*|sdma_6_*|dcn_3_*|mes_2_*|smu_13_*|vcn_4_*|gc_11_5_*) ;; *) non_rdna_count=$((non_rdna_count + 1)) ;; esac done if [ "$non_rdna_count" -gt 0 ]; then echo "ERROR: Non-RDNA firmware blob detected in rdna subset" exit 1 fi echo "Verified subset contains only RDNA-oriented firmware families" else if ls "$FIRMWARE_DIR"/*.bin >/dev/null 2>&1; then echo "Verified full AMD firmware set copied successfully" else echo "ERROR: No firmware blobs were copied" exit 1 fi fi shopt -u nullglob else echo "ERROR: amdgpu firmware directory not found in linux-firmware" exit 1 fi } copy_intel_dmc_firmware() { echo "Copying bounded Intel DMC firmware blobs..." if [ ! -d "$TEMP_DIR/linux-firmware/i915" ]; then echo "ERROR: i915 firmware directory not found in linux-firmware" exit 1 fi local selected_blobs=() local candidates=( adlp_dmc.bin adlp_dmc_ver2_16.bin tgl_dmc.bin tgl_dmc_ver2_12.bin dg2_dmc.bin dg2_dmc_ver2_06.bin mtl_dmc.bin ) for blob in "${candidates[@]}"; do if [ -f "$TEMP_DIR/linux-firmware/i915/$blob" ]; then selected_blobs+=("$TEMP_DIR/linux-firmware/i915/$blob") fi done if [ "${#selected_blobs[@]}" -eq 0 ]; then echo "ERROR: No Intel DMC firmware blobs were found" exit 1 fi rm -f "$FIRMWARE_DIR"/*.bin cp -v "${selected_blobs[@]}" "$FIRMWARE_DIR/" cat > "$FIRMWARE_DIR/MANIFEST.txt" <<'MANIFEST' # Intel GPU Firmware for Red Bear OS (bounded startup slice) # Source: linux-firmware (https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git) # Scope: display-critical DMC blobs only # # This subset is intentionally bounded to startup/display proof for current Intel DRM work. # It does NOT include GuC/HuC/GSC runtime/render/media firmware. # # Current bounded candidates: # - adlp_dmc.bin / adlp_dmc_ver2_16.bin # - tgl_dmc.bin / tgl_dmc_ver2_12.bin # - dg2_dmc.bin / dg2_dmc_ver2_06.bin # - mtl_dmc.bin MANIFEST echo "Copied ${#selected_blobs[@]} Intel DMC firmware blobs" } case "$VENDOR" in amd) copy_amd_firmware echo "=== Creating firmware manifest ===" cat > "$FIRMWARE_DIR/MANIFEST.txt" << 'MANIFEST' # AMD GPU Firmware for Red Bear OS # Source: linux-firmware (https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git) # License: Various — see linux-firmware WHENCE file for details # # Required for: RDNA2 (gfx10.3), RDNA3 (gfx11) # Minimum set for basic display output: # - PSP SOS + TA (security processor) # - GC ME/PFP/CE/MEC (graphics/compute) # - SDMA (DMA engine) # - DMCUB (Display Microcontroller) # # Key files for RDNA2 (Navi 21/22/23/24, gfx10.3): # psp_13_0_*_sos.bin, gc_10_3_*.bin, sdma_5_*.bin, dcn_3_*.bin # # Key files for RDNA3 (Navi 31/32/33, gfx11): # psp_13_*_sos.bin, gc_11_0_*.bin, sdma_6_*.bin, dcn_3_1_*.bin MANIFEST echo "$FIRMWARE_DIR/MANIFEST.txt created" ;; intel) copy_intel_dmc_firmware ;; esac # Summary echo "" echo "=== Firmware blobs installed ===" ls -la "$FIRMWARE_DIR/" | head -20 echo "..." echo "Total: $(ls "$FIRMWARE_DIR/"*.bin 2>/dev/null | wc -l) blobs" echo "" echo "WARNING: These firmware blobs are third-party upstream firmware." echo "They are NOT open source. Verify your license compliance."