Skip to content

Commit 126c387

Browse files
gchwiercarlescufi
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit db3c344)
1 parent 237a857 commit 126c387

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
@@ -147,6 +147,8 @@ def _append_batch(self, op, json_file):
147147
cmd += ['--reset-kind', _op['kind']]
148148
elif op_type == 'erase':
149149
cmd.append(f'--{_op["kind"]}')
150+
elif op_type == 'x-provision-keys':
151+
cmd += ['--key-file', _op['keyfile']]
150152

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

0 commit comments

Comments
 (0)