• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 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
5import logging
6
7from autotest_lib.server.cros import vboot_constants as vboot
8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
9
10
11class firmware_RONormalBoot(FirmwareTest):
12    """
13    Servo based firmware RO normal boot test.
14
15    This test only runs on the firmware on which its firmware preamble flags
16    have USE_RO_NORMAL enabled. Since we always build and pack a workable
17    RW firmware in the RW firmware body section, although it is not used when
18    the USE_RO_NORMAL flag is enabled.
19
20    On runtime, the test disables the RO normal boot flag in the current
21    firmware and checks its next boot result.
22    """
23    version = 1
24
25    def initialize(self, host, cmdline_args, dev_mode=False, ec_wp=None):
26        super(firmware_RONormalBoot, self).initialize(host, cmdline_args,
27                                                      ec_wp=ec_wp)
28        self.backup_firmware()
29        self.switcher.setup_mode('dev' if dev_mode else 'normal')
30        self.setup_usbkey(usbkey=False)
31
32    def cleanup(self):
33        self.restore_firmware()
34        super(firmware_RONormalBoot, self).cleanup()
35
36    def run_once(self):
37        flags = self.faft_client.bios.get_preamble_flags('a')
38        if flags & vboot.PREAMBLE_USE_RO_NORMAL == 0:
39            logging.info('The firmware USE_RO_NORMAL flag is disabled.')
40            return
41
42        logging.info("Disable the RO normal boot flag.")
43        self.check_state((self.checkers.ro_normal_checker, 'A'))
44        self.faft_client.bios.set_preamble_flags(('a',
45                                      flags ^ vboot.PREAMBLE_USE_RO_NORMAL))
46        self.switcher.mode_aware_reboot()
47
48        logging.info("Expected TwoStop boot, restore the original flags.")
49        self.check_state((lambda: self.checkers.ro_normal_checker('A',
50                                                                  twostop=True)))
51        self.faft_client.bios.set_preamble_flags('a', flags)
52        self.switcher.mode_aware_reboot()
53        self.check_state((self.checkers.ro_normal_checker, 'A'))
54