Reinstate EEPROM config changes

This reverts commit 04ec68ab5c.
This commit is contained in:
Simon Long 2020-06-19 09:31:38 +01:00
parent f6cb301d64
commit 06094eef3e
1 changed files with 67 additions and 0 deletions

View File

@ -1178,6 +1178,65 @@ EOF
fi
}
do_boot_order() {
if [ "$INTERACTIVE" = True ]; then
BOOTOPT=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Boot Device Order" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \
"B1 USB Boot" "Boot from USB device if SD card boot fails" \
"B2 Network Boot" "Boot from network if SD card boot fails" \
3>&1 1>&2 2>&3)
else
BOOTOPT=$1
true
fi
if [ $? -eq 0 ]; then
CURDATE=$(date -d "`vcgencmd bootloader_version | head -n 1`" +%Y%m%d)
FILNAME="none"
for filename in /lib/firmware/raspberrypi/bootloader/critical/pieeprom*.bin ; do
FILDATE=$(date -d "`echo $filename | cut -d - -f 2- | cut -d . -f 1`" +%Y%m%d)
if [ $FILDATE -eq $CURDATE ]; then
FILNAME=$filename
fi
done
if [ "$FILNAME" = "none" ]; then
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "No EEPROM bin file found for version `date -d $CURDATE +%Y-%m-%d` - aborting" 20 60 2
fi
return 1
fi
EECFG=$(mktemp)
vcgencmd bootloader_config > $EECFG
case "$BOOTOPT" in
B1*)
if ! grep -q "BOOT_ORDER" $EECFG ; then
sed $EECFG -i -e "\$a[all]\nBOOT_ORDER=0xf41"
else
sed $EECFG -i -e "s/^BOOT_ORDER=.*/BOOT_ORDER=0xf41/"
fi
STATUS="USB device"
;;
B2*)
if ! grep -q "BOOT_ORDER" $EECFG ; then
sed $EECFG -i -e "\$a[all]\nBOOT_ORDER=0xf21"
else
sed $EECFG -i -e "s/^BOOT_ORDER=.*/BOOT_ORDER=0xf21/"
fi
STATUS="Network"
;;
*)
whiptail --msgbox "Programmer error, unrecognised boot option" 20 60 2
return 1
;;
esac
EEBIN=$(mktemp)
rpi-eeprom-config --config $EECFG --out $EEBIN $FILNAME
rpi-eeprom-update -d -f $EEBIN
ASK_TO_REBOOT=1
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "$STATUS is default boot device" 20 60 1
fi
fi
}
get_boot_wait() {
if test -e /etc/systemd/system/dhcpcd.service.d/wait.conf; then
echo 0
@ -2371,6 +2430,13 @@ do_boot_menu() {
"B1 Desktop / CLI" "Choose whether to boot into a desktop environment or the command line" \
"B2 Wait for Network at Boot" "Choose whether to wait for network connection during boot" \
3>&1 1>&2 2>&3)
elif is_pifour ; then
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 \
"B1 Desktop / CLI" "Choose whether to boot into a desktop environment or the command line" \
"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" \
"B4 Boot Order" "Choose network or USB device boot" \
3>&1 1>&2 2>&3)
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 \
"B1 Desktop / CLI" "Choose whether to boot into a desktop environment or the command line" \
@ -2386,6 +2452,7 @@ do_boot_menu() {
B1\ *) do_boot_behaviour ;;
B2\ *) do_boot_wait ;;
B3\ *) do_boot_splash ;;
B4\ *) do_boot_order ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi