fingerprint: add fingerprint related test to generic test lists
Since currently we do not have generic fingerprint test, users may
end up using the legacy test in different boards. We thus add
fingerprint test to generic_common.test_list. Moreover, we modify
the UpdateFPFW test so that DUT updates the firmware from the release
image rather than a fixed version of a local copy.
BUG=b:187248821
TEST=make test; test manually on DUT
Change-Id: Ia0cc4a70cddae3ec152ca54570609416afe1d4fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/2886578
Tested-by: Ting-Hsuan Wang <phoebewang@chromium.org>
Reviewed-by: Cheng Yueh <cyueh@chromium.org>
Commit-Queue: Ting-Hsuan Wang <phoebewang@chromium.org>
diff --git a/po/vi-VN.po b/po/vi-VN.po
index 0da1347..75e38e8 100644
--- a/po/vi-VN.po
+++ b/po/vi-VN.po
@@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: ChromeOS Factory Software\n"
-"PO-Revision-Date: 2021-04-27 15:39+CST\n"
+"PO-Revision-Date: 2021-05-11 17:39+CST\n"
"Last-Translator: ChromeOS Factory Team\n"
"Language-Team: ChromeOS Factory Team\n"
"Language: vi-VN\n"
@@ -3351,6 +3351,10 @@
msgstr ""
#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Check Fingerprint Firmware"
+msgstr ""
+
+#: ../py/test/test_lists/generic_common.test_list.json
msgid "Check Point"
msgstr "Mức xác nhận"
@@ -3379,6 +3383,14 @@
msgstr "EC Viết bảo vệ"
#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Fingerprint Test Group"
+msgstr ""
+
+#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Fingerprint Sensor test"
+msgstr ""
+
+#: ../py/test/test_lists/generic_common.test_list.json
#: ../py/test/test_lists/generic_fat.test_list.json
#: ../py/test/test_lists/generic_fft.test_list.json
#: ../py/test/test_lists/generic_grt.test_list.json
@@ -3570,6 +3582,10 @@
msgstr "Cập nhật firmware CR50"
#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Update Fingerprint Firmware"
+msgstr ""
+
+#: ../py/test/test_lists/generic_common.test_list.json
#: ../py/test/test_lists/generic_unprovisioned.test_list.json
msgid "Update SKU ID"
msgstr "Cập nhật SKU ID"
diff --git a/po/zh-CN.po b/po/zh-CN.po
index 5a27477..0bddcf0 100644
--- a/po/zh-CN.po
+++ b/po/zh-CN.po
@@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: ChromeOS Factory Software\n"
-"PO-Revision-Date: 2021-04-27 15:39+CST\n"
+"PO-Revision-Date: 2021-05-11 17:39+CST\n"
"Last-Translator: ChromeOS Factory Team\n"
"Language-Team: ChromeOS Factory Team\n"
"Language: zh-CN\n"
@@ -3277,6 +3277,10 @@
msgstr "检查 CR50 版号是否未设置"
#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Check Fingerprint Firmware"
+msgstr "确认指纹韧体"
+
+#: ../py/test/test_lists/generic_common.test_list.json
msgid "Check Point"
msgstr "确认关卡"
@@ -3305,6 +3309,14 @@
msgstr "EC 写入保护"
#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Fingerprint Test Group"
+msgstr "测试指纹群组"
+
+#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Fingerprint Sensor test"
+msgstr "指纹感应器测试"
+
+#: ../py/test/test_lists/generic_common.test_list.json
#: ../py/test/test_lists/generic_fat.test_list.json
#: ../py/test/test_lists/generic_fft.test_list.json
#: ../py/test/test_lists/generic_grt.test_list.json
@@ -3496,6 +3508,10 @@
msgstr "更新 CR50 韧体"
#: ../py/test/test_lists/generic_common.test_list.json
+msgid "Update Fingerprint Firmware"
+msgstr "更新指纹韧体"
+
+#: ../py/test/test_lists/generic_common.test_list.json
#: ../py/test/test_lists/generic_unprovisioned.test_list.json
msgid "Update SKU ID"
msgstr "更新样式 ID"
diff --git a/py/test/pytests/update_fpmcu_firmware.py b/py/test/pytests/update_fpmcu_firmware.py
index f4b7ff6..8172d8b 100644
--- a/py/test/pytests/update_fpmcu_firmware.py
+++ b/py/test/pytests/update_fpmcu_firmware.py
@@ -6,7 +6,15 @@
Description
-----------
-The FPMCU firmware image to update is either from a given path in the
+This test provides two modes, `update mode` and `check mode`. Mode is
+specified by the test argument ``method``.
+
+1. In `update mode`, the test runs `flash_fp_mcu` to update the current
+ fingerprint firmware.
+2. In `check mode`, the test checks if the fingerprint firmware version
+ of the DUT is equal to the given version.
+
+The FPMCU firmware image updates/checks either from a given path in the
station or on the DUT, or from the release partition on the DUT.
Test Procedure
@@ -17,7 +25,11 @@
2. If the FPMCU firmware image is from the station, the image would be sent
to DUT.
3. If the FPMCU firmware image is not specified, the test mounts the release
- partition and get the FPMCU firmware image from there for update.
+ partition and gets the FPMCU firmware image from there.
+4. If `method` is set to `UPDATE`, DUT runs `flash_fp_mcu` to update the
+ fingerprint firmware using the specified image.
+5. If `method` is set to `CHECK_VERSION`, DUT compares the version of the
+ current fingerprint firmware and the version of the specified image.
Dependency
----------
@@ -29,22 +41,33 @@
Examples
--------
-To update fingerprint firmware with the image in DUT release partition,
+To update the fingerprint firmware with the image in DUT release partition,
add this in test list::
{
"pytest_name": "update_fpmcu_firmware"
}
-To update fingerprint firmware with a specified image in the station
+To update the fingerprint firmware with a specified image in the station
(only recommended in pre-PVT stages)::
{
"pytest_name": "update_fpmcu_firmware",
"args": {
+ "method": "UPDATE"
"firmware_file": "/path/on/station/to/image.bin"
}
}
+
+To check if the fingerprint firmware version is equal to the version in the
+release image::
+
+ {
+ "pytest_name": "update_fpmcu_firmware",
+ "args": {
+ "method": "CHECK_VERSION"
+ }
+ }
"""
import logging
@@ -56,6 +79,7 @@
from cros.factory.test.utils import fpmcu_utils
from cros.factory.utils.arg_utils import Arg
from cros.factory.utils import sys_utils
+from cros.factory.utils.type_utils import Enum
from cros.factory.utils.type_utils import Error
FLASHTOOL = '/usr/local/bin/flash_fp_mcu'
@@ -63,9 +87,15 @@
class UpdateFpmcuFirmwareTest(test_case.TestCase):
+ _METHOD_TYPE = Enum(['UPDATE', 'CHECK_VERSION'])
+
ARGS = [
Arg('firmware_file', str, 'The full path of the firmware binary file.',
- default=None)
+ default=None),
+ Arg(
+ 'method', _METHOD_TYPE,
+ 'Specify whether to update the fingerprint firmware or to check the '
+ 'fingerprint firmware version.', default=_METHOD_TYPE.UPDATE),
]
ui_class = test_ui.ScrollableLogUI
@@ -75,9 +105,10 @@
self._fpmcu = fpmcu_utils.FpmcuDevice(self._dut)
def runTest(self):
- # Before updating FPMCU firmware, HWWP must be disabled.
- if self._dut.CallOutput(['crossystem', 'wpsw_cur']).strip() != '0':
- raise Error('Hardware write protection is enabled.')
+ if self.args.method == self._METHOD_TYPE.UPDATE:
+ method_func = self.UpdateFpmcuFirmware
+ else:
+ method_func = self.CheckFpmcuFirmwareVersion
fpmcu_board = self._dut.CallOutput(
['cros_config', '/fingerprint', 'board'])
@@ -95,31 +126,29 @@
fpmcu_fw_files = self._dut.Glob(pattern)
self.assertEqual(len(fpmcu_fw_files), 1,
'No uniquely matched FPMCU firmware blob found')
- self.UpdateFpmcuFirmware(fpmcu_fw_files[0])
+ method_func(fpmcu_fw_files[0])
else:
self.assertEqual(self.args.firmware_file[0], '/',
'firmware_file should be a full path')
if self._dut.link.IsLocal():
- self.UpdateFpmcuFirmware(self.args.firmware_file)
+ method_func(self.args.firmware_file)
else:
with self._dut.temp.TempFile() as dut_temp_file:
self._dut.SendFile(self.args.firmware_file, dut_temp_file)
- self.UpdateFpmcuFirmware(dut_temp_file)
+ method_func(dut_temp_file)
def UpdateFpmcuFirmware(self, firmware_file):
- """Update FPMCU firmware by `flash_fp_mcu`."""
+ """Update FPMCU firmware by `flash_fp_mcu`.
+
+ Before updating FPMCU firmware, HWWP must be disabled.
+ """
+ if self._dut.CallOutput(['crossystem', 'wpsw_cur']).strip() != '0':
+ raise Error('Hardware write protection is enabled.')
+
flash_cmd = [FLASHTOOL, firmware_file]
- try:
- old_ro_ver, old_rw_ver = self._fpmcu.GetFpmcuFirmwareVersion()
- logging.info('Current FPMCU RO: %s, RW: %s', old_ro_ver, old_rw_ver)
- except Exception:
- logging.exception('Fail to read the current FPMCU RO/RW FW versions.')
-
- bin_ro_ver, bin_rw_ver = self.GetFirmwareVersionFromFile(firmware_file)
- logging.info('Ready to update FPMCU firmware to RO: %s, RW: %s.',
- bin_ro_ver, bin_rw_ver)
-
+ _, _, bin_ro_ver, bin_rw_ver = self.GetCurrentAndExpectedFirmwareVersion(
+ firmware_file)
session.console.debug(self._dut.CallOutput(flash_cmd))
new_ro_ver, new_rw_ver = self._fpmcu.GetFpmcuFirmwareVersion()
@@ -130,6 +159,32 @@
'New FPMCU RW: %s does not match the expected RW: %s.'
% (new_rw_ver, bin_rw_ver))
+ def CheckFpmcuFirmwareVersion(self, firmware_file):
+ cur_ro_ver, cur_rw_ver, bin_ro_ver, bin_rw_ver = \
+ self.GetCurrentAndExpectedFirmwareVersion(firmware_file)
+
+ self.assertEqual(
+ cur_ro_ver, bin_ro_ver,
+ 'Current FPMCU RO: %s does not match the expected RO: %s.' %
+ (cur_rw_ver, bin_ro_ver))
+ self.assertEqual(
+ cur_rw_ver, bin_rw_ver,
+ 'Current FPMCU RW: %s does not match the expected RW: %s.' %
+ (cur_rw_ver, bin_rw_ver))
+
+ def GetCurrentAndExpectedFirmwareVersion(self, firmware_file):
+ cur_ro_ver = cur_rw_ver = ''
+ try:
+ cur_ro_ver, cur_rw_ver = self._fpmcu.GetFpmcuFirmwareVersion()
+ logging.info('Current FPMCU RO: %s, RW: %s', cur_ro_ver, cur_rw_ver)
+ except Exception:
+ logging.exception('Fail to read the current FPMCU RO/RW FW versions.')
+
+ bin_ro_ver, bin_rw_ver = self.GetFirmwareVersionFromFile(firmware_file)
+ logging.info('Expected FPMCU RO: %s, RW: %s.', bin_ro_ver, bin_rw_ver)
+
+ return (cur_ro_ver, cur_rw_ver, bin_ro_ver, bin_rw_ver)
+
def GetFirmwareVersionFromFile(self, firmware_file):
"""Read RO and RW FW version from the FW binary file."""
ro_ver = self.ReadFmapArea(firmware_file, "RO_FRID")
diff --git a/py/test/test_lists/generic_common.test_list.json b/py/test/test_lists/generic_common.test_list.json
index b9ae4d1..c87dba1 100644
--- a/py/test/test_lists/generic_common.test_list.json
+++ b/py/test/test_lists/generic_common.test_list.json
@@ -225,6 +225,14 @@
"board_id_flags": "ffffffff"
}
},
+ "CheckFPFirmware": {
+ "pytest_name": "update_fpmcu_firmware",
+ "label": "Check Fingerprint Firmware",
+ "run_if": "device.component.has_fingerprint",
+ "args": {
+ "method": "CHECK_VERSION"
+ }
+ },
"CheckPoint": {
"inherit": "Barrier",
"label": "Check Point",
@@ -344,6 +352,24 @@
]
}
},
+ "FPSGroup": {
+ "label": "Fingerprint Test Group",
+ "run_if": "device.component.has_fingerprint",
+ "subtests": [
+ "UpdateFPFirmware",
+ "RebootStep",
+ "CheckFPFirmware",
+ "FPSTest"
+ ]
+ },
+ "FPSTest": {
+ "pytest_name": "fingerprint_mcu",
+ "label": "Fingerprint Sensor test",
+ "run_if": "device.component.has_fingerprint",
+ "args": {
+ "fpframe_retry_count": 2
+ }
+ },
"Finish": {
"inherit": "Message",
"label": "Finish"
@@ -1060,6 +1086,11 @@
"UpdateDeviceData": {
"pytest_name": "update_device_data"
},
+ "UpdateFPFirmware": {
+ "pytest_name": "update_fpmcu_firmware",
+ "label": "Update Fingerprint Firmware",
+ "run_if": "device.component.has_fingerprint"
+ },
"UpdateFirmware": {
"label": "Update Firmware",
"subtests": [
diff --git a/py/test/test_lists/generic_fat.test_list.json b/py/test/test_lists/generic_fat.test_list.json
index 3d9cd5e..866f5c0 100644
--- a/py/test/test_lists/generic_fat.test_list.json
+++ b/py/test/test_lists/generic_fat.test_list.json
@@ -39,7 +39,8 @@
"VerifyRootPartition",
"Barrier",
"BadBlocks",
- "Barrier"
+ "Barrier",
+ "FPSGroup"
]
},
"FATStart": {