blob: 174a6c6a2551977a67504c7b5c895931cfbdc897 [file] [log] [blame]
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -07001# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -07002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -07005"""Code to provide functions for FAFT tests.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -07006
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -07007These can be exposed via a xmlrpci server running on the DUT.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -07008"""
9
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080010import functools, os, shutil, tempfile
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070011
Yusuf Mohsinallycd108da2013-08-12 14:06:12 -070012import common
13from autotest_lib.client.cros.faft.utils import (cgpt_state,
14 chromeos_interface,
15 firmware_updater,
16 flashrom_handler,
17 kernel_handler,
18 saft_flashrom_util,
19 tpm_handler,
20 )
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070021
22
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +080023def allow_multiple_section_input(image_operator):
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080024 """Decorate a method to support multiple sections.
25
26 @param image_operator: Method accepting one section as its argument.
27 """
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +080028 @functools.wraps(image_operator)
29 def wrapper(self, section):
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080030 """Wrapper method to support multiple sections.
31
32 @param section: A list of sections of just a section.
33 """
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +080034 if type(section) in (tuple, list):
35 for sec in section:
36 image_operator(self, sec)
37 else:
38 image_operator(self, section)
39 return wrapper
40
41
Vic Yang13d22ec2012-06-18 15:12:47 +080042class LazyFlashromHandlerProxy:
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080043 """Proxy of FlashromHandler for lazy initialization."""
Vic Yang13d22ec2012-06-18 15:12:47 +080044 _loaded = False
45 _obj = None
46
47 def __init__(self, *args, **kargs):
48 self._args = args
49 self._kargs = kargs
50
51 def _load(self):
52 self._obj = flashrom_handler.FlashromHandler()
53 self._obj.init(*self._args, **self._kargs)
54 self._obj.new_image()
55 self._loaded = True
56
57 def __getattr__(self, name):
58 if not self._loaded:
59 self._load()
60 return getattr(self._obj, name)
61
Tom Wai-Hong Tamc1c4deb2012-07-26 14:28:11 +080062 def reload(self):
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080063 """Reload the FlashromHandler class."""
Tom Wai-Hong Tamc1c4deb2012-07-26 14:28:11 +080064 self._loaded = False
65
Vic Yang13d22ec2012-06-18 15:12:47 +080066
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -070067class RPCFunctions(object):
68 """A class which aggregates some useful functions for firmware testing.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070069
70 This class can be exposed via a XMLRPC server such that its functions can
Chun-ting Changd43aa9b2012-11-16 10:12:05 +080071 be accessed remotely. Method naming should fit the naming rule
72 '_[categories]_[method_name]' where categories contains system, ec, bios,
73 kernel, cgpt, tpm, updater, etc. Methods should be called by
74 'FAFTClient.[categories].[method_name]', because _dispatch will rename
75 this name to '_[categories]_[method_name]'.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070076
77 Attributes:
78 _chromeos_interface: An object to encapsulate OS services functions.
Vic Yang59cac9c2012-05-21 15:28:42 +080079 _bios_handler: An object to automate BIOS flashrom testing.
80 _ec_handler: An object to automate EC flashrom testing.
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +080081 _ec_image: An object to automate EC image for autest.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070082 _kernel_handler: An object to provide kernel related actions.
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +080083 _log_file: Path of the log file.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070084 _tpm_handler: An object to control TPM device.
Chun-ting Changcf924e92012-10-29 13:49:01 +080085 _updater: An object to update firmware.
ctchangc7e55ea2012-08-09 16:19:14 +080086 _temp_path: Path of a temp directory.
87 _keys_path: Path of a directory, keys/, in temp directory.
88 _work_path: Path of a directory, work/, in temp directory.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070089 """
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070090 def __init__(self):
91 """Initialize the data attributes of this class."""
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070092 # TODO(waihong): Move the explicit object.init() methods to the
93 # objects' constructors (ChromeOSInterface, FlashromHandler,
94 # KernelHandler, and TpmHandler).
95 self._chromeos_interface = chromeos_interface.ChromeOSInterface(False)
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +080096 # We keep the state of FAFT test in a permanent directory over reboots.
Tom Wai-Hong Tam07278c22012-02-08 16:53:00 +080097 state_dir = '/var/tmp/faft'
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +080098 self._log_file = os.path.join(state_dir, 'faft_client.log')
99 self._chromeos_interface.init(state_dir, log_file=self._log_file)
Tom Wai-Hong Tam46d2ca72013-07-01 09:50:55 +0800100 os.chdir(state_dir)
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +0800101
Vic Yang13d22ec2012-06-18 15:12:47 +0800102 self._bios_handler = LazyFlashromHandlerProxy(
103 saft_flashrom_util,
Vic Yang59cac9c2012-05-21 15:28:42 +0800104 self._chromeos_interface,
105 None,
106 '/usr/share/vboot/devkeys',
107 'bios')
Vic Yang59cac9c2012-05-21 15:28:42 +0800108
Todd Brochf2b1d012012-06-14 12:55:21 -0700109 self._ec_handler = None
110 if not os.system("mosys ec info"):
Vic Yang13d22ec2012-06-18 15:12:47 +0800111 self._ec_handler = LazyFlashromHandlerProxy(
112 saft_flashrom_util,
Todd Brochf2b1d012012-06-14 12:55:21 -0700113 self._chromeos_interface,
Vic Yang13d22ec2012-06-18 15:12:47 +0800114 'ec_root_key.vpubk',
Todd Brochf2b1d012012-06-14 12:55:21 -0700115 '/usr/share/vboot/devkeys',
116 'ec')
Todd Brochf2b1d012012-06-14 12:55:21 -0700117
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800118 self._ec_image = None
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700119
120 self._kernel_handler = kernel_handler.KernelHandler()
Tom Wai-Hong Tam07278c22012-02-08 16:53:00 +0800121 # TODO(waihong): The dev_key_path is a new argument. We do that in
122 # order not to break the old image and still be able to run.
123 try:
124 self._kernel_handler.init(self._chromeos_interface,
ctchangd60030f2012-08-29 15:39:56 +0800125 dev_key_path='/usr/share/vboot/devkeys',
126 internal_disk=True)
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800127 except TypeError:
Tom Wai-Hong Tam07278c22012-02-08 16:53:00 +0800128 # Copy the key to the current working directory.
129 shutil.copy('/usr/share/vboot/devkeys/kernel_data_key.vbprivk', '.')
ctchangd60030f2012-08-29 15:39:56 +0800130 self._kernel_handler.init(self._chromeos_interface,
131 internal_disk=True)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700132
133 self._tpm_handler = tpm_handler.TpmHandler()
134 self._tpm_handler.init(self._chromeos_interface)
135
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800136 self._cgpt_state = cgpt_state.CgptState(
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800137 'SHORT', self._chromeos_interface, self._system_get_root_dev())
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800138
Yusuf Mohsinallycd108da2013-08-12 14:06:12 -0700139 self._updater = firmware_updater.FirmwareUpdater(self._chromeos_interface)
Chun-ting Changcf924e92012-10-29 13:49:01 +0800140
ctchangc7e55ea2012-08-09 16:19:14 +0800141 # Initialize temporary directory path
142 self._temp_path = '/var/tmp/faft/autest'
143 self._keys_path = os.path.join(self._temp_path, 'keys')
144 self._work_path = os.path.join(self._temp_path, 'work')
145
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800146 def _dispatch(self, method, params):
147 """This _dispatch method handles string conversion especially.
148
149 Since we turn off allow_dotted_names option. So any string conversion,
150 like str(FAFTClient.method), i.e. FAFTClient.method.__str__, failed
151 via XML RPC call.
152 """
153 is_str = method.endswith('.__str__')
154 if is_str:
155 method = method.rsplit('.', 1)[0]
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800156
157 categories = ('system', 'bios', 'ec', 'kernel',
158 'tpm', 'cgpt', 'updater')
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800159 try:
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800160 if method.split('.', 1)[0] in categories:
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800161 func = getattr(self, '_%s_%s' % (method.split('.', 1)[0],
162 method.split('.', 1)[1]))
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800163 else:
164 func = getattr(self, method)
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800165 except AttributeError:
166 raise Exception('method "%s" is not supported' % method)
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800167
168 if is_str:
169 return str(func)
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800170 else:
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800171 self._chromeos_interface.log('Dispatching method %s with args %s' %
172 (str(func), str(params)))
173 return func(*params)
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800174
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800175 def _system_is_available(self):
Tom Wai-Hong Tambea57b32011-09-02 18:27:47 +0800176 """Function for polling the RPC server availability.
177
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800178 @return: Always True.
Tom Wai-Hong Tambea57b32011-09-02 18:27:47 +0800179 """
180 return True
181
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +0800182 def _system_dump_log(self, remove_log=False):
183 """Dump the log file.
184
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800185 @param remove_log: Remove the log file after dump.
186 @return: String of the log file content.
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +0800187 """
188 log = open(self._log_file).read()
189 if remove_log:
190 os.remove(self._log_file)
191 return log
192
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800193 def _system_run_shell_command(self, command):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700194 """Run shell command.
195
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800196 @param command: A shell command to be run.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700197 """
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700198 self._chromeos_interface.run_shell_command(command)
199
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800200 def _system_run_shell_command_get_output(self, command):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700201 """Run shell command and get its console output.
202
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800203 @param command: A shell command to be run.
204 @return: A list of strings stripped of the newline characters.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700205 """
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700206 return self._chromeos_interface.run_shell_command_get_output(command)
207
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800208 def _system_software_reboot(self):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700209 """Request software reboot."""
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700210 self._chromeos_interface.run_shell_command('reboot')
211
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800212 def _system_get_platform_name(self):
Tom Wai-Hong Tam678ab152011-12-14 15:27:24 +0800213 """Get the platform name of the current system.
214
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800215 @return: A string of the platform name.
Tom Wai-Hong Tam678ab152011-12-14 15:27:24 +0800216 """
Vic Yang2bbb8672012-11-12 12:14:53 +0800217 # 'mosys platform name' sometimes fails. Let's get the verbose output.
218 lines = self._chromeos_interface.run_shell_command_get_output(
219 '(mosys -vvv platform name 2>&1) || echo Failed')
220 if lines[-1].strip() == 'Failed':
221 raise Exception('Failed getting platform name: ' + '\n'.join(lines))
222 return lines[-1]
Tom Wai-Hong Tam678ab152011-12-14 15:27:24 +0800223
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800224 def _system_get_crossystem_value(self, key):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700225 """Get crossystem value of the requested key.
226
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800227 @param key: A crossystem key.
228 @return: A string of the requested crossystem value.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700229 """
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700230 return self._chromeos_interface.run_shell_command_get_output(
231 'crossystem %s' % key)[0]
232
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800233 def _system_get_root_dev(self):
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800234 """Get the name of root device without partition number.
235
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800236 @return: A string of the root device without partition number.
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800237 """
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800238 return self._chromeos_interface.get_root_dev()
239
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800240 def _system_get_root_part(self):
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800241 """Get the name of root device with partition number.
242
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800243 @return: A string of the root device with partition number.
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800244 """
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800245 return self._chromeos_interface.get_root_part()
246
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800247 def _system_set_try_fw_b(self):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700248 """Set 'Try Frimware B' flag in crossystem."""
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700249 self._chromeos_interface.cs.fwb_tries = 1
250
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800251 def _system_request_recovery_boot(self):
Tom Wai-Hong Tam76c75072011-10-25 18:00:12 +0800252 """Request running in recovery mode on the restart."""
Tom Wai-Hong Tam76c75072011-10-25 18:00:12 +0800253 self._chromeos_interface.cs.request_recovery()
254
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800255 def _system_get_dev_boot_usb(self):
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800256 """Get dev_boot_usb value which controls developer mode boot from USB.
257
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800258 @return: True if enable, False if disable.
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800259 """
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800260 return self._chromeos_interface.cs.dev_boot_usb == '1'
261
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800262 def _system_set_dev_boot_usb(self, value):
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800263 """Set dev_boot_usb value which controls developer mode boot from USB.
264
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800265 @param value: True to enable, False to disable.
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800266 """
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800267 self._chromeos_interface.cs.dev_boot_usb = 1 if value else 0
268
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800269 def _system_is_removable_device_boot(self):
270 """Check the current boot device is removable.
271
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800272 @return: True: if a removable device boots.
273 False: if a non-removable device boots.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800274 """
275 root_part = self._chromeos_interface.get_root_part()
276 return self._chromeos_interface.is_removable_device(root_part)
277
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800278 def _system_create_temp_dir(self, prefix='backup_'):
279 """Create a temporary directory and return the path."""
280 return tempfile.mkdtemp(prefix=prefix)
281
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800282 def _bios_reload(self):
283 """Reload the firmware image that may be changed."""
284 self._bios_handler.reload()
285
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800286 def _bios_get_gbb_flags(self):
Tom Wai-Hong Tam8c9eed62011-12-28 15:05:05 +0800287 """Get the GBB flags.
288
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800289 @return: An integer of the GBB flags.
Tom Wai-Hong Tam8c9eed62011-12-28 15:05:05 +0800290 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800291 return self._bios_handler.get_gbb_flags()
Tom Wai-Hong Tam8c9eed62011-12-28 15:05:05 +0800292
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800293 def _bios_get_preamble_flags(self, section):
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800294 """Get the preamble flags of a firmware section.
295
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800296 @param section: A firmware section, either 'a' or 'b'.
297 @return: An integer of the preamble flags.
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800298 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800299 return self._bios_handler.get_section_flags(section)
300
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800301 def _bios_set_preamble_flags(self, section, flags):
Vic Yang91b73cf2012-07-31 17:18:11 +0800302 """Set the preamble flags of a firmware section.
303
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800304 @param section: A firmware section, either 'a' or 'b'.
305 @param flags: An integer of preamble flags.
Vic Yang91b73cf2012-07-31 17:18:11 +0800306 """
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800307 version = self._bios_get_version(section)
Vic Yang91b73cf2012-07-31 17:18:11 +0800308 self._bios_handler.set_section_version(section, version, flags,
309 write_through=True)
310
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800311 def _bios_get_body_sha(self, section):
Tom Wai-Hong Tam4e10b9f2012-09-06 16:23:02 +0800312 """Get SHA1 hash of BIOS RW firmware section.
313
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800314 @param section: A firmware section, either 'a' or 'b'.
315 @param flags: An integer of preamble flags.
Tom Wai-Hong Tam4e10b9f2012-09-06 16:23:02 +0800316 """
317 return self._bios_handler.get_section_sha(section)
318
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800319 def _bios_get_sig_sha(self, section):
ctchang38ae4922012-09-03 17:01:16 +0800320 """Get SHA1 hash of firmware vblock in section."""
321 return self._bios_handler.get_section_sig_sha(section)
322
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +0800323 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800324 def _bios_corrupt_sig(self, section):
Tom Wai-Hong Tam9aea8212011-12-12 15:08:45 +0800325 """Corrupt the requested firmware section signature.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700326
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800327 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700328 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800329 self._bios_handler.corrupt_firmware(section)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700330
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +0800331 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800332 def _bios_restore_sig(self, section):
Tom Wai-Hong Tam9aea8212011-12-12 15:08:45 +0800333 """Restore the previously corrupted firmware section signature.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700334
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800335 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700336 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800337 self._bios_handler.restore_firmware(section)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700338
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800339 @allow_multiple_section_input
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800340 def _bios_corrupt_body(self, section):
341 """Corrupt the requested firmware section body.
342
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800343 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800344 """
345 self._bios_handler.corrupt_firmware_body(section)
346
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800347 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800348 def _bios_restore_body(self, section):
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800349 """Restore the previously corrupted firmware section body.
350
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800351 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800352 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800353 self._bios_handler.restore_firmware_body(section)
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800354
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800355 def __bios_modify_version(self, section, delta):
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800356 """Modify firmware version for the requested section, by adding delta.
357
358 The passed in delta, a positive or a negative number, is added to the
359 original firmware version.
360 """
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800361 original_version = self._bios_get_version(section)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800362 new_version = original_version + delta
Vic Yang59cac9c2012-05-21 15:28:42 +0800363 flags = self._bios_handler.get_section_flags(section)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800364 self._chromeos_interface.log(
365 'Setting firmware section %s version from %d to %d' % (
366 section, original_version, new_version))
Vic Yang59cac9c2012-05-21 15:28:42 +0800367 self._bios_handler.set_section_version(section, new_version, flags,
368 write_through=True)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800369
370 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800371 def _bios_move_version_backward(self, section):
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800372 """Decrement firmware version for the requested section."""
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800373 self.__bios_modify_version(section, -1)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800374
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800375 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800376 def _bios_move_version_forward(self, section):
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800377 """Increase firmware version for the requested section."""
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800378 self.__bios_modify_version(section, 1)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800379
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800380 def _bios_get_version(self, section):
381 """Retrieve firmware version of a section."""
382 return self._bios_handler.get_section_version(section)
383
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800384 def _bios_get_datakey_version(self, section):
ctchangc7e55ea2012-08-09 16:19:14 +0800385 """Return firmware data key version."""
386 return self._bios_handler.get_section_datakey_version(section)
387
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800388 def _bios_get_kernel_subkey_version(self, section):
ctchangc7e55ea2012-08-09 16:19:14 +0800389 """Return kernel subkey version."""
390 return self._bios_handler.get_section_kernel_subkey_version(section)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800391
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800392 def _bios_setup_EC_image(self, ec_path):
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800393 """Setup the new EC image for later update.
394
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800395 @param ec_path: The path of the EC image to be updated.
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800396 """
397 self._ec_image = flashrom_handler.FlashromHandler()
398 self._ec_image.init(saft_flashrom_util,
399 self._chromeos_interface,
400 'ec_root_key.vpubk',
401 '/usr/share/vboot/devkeys',
402 'ec')
403 self._ec_image.new_image(ec_path)
404
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800405 def _bios_get_EC_image_sha(self):
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800406 """Get SHA1 hash of RW firmware section of the EC autest image."""
407 return self._ec_image.get_section_sha('rw')
408
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800409 def _bios_update_EC_from_image(self, section, flags):
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800410 """Update EC via software sync design.
411
412 It copys the RW section from the EC image, which is loaded by calling
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800413 bios_setup_EC_image(), to the EC area of the specified RW section on the
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800414 current AP firmware.
415
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800416 @param section: A firmware section on current BIOS, either 'a' or 'b'.
417 @param flags: An integer of preamble flags.
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800418 """
419 blob = self._ec_image.get_section_body('rw')
420 self._bios_handler.set_section_ecbin(section, blob,
421 write_through=True)
Chun-ting Chang708a2762012-12-10 12:25:13 +0800422 self._bios_set_preamble_flags(section, flags)
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800423
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800424 def _bios_dump_whole(self, bios_path):
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800425 """Dump the current BIOS firmware to a file, specified by bios_path.
426
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800427 @param bios_path: The path of the BIOS image to be written.
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800428 """
429 self._bios_handler.dump_whole(bios_path)
430
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800431 def _bios_dump_rw(self, dir_path):
ctchang38ae4922012-09-03 17:01:16 +0800432 """Dump the current BIOS firmware RW to dir_path.
433
434 VBOOTA, VBOOTB, FVMAIN, FVMAINB need to be dumped.
435
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800436 @param dir_path: The path of directory which contains files to be
437 written.
ctchang38ae4922012-09-03 17:01:16 +0800438 """
439 if not os.path.isdir(dir_path):
440 raise Exception("%s doesn't exist" % dir_path)
441
442 VBOOTA_blob = self._bios_handler.get_section_sig('a')
443 VBOOTB_blob = self._bios_handler.get_section_sig('b')
444 FVMAIN_blob = self._bios_handler.get_section_body('a')
445 FVMAINB_blob = self._bios_handler.get_section_body('b')
446
447 open(os.path.join(dir_path, 'VBOOTA'), 'w').write(VBOOTA_blob)
448 open(os.path.join(dir_path, 'VBOOTB'), 'w').write(VBOOTB_blob)
449 open(os.path.join(dir_path, 'FVMAIN'), 'w').write(FVMAIN_blob)
450 open(os.path.join(dir_path, 'FVMAINB'), 'w').write(FVMAINB_blob)
451
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800452 def _bios_write_whole(self, bios_path):
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800453 """Write the firmware from bios_path to the current system.
454
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800455 @param bios_path: The path of the source BIOS image.
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800456 """
457 self._bios_handler.new_image(bios_path)
458 self._bios_handler.write_whole()
459
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800460 def _bios_write_rw(self, dir_path):
ctchang38ae4922012-09-03 17:01:16 +0800461 """Write the firmware RW from dir_path to the current system.
462
463 VBOOTA, VBOOTB, FVMAIN, FVMAINB need to be written.
464
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800465 @param dir_path: The path of directory which contains the source files.
ctchang38ae4922012-09-03 17:01:16 +0800466 """
467 if not os.path.exists(os.path.join(dir_path, 'VBOOTA')) or \
468 not os.path.exists(os.path.join(dir_path, 'VBOOTB')) or \
469 not os.path.exists(os.path.join(dir_path, 'FVMAIN')) or \
470 not os.path.exists(os.path.join(dir_path, 'FVMAINB')):
471 raise Exception("Source firmware file(s) doesn't exist.")
472
473 VBOOTA_blob = open(os.path.join(dir_path, 'VBOOTA'), 'rb').read()
474 VBOOTB_blob = open(os.path.join(dir_path, 'VBOOTB'), 'rb').read()
475 FVMAIN_blob = open(os.path.join(dir_path, 'FVMAIN'), 'rb').read()
476 FVMAINB_blob = open(os.path.join(dir_path, 'FVMAINB'), 'rb').read()
477
478 self._bios_handler.set_section_sig('a', VBOOTA_blob,
479 write_through=True)
480 self._bios_handler.set_section_sig('b', VBOOTB_blob,
481 write_through=True)
482 self._bios_handler.set_section_body('a', FVMAIN_blob,
483 write_through=True)
484 self._bios_handler.set_section_body('b', FVMAINB_blob,
485 write_through=True)
486
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800487 def _ec_get_version(self):
488 """Get EC version via mosys.
489
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800490 @return: A string of the EC version.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800491 """
492 return self._chromeos_interface.run_shell_command_get_output(
493 'mosys ec info | sed "s/.*| //"')[0]
494
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800495 def _ec_get_firmware_sha(self):
496 """Get SHA1 hash of EC RW firmware section."""
497 return self._ec_handler.get_section_sha('rw')
498
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800499 @allow_multiple_section_input
500 def _ec_corrupt_sig(self, section):
501 """Corrupt the requested EC section signature.
502
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800503 @param section: A EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800504 """
505 self._ec_handler.corrupt_firmware(section, corrupt_all=True)
506
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800507 @allow_multiple_section_input
508 def _ec_restore_sig(self, section):
509 """Restore the previously corrupted EC section signature.
510
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800511 @param section: An EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800512 """
513 self._ec_handler.restore_firmware(section, restore_all=True)
514
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800515 @allow_multiple_section_input
516 def _ec_corrupt_body(self, section):
517 """Corrupt the requested EC section body.
518
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800519 @param section: An EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800520 """
521 self._ec_handler.corrupt_firmware_body(section, corrupt_all=True)
522
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800523 @allow_multiple_section_input
524 def _ec_restore_body(self, section):
525 """Restore the previously corrupted EC section body.
526
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800527 @param section: An EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800528 """
529 self._ec_handler.restore_firmware_body(section, restore_all=True)
530
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800531 def _ec_dump_firmware(self, ec_path):
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800532 """Dump the current EC firmware to a file, specified by ec_path.
533
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800534 @param ec_path: The path of the EC image to be written.
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800535 """
536 self._ec_handler.dump_whole(ec_path)
537
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800538 def _ec_set_write_protect(self, enable):
Tom Wai-Hong Tam44204b32012-11-20 13:55:40 +0800539 """Enable write protect of the EC flash chip.
540
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800541 @param enable: True if activating EC write protect. Otherwise, False.
Tom Wai-Hong Tam44204b32012-11-20 13:55:40 +0800542 """
Tom Wai-Hong Tam44204b32012-11-20 13:55:40 +0800543 if enable:
544 self._ec_handler.enable_write_protect()
545 else:
546 self._ec_handler.disable_write_protect()
547
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800548 @allow_multiple_section_input
549 def _kernel_corrupt_sig(self, section):
550 """Corrupt the requested kernel section.
551
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800552 @param section: A kernel section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800553 """
554 self._kernel_handler.corrupt_kernel(section)
555
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800556 @allow_multiple_section_input
557 def _kernel_restore_sig(self, section):
558 """Restore the requested kernel section (previously corrupted).
559
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800560 @param section: A kernel section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800561 """
562 self._kernel_handler.restore_kernel(section)
563
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800564 def __kernel_modify_version(self, section, delta):
565 """Modify kernel version for the requested section, by adding delta.
566
567 The passed in delta, a positive or a negative number, is added to the
568 original kernel version.
569 """
570 original_version = self._kernel_handler.get_version(section)
571 new_version = original_version + delta
572 self._chromeos_interface.log(
573 'Setting kernel section %s version from %d to %d' % (
574 section, original_version, new_version))
575 self._kernel_handler.set_version(section, new_version)
576
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800577 @allow_multiple_section_input
578 def _kernel_move_version_backward(self, section):
579 """Decrement kernel version for the requested section."""
580 self.__kernel_modify_version(section, -1)
581
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800582 @allow_multiple_section_input
583 def _kernel_move_version_forward(self, section):
584 """Increase kernel version for the requested section."""
585 self.__kernel_modify_version(section, 1)
586
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800587 def _kernel_get_version(self, section):
588 """Return kernel version."""
589 return self._kernel_handler.get_version(section)
590
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800591 def _kernel_get_datakey_version(self, section):
592 """Return kernel datakey version."""
593 return self._kernel_handler.get_datakey_version(section)
594
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800595 def _kernel_diff_a_b(self):
596 """Compare kernel A with B.
597
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800598 @return: True: if kernel A is different with B.
599 False: if kernel A is the same as B.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800600 """
601 rootdev = self._chromeos_interface.get_root_dev()
Vic (Chun-Ju) Yanga1eff6b2014-01-28 16:34:03 +0800602 kernel_a = self._chromeos_interface.join_part(rootdev, '2')
603 kernel_b = self._chromeos_interface.join_part(rootdev, '4')
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800604
605 # The signature (some kind of hash) for the kernel body is stored in
606 # the beginning. So compare the first 64KB (including header, preamble,
607 # and signature) should be enough to check them identical.
608 header_a = self._chromeos_interface.read_partition(kernel_a, 0x10000)
609 header_b = self._chromeos_interface.read_partition(kernel_b, 0x10000)
610
611 return header_a != header_b
612
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800613 def _kernel_resign_with_keys(self, section, key_path=None):
614 """Resign kernel with temporary key."""
615 self._kernel_handler.resign_kernel(section, key_path)
616
Vic (Chun-Ju) Yang33ef9e02014-02-07 14:30:19 +0800617 def _kernel_dump(self, section, kernel_path):
618 """Dump the specified kernel to a file.
619
620 @param section: The kernel to dump. May be A or B.
621 @param kernel_path: The path to the kernel image to be written.
622 """
623 self._kernel_handler.dump_kernel(section, kernel_path)
624
625 def _kernel_write(self, section, kernel_path):
626 """Write a kernel image to the specified section.
627
628 @param section: The kernel to dump. May be A or B.
629 @param kernel_path: The path to the kernel image.
630 """
631 self._kernel_handler.write_kernel(section, kernel_path)
632
633 def _kernel_get_sha(self, section):
634 """Return the SHA1 hash of the specified kernel section."""
635 return self._kernel_handler.get_sha(section)
636
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800637 def _tpm_get_firmware_version(self):
638 """Retrieve tpm firmware body version."""
639 return self._tpm_handler.get_fw_version()
640
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800641 def _tpm_get_firmware_datakey_version(self):
642 """Retrieve tpm firmware data key version."""
643 return self._tpm_handler.get_fw_body_version()
644
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800645 def _cgpt_run_test_loop(self):
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800646 """Run the CgptState test loop. The tst logic is handled in the client.
647
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800648 @return: 0: there are more cgpt tests to execute.
649 1: no more CgptState test, finished.
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800650 """
651 return self._cgpt_state.test_loop()
652
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800653 def _cgpt_set_test_step(self, step):
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800654 """Set the CgptState test step.
655
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800656 @param step: A test step number.
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800657 """
658 self._cgpt_state.set_step(step)
659
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800660 def _cgpt_get_test_step(self):
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800661 """Get the CgptState test step.
662
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800663 @return: A test step number.
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800664 """
665 return self._cgpt_state.get_step()
666
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800667 def _updater_setup(self, shellball=None):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800668 """Setup the updater.
669
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800670 @param shellball: Path of provided shellball. Use default shellball
671 if None,
Chun-ting Changcf924e92012-10-29 13:49:01 +0800672 """
673 self._updater.setup(self._chromeos_interface, shellball)
674
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800675 def _updater_cleanup(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800676 self._updater.cleanup_temp_dir()
677
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800678 def _updater_get_fwid(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800679 """Retrieve shellball's fwid.
680
681 This method should be called after updater_setup.
682
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800683 @return: Shellball's fwid.
Chun-ting Changcf924e92012-10-29 13:49:01 +0800684 """
685 return self._updater.retrieve_fwid()
686
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800687 def _updater_resign_firmware(self, version):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800688 """Resign firmware with version.
689
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800690 @param version: new version number.
Chun-ting Changcf924e92012-10-29 13:49:01 +0800691 """
692 self._updater.resign_firmware(version)
693
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800694 def _updater_repack_shellball(self, append):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800695 """Repack shellball with new fwid.
696
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800697 @param append: use for new fwid naming.
Chun-ting Changcf924e92012-10-29 13:49:01 +0800698 """
699 self._updater.repack_shellball(append)
700
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800701 def _updater_run_autoupdate(self, append):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800702 """Run chromeos-firmwareupdate with autoupdate mode."""
703 options = ['--noupdate_ec', '--nocheck_rw_compatible']
704 self._updater.run_firmwareupdate(mode='autoupdate',
705 updater_append=append,
706 options=options)
707
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800708 def _updater_run_factory_install(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800709 """Run chromeos-firmwareupdate with factory_install mode."""
710 options = ['--noupdate_ec']
711 self._updater.run_firmwareupdate(mode='factory_install',
712 options=options)
713
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800714 def _updater_run_bootok(self, append):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800715 """Run chromeos-firmwareupdate with bootok mode."""
716 self._updater.run_firmwareupdate(mode='bootok',
717 updater_append=append)
718
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800719 def _updater_run_recovery(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800720 """Run chromeos-firmwareupdate with recovery mode."""
721 options = ['--noupdate_ec', '--nocheck_rw_compatible']
722 self._updater.run_firmwareupdate(mode='recovery',
723 options=options)
724
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800725 def _updater_get_temp_path(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800726 """Get updater's temp directory path."""
727 return self._updater.get_temp_path()
728
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800729 def _updater_get_keys_path(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800730 """Get updater's keys directory path."""
731 return self._updater.get_keys_path()
732
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800733 def _updater_get_work_path(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800734 """Get updater's work directory path."""
735 return self._updater.get_work_path()
736
Tom Wai-Hong Tambea57b32011-09-02 18:27:47 +0800737 def cleanup(self):
738 """Cleanup for the RPC server. Currently nothing."""
739 pass