Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions firmware-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#where the stuff is
script_url="https://raw.githubusercontent.com/MrChromebox/scripts/master/"
# usage: sudo DEV_MODE=true bash firmware-util.sh
# it will use local version of scripts
dev_mode=${DEV_MODE:-false}

#ensure output of system tools in en-us for parsing
export LC_ALL=C
Expand All @@ -23,7 +26,7 @@ if grep -q "Chrom" /etc/lsb-release ; then
mkdir -p /usr/local/bin
cd /usr/local/bin
else
cd /tmp
[[ "$dev_mode" == false ]] && cd /tmp
fi

#check for cmd line param, expired CrOS certs
Expand All @@ -33,20 +36,22 @@ else
export CURL="curl"
fi

#get support scripts
echo -e "\nDownloading supporting files..."
rm -rf firmware.sh >/dev/null 2>&1
rm -rf functions.sh >/dev/null 2>&1
rm -rf sources.sh >/dev/null 2>&1
$CURL -sLO ${script_url}firmware.sh
rc0=$?
$CURL -sLO ${script_url}functions.sh
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
if [[ "$dev_mode" == false ]]; then
#get support scripts
echo -e "\nDownloading supporting files..."
rm -rf firmware.sh >/dev/null 2>&1
rm -rf functions.sh >/dev/null 2>&1
rm -rf sources.sh >/dev/null 2>&1
$CURL -sLO ${script_url}firmware.sh
rc0=$?
$CURL -sLO ${script_url}functions.sh
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
fi
fi

source ./sources.sh
Expand Down
69 changes: 49 additions & 20 deletions firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ else
fwTypeStr="UEFI"
fi

echo_green "\nInstall/Update ${fwTypeStr} Full ROM Firmware"

if [[ "$hasLocalPath" = true ]]; then
echo_green "\nInstall/Update Custom ${fwTypeStr} Full ROM Firmware from local path"
else
echo_green "\nInstall/Update ${fwTypeStr} Full ROM Firmware"
fi
echo_yellow "IMPORTANT: flashing the firmware has the potential to brick your device,
requiring relatively inexpensive hardware and some technical knowledge to
recover.Not all boards can be tested prior to release, and even then slight
Expand All @@ -187,6 +192,12 @@ read -ep "Do you wish to continue? [y/N] "
#spacing
echo -e ""

if [[ "$hasLocalPath" = true ]]; then
read -ep "Please provide local path for Full ROM Firmware: "
[[ -f "$REPLY" ]] || { exit_red "->$REPLY<- file does note exist"; return 1; }
coreboot_file=$REPLY
fi

# ensure hardware write protect disabled
[[ "$wpEnabled" = true ]] && { exit_red "\nHardware write-protect enabled, cannot flash Full ROM firmware."; return 1; }

Expand Down Expand Up @@ -253,16 +264,18 @@ OS; ${currOS} will no longer be bootable. See https://mrchromebox.tech/#faq"
[[ "$REPLY" = "y" || "$REPLY" = "Y" ]] || return
fi

#determine correct file / URL
firmware_source=${fullrom_source}
if [[ "$hasUEFIoption" = true || "$hasLegacyOption" = true ]]; then
if [ "$useUEFI" = true ]; then
eval coreboot_file=$`echo "coreboot_uefi_${device}"`
else
eval coreboot_file=$`echo "coreboot_${device}"`
fi
else
exit_red "Unknown or unsupported device (${device^^}); cannot continue."; return 1
if [[ "hasLocalPath" == false ]];then
#determine correct file / URL
firmware_source=${fullrom_source}
if [[ "$hasUEFIoption" = true || "$hasLegacyOption" = true ]]; then
if [ "$useUEFI" = true ]; then
eval coreboot_file=$`echo "coreboot_uefi_${device}"`
else
eval coreboot_file=$`echo "coreboot_${device}"`
fi
else
exit_red "Unknown or unsupported device (${device^^}); cannot continue."; return 1
fi
fi

#auron special case (upgrade from coolstar legacy rom)
Expand Down Expand Up @@ -381,13 +394,17 @@ fi

#download firmware file
cd /tmp
echo_yellow "\nDownloading Full ROM firmware\n(${coreboot_file})"
$CURL -sLO "${firmware_source}${coreboot_file}"
$CURL -sLO "${firmware_source}${coreboot_file}.sha1"

#verify checksum on downloaded file
sha1sum -c ${coreboot_file}.sha1 --quiet > /dev/null 2>&1
[[ $? -ne 0 ]] && { exit_red "Firmware download checksum fail; download corrupted, cannot flash."; return 1; }
if [[ "$hasLocalPath" = false ]]; then
echo_yellow "\nDownloading Full ROM firmware\n(${coreboot_file})"

$CURL -sLO "${firmware_source}${coreboot_file}"
$CURL -sLO "${firmware_source}${coreboot_file}.sha1"

#verify checksum on downloaded file
sha1sum -c ${coreboot_file}.sha1 --quiet > /dev/null 2>&1
[[ $? -ne 0 ]] && { exit_red "Firmware download checksum fail; download corrupted, cannot flash."; return 1; }
fi

#preferUSB?
if [[ "$preferUSB" = true && $useUEFI = false ]]; then
Expand Down Expand Up @@ -1426,10 +1443,15 @@ function uefi_menu() {
else
echo -e "${GRAY_TEXT}** ${GRAY_TEXT} 1)${GRAY_TEXT} Install/Update UEFI (Full ROM) Firmware${NORMAL}"
fi
if [[ "$hasUEFIoption" = true ]]; then
echo -e "${MENU}**${WP_TEXT} [WP]${NUMBER} 2)${MENU} Install/Update Custom UEFI (Full ROM) Firmware from local path ${NORMAL}"
else
echo -e "${GRAY_TEXT}** ${GRAY_TEXT} 2)${GRAY_TEXT} Install/Update Custom UEFI (Full ROM) Firmware from local path${NORMAL}"
fi
if [[ "$isChromeOS" = false && "$isFullRom" = true ]]; then
echo -e "${MENU}**${WP_TEXT} [WP]${NUMBER} 2)${MENU} Restore Stock Firmware ${NORMAL}"
echo -e "${MENU}**${WP_TEXT} [WP]${NUMBER} 3)${MENU} Restore Stock Firmware ${NORMAL}"
else
echo -e "${GRAY_TEXT}** ${GRAY_TEXT} 2)${GRAY_TEXT} Restore Stock ChromeOS Firmware ${NORMAL}"
echo -e "${GRAY_TEXT}** ${GRAY_TEXT} 3)${GRAY_TEXT} Restore Stock ChromeOS Firmware ${NORMAL}"
fi
if [[ "${device^^}" = "EVE" ]]; then
echo -e "${MENU}**${WP_TEXT} [WP]${NUMBER} D)${MENU} Downgrade Touchpad Firmware ${NORMAL}"
Expand All @@ -1450,7 +1472,14 @@ function uefi_menu() {
uefi_menu
;;

2) if [[ "$isChromeOS" = false && "$isUnsupported" = false \
2) if [[ "$hasUEFIoption" = true ]]; then
hasLocalPath=true
flash_coreboot
fi
uefi_menu
;;

3) if [[ "$isChromeOS" = false && "$isUnsupported" = false \
&& "$isFullRom" = true ]]; then
restore_stock_firmware
menu_fwupdate
Expand Down
1 change: 1 addition & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ hasCR50=false
kbl_use_rwl18=false
useAltfwStd=false
runsWindows=false
hasLocalPath=false

hsw_boxes=('mccloud' 'panther' 'tricky' 'zako')
hsw_books=('falco' 'leon' 'monroe' 'peppy' 'wolf')
Expand Down