diff options
-rw-r--r-- | src/flashrom.sh | 31 |
1 files changed, 31 insertions, 0 deletions
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 +} |