Files
reterminal-dm4/emmc-provisioning/scripts/check-network-boot-priority.sh
nearxos 5238d457e8 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.
2026-02-21 15:05:17 +02:00

42 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# Check if boot order is set as expected on a Pi 4 / CM4 (reTerminal).
# Run on the device: ./check-network-boot-priority.sh
# Or from your machine: ssh pi@<device-ip> 'bash -s' < scripts/check-network-boot-priority.sh
set -e
# BOOT_ORDER nibbles (right-to-left): 1=SD/eMMC, 2=network, f=restart.
# 0xf21 = eMMC first, then network, then restart.
WANT_BOOT_ORDER="0xf21"
get_config() {
if command -v vcgencmd >/dev/null 2>&1; then
vcgencmd bootloader_config 2>/dev/null || true
fi
if command -v rpi-eeprom-update >/dev/null 2>&1 && command -v rpi-eeprom-config >/dev/null 2>&1; then
PEE="$(rpi-eeprom-update -l 2>/dev/null)"
if [[ -n "$PEE" && -f "$PEE" ]]; then
rpi-eeprom-config "$PEE" 2>/dev/null || true
fi
fi
}
BOOTCONF="$(get_config)"
BOOT_ORDER="$(echo "$BOOTCONF" | grep -oE 'BOOT_ORDER=[0-9A-Fa-fx]+' | head -1 | cut -d= -f2)"
if [[ -z "$BOOT_ORDER" ]]; then
echo "Could not read EEPROM config (vcgencmd bootloader_config or rpi-eeprom-config)."
echo "Is this a Raspberry Pi 4 or CM4 with rpi-eeprom / vcgencmd?"
exit 1
fi
echo "BOOT_ORDER=$BOOT_ORDER (current)"
echo "Expected: $WANT_BOOT_ORDER (1=eMMC, 2=network, f=restart; eMMC first, then network)"
if [[ "$(echo "$BOOT_ORDER" | tr '[:upper:]' '[:lower:]')" == "$(echo "$WANT_BOOT_ORDER" | tr '[:upper:]' '[:lower:]')" ]]; then
echo "Result: Boot order matches expected (eMMC first, then network)."
exit 0
fi
echo "Result: Boot order does NOT match (current: $BOOT_ORDER, expected: $WANT_BOOT_ORDER). Set via rpi-eeprom-config --edit or cloud-init first-boot."
exit 2