Initial support for updating eeprom.
This commit is contained in:
77
.includes/eeprom.sh
Normal file
77
.includes/eeprom.sh
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# EEPROM Update for Raspberry Pi 4/400/5/500
|
||||||
|
# Checks for and applies firmware updates to the Pi's EEPROM
|
||||||
|
|
||||||
|
# sudoFlags is defined in the main configure-stormux.sh script
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
|
||||||
|
updateEeprom() {
|
||||||
|
# Detect Pi version from device tree
|
||||||
|
local piModel
|
||||||
|
piModel=$(cat /sys/firmware/devicetree/base/model 2>/dev/null)
|
||||||
|
|
||||||
|
# Determine which EEPROM package is needed
|
||||||
|
local eepromPackage=""
|
||||||
|
if [[ "$piModel" == *"Raspberry Pi 5"* ]] || [[ "$piModel" == *"Raspberry Pi 500"* ]]; then
|
||||||
|
eepromPackage="rpi5-eeprom"
|
||||||
|
elif [[ "$piModel" == *"Raspberry Pi 4"* ]] || [[ "$piModel" == *"Raspberry Pi 400"* ]]; then
|
||||||
|
eepromPackage="rpi4-eeprom"
|
||||||
|
else
|
||||||
|
# Default to rpi4-eeprom for unknown models
|
||||||
|
eepromPackage="rpi4-eeprom"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install EEPROM package if not present
|
||||||
|
if ! pacman -Q "$eepromPackage" &> /dev/null; then
|
||||||
|
infobox "Installing ${eepromPackage}..."
|
||||||
|
if ! install_package "$eepromPackage"; then
|
||||||
|
msgbox "Failed to install ${eepromPackage}. Please check your internet connection and try again."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for EEPROM updates
|
||||||
|
infobox "Checking for EEPROM updates..."
|
||||||
|
local checkOutput
|
||||||
|
local checkResult
|
||||||
|
checkOutput=$(sudo "${sudoFlags[@]}" rpi-eeprom-update 2>&1)
|
||||||
|
checkResult=$?
|
||||||
|
|
||||||
|
case $checkResult in
|
||||||
|
0)
|
||||||
|
# Up to date
|
||||||
|
msgbox "EEPROM is up to date.\n\n${checkOutput}"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
# Update available
|
||||||
|
if [[ "$(yesno "An EEPROM update is available.\n\n${checkOutput}\n\nWould you like to apply this update?")" == "Yes" ]]; then
|
||||||
|
infobox "Applying EEPROM update..."
|
||||||
|
if sudo "${sudoFlags[@]}" rpi-eeprom-update -a; then
|
||||||
|
msgbox "EEPROM update applied successfully. A reboot is required to complete the update."
|
||||||
|
restart
|
||||||
|
else
|
||||||
|
msgbox "Failed to apply EEPROM update. Please try again or check the log file for details."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
# Failed
|
||||||
|
msgbox "EEPROM update check failed.\n\n${checkOutput}"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
# EEPROM frozen
|
||||||
|
msgbox "EEPROM is currently frozen and cannot be updated.\n\n${checkOutput}\n\nThis may require a reboot to resolve."
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Unknown error
|
||||||
|
msgbox "Unexpected error checking EEPROM status (exit code: ${checkResult}).\n\n${checkOutput}"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute the update function when sourced
|
||||||
|
updateEeprom
|
||||||
@@ -124,6 +124,9 @@ while [[ "$choice" != "Exit" ]]; do
|
|||||||
"Configure StormUX Repository")
|
"Configure StormUX Repository")
|
||||||
add_stormux_repo
|
add_stormux_repo
|
||||||
;;
|
;;
|
||||||
|
"Update EEPROM")
|
||||||
|
source .includes/eeprom.sh
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
options=(
|
options=(
|
||||||
"Change username"
|
"Change username"
|
||||||
@@ -147,6 +150,7 @@ while [[ "$choice" != "Exit" ]]; do
|
|||||||
options+=("Set timezone"
|
options+=("Set timezone"
|
||||||
"Get help on IRC"
|
"Get help on IRC"
|
||||||
"Update configure-stormux"
|
"Update configure-stormux"
|
||||||
|
"Update EEPROM"
|
||||||
"Convert to Server"
|
"Convert to Server"
|
||||||
"Configure StormUX Repository"
|
"Configure StormUX Repository"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user