Skip to content

boards: nordic: nrf7002dk: Add SPI nrfutil config #2694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 1, 2025
4 changes: 2 additions & 2 deletions boards/nordic/nrf5340dk/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP_NS)
endif()

if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP OR CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP_NS)
board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000")
board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000")
endif()

if(CONFIG_TFM_FLASH_MERGED_BINARY)
set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex)
endif()

if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUNET)
board_runner_args(jlink "--device=nrf5340_xxaa_net" "--speed=4000")
board_runner_args(jlink "--device=nrf5340_xxaa_net" "--speed=4000")
endif()

include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake)
Expand Down
6 changes: 2 additions & 4 deletions boards/nordic/nrf54l15dk/board.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_SOC_NRF54L05_CPUAPP OR CONFIG_SOC_NRF54L10_CPUAPP OR
CONFIG_SOC_NRF54L15_CPUAPP)
if(CONFIG_SOC_NRF54L05_CPUAPP OR CONFIG_SOC_NRF54L10_CPUAPP OR CONFIG_SOC_NRF54L15_CPUAPP)
board_runner_args(jlink "--device=cortex-m33" "--speed=4000")
elseif(CONFIG_SOC_NRF54L05_CPUFLPR OR CONFIG_SOC_NRF54L10_CPUFLPR OR
CONFIG_SOC_NRF54L15_CPUFLPR)
elseif(CONFIG_SOC_NRF54L05_CPUFLPR OR CONFIG_SOC_NRF54L10_CPUFLPR OR CONFIG_SOC_NRF54L15_CPUFLPR)
set(JLINKSCRIPTFILE ${CMAKE_CURRENT_LIST_DIR}/support/nrf54l_05_10_15_cpuflpr.JLinkScript)
board_runner_args(jlink "--device=RISC-V" "--speed=4000" "-if SW" "--tool-opt=-jlinkscriptfile ${JLINKSCRIPTFILE}")
endif()
Expand Down
1 change: 1 addition & 0 deletions boards/nordic/nrf7002dk/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR
CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR
CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 OR
CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS)
board_runner_args(nrfutil "--ext-mem-config-file=${BOARD_DIR}/nrf7002dk_spi_nrfutil_config.json")
board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000")
endif()

Expand Down
17 changes: 17 additions & 0 deletions boards/nordic/nrf7002dk/nrf7002dk_spi_nrfutil_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"firmware_config": {
"peripheral": "SPIM0"
},
"pins": {
"sck": 8,
"csn": 11,
"io0": 9,
"io1": 10,
"io2": 4294967295,
"io3": 4294967295
},
"flash_size": 8388608,
"page_size": 4096,
"sck_frequency": 8000000,
"address_mode": "MODE24BIT"
}
1 change: 1 addition & 0 deletions boards/nordic/thingy53/board.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_BOARD_THINGY53_NRF5340_CPUAPP OR CONFIG_BOARD_THINGY53_NRF5340_CPUAPP_NS)
board_runner_args(nrfutil "--ext-mem-config-file=${BOARD_DIR}/thingy53_qspi_nrfutil_config.json")
board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000")
elseif(CONFIG_BOARD_THINGY53_NRF5340_CPUNET)
board_runner_args(jlink "--device=nrf5340_xxaa_net" "--speed=4000")
Expand Down
22 changes: 22 additions & 0 deletions boards/nordic/thingy53/thingy53_qspi_nrfutil_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"firmware_config": {
"peripheral": "QSPI"
},
"pins": {
"sck": 17,
"csn": 18,
"io0": 13,
"io1": 14,
"io2": 15,
"io3": 16
},
"flash_size": 67108864,
"sck_frequency": 8000000,
"address_mode": "MODE24BIT",
"readoc": "READ2IO",
"writeoc": "PP",
"pp_size": "PPSIZE256",
"sck_delay": 128,
"rx_delay": 2,
"page_size": 4096
}
7 changes: 7 additions & 0 deletions doc/releases/migration-guide-4.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ Boards
instead of pin reset when flashing with ``west flash``. If you want to keep
using pin reset on the nRF52 family of ICs you can use ``west flash --pinreset``.

* Erasing the external memory when programming a new firmware image with ``west
flash`` on the nRF52 and nRF53 series now always correctly honors the
``--erase`` flag (and its absence) both when using the ``nrfjprog`` and
``nrfutil`` backends. Prior to this release, the ``nrjfprog`` backend would
always erase only the sectors of the external flash used by the new firmware,
and the ``nrfutil`` one would always erase the whole external flash.

Devicetree
**********

Expand Down
2 changes: 1 addition & 1 deletion scripts/west_commands/runners/nrf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def program_hex(self):
if self.family in xip_ranges:
xip_start, xip_end = xip_ranges[self.family]
if self.hex_refers_region(xip_start, xip_end):
ext_mem_erase_opt = 'ERASE_ALL'
ext_mem_erase_opt = erase_arg

self.op_program(self.hex_, erase_arg, ext_mem_erase_opt, defer=True, core=core)
self.flush(force=False)
Expand Down
7 changes: 5 additions & 2 deletions scripts/west_commands/runners/nrfjprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ def do_exec_op(self, op, force=False):
raise RuntimeError(f'Invalid erase mode: {erase}')

if opts.get('ext_mem_erase_mode'):
# In the future there might be multiple QSPI erase modes
cmd.append('--qspisectorerase')
if opts['ext_mem_erase_mode'] == 'ERASE_RANGES_TOUCHED_BY_FIRMWARE':
cmd.append('--qspisectorerase')
elif opts['ext_mem_erase_mode'] == 'ERASE_ALL':
cmd.append('--qspichiperase')

if opts.get('verify'):
# In the future there might be multiple verify modes
cmd.append('--verify')
Expand Down
19 changes: 15 additions & 4 deletions scripts/west_commands/runners/nrfutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ class NrfUtilBinaryRunner(NrfBinaryRunner):

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

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

self.suit_starter = suit_starter
self.ext_mem_config_file = ext_mem_config_file

self._ops = []
self._op_id = 1
Expand All @@ -43,14 +44,19 @@ def do_create(cls, cfg, args):
reset=args.reset,
tool_opt=args.tool_opt, force=args.force,
recover=args.recover,
suit_starter=args.suit_manifest_starter)
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')


def _exec(self, args):
jout_all = []
Expand Down Expand Up @@ -139,8 +145,13 @@ def _exec_batch(self):
self._ops = []
self._op_id = 1
self.logger.debug(f'Executing batch in: {json_file}')
self._exec(['x-execute-batch', '--batch-path', f'{json_file}',
'--serial-number', f'{self.dev_id}'])
precmd = []
if self.ext_mem_config_file:
# This needs to be prepended, as it's a global option
precmd = ['--x-ext-mem-config-file', self.ext_mem_config_file]

self._exec(precmd + ['x-execute-batch', '--batch-path', f'{json_file}',
'--serial-number', f'{self.dev_id}'])

def do_exec_op(self, op, force=False):
self.logger.debug(f'Executing op: {op}')
Expand Down
Loading