Skip to content

Commit f42cef9

Browse files
carlescufikartben
authored andcommitted
runners: nrf: Default to ERASE_NONE for the nRF54L series
The Nordic nRF54L series ICs use RRAM instead of flash. This implies that erasing the internal storage before writing the new firmware is not required anymore (unlike NOR flash, which does). Note that RRAM on nRF54L devices is not physically paged, and paging is only artificially provided, with a page size of 4096 bytes, for an easier transition of nRF52 software to nRF54L devices. In order to speed up the flashing operation and avoiding doing wasteful write operations on the RRAM, default to ERASE_NONE for ICs in these series. A new ``--erase-pages`` command-line switch has been added to allow users to keep erasing the pages that will be written to the firmware. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
1 parent 69c5c6f commit f42cef9

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

doc/releases/migration-guide-4.2.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ Boards
3838
nRF Util can be found
3939
`here <https://docs.nordicsemi.com/bundle/nrfutil/page/README.html>`_.
4040

41+
* All boards based on a Nordic IC of the nRF54L series now default to not
42+
erasing any part of the internal storage when flashing. If you'd like to
43+
revert to the previous default of erasing the pages that will be written to by
44+
the firmware to be flashed you can use the new ``--erase-pages`` command-line
45+
switch when invoking ``west flash``.
46+
Note that RRAM on nRF54L devices is not physically paged, and paging is
47+
only artificially provided, with a page size of 4096 bytes, for an easier
48+
transition of nRF52 software to nRF54L devices.
49+
4150
* The config option :kconfig:option:`CONFIG_NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME` has been deprecated
4251
in favor of :kconfig:option:`CONFIG_NATIVE_SIM_SLOWDOWN_TO_REAL_TIME`.
4352

scripts/west_commands/runners/nrf_common.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
7979
'''Runner front-end base class for nrf tools.'''
8080

8181
def __init__(self, cfg, family, softreset, pinreset, dev_id, erase=False,
82-
reset=True, tool_opt=None, force=False, recover=False):
82+
erase_pages=False, reset=True, tool_opt=None, force=False,
83+
recover=False):
8384
super().__init__(cfg)
8485
self.hex_ = cfg.hex_file
8586
# The old --nrf-family options takes upper-case family names
@@ -88,6 +89,7 @@ def __init__(self, cfg, family, softreset, pinreset, dev_id, erase=False,
8889
self.pinreset = pinreset
8990
self.dev_id = dev_id
9091
self.erase = bool(erase)
92+
self.erase_pages = bool(erase_pages)
9193
self.reset = bool(reset)
9294
self.force = force
9395
self.recover = bool(recover)
@@ -137,6 +139,9 @@ def do_add_parser(cls, parser):
137139
help='''erase all user available non-volatile
138140
memory and disable read back protection before
139141
flashing (erases flash for both cores on nRF53)''')
142+
parser.add_argument('--erase-pages', required=False,
143+
action='store_true', dest='erase_pages',
144+
help='erase pages to be used by the firmware')
140145

141146
parser.set_defaults(reset=True)
142147

@@ -413,9 +418,13 @@ def program_hex(self):
413418
else:
414419
if self.erase:
415420
erase_arg = 'ERASE_ALL'
421+
elif self.family == 'nrf54l' and not self.erase_pages:
422+
erase_arg = 'ERASE_NONE'
416423
else:
417424
erase_arg = 'ERASE_RANGES_TOUCHED_BY_FIRMWARE'
418425

426+
self.logger.debug(f'Erase type: {erase_arg}')
427+
419428
xip_ranges = {
420429
'nrf52': (0x12000000, 0x19FFFFFF),
421430
'nrf53': (0x10000000, 0x1FFFFFFF),
@@ -424,7 +433,9 @@ def program_hex(self):
424433
if self.family in xip_ranges:
425434
xip_start, xip_end = xip_ranges[self.family]
426435
if self.hex_refers_region(xip_start, xip_end):
427-
ext_mem_erase_opt = erase_arg
436+
# Default to pages for the external memory
437+
ext_mem_erase_opt = erase_arg if erase_arg == 'ERASE_ALL' else \
438+
'ERASE_RANGES_TOUCHED_BY_FIRMWARE'
428439

429440
self.op_program(self.hex_, erase_arg, ext_mem_erase_opt, defer=True, core=core)
430441
self.flush(force=False)
@@ -517,6 +528,16 @@ def do_run(self, command, **kwargs):
517528
raise RuntimeError('Options --softreset and --pinreset are mutually '
518529
'exclusive.')
519530

531+
if self.erase and self.erase_pages:
532+
raise RuntimeError('Options --erase and --erase-pages are mutually '
533+
'exclusive.')
534+
535+
self.ensure_family()
536+
537+
if self.family != 'nrf54l' and self.erase_pages:
538+
raise RuntimeError('Option --erase-pages can only be used with the '
539+
'nRF54L family.')
540+
520541
self.ensure_output('hex')
521542
if IntelHex is None:
522543
raise RuntimeError('Python dependency intelhex was missing; '
@@ -527,7 +548,6 @@ def do_run(self, command, **kwargs):
527548
self.hex_contents.loadfile(self.hex_, format='hex')
528549

529550
self.ensure_snr()
530-
self.ensure_family()
531551

532552
self.ops = deque()
533553

scripts/west_commands/runners/nrfjprog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class NrfJprogBinaryRunner(NrfBinaryRunner):
1818
'''Runner front-end for nrfjprog.'''
1919

2020
def __init__(self, cfg, family, softreset, pinreset, dev_id, erase=False,
21-
reset=True, tool_opt=None, force=False, recover=False,
22-
qspi_ini=None):
21+
erase_pages=False, reset=True, tool_opt=None, force=False,
22+
recover=False, qspi_ini=None):
2323

24-
super().__init__(cfg, family, softreset, pinreset, dev_id, erase, reset,
25-
tool_opt, force, recover)
24+
super().__init__(cfg, family, softreset, pinreset, dev_id, erase,
25+
erase_pages, reset, tool_opt, force, recover)
2626

2727
self.qspi_ini = qspi_ini
2828

@@ -46,7 +46,7 @@ def tool_opt_help(cls) -> str:
4646
def do_create(cls, cfg, args):
4747
return NrfJprogBinaryRunner(cfg, args.nrf_family, args.softreset,
4848
args.pinreset, args.dev_id, erase=args.erase,
49-
reset=args.reset,
49+
erase_pages=args.erase_pages, reset=args.reset,
5050
tool_opt=args.tool_opt, force=args.force,
5151
recover=args.recover, qspi_ini=args.qspi_ini)
5252
@classmethod

scripts/west_commands/runners/nrfutil.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class NrfUtilBinaryRunner(NrfBinaryRunner):
1717
'''Runner front-end for nrfutil.'''
1818

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

23-
super().__init__(cfg, family, softreset, pinreset, dev_id, erase, reset,
24-
tool_opt, force, recover)
23+
super().__init__(cfg, family, softreset, pinreset, dev_id, erase,
24+
erase_pages, reset, tool_opt, force, recover)
2525

2626
self.suit_starter = suit_starter
2727
self.ext_mem_config_file = ext_mem_config_file
@@ -50,7 +50,7 @@ def tool_opt_help(cls) -> str:
5050
def do_create(cls, cfg, args):
5151
return NrfUtilBinaryRunner(cfg, args.nrf_family, args.softreset,
5252
args.pinreset, args.dev_id, erase=args.erase,
53-
reset=args.reset,
53+
erase_pages=args.erase_pages, reset=args.reset,
5454
tool_opt=args.tool_opt, force=args.force,
5555
recover=args.recover,
5656
suit_starter=args.suit_manifest_starter,
@@ -66,7 +66,6 @@ def do_add_parser(cls, parser):
6666
dest='ext_mem_config_file',
6767
help='path to an JSON file with external memory configuration')
6868

69-
7069
def _exec(self, args):
7170
jout_all = []
7271

0 commit comments

Comments
 (0)