Files
reterminal-dm4/emmc-provisioning/scripts/install-eeprom-tools-on-lxc.sh
nearxos b39e73324f Add EEPROM update functionality and UI enhancements
Implement a new feature to allow users to update the EEPROM via the dashboard, including the generation of necessary update files. Enhance the device action handling to support the 'eeprom_update' action for USB-connected devices, ensuring proper validation of boot order presets. Update the dashboard UI to include an EEPROM update option alongside existing actions, improving user experience. Modify related scripts to handle EEPROM updates effectively, including file management and error handling during the update process.
2026-02-21 16:02:08 +02:00

61 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install rpi-eeprom-config and pieeprom.bin on the LXC (or host) where the dashboard runs.
# Required for "Update EEPROM" from the dashboard when a device is connected via USB boot.
# Run on the LXC: bash -s < scripts/install-eeprom-tools-on-lxc.sh
# Or: ssh root@<LXC-IP> 'bash -s' < emmc-provisioning/scripts/install-eeprom-tools-on-lxc.sh
set -e
RPI_EEPROM_RAW="https://raw.githubusercontent.com/raspberrypi/rpi-eeprom/master"
EEPROM_DIR="${EEPROM_DIR:-/opt/cm4-provisioning/eeprom}"
echo "Installing EEPROM tools to $EEPROM_DIR"
if ! command -v python3 >/dev/null 2>&1; then
echo "ERROR: Python 3 is required to run rpi-eeprom-config. Install it (e.g. apt install python3) and re-run."
exit 1
fi
if command -v curl >/dev/null 2>&1; then
GET="curl -sL"
GET_O="curl -sL -o"
elif command -v wget >/dev/null 2>&1; then
GET="wget -q -O -"
GET_O="wget -q -O"
else
echo "ERROR: curl or wget required"
exit 1
fi
mkdir -p "$EEPROM_DIR"
cd "$EEPROM_DIR"
echo "Downloading rpi-eeprom-config..."
$GET_O "$EEPROM_DIR/rpi-eeprom-config" "$RPI_EEPROM_RAW/rpi-eeprom-config"
$GET_O "$EEPROM_DIR/rpi-eeprom-digest" "$RPI_EEPROM_RAW/rpi-eeprom-digest"
chmod +x "$EEPROM_DIR/rpi-eeprom-config" "$EEPROM_DIR/rpi-eeprom-digest"
echo "Finding latest BCM2711 EEPROM firmware..."
LATEST_FW=$($GET "https://api.github.com/repos/raspberrypi/rpi-eeprom/contents/firmware-2711/default" \
| grep -o '"name" *: *"pieeprom-[^"]*\.bin"' | sed 's/"name" *: *"//;s/"//' | sort | tail -1)
if [ -z "$LATEST_FW" ]; then
echo "WARNING: Could not determine latest firmware from GitHub API. Try again or download pieeprom.bin manually."
exit 1
fi
echo "Downloading $LATEST_FW..."
$GET_O "$EEPROM_DIR/pieeprom.bin" "$RPI_EEPROM_RAW/firmware-2711/default/$LATEST_FW"
if [ ! -s "$EEPROM_DIR/pieeprom.bin" ]; then
echo "ERROR: pieeprom.bin is missing or empty"
exit 1
fi
echo "Verifying rpi-eeprom-config..."
if ! python3 "$EEPROM_DIR/rpi-eeprom-config" "$EEPROM_DIR/pieeprom.bin" >/dev/null 2>&1; then
echo "WARNING: rpi-eeprom-config could not read pieeprom.bin (non-fatal)"
fi
echo "Done. EEPROM tools installed:"
ls -la "$EEPROM_DIR"