Commit graph

20 commits

Author SHA1 Message Date
Grzegorz Chwierut
db3c344af9 west: runners: Add ncs-provision to west flash command
Added automatic KMU key provisioning, when keyfile.json
file exists in the build directory.
This enables automated key provisioning during the
flashing process to enable testing nRF54L aplications using Twister.
Only applicable on nrfutil runner.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-06-11 16:09:05 -07:00
Carles Cufi
6659d2d711 scripts: runners: nrfutil: Check return code after Popen
The code invoking nrfutil was not checking the return code of the
subprocess, which meant that if the underlying tool was exiting with a
failure error code it remained undetected.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-05-13 17:45:09 +02:00
Carles Cufi
999b6a14a4 west: runners: nrf: Add an option to control the ext erase mode
The erase mode for any external memory that is mapped to the address
space of the MCU is derived from the internal non-volatile memory erase
mode. In order to allow users to override the default value, add a new
--ext-erase-mode command-line option that takes an erase mode just like
--erase-mode does.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-04-16 08:07:44 +02:00
Carles Cufi
58e0e31c7e west: runners: nrf: Generalize the erase command
Instead of providing an `--erase-pages` command, generalize it to a new
`--erase-mode` one that can be set to `none`, `ranges`, or `all`. This
gives the user full control over the erase mode that will be passed on
to nrfutil.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-04-16 08:07:44 +02:00
Carles Cufi
f42cef9c81 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>
2025-03-31 22:01:35 +02:00
Carles Cufi
c9151be798 west: runners: Add support for multiple device IDs
In order to enable the use case where the underlying flash tool supports
bulk-flashing using multiple device IDs, augment the core runner class
with this new runner capability and implement it in the nrfutil runner,
since the nrfutil tool supports it natively.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-03-07 20:24:23 +01:00
Carles Cufi
2effae5594 scripts: runners: nrfutil: Add a new external memory config param
This acts in a similar way to nrfjprog's --qspiini parameter introduced
in 7eb364b, but works slightly differently in nrfutil: it requires a
config file in JSON format instead of .ini, and it is passed along to
the `execute-batch` command instead of providing it together with the
`program` command.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-05 21:01:57 +01:00
Carles Cufi
17a671ca00 scripts: runners: nrf: Default to soft reset for the nRF52 series
The Nordic nRF52 series have a peculiarity that is not shared with any
other Nordic families of SoCs: the reset pin can be reconfigured as a
regular GPIO. This has an unintended consequence: if the user has
reconfigured the pin in Devicetree to be a GPIO, `west flash` will
override that and configure the IC to use it as a reset pin, and the
firmware at boot won't be able to switch it back to GPIO, because that
requires a UICR erase. This behavior is very confusing to users, because
the GPIO does not work at all, since it is now just a reset line.

With this patch, `west flash` defaults to using soft reset instead of
pin reset for the nRF52 family of devices, to avoid overwriting the
reset pin configuration that the user includes in the image.

In order to be able to continue to use pin reset for users that so
desire it, a new option `--pinreset` is added that forces the use of pin
reset. The existing `--softreset` option is left exactly as it was, but
it is now applicable only to families other than the nRF52.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-05 01:13:42 +01:00
Carles Cufi
dc7d8bbe16 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 <carles.cufi@nordicsemi.no>
2025-02-03 16:59:40 +01:00
Carles Cufi
4e8ec169fb scripts: runners: nrfjprog: Remove erasepage handling
This is no longer used at all.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-02-03 16:59:40 +01:00
Carles Cufi
6e9e839195 scripts: runners: nrfutil: Switch to command-line args instead of JSON
Instead of pre-generating the JSON batch to then execute it, use
command-line arguments and --x-append-batch to generate the JSON file
tht will then be passed to x-execute-batch.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-01-27 21:04:06 +01:00
Pieter De Gendt
bf7f41d880 scripts: west_commands: runners: Sort and format imports (I001)
Apply sorting and formatting rules on imports.

See
https://docs.astral.sh/ruff/rules/unsorted-imports/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
1e1c7f7c16 scripts: west_commands: runners: Fix mutable-argument-default (B006)
Do not use mutable default arguments.

See https://docs.astral.sh/ruff/rules/mutable-argument-default/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
7f72dd3a0f scripts: west_commands: runners: Fix f-string-missing-placeholders (F541)
Constant strings should not be f-strings.

See https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Carles Cufi
0705a6301c west: runners: nrf: Add support for the suit manifest starter
With the recent introduction of the SUIT manifest starter binary blob,
it is now possible to use it with the nRF54H20 during the flashing
procedure in order to provide a valid SUIT manifest to the system.

This PR introduces the code that handles programming the SUIT manifest
starter, as well as a new --suit-manifest-starter command-line option.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2024-10-25 22:43:19 +01:00
Tomasz Moń
e136f02ea6 scripts: west_commands: runners: nrfutil: Only flash with J-Links
The nrfutil runner calls "nrfutil --json device list" which outputs
information about all connected serial ports. The list includes not only
actual boards but also any ttyACM instance. If the ttyACM instance does
not have serial number, then the nrfutil runner will fail on matching
serial number regexp on NoneType.

Fix the issue by limiting nrfutil runner board output to only devices
that have trait jlink set.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-29 08:31:01 -07:00
Gerard Marull-Paretas
acc0a43fb9 scripts: west_commands: runners: nrfutil: provide live feedback
nrfutil runner uses the batch-mode, so no live feedback is provided to
the user. However, batch-mode reports batch progress containing
human-readable strings of the operation being done. This patch changes
the _exec() implementation to parse the subprocess output in real-time,
logging to info the 'batch_update' reports. Note that only the first
batch update of a sequence (percentage = 0) is logged because first,
percentage resolution seems to be pretty bad, and, because logging
messages cannot be easily _appended_.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-03-20 11:35:47 +01:00
Gerard Marull-Paretas
0387214bfc scripts: west_commands: runners: nrfutil: use x-execute-batch
execute-batch is now named x-execute-batch, as it is an experimental
option.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-03-20 11:35:47 +01:00
Carles Cufi
2d38c095a6 west: runners: Add support for a common --reset argument
Some of the runners in the tree have been adding their own,
class-specific versions of a switch to instruct the runner to reset or
not the device after flashing.

In order to better support multi-image builds that require more than one
flash operation, introduce a new --reset,--no-reset command-line
parameter that is part of the RunnerCaps so taht this functionality can
be accessed in a standardized manner.

Implementations for the new parameter are provided for the runner
classes that were already configurable in this regard.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-28 11:08:25 -07:00
Carles Cufi
b022835146 scripts: runners: nrf: Add support for the new nRF Util tool
Add support for Nordic's new nRF Util tool, aka nrfutil. Via its
"device" command, nrfutil now supports most of the functionality offered
by nrfjprog.

The tool itself can be found here:

https://www.nordicsemi.com/Products/Development-tools/nrf-util

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-04-17 09:29:04 -07:00