Update eMMC provisioning scripts: enhance error handling in flash-emmc-on-connect.sh to provide clearer instructions for fixing boot file issues, and improve fix-gadget-bootcode-on-host.sh to remove broken symlinks and ensure required tools are installed.

This commit is contained in:
nearxos
2026-02-18 19:07:24 +02:00
parent 5ff46e67d8
commit 3abc004465
2 changed files with 25 additions and 11 deletions

View File

@@ -92,7 +92,7 @@ fi
# rpiboot requires bootfiles.bin or one of bootcode*.bin in the gadget dir; empty dir causes "No 'bootcode' files found"
if [[ ! -f "$RPIBOOT_GADGET/bootfiles.bin" && ! -f "$RPIBOOT_GADGET/bootcode.bin" && ! -f "$RPIBOOT_GADGET/bootcode4.bin" && ! -f "$RPIBOOT_GADGET/bootcode5.bin" ]]; then
log "rpiboot gadget dir has no boot files: $RPIBOOT_GADGET (reinstall usbboot)"
write_status "error" "rpiboot gadget empty" "null" "No boot files in $RPIBOOT_GADGET. Reinstall usbboot: run install-usbboot-on-host.sh on the host or build-and-deploy-usbboot-to-host.sh from your machine."
write_status "error" "rpiboot gadget empty" "null" "No boot files in $RPIBOOT_GADGET. On the host run: fix-gadget-bootcode-on-host.sh (or from your machine: ssh root@HOST 'bash -s' < scripts/fix-gadget-bootcode-on-host.sh). See docs troubleshooting."
exit 1
fi

View File

@@ -1,23 +1,37 @@
#!/usr/bin/env bash
# Run on the Proxmox host (as root) when rpiboot fails with "No 'bootcode' files found".
# Cause: mass-storage-gadget64/bootfiles.bin is a broken symlink (-> ../firmware/bootfiles.bin).
# This script removes the symlink and extracts bootcode4.bin from the installed rpiboot binary.
# Run on the Proxmox host (as root) when rpiboot fails with "No 'bootcode' files found" / "rpiboot gadget empty".
# Cause: mass-storage-gadget64 has no real boot files (broken symlinks or Git LFS not pulled).
# This script removes broken symlinks and extracts bootcode4.bin from the installed rpiboot binary.
#
# On host: bash fix-gadget-bootcode-on-host.sh
# From your machine: ssh root@10.130.60.224 'bash -s' < scripts/fix-gadget-bootcode-on-host.sh
# From your machine: ssh root@HOST 'bash -s' < chromium-setup/emmc-provisioning/scripts/fix-gadget-bootcode-on-host.sh
set -e
GADGET="${1:-/opt/usbboot/mass-storage-gadget64}"
RPIBOOT="${2:-/opt/usbboot/rpiboot}"
[[ -d "$GADGET" ]] || { echo "Error: $GADGET not found"; exit 1; }
[[ -x "$RPIBOOT" ]] || { echo "Error: $RPIBOOT not found"; exit 1; }
[[ -x "$RPIBOOT" ]] || { echo "Error: $RPIBOOT not found (install usbboot first: install-usbboot-on-host.sh)"; exit 1; }
# Remove broken bootfiles.bin symlink if present
if [[ -L "$GADGET/bootfiles.bin" ]] && ! [[ -f "$GADGET/bootfiles.bin" ]]; then
rm -f "$GADGET/bootfiles.bin"
echo "Removed broken symlink $GADGET/bootfiles.bin"
fi
# Ensure readelf and objdump are available (binutils)
for cmd in readelf objdump; do
if ! command -v "$cmd" &>/dev/null; then
echo "Installing binutils (required for $cmd)..."
apt-get update -qq && apt-get install -y -qq binutils 2>/dev/null || {
echo "Error: $cmd not found. Install binutils: apt-get install -y binutils"
exit 1
}
break
fi
done
# Remove broken symlinks in gadget dir so we can replace with real boot file
for f in bootfiles.bin bootcode.bin bootcode4.bin bootcode5.bin; do
if [[ -L "$GADGET/$f" ]] && ! [[ -f "$GADGET/$f" ]]; then
rm -f "$GADGET/$f"
echo "Removed broken symlink $GADGET/$f"
fi
done
# If we already have a valid boot file, done
if [[ -f "$GADGET/bootcode4.bin" ]] || [[ -f "$GADGET/bootfiles.bin" ]]; then