finalize: Remove has_fpmcu_cmd_arg
We shouldn't need an arg to force to skip FPMCU entropy init.
Instead, we should check both cros_fp path in rootfs and fingerprint
attribute in cros_config to determine if the DUT has FPMCU and
thus entropy init needs to be executed in factory finalization.
BUG=b:141172626
TEST=manual test on Helios
Change-Id: Ia4c2021a30ce1b84139f03de16548c074808c69e
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1902267
Tested-by: Philip Chen <philipchen@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Wei-Han Chen <stimim@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index b31833e..06be772 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -56,6 +56,7 @@
_global_gooftool = None
_gooftool_lock = threading.Lock()
+_has_fpmcu = None
def GetGooftool(options):
@@ -71,6 +72,24 @@
return _global_gooftool
+def HasFpmcu():
+ global _has_fpmcu # pylint: disable=global-statement
+
+ if _has_fpmcu is None:
+ FPMCU_PATH = '/dev/cros_fp'
+ has_fpmcu_path = os.path.exists(FPMCU_PATH)
+ has_cros_config_fpmcu = False
+ if Shell(['cros_config', '/fingerprint', 'board']):
+ has_cros_config_fpmcu = True
+
+ if has_fpmcu_path is False and has_cros_config_fpmcu is True:
+ raise Error('FPMCU found in cros_config but missing in %s.' % FPMCU_PATH)
+ elif has_fpmcu_path is True and has_cros_config_fpmcu is False:
+ raise Error('FPMCU found in %s but missing in cros_config.' % FPMCU_PATH)
+
+ _has_fpmcu = has_fpmcu_path
+
+ return _has_fpmcu
def Command(cmd_name, *args, **kwargs):
"""Decorator for commands in gooftool.
@@ -244,14 +263,6 @@
'--no_generate_mfg_date', action='store_false', dest='generate_mfg_date',
help='Do not generate manufacturing date nor write mfg_date into VPD.')
-_has_fpmcu_cmd_arg = CmdArg(
- '--has_fpmcu', action='store_true', default=None,
- help='Force execution of fpmcu related commands.')
-
-_no_fpmcu_cmd_arg = CmdArg(
- '--no_fpmcu', action='store_false', default=None, dest='has_fpmcu',
- help='Skip fpmcu related commands.')
-
@Command(
'verify_ec_key',
@@ -738,9 +749,7 @@
_rlz_embargo_end_date_offset_cmd_arg,
_waive_list_cmd_arg,
_skip_list_cmd_arg,
- _no_generate_mfg_date_cmd_arg,
- _has_fpmcu_cmd_arg,
- _no_fpmcu_cmd_arg)
+ _no_generate_mfg_date_cmd_arg)
def Finalize(options):
"""Verify system readiness and trigger transition into release state.
@@ -840,20 +849,14 @@
raise Error('File does not exist: %s' % options.file)
-@Command('fpmcu_initialize_entropy',
- _has_fpmcu_cmd_arg,
- _no_fpmcu_cmd_arg)
+@Command('fpmcu_initialize_entropy')
def FpmcuInitializeEntropy(options):
"""Initialze entropy of FPMCU."""
- fpmcu_exists = os.path.exists('/dev/cros_fp')
- if options.has_fpmcu is None:
- options.has_fpmcu = fpmcu_exists
- if options.has_fpmcu:
- if not fpmcu_exists:
- raise Error('FPS not found on device.')
+
+ if HasFpmcu():
GetGooftool(options).FpmcuInitializeEntropy()
- elif fpmcu_exists:
- logging.warning('FPS found. Entropy initialization skipped.')
+ else:
+ logging.info('No FPS on this board.')
def main():