scripts: runners: nrf: Use nrfutil error codes
Standardize to nrfutil error codes instead of nrfjprog ones. This is because nrfutil has a wider range of functionality and will eventually be the default runner for all nRF devices. It is also consistent with the internal operation representation, which is now using the nrfutil format already. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
5847890a18
commit
ff9c38316e
2 changed files with 21 additions and 8 deletions
|
@ -21,9 +21,8 @@ try:
|
|||
except ImportError:
|
||||
IntelHex = None
|
||||
|
||||
# https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf_cltools%2FUG%2Fcltools%2Fnrf_nrfjprogexe_return_codes.html&cp=9_1_3_1
|
||||
UnavailableOperationBecauseProtectionError = 16
|
||||
VerifyError = 55
|
||||
ErrNotAvailableBecauseProtection = 24
|
||||
ErrVerify = 25
|
||||
|
||||
class NrfBinaryRunner(ZephyrBinaryRunner):
|
||||
'''Runner front-end base class for nrf tools.'''
|
||||
|
@ -230,7 +229,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
|
|||
try:
|
||||
self.flush_ops()
|
||||
except subprocess.CalledProcessError as cpe:
|
||||
if cpe.returncode == UnavailableOperationBecauseProtectionError:
|
||||
if cpe.returncode == ErrNotAvailableBecauseProtection:
|
||||
if self.family == 'NRF53_FAMILY':
|
||||
family_help = (
|
||||
' Note: your target is an nRF53; all flash memory '
|
||||
|
@ -245,7 +244,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
|
|||
'must be recovered.\n'
|
||||
' To fix, run "west flash --recover" instead.\n' +
|
||||
family_help)
|
||||
if cpe.returncode == VerifyError:
|
||||
if cpe.returncode == ErrVerify:
|
||||
# If there are data in the UICR region it is likely that the
|
||||
# verify failed du to the UICR not been erased before, so giving
|
||||
# a warning here will hopefully enhance UX.
|
||||
|
|
|
@ -5,9 +5,15 @@
|
|||
|
||||
'''Runner for flashing with nrfjprog.'''
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from runners.nrf_common import NrfBinaryRunner
|
||||
from runners.nrf_common import ErrNotAvailableBecauseProtection, ErrVerify, \
|
||||
NrfBinaryRunner
|
||||
|
||||
# https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf_cltools%2FUG%2Fcltools%2Fnrf_nrfjprogexe_return_codes.html&cp=9_1_3_1
|
||||
UnavailableOperationBecauseProtectionError = 16
|
||||
VerifyError = 55
|
||||
|
||||
class NrfJprogBinaryRunner(NrfBinaryRunner):
|
||||
'''Runner front-end for nrfjprog.'''
|
||||
|
@ -81,6 +87,14 @@ class NrfJprogBinaryRunner(NrfBinaryRunner):
|
|||
else:
|
||||
raise RuntimeError(f'Invalid operation: {op_type}')
|
||||
|
||||
self.check_call(cmd + ['-f', families[self.family]] + core_opt +
|
||||
['--snr', self.dev_id] + self.tool_opt)
|
||||
try:
|
||||
self.check_call(cmd + ['-f', families[self.family]] + core_opt +
|
||||
['--snr', self.dev_id] + self.tool_opt)
|
||||
except subprocess.CalledProcessError as cpe:
|
||||
# Translate error codes
|
||||
if cpe.returncode == UnavailableOperationBecauseProtectionError:
|
||||
cpe.returncode = ErrNotAvailableBecauseProtection
|
||||
elif cpe.returncode == VerifyError:
|
||||
cpe.returncode = ErrVerify
|
||||
raise cpe
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue