Skip to content

Commit 4770e18

Browse files
carlescufiArekBalysNordic
authored andcommitted
[nrf fromtree] scripts: runners: nrfutil: Add a new external memory config param
This acts in a similar way to nrfjprog's --qspiini parameter introduced in 7eb364b, but works slightly differently in nrfutil: it requires a config file in JSON format instead of .ini, and it is passed along to the `execute-batch` command instead of providing it together with the `program` command. Signed-off-by: Carles Cufi <[email protected]> (cherry picked from commit 2effae5)
1 parent 7179ebc commit 4770e18

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

scripts/west_commands/runners/nrfutil.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ class NrfUtilBinaryRunner(NrfBinaryRunner):
1818

1919
def __init__(self, cfg, family, softreset, pinreset, dev_id, erase=False,
2020
reset=True, tool_opt=None, force=False, recover=False,
21-
suit_starter=False):
21+
suit_starter=False, ext_mem_config_file=None):
2222

2323
super().__init__(cfg, family, softreset, pinreset, dev_id, erase, reset,
2424
tool_opt, force, recover)
2525

2626
self.suit_starter = suit_starter
27+
self.ext_mem_config_file = ext_mem_config_file
2728

2829
self._ops = []
2930
self._op_id = 1
@@ -43,14 +44,19 @@ def do_create(cls, cfg, args):
4344
reset=args.reset,
4445
tool_opt=args.tool_opt, force=args.force,
4546
recover=args.recover,
46-
suit_starter=args.suit_manifest_starter)
47+
suit_starter=args.suit_manifest_starter,
48+
ext_mem_config_file=args.ext_mem_config_file)
4749

4850
@classmethod
4951
def do_add_parser(cls, parser):
5052
super().do_add_parser(parser)
5153
parser.add_argument('--suit-manifest-starter', required=False,
5254
action='store_true',
5355
help='Use the SUIT manifest starter file')
56+
parser.add_argument('--ext-mem-config-file', required=False,
57+
dest='ext_mem_config_file',
58+
help='path to an JSON file with external memory configuration')
59+
5460

5561
def _exec(self, args):
5662
jout_all = []
@@ -139,8 +145,13 @@ def _exec_batch(self):
139145
self._ops = []
140146
self._op_id = 1
141147
self.logger.debug(f'Executing batch in: {json_file}')
142-
self._exec(['x-execute-batch', '--batch-path', f'{json_file}',
143-
'--serial-number', f'{self.dev_id}'])
148+
precmd = []
149+
if self.ext_mem_config_file:
150+
# This needs to be prepended, as it's a global option
151+
precmd = ['--x-ext-mem-config-file', self.ext_mem_config_file]
152+
153+
self._exec(precmd + ['x-execute-batch', '--batch-path', f'{json_file}',
154+
'--serial-number', f'{self.dev_id}'])
144155

145156
def do_exec_op(self, op, force=False):
146157
self.logger.debug(f'Executing op: {op}')

0 commit comments

Comments
 (0)