Skip to content

Commit 696147c

Browse files
committed
[nrf fromlist] 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. Upstream PR #: 90605 Signed-off-by: Grzegorz Chwierut <[email protected]>
1 parent 8bcc6ab commit 696147c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

scripts/west_commands/runners/nrf_common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@ def program_hex(self):
469469
core = "Application"
470470

471471
self.op_program(self.hex_, erase_arg, ext_mem_erase_opt, defer=True, core=core)
472+
473+
if self.erase or self.recover:
474+
# provision keys if keyfile.json exists in the build directory
475+
keyfile = Path(self.cfg.build_dir).parent / 'keyfile.json'
476+
if keyfile.exists():
477+
self.logger.info(f'Provisioning key file: {keyfile}')
478+
self.exec_op('x-provision-keys', keyfile=str(keyfile), defer=True)
479+
472480
self.flush(force=False)
473481

474482

scripts/west_commands/runners/nrfutil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def _append_batch(self, op, json_file):
145145
cmd += ['--reset-kind', _op['kind']]
146146
elif op_type == 'erase':
147147
cmd.append(f'--{_op["kind"]}')
148+
elif op_type == 'x-provision-keys':
149+
cmd += ['--key-file', _op['keyfile']]
148150

149151
cmd += ['--core', op['core']] if op.get('core') else []
150152
cmd += ['--x-family', f'{self.family}']

0 commit comments

Comments
 (0)