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

Side by Side Diff: gooftool

Issue 6788005: factory_test_tools: support write protection for ARM (Closed) Base URL: ssh://gitrw.chromium.org:9222/factory_test_tools.git@master
Patch Set: fix by reviewer's comments Created 9 years, 8 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 | « gft_wpfw.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 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 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 """ 7 """
8 gooftool: Google Factory Tool, providing all Google Required Test 8 gooftool: Google Factory Tool, providing all Google Required Test
9 functionality. 9 functionality.
10 """ 10 """
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 VerboseMsg('MatchComponentsDatabases: Matching current system by %s' % db) 99 VerboseMsg('MatchComponentsDatabases: Matching current system by %s' % db)
100 (matched, failure) = hwcomp.match_current_system(db) 100 (matched, failure) = hwcomp.match_current_system(db)
101 if failure: 101 if failure:
102 DebugMsg('Unmatched for %s:%s\n' % (db, hwcomp.pformat(failure))) 102 DebugMsg('Unmatched for %s:%s\n' % (db, hwcomp.pformat(failure)))
103 else: 103 else:
104 matched_list[db] = matched 104 matched_list[db] = matched
105 VerboseMsg('Matched: %s' % db) 105 VerboseMsg('Matched: %s' % db)
106 return matched_list 106 return matched_list
107 107
108 108
109 def EnableWriteProtect(target): 109 def EnableWriteProtect(target, image):
110 """ Enables and verifies firmware write protection. """ 110 """ Enables and verifies firmware write protection. """
111 return gft_wpfw.EnableWriteProtect(target) 111 return gft_wpfw.EnableWriteProtect(target, image)
112 112
113 113
114 def WriteGBB(db_file): 114 def WriteGBB(db_file):
115 """ Writes a prepared GBB data to system main firwmare. """ 115 """ Writes a prepared GBB data to system main firwmare. """
116 flashrom = flashrom_util.flashrom_util(verbose_msg=VerboseMsg, 116 flashrom = flashrom_util.flashrom_util(verbose_msg=VerboseMsg,
117 exception_type=gft_common.GFTError) 117 exception_type=gft_common.GFTError)
118 flashrom.select_target('bios') 118 flashrom.select_target('bios')
119 image_file = gft_common.GetTemporaryFileName('wgbb') 119 image_file = gft_common.GetTemporaryFileName('wgbb')
120 if not flashrom.read_whole_to_file(image_file): 120 if not flashrom.read_whole_to_file(image_file):
121 ErrorDie('WriteGBB: failed to read current firmware.') 121 ErrorDie('WriteGBB: failed to read current firmware.')
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 ErrorDie('upload_report: failed to upload.') 305 ErrorDie('upload_report: failed to upload.')
306 return True 306 return True
307 307
308 308
309 @GFTLogCommand 309 @GFTLogCommand
310 def wpfw(): 310 def wpfw():
311 """ Enables and verifies firmware write protection. """ 311 """ Enables and verifies firmware write protection. """
312 if g_options.debug_dryrun_wpfw: 312 if g_options.debug_dryrun_wpfw:
313 ErrorMsg('wpfw is by-passed. This device CANNOT be qualified.') 313 ErrorMsg('wpfw is by-passed. This device CANNOT be qualified.')
314 return True 314 return True
315 if EnableWriteProtect('ec') and EnableWriteProtect('bios'): 315 hwcomp = InitializeHardwareComponents(do_probe=False)
316 return True 316 # TODO(hungte) chrome-os-partner:3023 We need a cleaner way for EC detection,
317 ErrorDie('wpfw: failed to enable firmware write protection.') 317 # for examing using crossystem. Currently we only know there is no EC on arm.
318 with os.popen("uname -m") as uname_process:
319 arch = uname_process.read().strip()
320 read_binary = gft_common.ReadBinaryFile
321 target_set = [('ec', hwcomp.load_ec_firmware),
322 ('bios', hwcomp.load_main_firmware)]
323 if arch.startswith('arm'):
324 VerboseMsg('wpfw: ARM platform detected, ignore EC.')
325 assert target_set[0][0] == 'ec'
326 target_set = target_set[1:]
327 assert len(target_set)
328 for target_name, loader_api in target_set:
329 if not EnableWriteProtect(target_name, read_binary(loader_api())):
330 ErrorDie('wpfw: failed to enable firmware write protection.')
331 return True
318 332
319 333
320 @GFTLogCommand 334 @GFTLogCommand
321 def prepare_wipe(): 335 def prepare_wipe():
322 """ Prepares system to reboot for transitioning to release state. """ 336 """ Prepares system to reboot for transitioning to release state. """
323 if g_options.debug_dryrun_prepare_wipe: 337 if g_options.debug_dryrun_prepare_wipe:
324 ErrorMsg('prepare_wipe is by-passed. This device CANNOT be qualified.') 338 ErrorMsg('prepare_wipe is by-passed. This device CANNOT be qualified.')
325 return True 339 return True
326 wipe_script = os.path.join(os.path.split(sys.argv[0])[0], 340 wipe_script = os.path.join(os.path.split(sys.argv[0])[0],
327 'gft_prepare_wipe.sh') 341 'gft_prepare_wipe.sh')
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 return_value = 1 491 return_value = 1
478 executed_commands = executed_commands + 1 492 executed_commands = executed_commands + 1
479 493
480 if executed_commands == 0: 494 if executed_commands == 0:
481 parser.print_help() 495 parser.print_help()
482 return return_value 496 return return_value
483 497
484 498
485 if __name__ == '__main__': 499 if __name__ == '__main__':
486 sys.exit(_main()) 500 sys.exit(_main())
OLDNEW
« no previous file with comments | « gft_wpfw.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698