Skip to content

Commit f391ea9

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. Signed-off-by: Grzegorz Chwierut <[email protected]>
1 parent 8bcc6ab commit f391ea9

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
@@ -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)