| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 """Google Factory Tool: Write Protection for Firmware | 7 """Google Factory Tool: Write Protection for Firmware |
| 8 | 8 |
| 9 This module enables or verifies that firmware write protection is properly | 9 This module enables or verifies that firmware write protection is properly |
| 10 activated. | 10 activated. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 # correct, because sometimes the factory test is executed several | 93 # correct, because sometimes the factory test is executed several |
| 94 # times without resetting WP status. | 94 # times without resetting WP status. |
| 95 if not flashrom.verify_write_protect(layout, 'ro'): | 95 if not flashrom.verify_write_protect(layout, 'ro'): |
| 96 if not (flashrom.enable_write_protect(layout, 'ro') | 96 if not (flashrom.enable_write_protect(layout, 'ro') |
| 97 and flashrom.verify_write_protect(layout, 'ro')): | 97 and flashrom.verify_write_protect(layout, 'ro')): |
| 98 ErrorDie('wpfw: cannot enable write protection for ' + name) | 98 ErrorDie('wpfw: cannot enable write protection for ' + name) |
| 99 VerboseMsg(' - Check Write Protection for ' + name) | 99 VerboseMsg(' - Check Write Protection for ' + name) |
| 100 flashrom.disable_write_protect() | 100 flashrom.disable_write_protect() |
| 101 if not flashrom.verify_write_protect(layout, 'ro'): | 101 if not flashrom.verify_write_protect(layout, 'ro'): |
| 102 ErrorDie('wpfw: not write-protected (modifiable status): ' + name) | 102 ErrorDie('wpfw: not write-protected (modifiable status): ' + name) |
| 103 |
| 104 # Always restore the target to BIOS(spi). Some platforms may fail to reboot if |
| 105 # target is EC(lpc). |
| 106 if target != flashrom.TARGET_BIOS: |
| 107 flashrom.select_target(flashrom.TARGET_BIOS) |
| 103 return True | 108 return True |
| 104 | 109 |
| 105 | 110 |
| 106 ############################################################################# | 111 ############################################################################# |
| 107 # Console main entry | 112 # Console main entry |
| 108 @gft_common.GFTConsole | 113 @gft_common.GFTConsole |
| 109 def _main(): | 114 def _main(): |
| 110 """ Main entry for console mode """ | 115 """ Main entry for console mode """ |
| 111 if len(sys.argv) != 2: | 116 if len(sys.argv) != 2: |
| 112 print 'Usage: %s target_code(bios/ec)\n' % sys.argv[0] | 117 print 'Usage: %s target_code(bios/ec)\n' % sys.argv[0] |
| 113 sys.exit(1) | 118 sys.exit(1) |
| 114 | 119 |
| 115 gft_common.SetDebugLevel(True) | 120 gft_common.SetDebugLevel(True) |
| 116 gft_common.SetVerboseLevel(True) | 121 gft_common.SetVerboseLevel(True) |
| 117 EnableWriteProtect(sys.argv[1]) | 122 EnableWriteProtect(sys.argv[1]) |
| 118 | 123 |
| 119 | 124 |
| 120 if __name__ == '__main__': | 125 if __name__ == '__main__': |
| 121 _main() | 126 _main() |
| OLD | NEW |