Home | History | Annotate | Download | only in platform_InstallFW
      1 # Copyright (c) 2010 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 
      5 import logging
      6 from autotest_lib.server import test, utils
      7 
      8 class platform_InstallFW(test.test):
      9     """Test to install FW on DUT"""
     10     version = 1
     11 
     12     def run_once(self, host=None, fw_type=None, fw_path=None, fw_name=None):
     13         """Run test to install firmware.
     14 
     15         @param host: host to run on
     16         @param fw_type: must be either "bios" or "ec"
     17         @param fw_path: path to fw binary or set to "local"
     18         @param fw_name: (optional) name of binary file
     19         """
     20 
     21         if fw_path == "local":
     22             fw_dst = "/usr/sbin/chromeos-firmwareupdate"
     23             is_shellball = True
     24         else:
     25             fw_src = "%s/%s" % (fw_path, fw_name)
     26             # Determine the firmware file is a shellball or a raw binary.
     27             is_shellball = (utils.system_output("file %s" % fw_src).find(
     28                     "shell script") != -1)
     29             fw_dst = "/tmp/%s" % fw_name
     30             # Copy binary from server to client.
     31             host.send_file(fw_src, fw_dst)
     32 
     33         # Install bios/ec on a client.
     34         if fw_type == "bios":
     35             if is_shellball:
     36                 host.run("sudo /bin/sh %s --mode recovery --update_main "
     37                          "--noupdate_ec" % fw_dst)
     38             else:
     39                 host.run("sudo /usr/sbin/flashrom -p host -w %s"
     40                          % fw_dst)
     41         if fw_type == "ec":
     42             if is_shellball:
     43                 host.run("sudo /bin/sh %s --mode recovery --update_ec "
     44                          "--noupdate_main" % fw_dst)
     45             else:
     46                 host.run("sudo /usr/sbin/flashrom -p ec -w %s"
     47                          % fw_dst)
     48         # Reboot client after installing the binary.
     49         host.reboot()
     50         # Get the versions of BIOS and EC binaries.
     51         bios_info = host.run("crossystem fwid")
     52         logging.info("BIOS version info:\n %s", bios_info)
     53         ec_info = host.run("sudo mosys -k ec info")
     54         logging.info("EC version info:\n %s", ec_info)
     55