Skip to content

Instantly share code, notes, and snippets.

@peltho
Last active April 4, 2024 09:16
Show Gist options
  • Save peltho/a4e0a443775c6701364d853642832e99 to your computer and use it in GitHub Desktop.
Save peltho/a4e0a443775c6701364d853642832e99 to your computer and use it in GitHub Desktop.
Updating RPI4 EEPROM for ArchARM
pacman -Syu --needed git python3 binutils
git clone https://github.com/raspberrypi/rpi-eeprom.git /opt/rpi-eeprom
mkdir -p /lib/firmware/raspberrypi
ln -s /opt/rpi-eeprom/firmware-2711/ /lib/firmware/raspberrypi/bootloader
#!/usr/bin/env bash
VC_UTIL_PATH=/opt/vc/bin
EEPROM_UTIL_PATH=/opt/rpi-eeprom
EEPROM_CONFIG_UTIL=$EEPROM_UTIL_PATH/rpi-eeprom-config
EEPROM_UPDATE_UTIL=$EEPROM_UTIL_PATH/rpi-eeprom-update
# Use the latest EEPROM
EEPROM_PATH=/lib/firmware/raspberrypi/bootloader/beta
unset EEPROM_FILE
for file in $EEPROM_PATH/pieeprom-*; do
EEPROM_FILE=$file
done
TEMP_BOOTCONF=/tmp/bootconf.txt
TEMP_EEPROM=/tmp/pieeprom.bin
# Serial output
# 0 = off (default), 1 = on
# Useful for debugging early boot issues
BOOT_UART=0
# Boot attempt order, from LSB (right) to MSB (left)
# 1 = SD card, 2 = network boot, 4 = USB mass storage device
# Value 0x21 (SD card first) is the same as Pi 1B+, Pi 2B, Pi 3B, Pi 3B+
# Value 0xf41 is the default for newer Pi 4 EEPROM versions
# Value 0xf241 allows network boot if local boot methods fail
BOOT_ORDER=0xf241
# Network boot TFTP directory prefix
# 0 = serial number (same as Pi 1B+, Pi 2B, Pi 3B, Pi 3B+)
# 1 = value of $TFTP_PREFIX_STR
# 2 = MAC address, dash (-) separated, lower case
TFTP_PREFIX=0
TFTP_PREFIX_STR=
$EEPROM_CONFIG_UTIL $EEPROM_FILE > $TEMP_BOOTCONF
sed -i -E "s/^(BOOT_UART=).*$/\1$BOOT_UART/" $TEMP_BOOTCONF
sed -i -E "s/^(BOOT_ORDER=).*$/\1$BOOT_ORDER/" $TEMP_BOOTCONF
sed -i -E "s/^(\[none\])$/TFTP_PREFIX=$TFTP_PREFIX\n\1/" $TEMP_BOOTCONF
sed -i -E "s/^(\[none\])$/TFTP_PREFIX_STR=$TFTP_PREFIX_STR\n\1/" $TEMP_BOOTCONF
$EEPROM_CONFIG_UTIL --out $TEMP_EEPROM --config $TEMP_BOOTCONF $EEPROM_FILE
PATH=$PATH:$VC_UTIL_PATH:$EEPROM_UTIL_PATH $EEPROM_UPDATE_UTIL -d -f $TEMP_EEPROM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment