Add check for EC presence
This patch adds a check for EC presence by using the "mosys ec info"
command. If the EC is not present, then skip any operation that
updates EC firmware ROM (e.g. all "flashrom -p internal:bus=lpc" call sites)
BUG=chrome-os-partner:6783
TEST=Tested on stumpy
Change-Id: I1ffbf035d61309e42d7f6687ab910341c372883e
Reviewed-on: https://gerrit.chromium.org/gerrit/11422
Reviewed-by: Jay Kim <yongjaek@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/11565
diff --git a/factory_install.sh b/factory_install.sh
index 303bf6e..0e59056 100644
--- a/factory_install.sh
+++ b/factory_install.sh
@@ -31,6 +31,7 @@
# Global variables
DST_DRIVE=""
+EC_PRESENT=0
# Starting
# Change color in tty1 by ANSI escape sequence code
@@ -75,13 +76,20 @@
clear_fwwp() {
log "Firmware Write Protect disabled, clearing status registers."
- flashrom -p internal:bus=lpc --wp-disable
+ if [ $EC_PRESENT -eq 1 ]; then
+ flashrom -p internal:bus=lpc --wp-disable
+ fi
flashrom -p internal:bus=spi --wp-disable
log "WP registers should be cleared now"
}
ensure_fwwp_consistency() {
local ec_wp main_wp
+
+ if [ $EC_PRESENT -eq 0 ]; then
+ return
+ fi
+
ec_wp="$(flashrom -p internal:bus=lpc --wp-status 2>/dev/null)" || return
main_wp="$(flashrom -p internal:bus=spi --wp-status 2>/dev/null)"
ec_wp="$(echo "$ec_wp" | sed -nr 's/WP.*(disabled|enabled).$/\1/pg')"
@@ -603,6 +611,23 @@
fi
}
+test_ec_presence() {
+ set +e # Failure is an option here.
+
+ # If "mosys ec info" command succeeds (returns 0), then EC is present
+ # in system. Otherwise, assume EC is not present or supported.
+ mosys ec info >/dev/null
+ if [ $? -eq 0 ]; then
+ log "EC is present"
+ EC_PRESENT=1
+ else
+ log "EC is not present or supported"
+ EC_PRESENT=0
+ fi
+
+ set -e
+}
+
#
# factory_install.sh implements two operations for assembly line
# operators: install (obviously) and reset.
@@ -627,6 +652,9 @@
lightup_screen
colorize "green"
+
+ test_ec_presence
+
reset_chromeos_device
local install_from_omaha="1"