Skip to content

Commit

Permalink
Formatting: Use consistent intendation (4 spaces)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt DeVillier <[email protected]>
  • Loading branch information
MrChromebox committed Feb 17, 2023
1 parent ad259ad commit 3c8026e
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 387 deletions.
16 changes: 8 additions & 8 deletions firmware-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ export LC_ALL=C

#set working dir
if grep -q "Chrom" /etc/lsb-release ; then
# needed for ChromeOS/ChromiumOS v82+
mkdir -p /usr/local/bin
cd /usr/local/bin
# needed for ChromeOS/ChromiumOS v82+
mkdir -p /usr/local/bin
cd /usr/local/bin
else
cd /tmp
cd /tmp
fi

#check for cmd line param, expired CrOS certs
if ! curl -sLo /dev/null https://mrchromebox.tech/index.html || [[ "$1" = "-k" ]]; then
export CURL="curl -k"
export CURL="curl -k"
else
export CURL="curl"
export CURL="curl"
fi

#get support scripts
Expand All @@ -45,8 +45,8 @@ rc1=$?
$CURL -sLO ${script_url}sources.sh
rc2=$?
if [[ $rc0 -ne 0 || $rc1 -ne 0 || $rc2 -ne 0 ]]; then
echo -e "Error downloading one or more required files; cannot continue"
exit 1
echo -e "Error downloading one or more required files; cannot continue"
exit 1
fi

source ./sources.sh
Expand Down
202 changes: 101 additions & 101 deletions firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ elif [ "$isZen2" = true ]; then
elif [ "$isTgl" = true ]; then
rwlegacy_file=$rwl_altfw_tgl
elif [ "$isGlk" = true ]; then
rwlegacy_file=$rwl_altfw_glk
rwlegacy_file=$rwl_altfw_glk
else
echo_red "Unknown or unsupported device (${device}); cannot update RW_LEGACY firmware."
read -ep "Press enter to return to the main menu"
Expand Down Expand Up @@ -92,9 +92,9 @@ md5sum -c ${rwlegacy_file}.md5 --quiet 2> /dev/null
if [ "$preferUSB" = true ]; then
#swanky special case
if [[ "$device" = "swanky" ]]; then
$CURL -sLo bootorder "${cbfs_source}bootorder.usb2"
$CURL -sLo bootorder "${cbfs_source}bootorder.usb2"
else
$CURL -sLo bootorder "${cbfs_source}bootorder.usb"
$CURL -sLo bootorder "${cbfs_source}bootorder.usb"
fi
if [ $? -ne 0 ]; then
echo_red "Unable to download bootorder file; boot order cannot be changed."
Expand Down Expand Up @@ -406,13 +406,13 @@ sha1sum -c ${coreboot_file}.sha1 --quiet > /dev/null 2>&1

#preferUSB?
if [[ "$preferUSB" = true && $useUEFI = false ]]; then
$CURL -sLo bootorder "${cbfs_source}bootorder.usb"
if [ $? -ne 0 ]; then
echo_red "Unable to download bootorder file; boot order cannot be changed."
else
${cbfstoolcmd} ${coreboot_file} remove -n bootorder > /dev/null 2>&1
${cbfstoolcmd} ${coreboot_file} add -n bootorder -f /tmp/bootorder -t raw > /dev/null 2>&1
fi
$CURL -sLo bootorder "${cbfs_source}bootorder.usb"
if [ $? -ne 0 ]; then
echo_red "Unable to download bootorder file; boot order cannot be changed."
else
${cbfstoolcmd} ${coreboot_file} remove -n bootorder > /dev/null 2>&1
${cbfstoolcmd} ${coreboot_file} add -n bootorder -f /tmp/bootorder -t raw > /dev/null 2>&1
fi
fi

#persist serial number?
Expand Down Expand Up @@ -480,11 +480,11 @@ fi
#clear SW WP range
${flashromcmd} --wp-range 0 0 > /dev/null 2>&1
if [ $? -ne 0 ]; then
# use new command format as of commit 99b9550
${flashromcmd} --wp-range 0,0 > /dev/null 2>&1
if [[ $? -ne 0 && $swWp = "enabled" ]]; then
exit_red "Error clearing software write-protect range; unable to flash firmware."; return 1
fi
# use new command format as of commit 99b9550
${flashromcmd} --wp-range 0,0 > /dev/null 2>&1
if [[ $? -ne 0 && $swWp = "enabled" ]]; then
exit_red "Error clearing software write-protect range; unable to flash firmware."; return 1
fi
fi

#flash Full ROM firmware
Expand All @@ -502,17 +502,17 @@ fi
#check if flashrom supports logging to file
if ${flashromcmd} -L -o /dev/null >/dev/null 2>&1 ; then
output_params=">/dev/null 2>&1 -o /tmp/flashrom.log"
${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} >/dev/null 2>&1 -o /tmp/flashrom.log
${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} >/dev/null 2>&1 -o /tmp/flashrom.log
else
output_params=">/tmp/flashrom.log 2>&1"
${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} >/tmp/flashrom.log 2>&1
${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} >/tmp/flashrom.log 2>&1
fi
if [ $? -ne 0 ]; then
echo_red "Error running cmd: ${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} ${output_params}"
if [ -f /tmp/flashrom.log ]; then
read -rp "Press enter to view the flashrom log file, then space for next page, q to quit"
echo_red "Error running cmd: ${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} ${output_params}"
if [ -f /tmp/flashrom.log ]; then
read -rp "Press enter to view the flashrom log file, then space for next page, q to quit"
more /tmp/flashrom.log
fi
fi
exit_red "An error occurred flashing the Full ROM firmware. DO NOT REBOOT!"; return 1
else
echo_green "Full ROM firmware successfully installed/updated."
Expand Down Expand Up @@ -613,14 +613,14 @@ read -ep "Do you wish to continue? [y/N] "

# check if EOL
if [ "$isEOL" = true ]; then
echo_yellow "\nVERY IMPORTANT:
echo_yellow "\nVERY IMPORTANT:
Your device has reached end of life (EOL) and is no longer supported by Google.
Returning the to stock firmware **IS NOT RECOMMENDED**.
MrChromebox will not provide any support for EOL devices running anything
other than the latest UEFI Full ROM firmware release."

read -ep "Do you wish to continue? [y/N] "
[[ "$REPLY" = "Y" || "$REPLY" = "y" ]] || return
read -ep "Do you wish to continue? [y/N] "
[[ "$REPLY" = "Y" || "$REPLY" = "y" ]] || return
fi

#spacing
Expand Down Expand Up @@ -673,82 +673,82 @@ Connect the USB/SD device which contains the backed-up stock firmware and press
echo -e ""

else
if [[ "$hasShellball" = true ]]; then
#download firmware extracted from recovery image
echo_yellow "\nThat's ok, I'll download a shellball firmware for you."

if [ "${boardName^^}" = "PANTHER" ]; then
echo -e "Which device do you have?\n"
echo "1) Asus CN60 [PANTHER]"
echo "2) HP CB1 [ZAKO]"
echo "3) Dell 3010 [TRICKY]"
echo "4) Acer CXI [MCCLOUD]"
echo "5) LG Chromebase [MONROE]"
echo ""
read -ep "? " fw_num
if [[ $fw_num -lt 1 || $fw_num -gt 5 ]]; then
exit_red "Invalid input - cancelling"
return 1
fi
#confirm menu selection
echo -e ""
read -ep "Confirm selection number ${fw_num} [y/N] "
[[ "$REPLY" = "y" || "$REPLY" = "Y" ]] || { exit_red "User cancelled restoring stock firmware"; return; }

#download firmware file
echo -e ""
echo_yellow "Downloading recovery image firmware file"
case "$fw_num" in
1) _device="panther";
;;
2) _device="zako";
;;
3) _device="tricky";
;;
4) _device="mccloud";
;;
5) _device="monroe";
;;
esac
else
#confirm device detection
echo_yellow "Confirm system details:"
echo -e "Device: ${deviceDesc}"
echo -e "Board Name: ${boardName^^}"
echo -e ""
read -ep "? [y/N] "
if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then
exit_red "Device detection failed; unable to restoring stock firmware"
return 1
fi
echo -e ""
_device=${boardName,,}
fi

#download shellball ROM
echo_yellow "Downloading shellball.${_device}.bin"
$CURL -sLo /tmp/stock-firmware.rom ${shellball_source}shellball.${_device}.bin;
[[ $? -ne 0 ]] && { exit_red "Error downloading; unable to restore stock firmware."; return 1; }

else
# no shellball available, offer to use recovery image
if [[ "$hasShellball" = true ]]; then
#download firmware extracted from recovery image
echo_yellow "\nThat's ok, I'll download a shellball firmware for you."

if [ "${boardName^^}" = "PANTHER" ]; then
echo -e "Which device do you have?\n"
echo "1) Asus CN60 [PANTHER]"
echo "2) HP CB1 [ZAKO]"
echo "3) Dell 3010 [TRICKY]"
echo "4) Acer CXI [MCCLOUD]"
echo "5) LG Chromebase [MONROE]"
echo ""
read -ep "? " fw_num
if [[ $fw_num -lt 1 || $fw_num -gt 5 ]]; then
exit_red "Invalid input - cancelling"
return 1
fi
#confirm menu selection
echo -e ""
read -ep "Confirm selection number ${fw_num} [y/N] "
[[ "$REPLY" = "y" || "$REPLY" = "Y" ]] || { exit_red "User cancelled restoring stock firmware"; return; }

#download firmware file
echo -e ""
echo_yellow "Downloading recovery image firmware file"
case "$fw_num" in
1) _device="panther";
;;
2) _device="zako";
;;
3) _device="tricky";
;;
4) _device="mccloud";
;;
5) _device="monroe";
;;
esac
else
#confirm device detection
echo_yellow "Confirm system details:"
echo -e "Device: ${deviceDesc}"
echo -e "Board Name: ${boardName^^}"
echo -e ""
read -ep "? [y/N] "
if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then
exit_red "Device detection failed; unable to restoring stock firmware"
return 1
fi
echo -e ""
_device=${boardName,,}
fi

#download shellball ROM
echo_yellow "Downloading shellball.${_device}.bin"
$CURL -sLo /tmp/stock-firmware.rom ${shellball_source}shellball.${_device}.bin;
[[ $? -ne 0 ]] && { exit_red "Error downloading; unable to restore stock firmware."; return 1; }

else
# no shellball available, offer to use recovery image
echo_red "\nUnfortunately I don't have a stock firmware available to download for '${boardName^^}' at this time."
echo_yellow "Would you like to use one from a ChromeOS recovery image?\n
echo_yellow "Would you like to use one from a ChromeOS recovery image?\n
This will be a 2GB+ download and take a bit of time depending on your connection"
read -ep "Download and extract firmware from a recovery image? [y/N] "
if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then
echo_yellow "Sit tight, this will take some time as recovery images are 2GB+"
$CURL -LO https://raw.githubusercontent.com/coreboot/coreboot/master/util/chromeos/crosfirmware.sh
if ! bash crosfirmware.sh ${boardName,,} ; then
exit_red "Downloading/extracting from the recovery image failed"
return 1
fi
mv coreboot-Google_* /tmp/stock-firmware.rom
echo_yellow "Stock firmware successfully extracted from ChromeOS recovery image"
else
exit_red "No stock firmware available to restore"
return 1
fi
read -ep "Download and extract firmware from a recovery image? [y/N] "
if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then
echo_yellow "Sit tight, this will take some time as recovery images are 2GB+"
$CURL -LO https://raw.githubusercontent.com/coreboot/coreboot/master/util/chromeos/crosfirmware.sh
if ! bash crosfirmware.sh ${boardName,,} ; then
exit_red "Downloading/extracting from the recovery image failed"
return 1
fi
mv coreboot-Google_* /tmp/stock-firmware.rom
echo_yellow "Stock firmware successfully extracted from ChromeOS recovery image"
else
exit_red "No stock firmware available to restore"
return 1
fi
fi

#extract VPD from current firmware if present
Expand Down Expand Up @@ -1309,10 +1309,10 @@ function show_header() {
fi
if [ "$wpEnabled" = true ]; then
echo -e "${MENU}**${NUMBER} Fw WP: ${RED_TEXT}Enabled${NORMAL}"
WP_TEXT=${RED_TEXT}
WP_TEXT=${RED_TEXT}
else
echo -e "${MENU}**${NUMBER} Fw WP: ${NORMAL}Disabled"
WP_TEXT=${GREEN_TEXT}
WP_TEXT=${GREEN_TEXT}
fi
echo -e "${MENU}*********************************************************${NORMAL}"
}
Expand Down Expand Up @@ -1343,7 +1343,7 @@ function stock_menu() {
echo -e "${GRAY_TEXT}** ${GRAY_TEXT} 4)${GRAY_TEXT} Set Hardware ID (HWID) ${NORMAL}"
fi
if [[ "$unlockMenu" = true || ( "$isFullRom" = false && "$isBootStub" = false && \
("$isHsw" = true || "$isBdw" = true || "$isByt" = true || "$isBsw" = true )) ]]; then
("$isHsw" = true || "$isBdw" = true || "$isByt" = true || "$isBsw" = true )) ]]; then
echo -e "${MENU}**${WP_TEXT} [WP]${NUMBER} 5)${MENU} Remove ChromeOS Bitmaps ${NORMAL}"
echo -e "${MENU}**${WP_TEXT} [WP]${NUMBER} 6)${MENU} Restore ChromeOS Bitmaps ${NORMAL}"
fi
Expand Down
Loading

0 comments on commit 3c8026e

Please sign in to comment.