From 0f0e30eb44f2bbbaa58c891ed24bd785d2e2c008 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 28 Oct 2015 15:57:47 -0400 Subject: flashrom_write(): New function --- (limited to 'src') diff --git a/src/flashrom.sh b/src/flashrom.sh index 078dc79..cf0bcbf 100644 --- a/src/flashrom.sh +++ b/src/flashrom.sh @@ -17,6 +17,7 @@ flashrom_probe() { + local line='' local board_vendor='' local board_part='' local board_found=false @@ -83,3 +84,33 @@ flashrom_probe() return 0 } + +flashrom_write() +{ + local chip="${1}" + shift 1 + local line='' + local verified=false + + info 'Writing flash' + + IFS='' + while read -r line; do + unset IFS + if [ "x${line}" = 'xVerifying flash... VERIFIED.' ]; then + verified=true + fi + dbg 'flashrom: %s' "${line}" + IFS='' + done <<-EOF + $(${FLASHROM} -p internal -c "${chip}" -w "$(get_temp_dir)/rom") + EOF + unset IFS + + if ! ${verified}; then + err 'Failed to write firmware' + return 1 + fi + + return 0 +} -- cgit v0.9.1