Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import pprint | 8 import pprint |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 'hash_ro_firmware', | 38 'hash_ro_firmware', |
| 39 'part_id_audio_codec', | 39 'part_id_audio_codec', |
| 40 'part_id_cpu', | 40 'part_id_cpu', |
| 41 'part_id_display_panel', | 41 'part_id_display_panel', |
| 42 'part_id_dram', | 42 'part_id_dram', |
| 43 'part_id_embedded_controller', | 43 'part_id_embedded_controller', |
| 44 'part_id_ethernet', | 44 'part_id_ethernet', |
| 45 'part_id_flash_chip', | 45 'part_id_flash_chip', |
| 46 'part_id_ec_flash_chip', | 46 'part_id_ec_flash_chip', |
| 47 'part_id_hwqual', | 47 'part_id_hwqual', |
| 48 'part_id_keyboard', | |
| 48 'part_id_storage', | 49 'part_id_storage', |
| 49 'part_id_tpm', | 50 'part_id_tpm', |
| 50 'part_id_wireless', | 51 'part_id_wireless', |
| 51 'vendor_id_touchpad', | 52 'vendor_id_touchpad', |
| 52 'version_rw_firmware', | 53 'version_rw_firmware', |
| 54 'version_3g_firmware', | |
| 53 ] | 55 ] |
| 54 _pci_cids = [ | 56 _pci_cids = [ |
| 55 'part_id_chipset', | 57 'part_id_chipset', |
| 56 'part_id_usb_hosts', | 58 'part_id_usb_hosts', |
| 57 'part_id_vga', | 59 'part_id_vga', |
| 58 ] | 60 ] |
| 59 _usb_cids = [ | 61 _usb_cids = [ |
| 60 'part_id_bluetooth', | 62 'part_id_bluetooth', |
| 61 'part_id_webcam', | 63 'part_id_webcam', |
| 62 'part_id_3g', | 64 'part_id_3g', |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 def get_part_id_hwqual(self): | 284 def get_part_id_hwqual(self): |
| 283 part_id = gft_common.SystemOutput('crossystem hwid').strip() | 285 part_id = gft_common.SystemOutput('crossystem hwid').strip() |
| 284 return (part_id if part_id else self._not_present) | 286 return (part_id if part_id else self._not_present) |
| 285 | 287 |
| 286 def get_part_id_storage(self): | 288 def get_part_id_storage(self): |
| 287 cmd = ('cd $(find /sys/devices -name sda)/../..; ' | 289 cmd = ('cd $(find /sys/devices -name sda)/../..; ' |
| 288 'cat vendor model | tr "\n" " " | sed "s/ \\+/ /g"') | 290 'cat vendor model | tr "\n" " " | sed "s/ \\+/ /g"') |
| 289 part_id = gft_common.SystemOutput(cmd).strip() | 291 part_id = gft_common.SystemOutput(cmd).strip() |
| 290 return part_id | 292 return part_id |
| 291 | 293 |
| 294 def get_part_id_keyboard(self): | |
| 295 # VPD value "initial_locale"="en-US" should be listed. | |
|
Louis
2011/04/11 02:43:12
Could you change the example as following to match
| |
| 296 image_file = self.load_main_firmware() | |
| 297 part_id = gft_common.SystemOutput( | |
| 298 'vpd -i RO_VPD -l -f %s | grep keyboard_layout | cut -f4 -d\\"' % | |
|
Louis
2011/04/11 02:43:12
shall we escape -f %s like
-f \\"%s\\"
Ignore
| |
| 299 image_file).strip() | |
| 300 return part_id or self._not_present | |
| 301 | |
| 292 def get_part_id_tpm(self): | 302 def get_part_id_tpm(self): |
| 293 """ Returns Manufacturer_info : Chip_Version """ | 303 """ Returns Manufacturer_info : Chip_Version """ |
| 294 cmd = 'tpm_version' | 304 cmd = 'tpm_version' |
| 295 tpm_output = gft_common.SystemOutput(cmd) | 305 tpm_output = gft_common.SystemOutput(cmd) |
| 296 tpm_lines = tpm_output.splitlines() | 306 tpm_lines = tpm_output.splitlines() |
| 297 tpm_dict = {} | 307 tpm_dict = {} |
| 298 for tpm_line in tpm_lines: | 308 for tpm_line in tpm_lines: |
| 299 [key, colon, value] = tpm_line.partition(':') | 309 [key, colon, value] = tpm_line.partition(':') |
| 300 tpm_dict[key.strip()] = value.strip() | 310 tpm_dict[key.strip()] = value.strip() |
| 301 part_id = '' | 311 part_id = '' |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 data = flashrom.get_section(base_img, layout, name) | 395 data = flashrom.get_section(base_img, layout, name) |
| 386 block = vblock.unpack_verification_block(data) | 396 block = vblock.unpack_verification_block(data) |
| 387 ver = block['VbFirmwarePreambleHeader']['firmware_version'] | 397 ver = block['VbFirmwarePreambleHeader']['firmware_version'] |
| 388 versions[index] = ver | 398 versions[index] = ver |
| 389 # we embed error reports in return value. | 399 # we embed error reports in return value. |
| 390 assert len(versions) == 2 | 400 assert len(versions) == 2 |
| 391 if versions[0] != versions[1]: | 401 if versions[0] != versions[1]: |
| 392 return 'A=%d, B=%d' % (versions[0], versions[1]) | 402 return 'A=%d, B=%d' % (versions[0], versions[1]) |
| 393 return '%d' % versions[0] | 403 return '%d' % versions[0] |
| 394 | 404 |
| 405 def get_version_3g_firmware(self): | |
| 406 version = 'Unknown' | |
| 407 # TODO(hungte) use mm.py directly to prevent the need of shell scripting | |
| 408 modem_status = gft_common.SystemOutput('modem status').splitlines() | |
| 409 if not modem_status: | |
| 410 return self._not_present | |
| 411 | |
| 412 # status format: | |
| 413 # Manufacturer: $VENDOR | |
| 414 # Modem: $MODEM | |
| 415 # Version: $VERSION_MAY_BE_MULTILINE | |
| 416 def ParseInfo(name): | |
| 417 data = [line for line in modem_status if line.find('%s: ' % name) >= 0] | |
| 418 assert len(data) < 2 | |
| 419 return data[0].split(': ', 1)[1].strip() | |
| 420 | |
| 421 version = ParseInfo('Version') | |
| 422 vendor = ParseInfo('Manufacturer') | |
| 423 modem = ParseInfo('Modem') | |
| 424 | |
| 425 if vendor == 'Samsung' and modem == 'GT-Y3300X': | |
| 426 # The real version is in "Version:" +2 lines | |
| 427 version = '' | |
| 428 for i, line in enumerate(modem_status): | |
| 429 if 'Version: ' in line: | |
| 430 version = modem_status[i + 2].strip() | |
| 431 break | |
| 432 return version or 'Unknown' | |
| 433 | |
| 395 def _read_gbb_component(self, name): | 434 def _read_gbb_component(self, name): |
| 396 image_file = self.load_main_firmware() | 435 image_file = self.load_main_firmware() |
| 397 if not image_file: | 436 if not image_file: |
| 398 ErrorDie('cannot load main firmware') | 437 ErrorDie('cannot load main firmware') |
| 399 filename = gft_common.GetTemporaryFileName('gbb%s' % name) | 438 filename = gft_common.GetTemporaryFileName('gbb%s' % name) |
| 400 if os.system('gbb_utility -g --%s=%s %s >/dev/null 2>&1' % | 439 if os.system('gbb_utility -g --%s=%s %s >/dev/null 2>&1' % |
| 401 (name, filename, image_file)) != 0: | 440 (name, filename, image_file)) != 0: |
| 402 ErrorDie('cannot get %s from GBB' % name) | 441 ErrorDie('cannot get %s from GBB' % name) |
| 403 value = gft_common.ReadBinaryFile(filename) | 442 value = gft_common.ReadBinaryFile(filename) |
| 404 os.remove(filename) | 443 os.remove(filename) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 | 634 |
| 596 for arg in args: | 635 for arg in args: |
| 597 (matched, failures) = components.match_current_system(arg) | 636 (matched, failures) = components.match_current_system(arg) |
| 598 print 'Probed (%s):' % arg | 637 print 'Probed (%s):' % arg |
| 599 print components.pformat(matched) | 638 print components.pformat(matched) |
| 600 print 'Failures (%s):' % arg | 639 print 'Failures (%s):' % arg |
| 601 print components.pformat(failures) | 640 print components.pformat(failures) |
| 602 | 641 |
| 603 if __name__ == '__main__': | 642 if __name__ == '__main__': |
| 604 _main(sys.argv[0], sys.argv[1:]) | 643 _main(sys.argv[0], sys.argv[1:]) |
| OLD | NEW |