west: runners: Add ncs-provision to west flash command

Added automatic KMU key provisioning, when keyfile.json
file exists in the build directory.
This enables automated key provisioning during the
flashing process to enable testing nRF54L aplications using Twister.
Only applicable on nrfutil runner.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
This commit is contained in:
Grzegorz Chwierut 2025-05-29 15:49:29 +02:00 committed by Dan Kalowsky
commit db3c344af9
2 changed files with 10 additions and 0 deletions

View file

@ -469,6 +469,14 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
core = "Application"
self.op_program(self.hex_, erase_arg, ext_mem_erase_opt, defer=True, core=core)
if self.erase or self.recover:
# provision keys if keyfile.json exists in the build directory
keyfile = Path(self.cfg.build_dir).parent / 'keyfile.json'
if keyfile.exists():
self.logger.info(f'Provisioning key file: {keyfile}')
self.exec_op('x-provision-keys', keyfile=str(keyfile), defer=True)
self.flush(force=False)

View file

@ -147,6 +147,8 @@ class NrfUtilBinaryRunner(NrfBinaryRunner):
cmd += ['--reset-kind', _op['kind']]
elif op_type == 'erase':
cmd.append(f'--{_op["kind"]}')
elif op_type == 'x-provision-keys':
cmd += ['--key-file', _op['keyfile']]
cmd += ['--core', op['core']] if op.get('core') else []
cmd += ['--x-family', f'{self.family}']