FAFT: Add support of EC write protect
This method asserts/deasserts hardware write protect pin and set
corresponding EC write protect flags.
Signed-off-by: Vic Yang <victoryang@chromium.org>
BUG=chrome-os-partner:13229
TEST=Check we can enable/disable write protect.
Change-Id: I624253cb8e3c93cf4ea3607adf0dd7b156d589c8
Reviewed-on: https://gerrit.chromium.org/gerrit/31551
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index f9911d1..69f96b5 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -720,7 +720,7 @@
})
- def enable_write_protect(self, enable):
+ def set_hardware_write_protect(self, enabled):
"""Set hardware write protect pin.
Args:
@@ -728,7 +728,37 @@
"""
self.servo.set('fw_wp_vref', self.client_attr.wp_voltage)
self.servo.set('fw_wp_en', 'on')
- self.servo.set('fw_wp', 'on' if enable else 'off')
+ self.servo.set('fw_wp', 'on' if enabled else 'off')
+
+
+ def set_EC_write_protect_and_reboot(self, enabled):
+ """Set EC write protect status and reboot to take effect.
+
+ EC write protect is only activated if both hardware write protect pin
+ is asserted and software write protect flag is set. Also, a reboot is
+ required for write protect to take effect.
+
+ Since the software write protect flag cannot be unset if hardware write
+ protect pin is asserted, we need to deasserted the pin first if we are
+ deactivating write protect. Similarly, a reboot is required before we
+ can modify the software flag.
+
+ This method asserts/deasserts hardware write protect pin first, and
+ set corresponding EC software write protect flag.
+
+ Args:
+ enable: True if activating EC write protect. Otherwise, False.
+ """
+ self.set_hardware_write_protect(enabled)
+ if enabled:
+ # Set write protect flag and reboot to take effect.
+ self.send_uart_command("flashwp enable")
+ self.sync_and_ec_reboot()
+ else:
+ # Reboot after deasserting hardware write protect pin to deactivate
+ # write protect. And then remove software write protect flag.
+ self.sync_and_ec_reboot()
+ self.send_uart_command("flashwp disable")
def send_ctrl_d_to_dut(self):