1# Copyright 2019 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from autotest_lib.server import utils
6
7AUTHOR = "Chrome OS Team"
8NAME = "firmware_Fingerprint.RDP1"
9PURPOSE = """
10Verify that when RDP (readout protection) is set to level 1 and then changed to
11level 0, a mass erase takes place.
12"""
13CRITERIA = """
14Fails if transitioning from RDP level 1 to RDP level 0 does not trigger a
15mass erase.
16"""
17ATTRIBUTES = "suite:fingerprint"
18TIME = "SHORT"
19TEST_CATEGORY = "Functional"
20TEST_CLASS = "firmware"
21TEST_TYPE = "server"
22DEPENDENCIES = "servo_state:WORKING, fingerprint"
23JOB_RETRIES = 0
24
25DOC = """
26The test setup enables RDP level 1 by enabling hardware write protect and then
27enabling software write protect (with reboot of the EC); the test setup then
28disables hardware write protect, so that we can perform reads and change RDP
29levels through the bootloader (only accessible when HW write protect is
30disabled).
31
32When the test script starts, a read through the bootloader is done without
33disabling flash protection (changing RDP state). We verify that we are unable
34to read any data.
35
36Next a read through the bootloader is done, while also disabling flash
37protection (changing to RDP level 0), which triggers a mass erase. We verify
38that the bytes in the output are all 0xFF and that the firmware is no longer
39functional.
40"""
41
42test_images = [ 'TEST_IMAGE_ORIGINAL' ]
43
44args_dict = utils.args_to_dict(args)
45servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
46
47def run(machine):
48    host = hosts.create_host(machine, servo_args=servo_args)
49    job.run_test("firmware_Fingerprint", host=host,
50                 test_exe="rdp1.sh",
51                 test_exe_args=test_images,
52                 enable_hardware_write_protect=False,
53                 enable_software_write_protect=True)
54
55parallel_simple(run, machines)
56