Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions scripts/west_commands/runners/nrf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import abc
import contextlib
import functools

Check failure on line 10 in scripts/west_commands/runners/nrf_common.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Python lint error (F401) see https://docs.astral.sh/ruff/rules/unused-import

scripts/west_commands/runners/nrf_common.py:10 `functools` imported but unused

Check warning on line 10 in scripts/west_commands/runners/nrf_common.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

W0611

scripts/west_commands/runners/nrf_common.py:10 Unused import functools (unused-import)
import os
import shlex
import subprocess
Expand All @@ -16,10 +16,10 @@
from pathlib import Path
from re import escape, fullmatch

from zephyr_ext_common import ZEPHYR_BASE

Check failure on line 19 in scripts/west_commands/runners/nrf_common.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Python lint error (F401) see https://docs.astral.sh/ruff/rules/unused-import

scripts/west_commands/runners/nrf_common.py:19 `zephyr_ext_common.ZEPHYR_BASE` imported but unused

Check warning on line 19 in scripts/west_commands/runners/nrf_common.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

W0611

scripts/west_commands/runners/nrf_common.py:19 Unused ZEPHYR_BASE imported from zephyr_ext_common (unused-import)

sys.path.append(os.fspath(Path(__file__).parent.parent.parent))
import zephyr_module

Check failure on line 22 in scripts/west_commands/runners/nrf_common.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Python lint error (F401) see https://docs.astral.sh/ruff/rules/unused-import

scripts/west_commands/runners/nrf_common.py:22 `zephyr_module` imported but unused

Check warning on line 22 in scripts/west_commands/runners/nrf_common.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

W0611

scripts/west_commands/runners/nrf_common.py:22 Unused import zephyr_module (unused-import)

from runners.core import RunnerCaps, ZephyrBinaryRunner

Expand Down Expand Up @@ -52,29 +52,6 @@
},
}

# Relative to the root of the hal_nordic module
SUIT_STARTER_PATH = Path('zephyr/blobs/suit/bin/suit_manifest_starter.hex')

@functools.cache
def _get_suit_starter():
path = None
modules = zephyr_module.parse_modules(ZEPHYR_BASE)
for m in modules:
if 'hal_nordic' in m.meta.get('name'):
path = Path(m.project)
break

if not path:
raise RuntimeError("hal_nordic project missing in the manifest")

suit_starter = path / SUIT_STARTER_PATH
if not suit_starter.exists():
raise RuntimeError("Unable to find suit manifest starter file, "
"please make sure to run \'west blobs fetch "
"hal_nordic\'")

return str(suit_starter.resolve())

class NrfBinaryRunner(ZephyrBinaryRunner):
'''Runner front-end base class for nrf tools.'''

Expand All @@ -95,9 +72,6 @@
self.force = force
self.recover = bool(recover)

# Only applicable for nrfutil
self.suit_starter = False

self.tool_opt = []
if tool_opt is not None:
for opts in [shlex.split(opt) for opt in tool_opt]:
Expand Down Expand Up @@ -384,55 +358,6 @@
self.exec_op('erase', core='Application', kind='all')
self.exec_op('erase', core='Network', kind='all')

# Manage SUIT artifacts.
# This logic should be executed only once per build.
# Use sysbuild board qualifiers to select the context,
# with which the artifacts will be programmed.
if self.build_conf.get('CONFIG_BOARD_QUALIFIERS') == self.sysbuild_conf.get(
'SB_CONFIG_BOARD_QUALIFIERS'
):
mpi_hex_dir = Path(os.path.join(self.cfg.build_dir, 'zephyr'))

# Handle Manifest Provisioning Information
if self.sysbuild_conf.getboolean('SB_CONFIG_SUIT_MPI_GENERATE'):
app_mpi_hex_file = os.fspath(
mpi_hex_dir / self.sysbuild_conf.get('SB_CONFIG_SUIT_MPI_APP_AREA_PATH'))
rad_mpi_hex_file = os.fspath(
mpi_hex_dir / self.sysbuild_conf.get('SB_CONFIG_SUIT_MPI_RAD_AREA_PATH')
)
if os.path.exists(app_mpi_hex_file):
self.op_program(
app_mpi_hex_file,
'ERASE_NONE',
None,
defer=True,
core='Application',
)
if os.path.exists(rad_mpi_hex_file):
self.op_program(
rad_mpi_hex_file,
'ERASE_NONE',
None,
defer=True,
core='Network',
)

# Handle SUIT root manifest if application manifests are not used.
# If an application firmware is built, the root envelope is merged
# with other application manifests as well as the output HEX file.
if core != 'Application' and self.sysbuild_conf.get('SB_CONFIG_SUIT_ENVELOPE'):
app_root_envelope_hex_file = os.fspath(
mpi_hex_dir / 'suit_installed_envelopes_application_merged.hex'
)
if os.path.exists(app_root_envelope_hex_file):
self.op_program(
app_root_envelope_hex_file,
'ERASE_NONE',
None,
defer=True,
core='Application',
)

if self.build_conf.getboolean("CONFIG_NRF_HALTIUM_GENERATE_UICR"):
zephyr_build_dir = Path(self.cfg.build_dir) / 'zephyr'

Expand Down Expand Up @@ -518,18 +443,6 @@
def do_require(self):
''' Ensure the tool is installed '''

def _check_suit_starter(self, op):
op = op['operation']
if op['type'] not in ('erase', 'recover', 'program'):
return None
if op['type'] == 'program' and op['options']['chip_erase_mode'] != "ERASE_UICR":
return None

file = _get_suit_starter()
self.logger.debug(f'suit starter: {file}')

return file

def op_program(self, hex_file, erase, ext_mem_erase, defer=False, core=None):
args = self._op_program(hex_file, erase, ext_mem_erase)
self.exec_op('program', defer, core, **args)
Expand All @@ -556,12 +469,6 @@
return op

_op = _exec_op(op, defer, core, **kwargs)
# Check if the suit manifest starter needs programming
if self.suit_starter and self.family == 'nrf54h':
file = self._check_suit_starter(_op)
if file:
args = self._op_program(file, 'ERASE_NONE', None)
_exec_op('program', defer, core, **args)

@abc.abstractmethod
def do_exec_op(self, op, force=False):
Expand Down
8 changes: 1 addition & 7 deletions scripts/west_commands/runners/nrfutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ class NrfUtilBinaryRunner(NrfBinaryRunner):

def __init__(self, cfg, family, softreset, pinreset, dev_id, erase=False,
erase_mode=None, ext_erase_mode=None, reset=True, tool_opt=None,
force=False, recover=False, suit_starter=False,
ext_mem_config_file=None):
force=False, recover=False, ext_mem_config_file=None):

super().__init__(cfg, family, softreset, pinreset, dev_id, erase,
erase_mode, ext_erase_mode, reset, tool_opt, force,
recover)

self.suit_starter = suit_starter
self.ext_mem_config_file = ext_mem_config_file

self._ops = []
Expand Down Expand Up @@ -56,15 +54,11 @@ def do_create(cls, cfg, args):
ext_erase_mode=args.ext_erase_mode,
reset=args.reset, tool_opt=args.tool_opt,
force=args.force, recover=args.recover,
suit_starter=args.suit_manifest_starter,
ext_mem_config_file=args.ext_mem_config_file)

@classmethod
def do_add_parser(cls, parser):
super().do_add_parser(parser)
parser.add_argument('--suit-manifest-starter', required=False,
action='store_true',
help='Use the SUIT manifest starter file')
parser.add_argument('--ext-mem-config-file', required=False,
dest='ext_mem_config_file',
help='path to an JSON file with external memory configuration')
Expand Down
Loading