Tweaks to boot ROM update code

This commit is contained in:
Simon Long 2020-07-06 14:04:52 +01:00
parent bc5a153c02
commit 4a55376c60

View File

@ -1248,8 +1248,8 @@ do_boot_order() {
do_boot_rom() { do_boot_rom() {
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
BOOTOPT=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Boot ROM Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ BOOTOPT=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Boot ROM Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \
"E1 Stable" "Use the stable boot ROM software image" \ "E1 Latest" "Use the latest version boot ROM software" \
"E2 Critical" "Use the critical boot ROM software image" \ "E2 Default" "Use the factory default boot ROM software" \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
else else
BOOTOPT=$1 BOOTOPT=$1
@ -1259,11 +1259,11 @@ do_boot_rom() {
case "$BOOTOPT" in case "$BOOTOPT" in
E1*) E1*)
sed /etc/default/rpi-eeprom-update -i -e "s/FIRMWARE_RELEASE_STATUS.*/FIRMWARE_RELEASE_STATUS=\"stable\"/" sed /etc/default/rpi-eeprom-update -i -e "s/FIRMWARE_RELEASE_STATUS.*/FIRMWARE_RELEASE_STATUS=\"stable\"/"
EETYPE="Stable" EETYPE="Latest version"
;; ;;
E2*) E2*)
sed /etc/default/rpi-eeprom-update -i -e "s/FIRMWARE_RELEASE_STATUS.*/FIRMWARE_RELEASE_STATUS=\"critical\"/" sed /etc/default/rpi-eeprom-update -i -e "s/FIRMWARE_RELEASE_STATUS.*/FIRMWARE_RELEASE_STATUS=\"critical\"/"
EETYPE="Critical" EETYPE="Factory default"
;; ;;
*) *)
whiptail --msgbox "Programmer error, unrecognised boot ROM option" 20 60 2 whiptail --msgbox "Programmer error, unrecognised boot ROM option" 20 60 2
@ -1271,28 +1271,22 @@ do_boot_rom() {
;; ;;
esac esac
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "$EETYPE EEPROM set - will be loaded at next reboot.\nWould you like to reset boot ROM to defaults?" 20 60 2 whiptail --yesno "$EETYPE boot ROM selected - will be loaded at next reboot.\n\nReset boot ROM to defaults?" 20 60 2
DEFAULTS=$? DEFAULTS=$?
else else
DEFAULTS=$2 DEFAULTS=$2
fi fi
if [ "$DEFAULTS" -eq 0 ]; then # yes if [ "$DEFAULTS" -eq 0 ]; then # yes
CURDATE=$(date -d "`vcgencmd bootloader_version | head -n 1`" +%Y%m%d)
FILNAME="none"
if grep -q "stable" /etc/default/rpi-eeprom-update ; then if grep -q "stable" /etc/default/rpi-eeprom-update ; then
EEPATH="/lib/firmware/raspberrypi/bootloader/stable/pieeprom*.bin" EEPATH="/lib/firmware/raspberrypi/bootloader/stable/"
else else
EEPATH="/lib/firmware/raspberrypi/bootloader/critical/pieeprom*.bin" EEPATH="/lib/firmware/raspberrypi/bootloader/critical/"
fi fi
for filename in $EEPATH ; do MATCH=".*/pieeprom-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].bin"
FILDATE=$(date -d "`echo $filename | cut -d - -f 2- | cut -d . -f 1`" +%Y%m%d) FILNAME="$(find "${EEPATH}" -maxdepth 1 -type f -size 524288c -regex "${MATCH}" | sort -r | head -n1)"
if [ $FILDATE -eq $CURDATE ]; then if [ -z "$FILNAME" ]; then
FILNAME=$filename
fi
done
if [ "$FILNAME" = "none" ]; then
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "No EEPROM bin file found for version `date -d $CURDATE +%Y-%m-%d` - cannot reset to defaults" 20 60 2 whiptail --msgbox "No EEPROM bin file found - cannot reset to defaults" 20 60 2
fi fi
else else
rpi-eeprom-update -d -f $FILNAME rpi-eeprom-update -d -f $FILNAME
@ -2521,7 +2515,7 @@ do_boot_menu() {
"B2 Wait for Network at Boot" "Choose whether to wait for network connection during boot" \ "B2 Wait for Network at Boot" "Choose whether to wait for network connection during boot" \
"B3 Splash Screen" "Choose graphical splash screen or text boot" \ "B3 Splash Screen" "Choose graphical splash screen or text boot" \
"B4 Boot Order" "Choose network or USB device boot" \ "B4 Boot Order" "Choose network or USB device boot" \
"B5 Boot ROM Version" "Select stable or critical boot ROM release" \ "B5 Boot ROM Version" "Select latest or default boot ROM software" \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
else else
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Boot Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \ FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Boot Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \