1# Copyright (c) 2011 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.faft.firmware_test import FirmwareTest 8from autotest_lib.server.cros.servo import chrome_ec 9from autotest_lib.server.cros import vboot_constants as vboot 10 11 12class firmware_DevMode(FirmwareTest): 13 """ 14 Servo based developer firmware boot test. 15 """ 16 version = 1 17 18 def initialize(self, host, cmdline_args, ec_wp=None): 19 super(firmware_DevMode, self).initialize( 20 host, cmdline_args, ec_wp=ec_wp) 21 self.switcher.setup_mode('normal') 22 self.setup_usbkey(usbkey=False) 23 24 def run_once(self): 25 """Method which actually runs the test.""" 26 self.check_state((self.checkers.crossystem_checker, { 27 'devsw_boot': '0', 28 'mainfw_type': 'normal', 29 })) 30 31 logging.info("Enable dev mode.") 32 self.switcher.reboot_to_mode( 33 'dev', from_mode='normal', sync_before_boot=False) 34 35 logging.info("Expected developer mode boot and enable normal mode.") 36 self.check_state((self.checkers.crossystem_checker, { 37 'devsw_boot': '1', 38 'mainfw_type': 'developer', 39 })) 40 self.switcher.reboot_to_mode(to_mode='normal') 41 42 logging.info("Expected normal mode boot, done.") 43 self.check_state((self.checkers.crossystem_checker, { 44 'devsw_boot': '0', 45 'mainfw_type': 'normal', 46 })) 47 48 if ( 49 self.check_ec_capability() and 50 self.faft_config.mode_switcher_type == 'jetstream_switcher'): 51 if self.gbb_flags & vboot.GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC: 52 # In order to test that entering dev mode does not work when 53 # EC_IN_RW=1, EC software sync must be enabled. If EC software 54 # sync is disabled, then we must skip this portion of the test. 55 logging.info("Skipping dev mode transition in EC RW test.") 56 return 57 58 logging.info("Rebooting into fake recovery mode (EC still in RW).") 59 self._client.power_off_via_servo() 60 self.ec.set_hostevent(chrome_ec.HOSTEVENT_KEYBOARD_RECOVERY) 61 self.servo.power_short_press() 62 63 logging.info("Trying to transition to dev mode with EC_IN_RW=1.") 64 self.switcher.trigger_rec_to_dev() 65 self.switcher.bypass_dev_mode() 66 if not self._client.ping_wait_up( 67 timeout=self.faft_config.delay_reboot_to_ping): 68 logging.info("DUT didn't come back up (expected!), rebooting.") 69 self.switcher.simple_reboot(sync_before_boot=False) 70 self.switcher.wait_for_client() 71 72 logging.info("DUT is back up, should still be in normal mode now.") 73 self.check_state((self.checkers.crossystem_checker, { 74 'devsw_boot': '0', 75 'mainfw_type': 'normal', 76 })) 77