Add EC related functions for EC FAFT
To do EC FAFT, we need to control flashrom for EC and check status of
EC. This CL adds EC flashrom control and functions to reboot EC and
check EC running copy.
BUG=chrome-os-partner:9188
TEST=Run firmware_CorruptFwBodyB and it still works.
Check we can corrupt and restore EC with this CL.
Check we can reboot EC.
Check we can get the status of EC.
Change-Id: Ia0a1c737707c71792ee503f41e6da7c98980ada1
Reviewed-on: https://gerrit.chromium.org/gerrit/23111
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 5696ddc..b4ae003 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -92,6 +92,10 @@
USB_PLUG_DELAY = 10
# Delay after running the 'sync' command.
SYNC_DELAY = 5
+ # Delay for waiting client to return before EC reboot
+ EC_REBOOT_DELAY = 1
+ # Delay between EC reboot and pressing power button
+ POWER_BTN_DELAY = 0.5
CHROMEOS_MAGIC = "CHROMEOS"
CORRUPTED_MAGIC = "CORRUPTD"
@@ -405,6 +409,25 @@
return True
+ def ec_act_copy_checker(self, expected_copy):
+ """Check the EC running firmware copy matches.
+
+ Args:
+ expected_copy: A string containing 'RO', 'A', or 'B' indicating
+ the expected copy of EC running firmware.
+
+ Returns:
+ True if the current EC running copy matches; otherwise, False.
+ """
+ lines = self.faft_client.run_shell_command_get_output('ectool version')
+ pattern = re.compile("Firmware copy: (.*)")
+ for line in lines:
+ matched = pattern.match(line)
+ if matched and matched.group(1) == expected_copy:
+ return True
+ return False
+
+
def check_root_part_on_non_recovery(self, part):
"""Check the partition number of root device and on normal/dev boot.
@@ -658,6 +681,16 @@
self.servo.warm_reset()
+ def sync_and_ec_reboot(self):
+ """Request the client sync and do a EC triggered reboot."""
+ self.faft_client.run_shell_command('sync')
+ time.sleep(self.SYNC_DELAY)
+ self.faft_client.run_shell_command('(sleep %d; ectool reboot_ec)&' %
+ self.EC_REBOOT_DELAY)
+ time.sleep(self.EC_REBOOT_DELAY + self.POWER_BTN_DELAY)
+ self.servo.power_normal_press()
+
+
def _modify_usb_kernel(self, usb_dev, from_magic, to_magic):
"""Modify the kernel header magic in USB stick.