| # Copyright 2020 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """A factory test to check the secdata version. |
| |
| Description |
| ----------- |
| This test checks if the secdata version is the expected version. |
| |
| Secdata is set by AP firmware. If the test fails, please confirm the expected |
| secdata version with the firmware team, and check if the AP firmware is too old. |
| |
| According to platform/vboot_reference/firmware/2lib/include/2secdata_struct.h, |
| secdata version is an 8-bit integer defined as (major << 4 | minor << 0). |
| |
| Test Procedure |
| -------------- |
| This is an automatic test that doesn't need any user interaction. |
| Ideally the test should always pass. However, if the test fails, we need to |
| clear secdata and let the system regenerate it again. It can be done by |
| |
| - Re-enable cr50 factory mode (`gsctool -a -F enable`), or |
| - Run `chromeos-tpm-recovery` by "(T) Reset TPM" action or "(R) Reset" action |
| in a factory shim, depending on whether the device is finalized or not |
| |
| |
| Dependency |
| ---------- |
| - `tpmc` |
| - `trunksd` not running. |
| |
| Examples |
| -------- |
| To verify that secdata version is 1.0: |
| |
| .. test_list:: |
| |
| generic_tpm_examples:CommonTests.CheckSecdataVersion |
| |
| """ |
| |
| from cros.factory.device import device_utils |
| from cros.factory.test import test_case |
| from cros.factory.utils.arg_utils import Arg |
| |
| |
| class SecdataVersionTest(test_case.TestCase): |
| """Checks the secdata version.""" |
| related_components = ( |
| test_case.TestCategory.SECURE_ELEMENT, |
| test_case.TestCategory.TPM, |
| ) |
| ARGS = [ |
| Arg('major_version', int, 'Major version of secdata.', default=1), |
| Arg('minor_version', int, 'Minor version of secdata.', default=0) |
| ] |
| |
| def setUp(self): |
| self.dut = device_utils.CreateDUTInterface() |
| |
| def runTest(self): |
| out = int(self.dut.CallOutput(['tpmc', 'read', '0x1008', '1']), 16) |
| # yapf: disable |
| expect = self.args.major_version << 4 | self.args.minor_version << 0 # type: ignore #TODO(b/338318729) Fixit! # pylint: disable=line-too-long |
| # yapf: enable |
| self.assertEqual(out, expect, 'Secdata version is incorrect') |