Commit Graph

440 Commits

Author SHA1 Message Date
Marc Herbert 07f2c7a1df west: sign.py: give rimage a key placeholder when there's none
rimage always requires a key argument even when it does not use it.

Some configurations (IMX) use rimage only for "stitching" the image but
not for signing. These were failing to build directly from west with
pretty cryptic stack trace, see below. This has never been a problem for
the SOF project because it has always worked around this rimage
limitation by providing a bogus -k argument - very much like the one
added by this commit.

```
File "zephyrproject/zephyr/scripts/west_commands/sign.py",  in sign
  extra_ri_args += [ '-k', str(sof_src_dir / 'keys' / cmake_default_key) ]
TypeError: unsupported operand type(s) for /: 'PosixPath' and 'NoneType'
ninja: build stopped: subcommand failed.
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-06-19 08:38:48 +02:00
Anas Nashif 522624d6c6 west: build: keep kconfig quotes from testcase.yaml
When parsing extra configs from the yaml file, keep quotes.

Fixes #56248

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-31 10:02:28 -04:00
Niek Ilmer abf9e4d1f4 scripts: runners: ezflashcli: Add support to flash images for MCUboot
Internal bootloader will only run application image if valid product
header is present on flash. This means product header is required for
application that are not linked to code partition. Other applications
that are linked to code partition are meant to be run by MCUboot and
should not touch product header, with the exception of MCUboot itself
which is also run by internal bootloader so requires product header.

Default flash load offset for applications not linked to code partition
is set to 0x2400 as this is where internal bootloader looks for an
application image to run based on product header written by flasher.

Flash load offset for MCUboot is set from boot partition.

Valid product header is added by ezFlashCLI when using "flash_image"
command.

Co-authored-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Niek Ilmer <niek.ilmer.aj@renesas.com>
2023-05-26 05:53:02 -04:00
Marek Matej 8e40db577a west: esp32: Fix target flashing without the IDF boot
Make use of the IDF partition table only if asked to.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-05-25 16:15:54 +02:00
Evgeniy Paltsev 15b46039b8 ARC: used 64bit MDB binary by default.
This significantly improve user experience as 32 bit mdb binary
require to install multiple libraries before it can be used on
modern linux distros.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-05-22 10:16:28 +02:00
Marc Herbert 6697c5aa0b west: sign: rimage: drop default -c option when the user provides one
sign.py has an internal and indirect way to compute a default -c signing
schema option and pass it to rimage. It is built by appending
`$platform.toml` to whatever `rimage/config/` location was
found. Defaults are very convenient but in this case this computed -c
option can conflict with an explicit -c option spelled out by the user.

Scan for any explicit -c coming directly from the user. If any found,
ignore the default we computed. This is what is already being done for -k.

The precedence across rimage parameters coming from different places is
too complicated. Not passing multiple -c options simplifies the logic a
little bit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-05-18 12:40:30 -07:00
Torsten Rasmussen 49389b546a west: sign: Add Kconfig with application version
Adds a Kconfig option which controls the version of the application
to use when the image is signed using imgtool.

When an application VERSION file is present, the default value will be
identical to the application version, else it will be 0.0.0+0, but a
project may still decide another value, if it so prefers.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-17 13:56:58 +02:00
Torsten Rasmussen c03e1900ae scripts: adjust WEST_PYTHON to posix path
Adjust WEST_PYTHON to posix path to be consistent with other Python
scripts which passes paths to the Zephyr CMake build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-15 08:13:40 -07:00
Carles Cufi 0ebc37a972 scripts: runners: nrf: Fix the formatting of the old --nrf-family
The now legacy --nrf-family parameter takes the "raw" family name as
nrfjprog accepts it. But now we use an intermediate representation with
{FAMILY}_FAMILY as the format, so covert to it as required.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-04-27 09:50:48 +02:00
Roman Dobrodii 2e0820f08c scripts: west: add silabs_commander runner
- Runs Silabs Commanders which is useful for SiLabs boards that
can not use J-Link for various reasons.
- Flash support only, no debug.

Signed-off-by: Roman Dobrodii <rdobrodii@antmicro.com>
2023-04-25 10:34:16 -07:00
Georgij Cernysiov d641be7fc8 runners: stm32cubeprogrammer: fix program files path for win x64
The '%ProgramFiles%' is not guaranteed to be 'C:\Program Files' on
Windows x64.

The value will be 'C:\Program Files (x86)' if the west is executed by
32-bit Python.

To correct the issue '%ProgramW6432%' must be used.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-04-24 13:35:26 +02:00
Carles Cufi a7a9cb018a scripts: runners: tests: nrf: Refactor and add nrfutil runner tests
Refactor the existing nrfjprog tests to make them compatible with the
new nrfutil runner implementation, and extend them so that they are
exectued for both tools.

There is missing verification of the JSON generated by the nrfutil
runner, whcih will be added in a follow-up commit.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-04-17 09:29:04 -07:00
Carles Cufi a5e0cbc4fb scripts: runners: tests: nrf: Minor tweaks
- Rename the test file to test_nrf.py in preparation for future tests
  covering nrfutil as well
- Rename the test folder from nrfjprog/ to nrf/
- Change the id_fn returned string formatting so that it's compatible
  with executing a single test case via -k as a parameter (no spaces or
  commas)

You can now execute:
python -m pytest tests/test_nrf.py -k \
'test_nrfjprog_init[NRF51-pin_reset-override_snr-sector[anduicr]\
_erase-no_recover-no_tool_opt]'

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-04-17 09:29:04 -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
Carles Cufi 480b6fb7c0 scripts: runners: nrf: Do not force-flush until the end
In order to better support the ability of the upcoming nrfutil runner to
defer all operations and execute them all at once, defer flushing right
until the end, when everything has been queued up (recover, program and
reset) instead of forcing execution at the program stage.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-04-17 09:29:04 -07:00
Carles Cufi ff9c38316e 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>
2023-04-17 09:29:04 -07:00
Marc Herbert fad2da39aa intel_adsp: move `west sign` from `west flash` to earlier `west build`
Invoking `west sign` in `west build` accelerates twister because `west
build` is run in parallel, see rationale in superseded and very
different (CMake-based) PR #52942.

To maximize backwards compatibility:
- `west sign` is optional in `west build`
- `west flash` will sign (again) if any rimage --option is passed

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 2c80c4daa4 west: sign: add new rimage option --if-tool-available
Moving `west sign` from `west flash` to `west build` for rimage has
multiple advantages (including a bit more consistency with
imgtool). However it makes `west build` fail when rimage is missing.

To avoid forcing every CI and developer who never used it before to
install rimage, make signing optional when passing new `west sign`
option --if-tool-available. A clear warning is printed.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 5c4319d54f west: sign: clean any stale rimage output
We never want to leave stale outputs behind after failing.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 5bdb1467cf west: sign: define filename constants earlier in rimage signer
Zero functional change, pure preparation for the next commit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 2fbcdb5ff2 west: sign: add new west config [rimage].extra-args and a default key
Make RIMAGE_SIGN_KEY a CMake CACHE variable so `west sign` can find it
and use it as a default value.

Fixes https://github.com/thesofproject/sof/issues/6917

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 66ac6252ed west: sign: add west config [rimage].path = /path/to/rimage
Add a 3rd option besides --tool-path and $PATH

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert dedb002214 west: sign: rimage: simplify rimage --tool-data code
Reduce duplication, no functional change except for a shorter log
statement with slightly less information.

This is required by the next commits.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 5831164e7a west: sign: add west config [sign].tool = rimage/imgtool
The --tool parameter is not required anymore thanks a [sign] entry in
west config like this one:

```
[sign]
tool = imgtool
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert 030b740bd1 west: sign: add ability to read parameters from west config
No functional change yet, will be used in the next commits.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Marc Herbert efb855134e west: sign: rimage: add default value '-c sof/rimage/config'
Don't force 99% of the users to pass the same value.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-04-10 22:04:47 -04:00
Keith Short 3406d40ee0 scripts: runners: bossac: cleanup edt load
An explicit import of edtlib is not required when using
pickle.load() and creates a duplicate module object.

Local testing shows that pickle.load() throws the ModuleNotFoundError if
the sys.path cannot find the edtlib or associated modules.

Signed-off-by: Keith Short <keithshort@google.com>
2023-04-07 13:37:51 +02:00
Martí Bolívar 5422a317ad runners: bossac: add --delay option
Add an escape hatch so users can insert a customizable delay
between asking the board to reboot into bootloader mode and
trying to program the new image. This lets people account for
OS-specific enumeration time done after the board resets.

Fixes: #56540
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-04-05 19:42:49 +02:00
Martí Bolívar 1f9ab85354 west: build: appease the linter
The linter is complaining about unnecessary parens.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Marti Bolivar 5880feee33 west: build: add -S <snippet> argument
Writing '-S foo' is a convenience shorthand for adding snippets at
CMake time without having to add '-- -DSNIPPET=foo' to the west build
command line. It is worth adding a new one-letter command line option
because snippets are anticipated to be a very commonly used feature.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-03-26 16:12:41 +02:00
Nicolas VINCENT fa7170b846 west: runner: Use --verify and --verify-only with openocd and hex files
the options --verify and --verify-only where only used when flashing elf
files and were ignored for flashing hex files for example when using
openocd runner.
The command to verify the image is now dependant on the presence of
--verify or --verify-only, and the load command is not executed if
--verify-only is provided.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2023-03-21 09:36:29 +01:00
Evgeniy Paltsev 6599c3796d west: runners: mdb-hw: add hostlink-awareness
Add hostlink-awareness to mdb-hw runner. The mdb-nsim and arc-nsim
runners (as well as cmake scripting for nSIM boards) doesn't require
any changes.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-03-17 11:49:02 +01:00
Carles Cufi 341c01fcd0 scripts: runners: nrf_common: Fix QSPI erase switch
The QSPI erase switch is not part of the "firmware" dict, but rather
placed in the overall operation dict.

Fixes #55625.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-15 12:36:33 +00:00
João Dullius 79d9f45296 scripts: runners: bossac: Enable BOSSAC to run on Windows (native)
Fixes #37538 by correctly detecting WSL and blocking bossac from running
on that platform, but allowing it to run on Windows native.

Signed-off-by: João Dullius <joaodullius@bpmrep.com.br>
2023-03-06 13:17:09 -08:00
Carles Cufi e073210ec2 scripts: runners: nrfjprog: Use --tool-opt in all operations
Pass on the tool-specific options to nrfjprog during all operations, and
not only when programming. This is useful when combined with options
like --ip, that allows west flash to be used over the network.

Fixes #55340.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Carles Cufi ba86759a79 scripts: runners: tests: nrfjprog: Test --tool-opt
Add tests for the --tool-opt command-line switch, to ensure that if the
user includes additional tool options those get passed on to nrfjprog at
the end of the command-line to override any preceding ones.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Carles Cufi 8fc87c87b8 scripts: runners: nrf: Add support for multiple nRF backends
Generalize the logic that was previously in nrfjprog.py into a new
nrf_common.py, which can then use specific tool subclasses, one of which
is nrfjprog.py, to implement the actual tool invocation.

This commit lays down the groundwork for the addition of a new backend
for nRF boards, the new nrfutil tool from Nordic. Both nrfjprog and
nrfutil will coexist in the immediate future, but nrfutil is expected to
be the sole tool for everything nRF in due time.  This is why the internal
representation of the operations is based in JSON and is using the exact
format that nrfutil expects when using the 'execute-batch' option, that
takes a JSON file with an array of operations to be executed.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Carles Cufi c34da24596 scripts: west: runners: Support class hierarchies in the runners
Allow for multiple levels of inheritance in the runners in order to make
it possible to share common infrastructure in similar runners.
Also check if the class can be instantiated (i.e. it is not abstract) to
avoid returning abstract base classes.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-03-06 11:40:49 -08:00
Marc Herbert 7249594cd1 west: sign: rimage: log("Prefixing with xman...") only when doing it
Fixes commit 2fdc551acc ("sign.py: stop ignoring the -- -c foo.toml
option passed to rimage")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-02 10:54:13 +01:00
Dominik Ermel 86c4b4caa9 west/sign: Move from using partition label property
MCUmgr no longer uses DTS node property label to identify
slots for image upload and running application. It now uses DTS node
labels for that purpose.
This commit moves `west sign` from using label properties
to DTS node labels, same way the MCUmgr does.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-22 09:32:51 -08:00
Peter Johanson 26a04adb8b west: runners: uf2: Add new UF2 runner.
Add a new UF2 runner, supporting only the flash capability.

Searches for FAT partitions containing `INFO_UF2.TXT` files,
and can optionally filter on a matching `Board-ID` value in
that file.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-02-20 12:50:38 +01:00
Andrey Borisovich 802600da7b scripts: twister: west twister error codes match twister direct call
This commit fixes #54492 where return code 1 is returned
when twister tests fail when twister is called directly and
return code 0 in similar scenario but twister is invoked using
west.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
2023-02-07 09:22:34 -08:00
Marti Bolivar a2f203dd1a runners: restore obsolete synonyms for -i/--dev-id
This is a partial revert of commit
2cee5ff519
("scripts: west_commands: runners: remove deprecated options").

I remarked at the time that the removal of the older way of writing
things from the runners themselves seemed gratuitous since they are
easy to continue to support indefinitely and people may have been used
to the old way of doing things. It didn't seem worth the fight to push
for a revert at the time, though.

Since then I've run into real problems that their removal has caused
in the wild and I am convinced that this part of that patch was wrong.

Restore the original, undeprecated forms of these options, but make it
clear in the command line help that they're just obsolete alternative
spellings at this point.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-02 09:47:17 -08:00
Evgeniy Paltsev c85e5438b9 ARC: west runner: mdb-hw: fix incorrect argument handling for jtag
Currently we just pass in case of the unsupported jtag adapter
is selected. Fix that by rising ValueError as we do in case of
other incorrect arguments.

While I'm at it add few missing test-cases for mdb west runners.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-02 09:05:18 -08:00
Evgeniy Paltsev 963c7a2d40 ARC: west runner: mdb: fix unexpected empty argument pass to MDB
Currently, in case of multi-core target or in case jtag adapter
auto-selectio, we pass unexpected empty argument (empty quotes `''`)
to MDB binary due to argument generation error.

Fix that.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-02 09:05:18 -08:00
Evgeniy Paltsev d2d5177e58 ARC: west runner: mdb: remove dead code
Remove code which looking for `cld` process pid - this functionality
isn't use anymore by twister. And as manual MDB termination is also
fixed now this functionality isn't required for anything now.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-01 10:06:26 -08:00
Evgeniy Paltsev 0206effb46 ARC: west runner: mdb: fix unusable console after flash / debug
Currently we try to start MDB (MetaWare Debugger) in background
with ignored sigint no matter if we are planing to do debug
session (via `west debug`) or just run something on HW or on
nSIM (via `west flash`)

That cause really bad user experience as after we do
`west debug` or `west flash` we can't terminate the debugger
from the console. Moreover even if we terminate the debugger
process from separate terminal the console stil would be
broken so we need to do `stty sane` in it to make it usable
again.

Fix all that by proper starting the debugger process.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-01 10:06:26 -08:00
Anas Nashif 79b955c80a west: build: allow --test-item to accept twister style instance names
This will allow something like this:

west build -b qemu_x86  -T samples/hello_world/sample.basic.helloworld

instead of:

cd samples/hello_world
west build -b qemu_x86  -T sample.basic.helloworld

Using this option will allow to take twister output and just pass it to
west to reproduce failures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-28 17:05:19 -05:00
Anas Nashif 1008124358 west: build: handler errors in west build with --test-item
Handle errors and wrong test meta-data when using --test-item.

Fixes #52614

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-28 17:05:19 -05:00
Jamie McCrae ec7044437e treewide: Disable automatic argparse argument shortening
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00