gooftool: fix --clear_gbb_flags

Sometimes flashrom default target bus will be changed to LPC and then calling
flashrom without bus param will be incorrect value.

To fix that, we should always assign bus when calling flashrom.

BUG=chrome-os-partner:8396
TEST=./gooftool --clear_gbb_flags

Change-Id: I4d1f4cde3f04400e42c0cedef31544e7037b3798
Reviewed-on: https://gerrit.chromium.org/gerrit/17581
Reviewed-by: Tammo Spalink <tammo@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/gft_clear_gbb_flags.sh b/gft_clear_gbb_flags.sh
index b041c06..727b349 100755
--- a/gft_clear_gbb_flags.sh
+++ b/gft_clear_gbb_flags.sh
@@ -18,6 +18,8 @@
 TMPFILE="$(mktemp --tmpdir)"
 FIRMWARE_IMAGE="$([ -z "$1" ] || readlink -f "$1")"
 RETRIES=2
+FLASHROM_READ_PARAM="flashrom -p internal:bus=spi"
+FLASHROM_WRITE_PARAM="flashrom -p internal:bus=spi --fast-verify"
 
 cleanup() {
   rm -f "$_STDERR" "$_STDOUT" "$TMPFILE"
@@ -44,7 +46,7 @@
   local flags_info flags
   if [ -z "$FIRMWARE_IMAGE" ]; then
     FIRMWARE_IMAGE="$TMPFILE"
-    invoke "Read GBB" "flashrom -i GBB -r '$FIRMWARE_IMAGE'"
+    invoke "Read GBB" "$FLASHROM_READ_PARAM -i GBB -r '$FIRMWARE_IMAGE'"
   fi
 
   flags_info="$(invoke "Flags" "gbb_utility -g --flags '$FIRMWARE_IMAGE'")" ||
@@ -63,9 +65,9 @@
     # Try to update GBB flags
     alert "Clearing system GBB header flag..."
     invoke "Set Flags" "gbb_utility -s --flags=0 '$FIRMWARE_IMAGE' '$TMPFILE'"
-    invoke "Write GBB" "flashrom -w '$TMPFILE' -i GBB --fast-verify"
+    invoke "Write GBB" "$FLASHROM_WRITE_PARAM -i GBB -w '$TMPFILE'"
     rm -f "$TMPFILE"
-    invoke "Read GBB" "flashrom -r '$TMPFILE' -i GBB"
+    invoke "Read GBB" "$FLASHROM_READ_PARAM -i GBB -r '$TMPFILE'"
     alert "Re-try verification..."
     FIRMWARE_IMAGE="$TMPFILE"
   fi