From dc7d8bbe16a253588bc1a55c19f550e4f78a5bf7 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Thu, 30 Jan 2025 13:23:38 +0100 Subject: [PATCH] scripts: runners: nrf: Implement the erase command The `erase` command was being used but there was no "backend" implementation for it in nrfutil nor nrfjprog. Simplify the syntax and implement it for both tools. Signed-off-by: Carles Cufi --- scripts/west_commands/runners/nrf_common.py | 3 +-- scripts/west_commands/runners/nrfjprog.py | 2 ++ scripts/west_commands/runners/nrfutil.py | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/west_commands/runners/nrf_common.py b/scripts/west_commands/runners/nrf_common.py index e6576ca2455..55ff3741aa9 100644 --- a/scripts/west_commands/runners/nrf_common.py +++ b/scripts/west_commands/runners/nrf_common.py @@ -390,8 +390,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner): ) if not self.erase and generated_uicr: - self.exec_op('erase', core=core, option={'chip_erase_mode': 'ERASE_UICR', - 'ext_mem_erase_mode': 'ERASE_NONE'}) + self.exec_op('erase', core=core, kind='uicr') else: if self.erase: erase_arg = 'ERASE_ALL' diff --git a/scripts/west_commands/runners/nrfjprog.py b/scripts/west_commands/runners/nrfjprog.py index f8f1a404520..941a6d18f55 100644 --- a/scripts/west_commands/runners/nrfjprog.py +++ b/scripts/west_commands/runners/nrfjprog.py @@ -106,6 +106,8 @@ class NrfJprogBinaryRunner(NrfBinaryRunner): cmd.append('--reset') if _op['kind'] == 'RESET_PIN': cmd.append('--pinreset') + elif op_type == 'erase': + cmd.append(f'--erase{_op["kind"]}') else: raise RuntimeError(f'Invalid operation: {op_type}') diff --git a/scripts/west_commands/runners/nrfutil.py b/scripts/west_commands/runners/nrfutil.py index a943c3ddd4f..e9c27c9ed16 100644 --- a/scripts/west_commands/runners/nrfutil.py +++ b/scripts/west_commands/runners/nrfutil.py @@ -121,8 +121,7 @@ class NrfUtilBinaryRunner(NrfBinaryRunner): elif op_type == 'reset': cmd += ['--reset-kind', _op['kind']] elif op_type == 'erase': - cmd += ['--reset-kind', _op['kind']] - + cmd.append(f'--{_op["kind"]}') cmd += ['--core', op['core']] if op.get('core') else [] cmd += ['--x-family', f'{self.family}']