aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Lahoudere <fabien.lahoudere@collabora.com>2020-01-17 13:02:01 +0100
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>2020-01-30 09:08:09 +0100
commitdfc68505440f79648daa02a7d2627e984edd6e16 (patch)
tree5963f118e1ee1ab98d3749ac8cff5de6c79d5475
parent53015aba43167533675a077bb5c04677c131e823 (diff)
downloadcros-ec-tests-dfc68505440f79648daa02a7d2627e984edd6e16.tar.gz
cros_ec_mcu: test_cros_fp_reboot: Check firmware transitions to RW copy
There is a bug where, after a reboot, the Fingerprint firmware stays in a loop and can't switch to the RW firmware. This test checks that the transition from RO to RW happens. Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
-rw-r--r--cros/helpers/mcu.py51
-rw-r--r--cros/tests/cros_ec_mcu.py20
2 files changed, 71 insertions, 0 deletions
diff --git a/cros/helpers/mcu.py b/cros/helpers/mcu.py
index 2a876dd..e1f09f3 100644
--- a/cros/helpers/mcu.py
+++ b/cros/helpers/mcu.py
@@ -10,6 +10,7 @@ EC_CMD_PROTO_VERSION = 0x0000
EC_CMD_HELLO = 0x0001
EC_CMD_GET_VERSION = 0x0002
EC_CMD_GET_FEATURES = 0x000D
+EC_CMD_REBOOT = 0x00D1
EC_HOST_PARAM_SIZE = 0xFC
@@ -58,6 +59,9 @@ EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37
EC_FEATURE_SCP = 39
EC_FEATURE_ISH = 40
+EC_IMAGE_UNKNOWN = 0
+EC_IMAGE_RO = 1
+EC_IMAGE_RW = 2
class cros_ec_command(Structure):
_fields_ = [
@@ -77,6 +81,13 @@ class ec_params_hello(Structure):
class ec_response_hello(Structure):
_fields_ = [("out_data", c_uint)]
+class ec_response_get_version(Structure):
+ _fields_ = [
+ ("version_string_ro", c_ubyte * 32),
+ ("version_string_rw", c_ubyte * 32),
+ ("reserved", c_ubyte * 32),
+ ("current_image", c_uint),
+ ]
class ec_params_get_features(Structure):
_fields_ = [("in_data", c_ulong)]
@@ -163,3 +174,43 @@ def mcu_hello(s, name):
s.assertEqual(cmd.result, 0)
# magic number that the EC answers on HELLO
s.assertEqual(response.out_data, 0xA1B2C3D4)
+
+def mcu_get_version(name):
+ if os.path.exists("/dev/" + name):
+ fd = open("/dev/" + name, "r")
+
+ response = ec_response_get_version()
+
+ cmd = cros_ec_command()
+ cmd.version = 0
+ cmd.command = EC_CMD_GET_VERSION
+ cmd.insize = sizeof(response)
+ cmd.outsize = 0
+
+ fcntl.ioctl(fd, EC_DEV_IOCXCMD, cmd)
+ memmove(addressof(response), addressof(cmd.data), cmd.insize)
+
+ fd.close()
+ if cmd.result == 0:
+ return response
+
+def mcu_reboot(name):
+ fd = open("/dev/" + name, "r")
+ cmd = cros_ec_command()
+ cmd.version = 0
+ cmd.command = EC_CMD_REBOOT
+ cmd.insize = 0
+ cmd.outsize = 0
+ try:
+ fcntl.ioctl(fd, EC_DEV_IOCXCMD, cmd)
+ except IOError:
+ pass
+ fd.close()
+
+def check_mcu_reboot_rw(s, name):
+ if not os.path.exists("/dev/" + name):
+ s.skipTest("cros_fp not present, skipping")
+ mcu_reboot(name)
+ response = mcu_get_version(name)
+ s.assertEqual(response.current_image, EC_IMAGE_RW)
+
diff --git a/cros/tests/cros_ec_mcu.py b/cros/tests/cros_ec_mcu.py
index 3b161f1..b38613f 100644
--- a/cros/tests/cros_ec_mcu.py
+++ b/cros/tests/cros_ec_mcu.py
@@ -42,3 +42,23 @@ class TestCrosECMCU(unittest.TestCase):
def test_cros_pd_hello(self):
""" Checks basic comunication with the power delivery controller. """
mcu_hello(self, "cros_pd")
+
+ def test_cros_fp_reboot(self):
+ """ Test reboot command on Fingerprint MCU.
+
+ Coming out of reset, the MCU boot into its RO firmware and
+ jumps to the RW version after validate its signature. If the
+ protocol used in RO version is different of the RW version, when
+ a reboot is issued the AP still uses the protocol version queried
+ before transition, this causes the AP to no communicate correctly
+ with the RO firmware and thus it doesn't switches to RW firmware.
+
+ This test detects the that situation and reports a failure when
+ the embedded controller is not able to transition from RO to RW,
+ which is an indication that there is a problem.
+
+ The above issue was fixed with the kernel patch 241a69ae8ea8
+ ("platform/chrome: cros_ec: Query EC protocol version if EC
+ transitions between RO/RW).
+ """
+ check_mcu_reboot_rw(self, "cros_fp")