summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-10-28 15:57:47 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-10-28 15:57:47 (EDT)
commit0f0e30eb44f2bbbaa58c891ed24bd785d2e2c008 (patch)
tree7b25e33c114e9afa06fbd8de17016c615905904a
parent8f08d177034ecebbef56de92d645169171835b5d (diff)
downloadfirman.sh-0f0e30eb44f2bbbaa58c891ed24bd785d2e2c008.zip
firman.sh-0f0e30eb44f2bbbaa58c891ed24bd785d2e2c008.tar.gz
firman.sh-0f0e30eb44f2bbbaa58c891ed24bd785d2e2c008.tar.bz2
flashrom_write(): New function
-rw-r--r--src/flashrom.sh31
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
+}