Attempt to make switching to the 16K kernel safer. Configure-stormux should refuse to do it unless the eeprom is up to date.

This commit is contained in:
Storm Dragon
2026-06-23 19:47:14 -04:00
parent d015c0c0eb
commit 4a4c931785
2 changed files with 81 additions and 21 deletions
+75 -21
View File
@@ -5,11 +5,76 @@
# sudoFlags is defined in the main configure-stormux.sh script
# shellcheck disable=SC2154
updateEeprom() {
# Detect Pi version from device tree
local piModel
piModel=$(LC_ALL=C tr -d '\000' < /sys/firmware/devicetree/base/model 2>/dev/null)
getRaspberryPiModel() {
LC_ALL=C tr -d '\000' < /sys/firmware/devicetree/base/model 2>/dev/null
}
getEepromPackage() {
local piModel="$1"
if [[ "$piModel" == *"Raspberry Pi 5"* ]] || [[ "$piModel" == *"Raspberry Pi 500"* ]]; then
echo "rpi5-eeprom"
elif [[ "$piModel" == *"Raspberry Pi 4"* ]] || [[ "$piModel" == *"Raspberry Pi 400"* ]]; then
echo "rpi4-eeprom"
else
echo "rpi4-eeprom"
fi
}
ensureEepromPackage() {
local eepromPackage="$1"
if pacman -Q "$eepromPackage" &> /dev/null; then
return 0
fi
infobox "Installing ${eepromPackage}..."
if ! install_package "$eepromPackage"; then
msgbox "Failed to install ${eepromPackage}. Please check your internet connection and try again."
return 1
fi
}
requireCurrentEepromForPi5Kernel() {
local checkOutput
local checkResult
if ! command -v rpi-eeprom-update &> /dev/null; then
if ! ensureEepromPackage "rpi5-eeprom"; then
return 1
fi
fi
infobox "Checking EEPROM status before switching kernels..."
checkOutput=$(sudo "${sudoFlags[@]}" rpi-eeprom-update 2>&1)
checkResult=$?
case $checkResult in
0)
return 0
;;
1)
msgbox "The Raspberry Pi 5 kernel switch is blocked because an EEPROM update is available.\n\n${checkOutput}\n\nRun Update EEPROM, reboot if an update is applied, then try the kernel switch again."
;;
2)
msgbox "The Raspberry Pi 5 kernel switch is blocked because the EEPROM status check failed.\n\n${checkOutput}"
;;
3)
msgbox "The Raspberry Pi 5 kernel switch is blocked because the EEPROM is currently frozen and cannot be verified as up to date.\n\n${checkOutput}\n\nThis may require a reboot to resolve."
;;
*)
msgbox "The Raspberry Pi 5 kernel switch is blocked because EEPROM status could not be verified (exit code: ${checkResult}).\n\n${checkOutput}"
;;
esac
return 1
}
updateEeprom() {
local piModel
local eepromPackage
piModel=$(getRaspberryPiModel)
# Guard against non-Pi hardware
if [[ -z "$piModel" ]] || [[ "$piModel" != *"Raspberry Pi"* ]]; then
@@ -20,24 +85,11 @@ Detected model: ${piModel:-unknown}
If you are not running on a Raspberry Pi, this option will not work correctly."
return 1
fi
# 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
eepromPackage=$(getEepromPackage "$piModel")
# 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
if ! ensureEepromPackage "$eepromPackage"; then
return 1
fi
# Check for EEPROM updates
@@ -84,4 +136,6 @@ If you are not running on a Raspberry Pi, this option will not work correctly."
}
# Execute the update function when sourced
updateEeprom
if [[ "${eepromUpdateAutoRun:-true}" == "true" ]]; then
updateEeprom
fi
+6
View File
@@ -90,6 +90,12 @@ while [[ "$choice" != "Exit" ]]; do
sudo "${sudoFlags[@]}" systemctl enable bluetooth --now
;;
"Install Raspberry Pi 5 kernel")
eepromUpdateAutoRun=false
source .includes/eeprom.sh
unset eepromUpdateAutoRun
if ! requireCurrentEepromForPi5Kernel; then
continue
fi
yay -R --noconfirm linux-rpi
install_package linux-rpi-16k
;;