gooftool: add --clear_gbb_flags command

Shipping devices should have all flags in GBB header cleared.

The clear_gbb_flags needs to read GBB section from flashrom, causing 2 seconds
of execution time in each --finalize or --clear_gbb_flags call (and more if we
need to update GBB header).

Although the hash check in verify_hwid should ensure GBB data is properly
written, since this is a high risk security item, we currently enforce always
testing GBB hedader in each --finalize call. This may be improved in future.

BUG=chrome-os-partner:2317
TEST=# setup a BIOS with non-zero flags
     flashrom -r bios.bin
     gbb_utility -s --flags=3 bios.bin
     flashrom -i GBB -w bios.bin
     # check bios flags
     flashrom -r bios.bin
     gbb_utility --flags bios.bin # see 3
     # execute gooftool
     gooftool --clear_gbb_flags
     # check bios flags
     flashrom -r bios.bin
     gbb_utility --flags bios.bin # see 0

Change-Id: I3bdaa2ba52ed7dbc7cd21e6f5a34732740bec782
Reviewed-on: http://gerrit.chromium.org/gerrit/6730
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
3 files changed