set_gbb_flags: Aborts only if HW & SW WP are both enabled.

Early proto devices (for testers and developers) may have hardware write
protection enabled and software disabled. They can still flash SPI ROM  in that
case, and no need to disable hardware WP switch.

BRANCH=none
BUG=chromium:341242
TEST=./set_gbb_flags.sh 0x39 # see WP messages.

Change-Id: Id320410795a162a009b80360c2225c7510337591
Reviewed-on: https://chromium-review.googlesource.com/186336
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
diff --git a/scripts/image_signing/set_gbb_flags.sh b/scripts/image_signing/set_gbb_flags.sh
index 157913a..f114d41 100755
--- a/scripts/image_signing/set_gbb_flags.sh
+++ b/scripts/image_signing/set_gbb_flags.sh
@@ -51,19 +51,20 @@
 # Check write protection
 # ----------------------------------------------------------------------------
 check_write_protection() {
-  local ret=$FLAGS_TRUE
+  local hw_wp="" sw_wp=""
   if ! crossystem "wpsw_boot?0"; then
-    echo "Hardware write protection must be disabled."
-    ret=$FLAGS_FALSE
+    hw_wp="on"
   fi
   local wp_states="$(flashrom --wp-status 2>/dev/null | grep WP)"
   local wp_disabled="$(echo "$wp_states" | grep "WP:.*is disabled.")"
   local wp_zero_len="$(echo "$wp_states" | grep "WP:.*, len=0x00000000")"
   if [ -z "$wp_disabled" -a -z "$wp_zero_len" ]; then
-    echo "Software write protection must be disabled."
-    ret=$FLAGS_FALSE
+    sw_wp="on"
   fi
-  return $ret
+  if [ -n "$hw_wp" -a -n "$sw_wp" ]; then
+    return $FLAGS_FALSE
+  fi
+  return $FLAGS_TRUE
 }
 
 # Main