Update boot order configuration for eMMC first, then network
Modify the first-boot script and documentation to set the EEPROM boot order to 0xf21, prioritizing eMMC boot followed by network boot. Adjust network boot settings for faster failure on DHCP timeouts and update related scripts and documentation to reflect these changes. Enhance the rescue script to directly modify EEPROM settings without requiring a chroot into eMMC, streamlining the recovery process for devices stuck in network-only boot. Update relevant documentation to ensure clarity on the new boot order and its implications.
This commit is contained in:
@@ -214,10 +214,10 @@ grep -q '^RPI_EEPROM_USE_FLASHROM=' "$EEPROM_DEFAULT" && sed -i 's/^RPI_EEPROM_U
|
||||
grep -q '^CM4_ENABLE_RPI_EEPROM_UPDATE=' "$EEPROM_DEFAULT" && sed -i 's/^CM4_ENABLE_RPI_EEPROM_UPDATE=.*/CM4_ENABLE_RPI_EEPROM_UPDATE=1/' "$EEPROM_DEFAULT" || echo 'CM4_ENABLE_RPI_EEPROM_UPDATE=1' >> "$EEPROM_DEFAULT"
|
||||
log "Set RPI_EEPROM_USE_FLASHROM=1 and CM4_ENABLE_RPI_EEPROM_UPDATE=1 in $EEPROM_DEFAULT"
|
||||
|
||||
# --- 6d. Boot order: network first, then eMMC/SD (for future network boot / re-provisioning) ---
|
||||
# BOOT_ORDER: 0x2 = network, 0x1 = SD/eMMC. 0x21 = try network first, then local storage.
|
||||
# --- 6d. Boot order: eMMC/SD first, then network, then restart (0xf21) ---
|
||||
# BOOT_ORDER nibbles (right-to-left): 1=SD/eMMC, 2=network (TFTP), f=restart loop.
|
||||
# On CM4, rpi-eeprom-update -l only works after reboot (once 6c is applied). So we try now; if it fails, a one-shot runs after next boot.
|
||||
log "--- Boot order (network first, then eMMC/SD) ---"
|
||||
log "--- Boot order (0xf21: eMMC/SD first, then network, restart) ---"
|
||||
BOOTCONF="/tmp/first-boot-eeprom-conf.txt"
|
||||
BOOT_ORDER_SET=0
|
||||
if command -v rpi-eeprom-config >/dev/null 2>&1 && command -v rpi-eeprom-update >/dev/null 2>&1; then
|
||||
@@ -225,11 +225,17 @@ if command -v rpi-eeprom-config >/dev/null 2>&1 && command -v rpi-eeprom-update
|
||||
rpi-eeprom-config "$PEE" > "$BOOTCONF" 2>/dev/null || true
|
||||
fi
|
||||
if [[ -s "$BOOTCONF" ]]; then
|
||||
sed -i 's/^BOOT_ORDER=.*/BOOT_ORDER=0x21/' "$BOOTCONF"
|
||||
grep -q '^BOOT_ORDER=' "$BOOTCONF" || echo 'BOOT_ORDER=0x21' >> "$BOOTCONF"
|
||||
sed -i 's/^BOOT_ORDER=.*/BOOT_ORDER=0xf21/' "$BOOTCONF"
|
||||
grep -q '^BOOT_ORDER=' "$BOOTCONF" || echo 'BOOT_ORDER=0xf21' >> "$BOOTCONF"
|
||||
# Limit network boot: 3 retries, 1500ms DHCP timeout (fail fast to eMMC)
|
||||
sed -i '/^NET_BOOT_MAX_RETRIES=/d; /^DHCP_TIMEOUT=/d; /^DHCP_REQ_TIMEOUT=/d; /^TFTP_IP=/d; /^NET_INSTALL_AT_POWER_ON=/d' "$BOOTCONF"
|
||||
echo 'NET_BOOT_MAX_RETRIES=3' >> "$BOOTCONF"
|
||||
echo 'DHCP_TIMEOUT=1500' >> "$BOOTCONF"
|
||||
echo 'DHCP_REQ_TIMEOUT=500' >> "$BOOTCONF"
|
||||
echo 'NET_INSTALL_AT_POWER_ON=0' >> "$BOOTCONF"
|
||||
if rpi-eeprom-config --apply "$BOOTCONF" 2>/dev/null; then
|
||||
log "Boot order set to 0x21 (network first, then eMMC/SD); EEPROM update scheduled for next reboot"
|
||||
BOOT_ORDER_SET=1
|
||||
log "Boot order set to 0xf21 (eMMC first, then network, restart); EEPROM update scheduled for next reboot"
|
||||
@ BOOT_ORDER_SET=1
|
||||
else
|
||||
log "WARNING: rpi-eeprom-config --apply failed; boot order unchanged"
|
||||
fi
|
||||
@@ -247,15 +253,20 @@ if [[ "$BOOT_ORDER_SET" -eq 0 ]] && command -v rpi-eeprom-config >/dev/null 2>&1
|
||||
ONCE_SVC="/etc/systemd/system/set-cm4-boot-order-once.service"
|
||||
cat > "$ONCE_SCRIPT" << 'SETBOOTEOF'
|
||||
#!/bin/bash
|
||||
# One-shot: set BOOT_ORDER=0x21 (network first) when rpi-eeprom-update becomes available (e.g. after CM4 enable and reboot).
|
||||
# One-shot: set BOOT_ORDER=0xf21 (eMMC first, then network) when rpi-eeprom-update becomes available (e.g. after CM4 enable and reboot).
|
||||
BOOTCONF="/tmp/eeprom-boot-order-once.txt"
|
||||
if PEE="$(rpi-eeprom-update -l 2>/dev/null)" && [[ -n "$PEE" ]] && [[ -f "$PEE" ]]; then
|
||||
rpi-eeprom-config "$PEE" > "$BOOTCONF" 2>/dev/null
|
||||
if [[ -s "$BOOTCONF" ]]; then
|
||||
sed -i 's/^BOOT_ORDER=.*/BOOT_ORDER=0x21/' "$BOOTCONF"
|
||||
grep -q '^BOOT_ORDER=' "$BOOTCONF" || echo 'BOOT_ORDER=0x21' >> "$BOOTCONF"
|
||||
sed -i 's/^BOOT_ORDER=.*/BOOT_ORDER=0xf21/' "$BOOTCONF"
|
||||
grep -q '^BOOT_ORDER=' "$BOOTCONF" || echo 'BOOT_ORDER=0xf21' >> "$BOOTCONF"
|
||||
sed -i '/^NET_BOOT_MAX_RETRIES=/d; /^DHCP_TIMEOUT=/d; /^DHCP_REQ_TIMEOUT=/d; /^TFTP_IP=/d; /^NET_INSTALL_AT_POWER_ON=/d' "$BOOTCONF"
|
||||
echo 'NET_BOOT_MAX_RETRIES=3' >> "$BOOTCONF"
|
||||
echo 'DHCP_TIMEOUT=1500' >> "$BOOTCONF"
|
||||
echo 'DHCP_REQ_TIMEOUT=500' >> "$BOOTCONF"
|
||||
echo 'NET_INSTALL_AT_POWER_ON=0' >> "$BOOTCONF"
|
||||
if rpi-eeprom-config --apply "$BOOTCONF" 2>/dev/null; then
|
||||
echo "Boot order set to 0x21 (network first, then eMMC/SD)"
|
||||
echo "Boot order set to 0xf21 (eMMC first, then network)"
|
||||
fi
|
||||
fi
|
||||
rm -f "$BOOTCONF"
|
||||
@@ -267,7 +278,7 @@ SETBOOTEOF
|
||||
chmod 755 "$ONCE_SCRIPT"
|
||||
cat > "$ONCE_SVC" << 'SVCEOF'
|
||||
[Unit]
|
||||
Description=Set CM4 boot order once (network first)
|
||||
Description=Set CM4 boot order once (eMMC first, then network)
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
|
||||
Reference in New Issue
Block a user