Enhance eMMC provisioning scripts and documentation: add troubleshooting section for device connection issues, update flash script to prevent concurrent runs, and improve logging. Adjust deployment scripts to verify presence of boot files in mass-storage-gadget.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#!/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.
|
||||
#
|
||||
# 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
|
||||
|
||||
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; }
|
||||
|
||||
# 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
|
||||
|
||||
# If we already have a valid boot file, done
|
||||
if [[ -f "$GADGET/bootcode4.bin" ]] || [[ -f "$GADGET/bootfiles.bin" ]]; then
|
||||
echo "Already has bootcode4.bin or valid bootfiles.bin. OK."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get .data section file offset and address from ELF
|
||||
readelf -S "$RPIBOOT" | grep -q "\.data" || { echo "No .data section"; exit 1; }
|
||||
DATA_OFF=$(readelf -S "$RPIBOOT" | awk '/\.data\s/ { print "0x"$5; exit }')
|
||||
DATA_ADDR=$(readelf -S "$RPIBOOT" | awk '/\.data\s/ { print "0x"$4; exit }')
|
||||
LEN_SYM=$(objdump -t "$RPIBOOT" | awk '/msd_bootcode4_bin_len/ { print $1; exit }')
|
||||
BIN_SYM=$(objdump -t "$RPIBOOT" | awk '/msd_bootcode4_bin\s/ { print $1; exit }')
|
||||
[[ -n "$LEN_SYM" && -n "$BIN_SYM" ]] || { echo "msd_bootcode4_bin symbols not found in rpiboot"; exit 1; }
|
||||
|
||||
LEN_ADDR=$((0x$LEN_SYM))
|
||||
BIN_ADDR=$((0x$BIN_SYM))
|
||||
LEN_OFF=$((DATA_OFF + LEN_ADDR - DATA_ADDR))
|
||||
BIN_OFF=$((DATA_OFF + BIN_ADDR - DATA_ADDR))
|
||||
LEN=$(dd if="$RPIBOOT" bs=1 skip=$LEN_OFF count=4 2>/dev/null | od -An -t u4 | tr -d ' ')
|
||||
dd if="$RPIBOOT" of="$GADGET/bootcode4.bin" bs=1 skip=$BIN_OFF count=$LEN 2>/dev/null
|
||||
echo "Wrote $GADGET/bootcode4.bin ($LEN bytes). Verify: $RPIBOOT -d $GADGET -V"
|
||||
Reference in New Issue
Block a user