Skip to content

Commit 9f90d90

Browse files
committed
Check if flashrom supports logging, noverify before using param
Signed-off-by: Matt DeVillier <[email protected]>
1 parent 6291a42 commit 9f90d90

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

firmware.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,30 @@ fi
457457

458458
#flash Full ROM firmware
459459

460-
#flash without verify, to avoid IFD mismatch upon verification
460+
# ensure no issues overwriting log file
461+
rm -f /tmp/flashrom.log
462+
461463
echo_yellow "Installing Full ROM firmware (may take up to 90s)"
462-
${flashromcmd} ${flashrom_params} --noverify-all -w "${coreboot_file}" -o /tmp/flashrom.log > /dev/null 2>&1
464+
#check if flashrom supports --noverify-all
465+
if ${flashromcmd} -h | grep -q "noverify-all" ; then
466+
noverify="--noverify-all"
467+
else
468+
noverify="--noverify"
469+
fi
470+
#check if flashrom supports logging to file
471+
if ${flashromcmd} -L -o /dev/null >/dev/null 2>&1 ; then
472+
output_params=">/dev/null 2>&1 -o /tmp/flashrom.log"
473+
${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} >/dev/null 2>&1 -o /tmp/flashrom.log
474+
else
475+
output_params=">/tmp/flashrom.log 2>&1"
476+
${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} >/tmp/flashrom.log 2>&1
477+
fi
463478
if [ $? -ne 0 ]; then
464-
cat /tmp/flashrom.log
479+
echo_red "Error running cmd: ${flashromcmd} ${flashrom_params} ${noverify} -w ${coreboot_file} ${output_params}"
480+
if [ -f /tmp/flashrom.log ]; then
481+
read -rp "Press enter to view the flashrom log file, then space for next page, q to quit"
482+
more /tmp/flashrom.log
483+
fi
465484
exit_red "An error occurred flashing the Full ROM firmware. DO NOT REBOOT!"; return 1
466485
else
467486
echo_green "Full ROM firmware successfully installed/updated."

functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ fi
431431
#get device firmware info
432432
echo -e "\nGetting device/system info..."
433433
#try reading only BIOS region
434-
[[ "$isChromeoS" = "false" ]] && test_params=":ich_spi_mode=hwseq" || test_params=""
434+
[[ "$isChromeOS" = "false" ]] && test_params=":ich_spi_mode=hwseq" || test_params=""
435435
if ${flashromcmd}${test_params} --ifd -i bios -r /tmp/bios.bin > /dev/null 2>&1; then
436436
flashromcmd="${flashromcmd}${test_params}"
437437
flashrom_params="--ifd -i bios"

0 commit comments

Comments
 (0)