Skip to content

Commit c3dbbc8

Browse files
committed
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]>
1 parent f6821fb commit c3dbbc8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

scripts/west_commands/runners/nrf_common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ def program_hex(self):
468468
if self.build_conf.get('CONFIG_SOC_NRF54H20_IRON') and core == "Network":
469469
core = "Application"
470470

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

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)