From befcc3f3a399ad2ac6acde9a864cb7b57a6b3a20 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Wed, 1 Apr 2026 07:16:17 +0200 Subject: [PATCH] fix(rpi): Copy Pi firmware files to boot partition The raspi-firmware package installs firmware to /usr/lib/raspi-firmware/ but these files (start4.elf, fixup4.dat, DTBs, overlays) were not being copied to the boot partition, causing "firmware not found" boot failure. - Copy all .elf, .dat, .bin files from raspi-firmware - Copy overlays directory - Copy kernel DTBs (bcm*.dtb) - Add verification for critical boot files - Update config.txt with Pi 4/400 specific sections Co-Authored-By: Claude Opus 4.5 --- image/build-rpi-usb.sh | 84 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 9 deletions(-) diff --git a/image/build-rpi-usb.sh b/image/build-rpi-usb.sh index 69177dbc..0aa2c6a3 100755 --- a/image/build-rpi-usb.sh +++ b/image/build-rpi-usb.sh @@ -445,28 +445,45 @@ log "5/6 Configuring Pi bootloader..." mkdir -p "${ROOTFS}/boot/firmware" cat > "${ROOTFS}/boot/firmware/config.txt" </dev/null || warn "No .elf files found" + cp -v "${FIRMWARE_SRC}"/*.dat "${MNT}/boot/firmware/" 2>/dev/null || warn "No .dat files found" + cp -v "${FIRMWARE_SRC}"/*.bin "${MNT}/boot/firmware/" 2>/dev/null || true + cp -v "${FIRMWARE_SRC}"/*.dtb "${MNT}/boot/firmware/" 2>/dev/null || true + + # Copy overlays directory + if [[ -d "${FIRMWARE_SRC}/overlays" ]]; then + cp -rv "${FIRMWARE_SRC}/overlays" "${MNT}/boot/firmware/" + ok "Firmware overlays copied" + fi + ok "Pi firmware copied from raspi-firmware package" +else + warn "raspi-firmware not found at ${FIRMWARE_SRC}, trying alternative locations..." + # Alternative: firmware might be in /boot/firmware already + if [[ -d "${MNT}/boot/firmware" ]] && ls "${MNT}/boot/firmware/"*.elf >/dev/null 2>&1; then + ok "Firmware already present in /boot/firmware" + else + err "No Raspberry Pi firmware found! Install raspi-firmware package." + fi +fi + +# Copy Device Tree Blobs from kernel package +if ls "${MNT}/usr/lib/linux-image-"*/broadcom/*.dtb >/dev/null 2>&1; then + cp -v "${MNT}/usr/lib/linux-image-"*/broadcom/bcm*.dtb "${MNT}/boot/firmware/" 2>/dev/null || true + ok "Kernel DTBs copied" +fi + # Copy kernel and initrd to boot partition if ls "${MNT}/boot/vmlinuz-"* >/dev/null 2>&1; then cp "${MNT}/boot/vmlinuz-"* "${MNT}/boot/firmware/vmlinuz" @@ -542,6 +593,21 @@ else warn "No initrd found - boot may fail without initramfs" fi +# Verify critical boot files +log "Verifying boot files..." +MISSING_FILES=0 +for f in start4.elf fixup4.dat vmlinuz; do + if [[ ! -f "${MNT}/boot/firmware/${f}" ]]; then + warn "Missing: ${f}" + MISSING_FILES=1 + fi +done +if [[ $MISSING_FILES -eq 0 ]]; then + ok "All critical boot files present" +else + warn "Some boot files missing - Pi may not boot!" +fi + # Update fstab with proper UUIDs BOOT_UUID=$(blkid -s UUID -o value "${LOOP}p1") ROOT_UUID=$(blkid -s UUID -o value "${LOOP}p2")