faft: Wrap the underlying EC flash write protect command
This CL wraps the underlying flash write protect command into a method.
It makes the write protect more easy to be used without knowing any detail
of the EC command.
BUG=chromium-os:35254
TEST=run_remote_tests.sh --board link --remote dut ECWriteProtect/control$
Change-Id: If36345c5741ed7be9a962fba25fab25b4f2121e9
Reviewed-on: https://gerrit.chromium.org/gerrit/36867
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/chrome_ec.py b/server/cros/chrome_ec.py
index cc7445f..8ce7c9d 100644
--- a/server/cros/chrome_ec.py
+++ b/server/cros/chrome_ec.py
@@ -166,3 +166,15 @@
raise error.TestError(
'The flag %s of EC reboot command is invalid.' % flag)
self.send_command("reboot %s" % flags)
+
+
+ def set_flash_write_protect(self, enable):
+ """Set the software write protect of EC flash.
+
+ Args:
+ enable: True to enable write protect, False to disable.
+ """
+ if enable:
+ self.send_command("flashwp enable")
+ else:
+ self.send_command("flashwp disable")
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index 9e4b504..3bb327a 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -623,7 +623,7 @@
})
- def set_hardware_write_protect(self, enabled):
+ def set_hardware_write_protect(self, enable):
"""Set hardware write protect pin.
Args:
@@ -631,10 +631,10 @@
"""
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 enabled else 'off')
+ self.servo.set('fw_wp', 'on' if enable else 'off')
- def set_EC_write_protect_and_reboot(self, enabled):
+ def set_EC_write_protect_and_reboot(self, enable):
"""Set EC write protect status and reboot to take effect.
EC write protect is only activated if both hardware write protect pin
@@ -652,16 +652,16 @@
Args:
enable: True if activating EC write protect. Otherwise, False.
"""
- self.set_hardware_write_protect(enabled)
- if enabled:
+ self.set_hardware_write_protect(enable)
+ if enable:
# Set write protect flag and reboot to take effect.
- self.ec.send_command("flashwp enable")
+ self.ec.set_flash_write_protect(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.ec.send_command("flashwp disable")
+ self.ec.set_flash_write_protect(enable)
def press_ctrl_d(self):