Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: client/site_tests/hardware_Components/hardware_Components.py

Issue 3246002: Add flashrom memory layout detection by FMAP (using fmap_decode) (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: change site_fmap license header Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/site_tests/factory_EnableWriteProtect/factory_EnableWriteProtect.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import glob, hashlib, logging, os, pprint, re, sys 5 import glob, hashlib, logging, os, pprint, re, sys
6 from autotest_lib.client.bin import test, utils 6 from autotest_lib.client.bin import test, utils
7 from autotest_lib.client.common_lib import error 7 from autotest_lib.client.common_lib import error
8 from autotest_lib.client.common_lib import flashrom_util 8 from autotest_lib.client.common_lib import flashrom_util
9 from autotest_lib.client.common_lib import site_vblock 9 from autotest_lib.client.common_lib import site_vblock
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 Returns a hash of Read Only firmware parts, 232 Returns a hash of Read Only firmware parts,
233 to confirm we have proper keys / boot code / recovery image installed. 233 to confirm we have proper keys / boot code / recovery image installed.
234 """ 234 """
235 # hash_ro_list: RO section to be hashed 235 # hash_ro_list: RO section to be hashed
236 hash_ro_list = ['FV_BSTUB', 'FV_GBB', 'FVDEV'] 236 hash_ro_list = ['FV_BSTUB', 'FV_GBB', 'FVDEV']
237 flashrom = flashrom_util.flashrom_util() 237 flashrom = flashrom_util.flashrom_util()
238 if not flashrom.select_bios_flashrom(): 238 if not flashrom.select_bios_flashrom():
239 raise error.TestError('Cannot select BIOS flashrom') 239 raise error.TestError('Cannot select BIOS flashrom')
240 base_img = flashrom.read_whole() 240 base_img = flashrom.read_whole()
241 flashrom_size = len(base_img) 241 flashrom_size = len(base_img)
242 layout = flashrom.detect_chromeos_bios_layout(flashrom_size) 242 # XXX we can NOT trust base image here for layout, otherwise firmware
243 # can provide fake (non-used) GBB/BSTUB in garbage area.
244 layout = flashrom.detect_chromeos_bios_layout(flashrom_size, None)
243 if not layout: 245 if not layout:
244 raise error.TestError('Cannot detect ChromeOS flashrom laout') 246 raise error.TestError('Cannot detect ChromeOS flashrom laout')
245 hash_src = '' 247 hash_src = ''
246 for section in hash_ro_list: 248 for section in hash_ro_list:
247 src = flashrom.get_section(base_img, layout, section) 249 src = flashrom.get_section(base_img, layout, section)
248 if not src: 250 if not src:
249 raise error.TestError('Cannot get section [%s] from flashrom' % 251 raise error.TestError('Cannot get section [%s] from flashrom' %
250 section) 252 section)
251 hash_src = hash_src + src 253 hash_src = hash_src + src
252 if not hash_src: 254 if not hash_src:
253 raise error.TestError('Invalid hash source from flashrom.') 255 raise error.TestError('Invalid hash source from flashrom.')
254 return hashlib.sha256(hash_src).hexdigest() 256 return hashlib.sha256(hash_src).hexdigest()
255 257
256 258
257 def get_version_rw_firmware(self): 259 def get_version_rw_firmware(self):
258 """ 260 """
259 Returns the version of Read-Write (writable) firmware from VBOOT 261 Returns the version of Read-Write (writable) firmware from VBOOT
260 section. If A/B has different version, that means this system 262 section. If A/B has different version, that means this system
261 needs a reboot + firmwar update so return value is a "error report" 263 needs a reboot + firmwar update so return value is a "error report"
262 in the form "A=x, B=y". 264 in the form "A=x, B=y".
263 """ 265 """
264 versions = [None, None] 266 versions = [None, None]
265 section_names = ['VBOOTA', 'VBOOTB'] 267 section_names = ['VBOOTA', 'VBOOTB']
266 flashrom = flashrom_util.flashrom_util() 268 flashrom = flashrom_util.flashrom_util()
267 if not flashrom.select_bios_flashrom(): 269 if not flashrom.select_bios_flashrom():
268 raise error.TestError('Cannot select BIOS flashrom') 270 raise error.TestError('Cannot select BIOS flashrom')
269 base_img = flashrom.read_whole() 271 base_img = flashrom.read_whole()
270 flashrom_size = len(base_img) 272 flashrom_size = len(base_img)
271 layout = flashrom.detect_chromeos_bios_layout(flashrom_size) 273 # we can trust base image for layout, since it's only RW.
274 layout = flashrom.detect_chromeos_bios_layout(flashrom_size, base_imge)
272 if not layout: 275 if not layout:
273 raise error.TestError('Cannot detect ChromeOS flashrom laout') 276 raise error.TestError('Cannot detect ChromeOS flashrom laout')
274 for index, name in enumerate(section_names): 277 for index, name in enumerate(section_names):
275 data = flashrom.get_section(base_img, layout, name) 278 data = flashrom.get_section(base_img, layout, name)
276 block = site_vblock.unpack_verification_block(data) 279 block = site_vblock.unpack_verification_block(data)
277 ver = block['VbFirmwarePreambleHeader']['firmware_version'] 280 ver = block['VbFirmwarePreambleHeader']['firmware_version']
278 versions[index] = ver 281 versions[index] = ver
279 # we embed error reports in return value. 282 # we embed error reports in return value.
280 assert len(versions) == 2 283 assert len(versions) == 2
281 if versions[0] != versions[1]: 284 if versions[0] != versions[1]:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if self._failures: 344 if self._failures:
342 all_failures += 'Approved DB: %s' % db 345 all_failures += 'Approved DB: %s' % db
343 all_failures += self.pformat(self._failures) 346 all_failures += self.pformat(self._failures)
344 else: 347 else:
345 # If one of DBs is matched, record the hwqual_id and exit. 348 # If one of DBs is matched, record the hwqual_id and exit.
346 self.write_test_keyval( 349 self.write_test_keyval(
347 {'hwqual_id': self._approved['part_id_hwqual'][0]}) 350 {'hwqual_id': self._approved['part_id_hwqual'][0]})
348 return 351 return
349 352
350 raise error.TestFail(all_failures) 353 raise error.TestFail(all_failures)
OLDNEW
« no previous file with comments | « client/site_tests/factory_EnableWriteProtect/factory_EnableWriteProtect.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698