Commit graph

542 commits

Author SHA1 Message Date
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
Fabio Baltieri 79856e7637 west: runners: blackmagicprobe: guess the gdb port based on the OS
Add some logic in blackmagicprobe.py to guess the GDB serial port based
on the OS instead of just trying the flag or /dev/ttyACM0.

The new logic explicitly looks for the well known path for BMP on Linux
(/dev/ttyBmpGdb), so that we can remove it from the board files that
have it set explicitly right now. At the same time it still allows
setting the port from the flag and also checks an environment variable,
so that it can be used for systems with multiple probes.

As a fallback, it looks for a valid serial port, picking the first one
(the probe creates two, the GDB one is the first one), and raise an
exception if nothing is found.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2023-01-19 10:16:00 +01:00
Fabio Baltieri dabfffaf26 west: runners: blackmagicprobe: update reset on connect command
Recently the blackmagicprobe command for "connect under reset" has been
updated from "connect_srst" to "connect_rst". Update the flag name in
the west blackmagicprobe binding, keep the old one as well for
compatibility with out of tree boards, and send both the old and new
commands to GDB so that it works with both the old and new firmware. GDB
is going to get a "command not supported by this target" for one of the
two and proceed with the other one.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2023-01-19 10:16:00 +01:00
Al Semjonovs a7d6ca2bd9 west: west twister integration
Add twister command to west.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-13 15:39:04 -08:00
Henrik Brix Andersen d151424a6d scripts: west: runners: canopen: add SDO block transfer support
Add SDO block transfer support for the CANopen program download west
runner. SDO block transfers are experimental in the underlying CANopen for
Python.

Reduce the program download chunk size to half the program download buffer
size to avoid blocking IO.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-11 09:39:57 +01:00
Martí Bolívar 374411dfaf west: runners: improve pyocd runner test coverage
Make sure that this runner can handle multiple --tool-opt arguments,
and that the options specified for pyocd are passed to that tool in
order.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-12-29 10:36:02 +01:00
Gerhard Jörges 87a751c266 west: runners: add file argument
adds --file argument to west flash/debug as described in #52262.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-12-01 06:53:58 -08:00
Gerard Marull-Paretas 2cee5ff519 scripts: west_commands: runners: remove deprecated options
The --snr (nrfjprog) --id (jlink) and --board-id (pyocd) options were
deprecated a long time ago in favor of --dev-id. It is time to remove
them.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-30 14:15:30 +01:00
Martí Bolívar b907f74326 runners: trace32: mypy fixes
Fixes for the following issues that a new version of mypy started
reporting recently:

runners/trace32.py:34: error: Incompatible default for argument
"startup_args" (default has type "None", argument has type
"List[str]") [assignment]

runners/trace32.py:137: error: Incompatible default for argument
"cfg" (default has type "None", argument has type "Path") [assignment]

runners/trace32.py:34: note: PEP 484 prohibits implicit Optional.
Accordingly, mypy has changed its default to no_implicit_optional=True

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-11-09 11:10:09 -05:00
Adrian Bonislawski 30e4a4b71e west: sign: remove -i 3 parameter
in some builds there is need to pass different value for -i parameter
and current code will override it to 3
Also in rimage i parameter is by default set to 3

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-10-27 11:02:35 +02:00
Daniel DeGrasse 6a5b88e523 scripts: west: move domains.py to a generic library folder
Since twister can make use of domains.py as well, refactor west's use
this file so that domains.py can be moved to a generic library folder.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00
Markus Swarowsky 1fb23b6509 west: nrfjprog: Allow flashing UICR without erase
Currently, it is not possible to use a normal flash command to flash two
hex files that contain data in the UICR region, even though these
data don't conflict with each other.
However, that is not a technical limitation of the device, but of the
nrfjprog runner as it fails as soon as the hex file contained UICR data
and there was no --force/--erase/--recover used.
That approach was used in the past as program operation was used
without --verify, but as this option was added a while ago it is an
unnecessary limitation.

If the UICR wasn't erased before programming, the verify of the program
operation will now fail, so giving the user a warning in this case that
the hex files contain data in the UICR will still give the user a hint
of what might have caused the failing verify.
Additionally, it enables partial programming of the UICR without the
use of the --force option.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2022-10-24 21:35:24 +02:00
Manuel Arguelles 31b3993d58 scripts: west: introduce Lauterbach TRACE32 runner
This patch introduces a West runner for flashing and debugging with
Lauterbach TRACE32 debuggers. The runner consists of a wrapper around
TRACE32 software, and allows a Zephyr board to execute a custom start-up
script (Practice Script) for the different commands supported, including
the ability to pass extra arguments from CMake. Is up to the board using
this runner to define the actions performed on each command.

The `debug` command launches TRACE32 GUI to allow debug the Zephyr
application, while the `flash` command hides the GUI and executes the
start-up script in a background process.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-10-14 09:51:14 +02:00
Martí Bolívar 98bcc2d88e west: runners: blackmagicprobe: fix on windows
We need to give gdb slash-separated paths to ELF files on Windows.
Just make sure we always have slash-separated paths. We use this
technique in various places around the tree.

Fixes: #50789
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-10-10 09:54:14 +02:00
Erwan Gouriou 7b31b0e23c scripts: west_commands: openocd: Use 'reset init' by default
Instead of 'reset halt', default the command to reset and halt the target
to 'reset init'.

OpenOCD strictly requires 'reset init' to halt and prepare the device
before flash programming.
See https://openocd.org/doc/html/Flash-Commands.html chapter
"12.2 Preparing a Target before Flash Programming."

For targets implementing the init hook, it will allows to perform some
target specific init improvements (such as speed flash improvements).
Targets not implementing this hook will end up executing the usual and
previous 'halt'.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-10-07 12:19:46 -07:00
Carles Cufi 2da82552f5 west: completion: bash: Clean up, fix and add missing options
Although 8644b333cd added support for some
missing commands an options, the bash completion file was still in bad
need for some cleanup, fixes and additions.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-07 10:01:23 +02:00
Yves Vandervennet 9a4272853e west: jlink: adding optional flash loader flag required for some boards
With revision 7.70d, Segger changed the command line interface of the
jlink client, requiring some flash specific information, such as
the base address and the type of memory, e.g. QSPI.

This commit adds an optional argument to the West jlink runner,
'--loader' which passes the information to the jlink client.
This change is backward compatible with versions of jlink older
than v7.70d which introduces the CLI change.

Fixes: #50327

Signed-off-by: Yves Vandervennet <yves.vandervennet@nxp.com>
2022-09-21 09:33:42 -05:00
Torsten Rasmussen 65f45507a5 west: fix warning on user args in run_common
When using west runners with multi domains we want to warn users when
they user runner args on multi domain builds.

Therefore fix the `>1` to the correct `>0` which ensures the warning
is printed in all expected cases.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-20 16:58:09 +02:00
Carles Cufi 13ea65b6a9 west: Add completion support for zsh
As part of the overall work on improving west integration with Zephyr,
add support for zsh completion in the `west completion` command.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-09-06 08:43:15 -07:00
Andrzej Kaczmarek 868acfd505 scripts: Add ezFlashCLI runner
This adds support for ezFlashCLI tool to allow flashing DA1469x MCU
family from Renesas.

The tool is available at https://github.com/ezflash/ezFlashCLI or can
be installed via pip.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Ben Lauret <ben.lauret.wm@renesas.com>
2022-08-31 20:32:03 +02:00
Carles Cufi 8644b333cd west: Update bash autocomplete file
Update the existing bash autocomplete with the latest commands and
command-line switches.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-31 10:38:01 +02:00
Thomas Stranger f123094482 scripts: west: runners: stm32cubeprogrammer: enable exec from PATH
Allows to use the stm32cubeprogrammer runner on Linux to be executed
from any installation directory as long as the executable is found
in PATH.

Until now on Linux the programmer could only be used if it either has
been installed in the default location or if the executable path was
passed via the cli parameter.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-08-29 17:31:56 +02:00
Carles Cufi b662bc9093 scripts: modules: Move blob processing to zephyr_module.py
In preparation for the handling of taint flags in zephyr_module.py, move
blob-processing code from the west command to it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-29 15:57:59 +02:00
Carles Cufi 25db534a07 west: blobs: Finally fix the --format option handling
Turns out that `Namespace.format` was not a good fix to the issue
described in f033040812, it was returning
the default format even when the user specified -f/--format.

Replace "getattr" with a simple logical operation.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 17:31:24 +02:00
Carles Cufi f033040812 west: blobs: Fix --format handling
There were two issues with the original commit
e04487cad2b98385c850fa478e1d1ca97bf0e836:

- getattr() doesn't seem to work properly with args
- Comparison between bound methods with "is" seems not to work, so
  replace it with a simpler string comparison

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-24 07:38:42 -07:00
Martí Bolívar 21214cc83f west blobs: decrease verbosity
Make some no-op log messages require 'west -v blobs ...'.

The current implementation won't scale as the number of blobs goes up.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar e04487cad2 west blobs: fix --format handling
This option does not apply to 'west blobs clean' or 'west blobs
fetch'. Error out if it is given to either of those.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar b4c4736fb0 west blobs: tweak --format help
Make it consistent with the usual argparse style by using lower case
and no period at the end.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar a3f4edb127 west blobs: fix modules help
The help text is mixing up 'blobs' with 'modules', and doesn't
document the new behavior that uses all modules when nothing is
mentioned. Fix both issues.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Martí Bolívar 3b84dff0a5 west blobs: fix subcmd help
Without this patch, "west blobs -h" says:

  {list,fetch,clean} Select the sub-command to execute. Sub-commands
  available: - list: list binary blobs - fetch: fetch and store binary
  blobs - clean: remove fetched binary blobs

With this patch:

  {list,fetch,clean}    sub-command to execute

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-22 16:37:07 +00:00
Gerard Marull-Paretas 2d712c6c55 scripts: west_commands: runners: jlink: support pylink >= 0.14.2
It looks like the latest release, 0.14.2, changed the contents of
JLINK_SDK_NAME as it was before 0.14.0 release. That means that the
previous fix is only applicable to a couple of releases: 0.14.0/0.14.1.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 14:00:26 +02:00
Torsten Rasmussen f249f278bf west: warn that using runner args on multiple domains is experimental
The introduction of sysbuild and west build / flash / debug / etc.
support raises questions regarding how to handle user specified runner
arguments.

Some arguments may be acceptable for all domains, whereas others are
only valid for a single or few domains in a multi domain build.

Therefore, consider the usages of runner specific options experimental
when applied to multiple domains.

The following warning is printed to the user when using runner specific
arguments on multiple domains:
> WARNING: Specifying runner options for multiple domains is
> experimental.
> If problems are experienced, please specify a single domain using
> '--domain <domain>'

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-19 09:21:38 +02:00
Carles Cufi 0424509d6e west: blobs: Ensure that folder exists before fetching
The `<module>/zephyr/blobs/` folder, as well as any additional
sub-folders that might be required under `blobs/` may not exist when
fetching a blob. Ensure that the folder exists, create it if it doesn't.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Carles Cufi 5524f7a950 west: blobs: Add a clean sub-command
The new "clean" blobs sub-command deletes any blobs present on the
filesystem.

Also improve the help text for sub-commands.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Carles Cufi 02c95c64fe west: blobs: Rework the -m option
To align with other commands, such as "west update", convert the
accumulative -m option into an nargs="*"-type one that takes the list of
modules directly without a flag.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Carles Cufi 389af0885c west: blobs: Default to listing and fetching all blobs
Instead of both listing and fetching only the blobs in the
modules listed by the user in the command-line, default to
listing/fetching them all for ease-of-use and consistency with other
commands. Remove the --all options since it's meaningless now.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-18 15:25:43 +00:00
Torsten Rasmussen c3620c8a8e scripts: remove ZEPHYR_BASE as default root for board listing
Remove ZEPHYR_BASE as default root in list_boards.py.

This allows list_boards.py to be used to only print boards at given
root(s) without printing Zephyr default boards.

Secondly it remove the need in list_boards.py to have any knowledge of
ZEPHYR_BASE.

The `west boards` command already has ZEPHYR_BASE knowledge and can
easily add ZEPHYR_BASE to the list of roots it is already constructing,
thus removing the need for knowing that ZEPHYR_BASE is always added.

Update boards.cmake to pass ZEPHYR_BASE as an additional arch root, as
arch.cmake has not yet been processed,which means ZEPHYR_BASE is missing
in ARCH_ROOT list at this point in time.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-18 14:29:14 +02:00
Enjia Mai ad8f211729 runner: intel_adsp: no need to specify host in --pty if no port assign
No need to specify host again in --pty when not specifying the port,
slightly reduce the input.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Enjia Mai d935ec3a03 runner: intel_adsp: add parameters --tool-opt
Add parameter for possible extending in the future, --tool-opt
passes arguments to execution of the run service.
Ex.
  --tool-opt=--arg='white space' --tool-opt=-r --tool-opt=12345

will be parsed as ['--arg=white space', '-r', '12345']

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Enjia Mai e33fd73546 soc: xtensa: add support for specifying the service port
Add specifying the port for the remote cavstool remote service.
Ex.

    west flash --remote-host {host}:{port} \
               --pty {host}:{port}

Specify the port is optional when running west.

And another major change is now we have to specify the remote log
service by --pty to make it output the log message immediately.
Previously it will output directly. Why we make this change is
because this is more close to the behavior we use west flash.

Fixes. #46865

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Carles Cufi 336aa9dc88 modules: Basic binary blob infrastructure
This patch introduces the basic infrastructure to list and fetch binary
blobs. This includes:

- The new 'blobs' extension command
- An implementation of the `west blobs list` command
  with custom formatting
- A very simple mechanism for loading fetchers
- A basic implementation of an HTTP fetcher

In order to ensure consistency among the west extension commands in the
main zephyr tree, we reuse a similar class factory pattern that is present
for ZephyrBinaryRunner instances in the ZephyrBlobFetcher case. This
could be achieved with a simpler mechanism, but opted for consistency
before simplicity.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-16 05:59:02 -07:00
Carles Cufi a580b3d174 west: Fix handling of modules in the boards command
The boards command was not properly using the zephyr_module
functionality to obtain the board roots of all modules. Fix that by
moving the functionality required to the core zephyr_module file and
reuse it from external scripts.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-09 16:07:51 +02:00
Gerard Marull-Paretas a57001347f scripts: west_commands: runners: jlink: support pylink >= 0.14
pylink 0.14.0 changed the class variable where JLink DLL library name
(libjlinkarm) is stored. This patch adds support for new pylink
libraries while keeping backwards compatibility.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-05 12:58:23 +02:00
Torsten Rasmussen 69f4fa6a4e west: adding --domain to west build synopsis
Adding `--domain DOMAIN` to the west build synopsis.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-04 13:06:13 +02:00
Torsten Rasmussen 8408af6d7c scripts: west commands to support --domain
This commit extends the west commands build, flash, and debug to support
--domain when having multiple domains (images) defined in a domains.yaml
build file.

The domains.yaml uses the following yaml format to specify the
build directory of each domain in the multi image build:
> default: <domain-n>
> domains:
>   <domain-1>:
>     build_dir: <build_dir-domain-1>
>   <domain-2>:
>     build_dir: <build_dir-domain-2>
>   ...

`west <build|flash|debug>` has been extended to support
`--domain <domain>`.

`west build` calls CMake to create the build system, and if `--domain`
is given, then the build tool will be invoked afterwards for the
specified domain.

`west flash` will default flash all domains, but `--domain <domain>`
argument can be used to select a specific domain to flash, for example:
> west flash --domain mcuboot

`west debug` only a single domain can be debugged at any given time.
If `--domain` is not specified, then the default domain specified in the
domains.yml file will be used.
Users can still select a different domain, for example with:
> west debug --domain mcuboot

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Torsten Rasmussen 5fe5d6b43d scripts: extend west build command to support sysbuild CMake project
west build now support the sysbuild CMake project which allows users
to easily enable and build a bootloader together with any sample.

This will allow for cleaning up samples and boards which already does
custom multi image in a non-generic way, for example:
- mps2_an521 which includes a build for remote board
- samples/ipc/ which includes a samples for remote board
- esp32 which includes custom bootloaders

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-03 16:05:07 +02:00
Martí Bolívar 65e3593bf9 west_commands: runners: reserve -O for --tool-opt
The --tool-opt runner option is the recommended practice for allowing
runners to take additional arguments that are passed on to the
underlying tool. It exists because we don't want to add one runner
option for every single tool option that users might want to tweak --
that would be a nightmare.

Enough runners are using this option that it's time to promote it to a
common runner capability with consistent behavior, the same way we did
for the --dev-id option in the past. This removes boilerplate from
individual runner files and ensures consistent argument handling for
this option when it is supported.

Since --tool-opt is a bit long to type, and we've had some complaints
about that, take this as an opportunity to standardize on -O as a
short option equivalent for it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-03 05:06:53 +01:00
Alex Kolosov f59e9dd857 scripts: runners: improvements for spi_burn west runner
Following changes has been made by this commit:
    - fix issue when a binary is not able to be found by relative path
    - implement "west debug" command
    - implement --dt-flash option

Signed-off-by: Alex Kolosov <rikorsev@gmail.com>
2022-07-19 12:23:47 +00:00
Torsten Rasmussen f08af4ce68 west: zcmake.py: support UNINITIALIZED type if CMakeCache.txt file
A variable set by the user with `-DVAR=<val>` will be given the type
UNINITIALIZED.

This results in the variable not being read into the cmake_cache.

Support reading of CMake cache variables of type UNINITIALIZED.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-07-11 11:33:15 +02:00
Bartosz Bilas 888ce37799 runners: jlink: allow passing file path with spaces
Put file path within the " " marks to allow
passing file path with spaces.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-07-05 13:20:17 +02:00
Sylvio Alves 60417bad79 scripts: runners: esp32: add erase option
Adds option for erasing esp32 SoC.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2022-07-01 16:25:34 +02:00
Henrik Brix Andersen e12d06690e scripts: west: openocd: respect pre-load and post-verify cmds for elf
Respect --cmd-pre-load and --cmd-post-verify when flashing ELF files
(--use-elf).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-01 16:12:52 +02:00
Marc Herbert 9782b2cc05 scripts: intel_adsp: always invoke west sign
west flash invokes west build and we have no way to tell whether there
was any code change.

Also remove the rename() trick that achieved the same effect in a
a confusing way; just use copy() instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-06-30 10:34:30 +02:00
Marc Herbert 739aa951cd scripts: intel_adsp: don't invoke west sign with --tool-path None
When there is no rimage found in the path, don't invoke west sign with
"-tool-path None". This enhances the error message from the somewhat
cryptic:

  ERROR: --tool-path None: not an executable

... to the user friendlier:

  FATAL ERROR: rimage not found; either install it or provide --tool-path

Also log the complete west sign command at the "info" level before
running it to show that no signed firmware was found, to show which
rimage is used and in case other rimage problems arise. Invoking an
external command is an important "checkpoint".

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-06-30 10:33:53 +02:00
Andrzej Głąbek fb3e8138a2 west_commands: nrfjprog: Add handling of data targeting the XIP region
When a hex file contains some data that needs to be programmed using
the QSPI peripheral (because it targets the XIP region), nrfjprog
needs to be provided with an option that specifies the QSPI erase
method to be used (otherwise, reprogramming will fail).
This commit adds the "--qspisectorerase" option when needed and it
also fixes the programming routine for nRF53, so that data for the
XIP region is not incorrectly interpreted as intended for the network
core.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-06-24 20:29:00 +02:00
Jeremy Bettis 3b2d3129a5 west: Fix --openocd-search argument
Running west flash with the --openocd-search arg will result in the
openocd command being run with a -s param added for every character in
the passed DIR.

Fix the argparser to append all openocd-search DIRs into a list, instead
of just passing a string to the subcommand.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-06-20 10:26:23 +02:00
Anas Nashif 071f62cb75 west: remove intel_s1000_crb runners
Remove runners specific to the intel_s1000_crb board. it is no longer
available or supported in the zephyr tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-13 16:19:51 -04:00
Enjia Mai 12c44aaec7 scripts: runner: add a intel_adsp west runner
Add a intel_adsp west runner instead of using misc-flasher for
intel_adsp boards. Now running the test on intel_adsp_cavs by:

  west build -b intel_adsp cavs25 ...
  west flash --remote-host [remote hostname or ip addr] \
             --rimage-tool [path to rimage tool] \
             --config-dir [path to dir of .toml config file] \
             --key [path to signing key]

The intel_adsp west depends on the cavstool_server.py running
on the remote host machine.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-06-05 14:13:57 +02:00
Evgeniy Paltsev 554aa9cde3 ARC: west: mdb runner: change folder to run MDB
Make the build folder the place where MDB is run. Otherwise mdb
will store the .sc.project folder in the place where twister is
launched (so .sc.project folder will be shared across the runs)

For that we add **kwargs argument to popen_ignore_int method
so we can pass a cwd argument to the Popen constructor.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-06-02 13:09:51 +02:00
Erwan Gouriou 4d073a755d scripts: west: openocd runner: Add an option to specify target handle
Provide a way to specify the openocd target script handle used to
describe the core target.
In most target scripts '_TARGETNAME' is used, but it can happen that
'_TARGETNAME.foo' or '_CHIPNAME.bar' is used, specially on SoCs subject
to multicore.

Today, this option is required to enable rtos thread awareness,
using '$_TARGETNAME configure -rtos Zephyr' command, which is generated
by this runner.
It could be useful for similar needs in future.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-24 08:52:16 -07:00
Jordan Yates 06aae61019 scripts: zspdx: fix writing custom license IDs
The builtin list function `.sort()` sorts the list in-place and returns
None. As this is an invalid type for iteration, use the builtin `sorted`
function, which returns a sorted copy of the list, which we can iterate
over.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-23 10:18:06 +02:00
Jordan Yates 8e4107f9be scripts: ensure intended path for edtlib imports
When updating `sys.path` to allow importing the pickled edtlib instance,
add the path to the front of `sys.path`, not the end. This ensures that
the `devicetree.edtlib` module that is imported is the one relative
to the files being run, not some other version which may exist on the
path.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-13 10:09:45 -07:00
Esteban Valverde 74ae6f654e scripts: west_commands: runners: add runner for Cyclone V SoC FPGA DK
Add a runner to "flash" and "debug" Cyclone V SoC FPGA Development Kit
the runner is based on OpenOCD and GDB

Signed-off-by: Esteban Valverde <esteban.valverde.vega@intel.com>
2022-05-10 13:29:47 -04:00
Steve Winslow c2ae5b3bbf west: spdx: Exclude files not present after build
The list of files which are included in the `build.spdx` SPDX SBOM document
is based on the files recorded as build artifacts based on the CMake
file-based API metadata response.

In some situations, such as the case indicated in #42072, a build artifact
may be reported by CMake but no such file is present on the system
following the build. This results in the `build.spdx` SPDX SBOM being
invalid, as a result of trying to provide metadata for a non-existent
file (and specifically being unable to provide its checksum).

This commit fixes this bug by omitting files from `build.spdx` if they
do not exist on disk after the build is complete, even if the CMake
metadata claims that they should. The resulting SPDX document should
then be valid.

Fixes #42072

Signed-off-by: Steve Winslow <steve@swinslow.net>
2022-03-24 14:54:20 +01:00
Yuriy Vynnychek 1c78447428 scripts: runners: spi_burn: replaced delay by wait for response
Replaced hard-coded delay by wait for response during ICEman
connection.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
Signed-off-by: Alex Kolosov <rikorsev@gmail.com>
2022-03-23 18:33:24 +01:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Marc Herbert 29fd1826cb sign.py: pass west -v flag(s) to rimage
Give rimage the same number of -v that were given to west.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-03-11 11:52:38 -08:00
Markus Swarowsky 9510f96179 west: runners: Fix verify warning from nrfjprog
nrfjprog prints out a warning if a device is programed without the
--verify option, which can be confusing.
So added the option when programming with nrfjprog.
Then west flash can be used without getting a warning.
Also changed the tests to only accept programming with --verify
option.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2022-03-01 08:41:40 -08:00
Gregers Gram Rygg 4680180944 scripts: add board revision help text for west build
west build supports specifying the board revision using @revision, but
it's not mentioned in the help text. This commit updates the help text
to describe how to specify the board revision.

Signed-off-by: Gregers Gram Rygg <gregers.gram.rygg@nordicsemi.no>
2022-02-24 13:44:01 -08:00
Marc Herbert 2fdc551acc sign.py: stop ignoring the -- -c foo.toml option passed to rimage
The -c option points rimage at its main and mandatory configuration
file ("signing schema"). The -c option passed by sign.py to rimage comes
from _two_ different places:

A. From the command line, example:

   west sign -t rimage -- OTHER_ARGS_FOR_RIMAGE -c foo.toml

However passing -- -c signing_schema.toml on the west sign command line
has always been optional because:

B. west sign systematically adds another `-c bar.toml` option. The name
   'bar' is found in the CMakeCache. Right now 'bar' comes from
   a product specific `board.cmake` file.

There were two problems fixed by this commit:

1. The -c option from the command line was passed _first_ but the last
   -c wins with rimage. The command line should have precedence.

2. The "last -c wins" behavior is not documented/official, it's an
   rimage implementation deteail.

To fix both, simply scan the command line for a '-c' option. If any is
found then it takes precedence over the CMakeCache-based value which is
dropped.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-02-22 11:55:09 -08:00
Steve Winslow e12d9385c6 west: spdx: Fix missing field in build results
When using the west spdx functionality to create an SPDX SBOM
during a build, several SPDX Documents are created. In some
instances, the SPDX metadata field PackageLicenseInfoFromFiles
is required to be present according to the SPDX 2.2 spec, but is
being omitted from the build.spdx Document if no licenses were
detected.

This commit fixes this bug so that a NOASSERTION value is written
for this field for Packages that do not contain any detected
licenses.

Additionally, this ensures that Packages with a FilesAnalyzed
value of false do not have this field written, also in accordance
with the spec.

Fixes #42070

Signed-off-by: Steve Winslow <steve@swinslow.net>
2022-01-26 18:15:33 +01:00
Maureen Helm 1a7bc06086 debug: Remove deprecated CONFIG_OPENOCD_SUPPORT
CONFIG_OPENOCD_SUPPORT was deprecated in favor of
CONFIG_DEBUG_THREAD_INFO in Zephyr v2.6.0 and can now be removed.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-24 10:23:20 -05:00
Marcin Niestroj c9a3dae651 scripts: runners: esp32: remove print() call
This print() call was introduced as part of commit 16571db029 ("soc:
esp32: add support to mcuboot build") probably as a leftover from
debugging stage. Remove that, so flash command is not printed by
default. Those commmands can be easily printed by passing -v flag to
`west -v flash ...` command.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-01-05 19:48:18 -05:00
Carles Cufi fef2e30b7f runners: openocd: Default to an actual executable when not configured
Whenever build/zephyr/runners.yaml does not specify the location of the
openocd executable we seemd to be leaving the executable variable as
None. Instead, use its executable name.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-18 18:19:34 +01:00
Sylvio Alves 16571db029 soc: esp32: add support to mcuboot build
Select configuration when mcuboot is enabled.
At this moment, only UNSIGNED image is supported as per
Espressif's mcuboot porting.

This also updates esp32 runner to use proper bin_file name
and updates default bootloader check.

Move CMakeLists.txt content from board to soc directory
as this support is for esp32 architecture and not board
specific.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-12-18 07:20:38 -05:00
Shubham Kulkarni 5f11ac7c2a runners: esp32.py: Support flashing for MCUboot and IDF bootloader
IDF bootloader requires partition table which is not a requirement for
MCUboot. Hence, esp32.py is updated to flash partition table only if it
exists.

Current implementation only allows flashing zephyr.bin. This commit adds
capability to flash binaries with other names as well
(e.g. - zephyr.signed.bin)

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-12-18 07:20:38 -05:00
Andy Ross 2906d1aa51 soc/intel_adsp: Build bootloader with Zephyr
The presence of a separate build for the bootloader code has always
been a wart with this platform.  Sharing of code between the two has
required great care. We've had bugs with mismatched include paths,
macro definitions and compiler flags, etc...  And of course it's not
possible for one to see the other; in theory we'd like the ability to
call back into IMR code after startup, to use the space for temporary
storage, etc...

So let's finally do it.  This really isn't that complicated when you
see it in isolation:

+ Move the module manifest metadata into an "rimage_modules.c", and
  put them in their own NOLOAD section where we can grab them later
  with objcopy.

+ Make a new "imr" memory region in the main linker and just paste the
  bootloader linkage (which is now using its own specific sections) in
  there.

+ After zephyr.elf is built and cache-remapped, we can extract the imr
  sections and the appropriate manifest for the bootloader rimage
  module, and then do the converse by excluding them for the main
  image module.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-12-14 18:43:05 -06:00
Alex Kolosov f374d6b1f1 scripts: runners: Add west flash command for B91 platform
This commit implements west flash command for Telink B91 platform.
west flash command uses ICEman and SPI burn from AndeSight for flashing.

Signed-off-by: Alex Kolosov <rikorsev@gmail.com>
2021-12-06 07:28:38 -05:00
Yasushi SHOJI b652fe2a7b scripts: west_commands: runners: openocd: Add --verify-only
Add yet another option, --verify-only, to west flash.  This option
runs openocd with verify_image but without load_image.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-11-29 09:35:57 -05:00
Yasushi SHOJI da8a41d42a scripts: west_commands: runners: openocd: Add flash --verify
OpenOCD has verify_image command.  Add `--verify` option to west flash
so that openocd can do vierfy_image right after load_image.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-11-29 09:35:57 -05:00
Fabio Baltieri d0377d30e3 scripts: runners: add connect_srst support for blackmagicprobe
Black Magic Probe supports a "monitor connect_srst" command [1] to
configure whether to assert reset when connecting to the target. This is
useful to reprogram a target that may be idling in a low power state,
with an otherwise unresponsive debug core.

Adding a --connect-srst runner option for enabling this for "flash" and
"debug" operations to ensure that programming works in that case, but
also explicitly disabling it for "attach", to allow attaching to a
running target without changing its state.

Not turning this on by default since apparently some MCUs disable the
SWD interface while in reset.

[1] https://github.com/blacksphere/blackmagic/wiki/Useful-GDB-commands

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-11-22 22:20:02 -05:00
Maureen Helm 525fa76f4d boards: xtensa: Use a CMake variable to set the rimage target name
Removes hardcoded logic in the west signing script that translates
Zephyr board names to rimage target names. Instead, use a cached CMake
variable set at the board level to define its respective rimage target
name. This eliminates the need to modify the west signing script when
new SOF-supported boards are introduced to Zephyr.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-11-17 19:44:35 -05:00
Marc Herbert c2524a07a6 west: build.py: resolve symlinks in cached source directory check
Fixes the following error:

ERROR: Build directory "<whatever>" is for application "<symbolic source
  dir in CMakeCache.txt>", but source directory "<resolved source dir>"
  was specified; please clean it, use --pristine, or use --build-dir to
  set another build directory
FATAL ERROR: refusing to proceed without --force due to above error

Fixes initial commit ab82264ace ("scripts: add west build, flash, and
debug commands")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-11-10 08:27:16 -05:00
Gerson Fernando Budke 0de934b2a7 scripts: runner: Introduce gd32isp flash runner
Add GigaDevice ISP console flash runner.  This tool enable uses ROM
bootloader to flash devices using serial port.

The GD32_ISP_Console tool can be found at
  http://www.gd32mcu.com/download/down/document_id/175/path_type/1

Signed-off-by: Gerson Fernando Budke <gerson.budke@atl-electronics.com>
2021-11-07 05:20:50 -05:00
Bartosz Bilas 1502c6631d runners: jlink: exit with error in case of a failure
Add "ExitOnError 1" argument that treats any command-error
as fatal thus in the case of a programming error the "west flash"
command will return the correct error code instead of the default 0. It
fixes the false positive return codes when e.g we call west flash
command without a connected programmer or with the disconnected board.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-10-28 10:57:28 +02:00
Iuliana Prodan 602e675418 west: sign: add support for NXP i.MX8MP
Add support for signing i.MX8MP SOF with
Zephyr images with rimage.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-10-20 19:08:50 -04:00
Henrik Brix Andersen 5d34a45697 runners: openocd: always search the board support directory if found
Always add the boards/<arch>/<board>/support directory to the OpenOCD
runner search path if the directory exists.

This simplifies using custom --config <partial-board.cfg> runner
arguments without having to use the full path to the cfg file.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-10-19 17:38:54 +02:00
Steve Winslow 878ee1493e west: spdx: Fix --init for Windows builds
Currently, west spdx --init uses os.mknod to create an empty file
to enable the Cmake file-based API system. As reported in #39311,
Python on Windows does not implement os.mknod.

This commit switches to using open()/close() instead of os.mknod()
to address this issue.

Signed-off-by: Steve Winslow <steve@swinslow.net>
2021-10-18 09:47:30 -04:00
Julien Massot a35e046fb2 runners: openocd: prefer extended-remote for gdb connection
Instead of deprecated 'target remote'.
Fix:
Warn : Prefer GDB command "target extended-remote :3333"
instead of "target remote :3333"

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-10-17 11:47:36 -04:00
Julien Massot e4fac0e261 runners: openocd: gives configuration file before initialization
#38557 Reordered the argument for openocd, but we should not try
to call the init command before giving the board configuration
file stored in 'self.cfg_cmd'.

Move back this variable to it's original position.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-10-17 11:47:36 -04:00
Julien Massot 1cac55cf3a runners: openocd do not try to iterate over gdb_init if None
Commits 49bcc08033 introduced
a possible None object 'gdb_init', do not try to iterate over
this variable if it is a None object.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-10-17 11:47:36 -04:00
Henrik Brix Andersen 10fb5c203b runners: canopen: poll for flash ready
Poll the flash status instead of just reading the flash status once. Add
support for controlling the number of SDO retries and the SDO timeouts.

These changes allows for greater control of the CANopen program
download, which is especially useful on noisy or congested CAN networks
and on devices with slower flash access.

Fixes: #39409

Signed-off-by: Klaus H. Sorensen <khso@vestas.com>
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-10-14 10:44:21 +02:00
Carles Cufi 6a3593f4af west: runners: Add a deprecation action to the core code
In order to allow for further options to be deprecated with minimal
impact, add a deprecation argparse Action and a callable instantiator
that can be used to deprecate options in favor of new ones.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi 2ccfd22594 runners: pyocd: Convert to -i/--dev-id
Remove the previous pyocd-specific --board-id option and switch to
the common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi 285c2cabf1 runners: dfu-util: Convert to -i/--dev-id
Remove the previous dfu-util-specific --pid option and switch to the
common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi e3e23a51bb runners: canopen: Convert to -i/--dev-id
Remove the previous canopen-specific --node-id option and switch to the
common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi 5ee719ee9d runners: nrfjprog: Convert to -i/--dev-id
Remove the previous nrfjprog-specific --id option and switch to the
common -i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi f6b13ddb6f runners: jlink: Convert to -i/--dev-id
Remove the previous jlink-specific --id option and switch to the common
-i/--dev-id one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Carles Cufi 898f65f53c runners: Add new common -i/--dev-id command-line option
In an effort to standardize the way that a particular debugger or device
instance is identified when there are multiple present, introduce a new
-i/--dev-id option common to all runners that allows the user to specify
which device to interact with when there are multiple connected.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-10-11 20:56:27 -04:00
Sylvio Alves 49bcc08033 openocd: add hardcoded configs as input parameters
Debugging ESP32 SoCs is not possible if the commands
halt, target and load are enabled by default.
This MR allows this configs to be used as input parameters.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-10-08 12:59:55 +02:00
Daniel Leung 10eab23f08 west: sign/rimage: fix rimage argument if --no-manifest
If --no-manifest is specified, '-e' is still being passed
to rimage to build the extended manifest. Fix this so
that when --no-manifest is specified, '-e' is no longer
passed to rimage.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-10-06 19:43:30 -04:00
Iuliana Prodan 3ec07c5f47 west: sign: add support for NXP i.MX8QXP board
Add support for signing i.MX8QXP SOF with Zephyr images with rimage.

i.MX8QXP and i.MX8QM have the same board-level definitions,
so we use the generic imx8.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-09-27 21:52:31 -04:00
Gerson Fernando Budke 7bf00c935a scripts: runners: openocd: Fix empty search path
When enable thread awareness feature for OpenOCD the search path was
converted to a list.  In some environments OPENOCD_DEFAULT_PATH may
not be defined.  That create an empty search path list system fails.
This add a test to skips fill search_args with openocd_search values
when list is empty.

Fixes #38272.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-09-09 19:44:22 -04:00
Iuliana Prodan 82304213c3 west: sign: add support for NXP i.MX
Add support for signing i.MX SOF with Zephyr images with rimage.

Note that, for i.MX, we don't need a bootloader nor the .elf.mod files
since there is no need to change the VMA/LMA of each uncached section
to the equivalent address in the cached area of memory.
For the above reasons, I've updated the arguments given to "west sign"
command.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-08-28 23:27:02 -04:00
Henrik Brix Andersen 7d94b0ccfd runners: openocd: add support for custom reset halt command
Add support for specifying a custom OpenOCD command to be used for
resetting and halting a target.

As noted in the OpenOCD documentation, not all targets support the
"reset halt" command for halt-on-reset.

Some targets support a software emulation via the "soft_reset_halt"
command. Other targets may require a custom command (e.g. a command
defined in the target configuration file).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-08-27 13:08:17 -04:00
Gerson Fernando Budke c3db83ba58 scripts: runners: openocd: Enable thread awareness
Zephyr thread awareness is available for openocd but boards don't
have debuggers configuration.  This configure OpenOCD runner
automatically to complete configuration.

User still require enable CONFIG_DEBUG_THREAD_INFO=y to visualize
thread debug information.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-08-27 06:44:45 -04:00
Erwan Gouriou 5c24a6813d scripts/west_commands/runners: openocd: Add no-halt debug option
Some targets require no 'halt' to be issued i the gdb server command.
Add a --no-halt option to make it possible.
Keep use of halt as the default case.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-08-26 17:57:09 -04:00
Henrik Brix Andersen 0f958bd3ac runners: openocd: add support for multiple configuration files
Add support for passing the --config argument to the openocd west runner
multiple times.

This allows for using modular openocd configuration files (e.g. CPU core
configuration in one file, independent of the selected JTAG interface
type).

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-08-20 06:31:42 -04:00
Carles Cufi 2a173c2213 runners: jlink: Add support for specifying a serial number
Handle serial numbers provided from the command-line instead of forcing
the user to provide 'tool-opt' manually.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-08-03 17:39:51 +02:00
Sylvio Alves b3bf6d854e esp32: auto detect serial port
Current default serial port used for flashing is
/dev/ttyUSB0. This changes that to automatically detect the device
serial port or uses the one exported to the environment.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-08-03 13:59:04 +02:00
Marcin Niestroj 54b26ca7e8 scripts: west: boards: support listing out-of-tree boards
So far only upstream boards were listed. Use just introduced
zephyr_module.parse_modules() function to get information about
out-of-tree board roots. Append them to user provided args.board_roots,
so out-of-tree boards from west modules are listed as well.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-16 07:17:35 -04:00
Felipe Neves 132ab922a8 drivers: timer: esp32c3: add esp32c3 systimer driver to CODEOWNERS
Also added maintainer to the entry

Signed-off-by: Felipe Neves <ryukokki.felipe@gmail.com>
Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
2021-07-07 20:58:50 -04:00
Felipe Neves 5d736766ed soc: esp32c3: added initial soc support files for esp32c3
by adding the soc specific files such: soc initialization code,
linker scripts and support for esp32c3 devkitm

Signed-off-by: Felipe Neves <ryukokki.felipe@gmail.com>
Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
2021-07-07 20:58:50 -04:00
Watson Zeng 91aedd964e arc: west: mdb: reverse the launch order for multi cores
The ARConnect Inter-core Debug Unit (ICD) provides
additional debug assist features in multi-core scenarios.
In master core(core 0) initial stage, we will program ICD to halt
all other cores based on a halt occurring in one ore more core.
And all cores are in halt mode on reset, so we need to make
sure other slave cores have launched and in running mode
before we enable ICD in master core.

Currently we launch master first, Let's reverse the launch
order, launch master last, to make sure slave cores have
launched before we program and enable ICD.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-07-01 13:33:34 -04:00
Marc Herbert 88600d69e9 scripts: runners: add specific ImportError to warning message
So when for instance adding some `import wrong_module` line to a sample
runner like bossac.py this adds the text between parentheses ( ) below:

  The module for runner "bossac" could not be imported (No module named
  'wrong_module'). This most likely means it is not handling its
  dependencies properly. Please report this to the zephyr developers.

Test tip: changes to bossac.py do not trigger a fast, incremental doc
build. touch doc/guides/west/build-flash-debug.rst does it instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-06-16 10:39:08 +02:00
Anas Nashif 070cf6a7fc west: parse options from testcase.yaml/sample.yaml during build
Allow the use of build configurations from testcase/sample yaml files.
This addition makes it easy to build a sample or a test with the options
provided in the test file by pointing to the test section to be built on
the command line of `west build`.

Fixes #31993

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-11 20:56:10 -04:00
Martí Bolívar 91f0212399 doc: add docs for west spdx
These are based on the commit log in
fd31b9b4ac.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-06-01 07:26:33 -05:00
Gerson Fernando Budke f3a7f041bf scripts: runners: bossac: Add legacy mode
Add compatibility mode with old sam-ba flash bootloaders that don't have
offset capabilities.  These bootloaders flash to a pre-defined flash
region.  At end, bossac will suppress --offset parameter.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-05-21 21:20:58 +02:00
Martí Bolívar cc1e64be93 runners: openocd: fix 'debug'
The 'debug' command isn't reloading the binary. Fix it, keeping
'attach' support as-is.

Fixes: #33745

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-19 17:33:33 +02:00
George White f54e1eddbe runners: bossac: Arduino bootloader reset on macOS
Fixes compatibility with the Arduino bootloader reset mechanism when
using `west flash` on Darwin hosts.

stty is used to set the serial port in the bossac runner to 1200 baud on
Arduino ATSAMD21 bootloaders. The `-F` argument to stty is a GNU
coreutils addition, and thus it is missing from Darwin's BSD stty, so
change the flag to `-f` when we're not running on Linux.

On Darwin, set DEFAULT_BOSSAC_PORT to None and ask the user to select
one from a list of IOCalloutDevices reported by ioreg, modelled on the
get_board_snr from the nrfjprog runner. This is because serial port TTYs
are generated by the device driver, and therefore there is no safe
default.

Tested with an Arduino Nano 33 IoT board.

Signed-off-by: George White <me@galexite.uk>
2021-05-13 22:05:17 -04:00
Arvin Farahmand 2de6bf91d5 west: sign.py: fix logic bug
Fix bug where if `CONFIG_BOOTLOADER_MCUBOOT` is set sign.py incorrectly
shows warning `CONFIG_BOOTLOADER_MCUBOOT is not set to y...`.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-05-06 19:49:52 -05:00
Shubham Kulkarni 2caaacc191 scripts: esp32.py: Do not convert ELF to bin
ELF to binary generation is handled by build system

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-05-05 19:49:38 -04:00
Steve Winslow fd31b9b4ac west: spdx: Generate SPDX 2.2 tag-value documents
This adds support to generate SPDX 2.2 tag-value documents via the
new west spdx command. The CMake file-based APIs are leveraged to
create relationships from source files to the corresponding
generated build files. SPDX-License-Identifier comments in source
files are scanned and filled into the SPDX documents.

Before `west build` is run, a specific file must be created in the
build directory so that the CMake API reply will run. This can be
done by running:

    west spdx --init -d BUILD_DIR

After `west build` is run, SPDX generation is then activated by
calling `west spdx`; currently this requires passing the build
directory as a parameter again:

    west spdx -d BUILD_DIR

This will generate three SPDX documents in `BUILD_DIR/spdx/`:

1) `app.spdx`: This contains the bill-of-materials for the
application source files used for the build.

2) `zephyr.spdx`: This contains the bill-of-materials for the
specific Zephyr source code files that are used for the build.

3) `build.spdx`: This contains the bill-of-materials for the built
output files.

Each file in the bill-of-materials is scanned, so that its hashes
(SHA256 and SHA1) can be recorded, along with any detected licenses
if an `SPDX-License-Identifier` appears in the file.

SPDX Relationships are created to indicate dependencies between
CMake build targets; build targets that are linked together; and
source files that are compiled to generate the built library files.

`west spdx` can be called with optional parameters for further
configuration:

* `-n PREFIX`: specifies a prefix for the Document Namespaces that
will be included in the generated SPDX documents. See SPDX spec 2.2
section 2.5 at
https://spdx.github.io/spdx-spec/2-document-creation-information/.
If -n is omitted, a default namespace will be generated according
to the default format described in section 2.5 using a random UUID.

* `-s SPDX_DIR`: specifies an alternate directory where the SPDX
documents should be written. If not specified, they will be saved
in `BUILD_DIR/spdx/`.

* `--analyze-includes`: in addition to recording the compiled
source code files (e.g. `.c`, `.S`) in the bills-of-materials, if
this flag is specified, `west spdx` will attempt to determine the
specific header files that are included for each `.c` file. This
will take longer, as it performs a dry run using the C compiler
for each `.c` file (using the same arguments that were passed to it
for the actual build).

* `--include-sdk`: if `--analyze-includes` is used, then adding
`--include-sdk` will create a fourth SPDX document, `sdk.spdx`,
which will list any header files included from the SDK.

Signed-off-by: Steve Winslow <steve@swinslow.net>
2021-05-05 11:14:06 -04:00
Martí Bolívar 55e8807b08 runners: jlink: support thread_info_enabled
Automatically enable per-thread info in GDB if the binary and J-Link
support it.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 61996a35ac runners: jlink: extend 'nogui' support
Support this when debugging also.

Tweak the style for brevity also while we're here by propertizing the
supports_nogui method, etc.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar b733ddb48d runners: core: add thread_info_enabled property
This makes it easier for runners to check if the binary has thread
info support turned on, allowing automatic configuration of the
underlying tool to support threads, if possible.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 250b2133ee scripts: re-work BuildConfiguration boolean handling
Set options that are definitely true or false to True or False in the
options dict. Add a 'getboolean' method that also allows a fallback to
False in case the option is not mentioned in .config due to unmet
dependencies. This allows calling code to just ask about the option
they are interested in, even if the .config file doesn't mention the
option at all.

Propagate this to users within the runners package and 'west sign',
taking advantage of the new build_conf property.

Rename the 'bcfg' internal variable in sign.py to 'build_conf' to
match other source files that use BuildConfiguration instances, to
make it easier to grep for users.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 778a18cb1a runners: tests: don't patch BuildConfiguration
Instead of mocking out the BuildConfiguration class, just create its
input file and let the real class do the work.

This in turn exposes a bug in the way the board name is being pulled
out of the BuildConfiguration, which we fix to keep the tests passing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar f31a8f67a9 runners: jlink: silence commander output by default
This is really verbose, and I doubt anyone cares unless there is a
problem. Keep it around when run as 'west -v flash' to allow for
debugging, though.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 6357770eef runners: jlink: rework --dt-flash handling
Defer loading .config until we really need it, when we are flashing a
binary. Pre-emptively loading it is wasted effort if we're flashing a
.hex, which has been the default behavior when possible since
dcaabb860f ("west: runners: jlink: prefer .hex over .bin").

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 7640c39505 runners: jlink: clean up commander script logging
Put it all in one log message rather than splitting it up.

This makes it look cleaner now that each log message is prefixed with
'runners.link:'.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 2d43f660d9 runners: jlink: fix --commander help
The default commander path is platform specific.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 069c18d3ad runners: jlink: replace version parsing code
JLink versions like 'V7.0a' do not conform to PEP 440 version
conventions; the 'a' part is used by PEP 440 compliant versions for
alphas. It gets parsed to a legacy type by the packaging library,
which always is treated as a lower value when compared with a
conforming version string.

To fix, get the version from the shared library distributed with the
JLink tools. This has the side benefit of making the code work on
Windows. That's merely a nice to have for -nogui 1 detection for now,
but will be essential in the next commit.

Reported-by: Jake Mercer <jake.mercer@civica.co.uk>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar aded635dfa runners: core: add build_conf property
Make it easier to get a BuildConfiguration from runner code.
Stash the result so it only has to be computed once.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar e1e1bdc20f runners: core: add **kwargs to other subprocess wrappers
Just to make these match check_output().

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar bbb17df9a2 runners: core: refactor helper for getting flash address
Separate the logic that gets the right address from .config
into its own helper.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar c2c8e8824e runners: core: try to improve --dt-flash option help
This option has existed since the beginning of the runners package,
which greatly predates the way DT is used in zephyr right now. It
never really worked the way I wanted it to but it's too much work to
fix it now. Try to improve the help a bit at least while I'm looking
at it again.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 47007338af runners: core: return shutil.which() value from require()
Make it easy to get the full path to a required binary.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 09f55767b1 runners: tests: fix os.path.isfile patch
Copy a fix from test_nrfjprog.py to the other runner test suites. The
current code will enter an infinite recursion if you hit the path
where os.path.isfile is called, since it's been patched to
os_path_isfile_patch in the calling context. The fix is to cache the
'real' version in the parent scope and call it directly as a fallback.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Torsten Rasmussen 3dd65a7663 runners: remove dependencies from runners
Today, there is a build target is added for each runner: flash, debug,
debugserver, attach.

And those runners will have a dependency to Zephyr logical target that
is built before invoking `west <runner>`.

This design has some flaws, mainly that additional dependencies directly
on the target will not be built when running `west <runner>` directly.
That generator expressions cannot be used for the DEPENDS argument.

Instead, the build target `<runner>` will not have any dependencies, and
will raise a build error if a dependency is added to the target.
Due to how `add_dependencies()` work, this must be done as a build time
check, and not configure time check.

`west <runner>` will invoke a build before executing the runner, and
this way ensure the build target is up-to-date, which again removes the
need for a dedicated `west_<runner>_target`.

It also minimizes the risk of developer errors, as developers no longer
need to consider the need for adding additional dependencies.
If a custom target is part of the default `all` build, then it's ensured
to be up-to-date.

Fixes: Issue reported on slack.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-04-19 15:35:30 +02:00
Dominik Ermel 96bfaffc02 runners: nrfjprog: Fix nrfjprog after changes to BuildConfiguration
The commit fixes problem with nrfjprog runner for west flash,
that has been introduced with latest changes to BuildConfiguration
class.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-09 16:34:01 +02:00
Dominik Ermel e12e377e72 scripts: runners: Modify BuildConfiguration._parse to iterate over file
The method has been changed to iterate directly over file instead of
preloading it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-08 16:38:28 +02:00
Dominik Ermel 0dfd191e04 scripts: west_commands: Remove no longer needed load_dot_config(path)
The functionality of the function is now covered by BuildConfiguration
class.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-08 16:38:28 +02:00
Dominik Ermel 09980d6a50 scripts/west sign: Use BuildConfiguration instead of load_dot_config
The ImgtoolSigner.sign() is passed a BuildConfiguration object instance
that holds all of Kconfig options that have been defined for a build;
yet it has been reading the .config file once again, with the
load_dot_config, to check some of these options.
The commit replaces the code that has been using the load_dot_config
obtained data with the code that uses the BuildConfiguration object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-08 16:38:28 +02:00
Dominik Ermel cabb7d69ee scripts: runners: Copy load_dot_config to BuildConfiguration.get()
The body of load_dot_config method has been reimplemented in
BuildConfiguration.get(), replacing the previous code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-08 16:38:28 +02:00
Dominik Ermel 185d695986 scripts: runners: Add BuildConfiguration.path attribute to class
The BuildConfiguration.path attribute has been added that stores path
to .config file which has been used as source for options collected to
BuildCOnfiguration object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-04-08 16:38:28 +02:00
Mikkel Jakobsen 3fe785d4a7 scripts: west sign: fix devicetree module include
PR #33746 introduced changes to the devicetree python file
that requires changes in the python code that imports the
devicetree module.

This was omitted in the west sign command implementation.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-04-06 14:54:02 -05:00
Martí Bolívar 5332847644 dts: separate DT libraries from gen_defines.py
We are now in the process of extracting edtlib and dtlib into a
standalone source code library that we intend to share with other
projects.

Links related to the work making this standalone:

    https://pypi.org/project/devicetree/
    https://python-devicetree.readthedocs.io/en/latest/
    https://github.com/zephyrproject-rtos/python-devicetree

This standalone repo includes the same features as what we have in
Zephyr, but in its own 'devicetree' python package with PyPI
integration, etc.

To avoid making this a hard fork, move the code that's being made
standalone around in Zephyr into a new scripts/dts/python-devicetree
subdirectory, and handle the package and sys.path changes in the
various places in the tree that use it.

From now on, it will be possible to update the standalone repository
by just recursively copying scripts/dts/python-devicetree's contents
into it and committing the results.

This is an interim step; do NOT 'pip install devicetree' yet.
The code in the zephyr repository is still the canonical location.

(In the long term, people will get the devicetree package from PyPI
just like they do the 'yaml' package today, but that won't happen for
the foreseeable future.)

This commit is purely intended to avoid a hard fork for the standalone
code, and no functional changes besides the package structure and
location of the code itself are expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-04-02 08:28:12 -05:00
Pieter De Gendt f282c93b9a scripts: west_commands: runners: jlink check for WSL
The jlink runner performs a version check which is skipped on
Windows. If running inside WSL we also need to skip.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-03-30 18:45:25 -05:00
Pieter De Gendt ff5bb8d916 scripts: west_commands: runners: Custom jlink gdb host
Allow a custom (remote) gdb host passed as a debug argument
which tries to connect to an existing one instead of creating one.

This also allows to run the gdb server outside of a WSL
in Windows and the debugger inside of the WSL environment.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-03-30 18:45:25 -05:00
Martí Bolívar 524853ecfa runners: nrfjprog: workaround for multi-core hex files
The nrfjprog utility is not capable of flashing a hex file which
affects the flash memories of both coprocessors of the nRF53 family of
SoCs.

However, the user is capable of creating such a hex file using the
HEX_FILES_TO_MERGE build system variable.

An example use case is to build a bluetooth controller application for
the network core, then use the zephyr.hex file in that build directory
as the HEX_FILES_TO_MERGE argument for a separate Bluetooth
application build targeting the app core.

Work around this by detecting the situation and doing the right thing
by splitting the hex file back up again, even if thats a bit awkward.
Splitting the hex into app and network core components allows them to
be flashed separately. This is the only way we can get the job done
with nrfjprog.

This is arguably nicer since there's just one 'west flash' invocation.
At least in the use case named above, you wouldn't need to rebuild the
controller application very often, so this is a simpler user workflow.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-19 09:52:13 -04:00
Martí Bolívar 847ba43df9 scripts: run_common: improve error handling for missing runner
Catch the ValueError returned by get_runner_cls() and turn it in to a
log.die().

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-17 11:30:45 +01:00
Martí Bolívar d61545b513 scripts: runners: handle failure to import individual runners
We need all available runners to be defined as subclasses of
runners.core.ZephyrBinaryRunner in order to be able to look them up by
name at runtime. We do this by importing them from runners.__init__.

This process periodically fails when some runner or other cannot be
imported, usually because it is trying to import something outside of
stdlib and not handling ImportError.

Rather than letting this bring down the entire Python process, catch
and log the error. Sort the list again while we're here.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-17 11:30:45 +01:00
Martí Bolívar e6435fda94 scripts: runners: jlink: handle packaging ImportError
This too is violating the 'stdlib or handle ImportError' rule.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-17 11:30:45 +01:00
Martí Bolívar a56e1fa52d scripts: runners: bossac: handle edtlib ImportError
Runners may not import anything outside of stdlib unless they handle
the possible ImportError.

Apply this rule to the bossac runner. The general pattern is to have a
MISSING_REQUIREMENTS global that we handle at the beginning of
do_run(), but in this case this isn't a missing pip package, but a
misconfiguration. Just log a warning; it won't happen in practice.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-17 11:30:45 +01:00
Martí Bolívar b3c6470bb3 scripts: run_common: make edtlib importable to all runners
Runners can (and many should) depend on the devicetree to decide what
to do, especially as it relates to the flash layout. Make it so that
they do not have to manipulate sys.path to get a hold of the edtlib
directory by doing it in one place, before importing any of them.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-17 11:30:45 +01:00
Ioannis Glaropoulos 488e7ef39a west commands: runners: support for including config file in pyocd
Add support for including a board-specific config.yaml file
in the pyocd flash command. Similary to openOCD, the config
file is placed in the board directory under support/.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-03-16 20:01:53 -04:00
Jose Alberto Meza 49c626a33d scripts: west_commands: tests: Update dediprog expected command
Update test to account for new default parameters that allow
use image smaller than flash device capacity.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2021-03-16 10:02:57 +01:00
Jose Alberto Meza 4cbfc324e3 scripts: west_commands: runners: Remove need to match device capacity
Use fill option to be able to flash file images small than
flash device capacity.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2021-03-16 10:02:57 +01:00
Jordan Yates dcaabb860f west: runners: jlink: prefer .hex over .bin
Update the jlink runner to prefer flashing .hex files instead of .bin.
This can increase programming speed in cases where there are large
amounts of padding in an application.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-02-25 10:59:13 -06:00
Jian Kang 8c9b06ad82 board: cavs15: Add a option to control signing ways
Zephyr testcases(not SOF case) not use kernel DSP driver to load image
on ADSP board, thus do not need signing with xman. So add a input
'--no-manifest' to specify signing without xman in image. If use DSP
driver load image, we should not specify this.

Signed-off-by: Jian Kang <jianx.kang@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-11 13:52:30 -05:00
Martí Bolívar 16a7465d93 scripts: zcmake: fix for prerelease cmake versions
Handle a semantic versioning case used by Kitware that is not
supported by the packaging module we're using for version comparisons.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-09 09:14:37 -05:00
Martí Bolívar 46f2f8cbc9 runners: fix openocd with --use-elf
There are use cases where --use-elf is given and the hex file does not
exist. Handle them.

Fixes: #31944
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-03 16:26:27 -05:00
Martí Bolívar 5f327f9edf runners: pyocd: handle None in hex/bin files
Commit 3204554841 (" scripts: runners: error on missing
non-elf outputs") created the possibility of None bin_file and
hex_file attributes in the RunnerConfig without updating pyocd
appropriately. Fix that.

Fixes: #31921
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-03 10:36:26 -05:00
Martí Bolívar 698db69307 west sign: prefer 'python imgtool.py' on windows
We can't trust that a python file is executable on Windows, regardless
of what the mode bits say.

When we find that imgtool is a .py file, run 'python imgtool.py'
instead of 'imgtool.py' on that platform.

Fixes: #31876
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-02 17:59:13 -05:00
Martí Bolívar b4903d44bf west sign: adjust find_imgtool helper
Have it return a list, which is prepended to the final arguments list
passed to subprocess. No behavioral changes expected, but this enables
making it contain multiple strings instead of just one.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-02 17:59:13 -05:00
Martí Bolívar af5a79f6c1 west build: fix board detection
We can't trust the cache to have a CACHED_BOARD just because it exists.

Fixes: #31800

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-02 14:08:57 -05:00
Martí Bolívar 3204554841 scripts: runners: error on missing non-elf outputs
The RunnerConfig class stores the locations of the Zephyr output files
in various formats (elf, hex, bin). A longstanding issue with the
representation is that these might not exist if the corresponding
Kconfig options are not set. For example, if
CONFIG_BUILD_OUTPUT_BIN=n, there is no .bin file.

Change this so the type system knows these are Optional[str], not str.

Fix the runners that use non-ELF outputs so they check for the
existence of the relevant file before using it, mostly using a new
ZephyrBinaryRunner.ensure_output helper.

I'm not going to bother with checking for the ELF file itself; that's
always there as far as I can tell.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-02 14:01:22 -05:00
Anas Nashif fee9af2bda west: rimage: get config dir from command line
If we do not have the configuration path via cmake, then check if the
configuration path was provided on the command line and use it instead,
if both fail, bail out and die.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-26 06:19:34 -05:00
Anas Nashif b553166a09 west: sign: add new option -D for configurations
rimage signing tool requires the path to the configuration directory.
This can be fetched using cmake cache if we are building with a module
that has rimage integrated like the sof module, however, we should be
able to sign images that were built standalone and without SOF, so
support this new option to provide the location of the configuration
files for the tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-26 06:19:34 -05:00
Torsten Rasmussen 774103d050 cmake: pristine.cmake requires SOURCE_DIR and BINARY_DIR as arguments
Calling cmake/pristine.cmake now requires SOURCE_DIR and BINARY_DIR as
arguments.

This ensures that pristine.cmake can evaluate if pristine is requested
on in-source builds, and bail out in such case with an error message.

All uses of `pristine.cmake` has been updated to use the new arguments.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-23 08:31:13 -05:00
Martí Bolívar c19c6fb438 Revert "scripts: west build: default build.pristine to auto"
This reverts commit c505ca38cf.

Fixes: #31358

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-01-17 08:58:54 -06:00
Martí Bolívar 0d5e6c13e9 boards/shields: re-work handling in cmake and west
Remove the boards and shields lists from the 'usage' target output.
That might have been readable at some point long ago in Zephyr's
history, when only a few boards were available, but right now it's
obscuring the high level targets we really want 'usage' to print.

Instead, add 'boards' and 'shields' targets which the user can run to
get those lists, and reference them from the 'usage' output. This
makes 'usage' squintable again. We use the new list_boards.py script
from the 'boards' target.

Reference the 'help' target from 'usage' as well, and drop the
recommendation that people run '--target help' from the 'west build
--help' output for the 'west build --target' option. The canonical
place to look is 'usage' now.

Use the new list_boards.py code from 'west boards' as well, which
allows us to add the board's directory as a format string key, in
addition to its name and architecture.

Keep west-completion.bash up to date. While doing that, I noticed that
a bunch of references to this file refer to a stale location, so fix
those too.

Finally, the 'usage' output is what we print for a failed board or
shield lookup, so that needs to be updated also. Handle that by
invoking boards.cmake and a new shields.cmake in CMake script mode to
print the relevant output.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-01-15 15:07:49 -05:00
Kumar Gala 3befd7d45f cleanup: rename sanitycheck references to twister
Cleanup references to sanitycheck that should now be twister.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-14 07:50:52 -06:00
Martí Bolívar 7745f3edba west boards: add --name filter
This is an optional regular expression that can be used to filter the
output.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-01-14 12:39:21 +01:00
Guennadi Liakhovetski 3de40b48c3 rimage: update rimage: add configuration and extended manifest
rimage dropped its "-m" parameter and switched over to using "-c"
for a configuration file, including a target name.

Add support for extended manifest for all cAVS versions.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Martí Bolívar a8612eb308 runners: fix nrfjprog UICR check
It's fine to flash an image with UICR data as long as the user has
given any of the --erase, --recover, or --force options. Silence the
error correctly.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-01-05 08:44:05 -06:00
Eugeniy Paltsev 3134bc1ea0 runners: nsim: allow to use runner if gdb is missing
As of today we check for gdb presence in 'do_create' method and
raise an exception in case of gdb is missing. That makes nsim
runner unusable without gdb even for the commands which don't use
it (like 'flash' command).

Fix that.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-12-27 18:19:10 +01:00
Jacob Trueb 278aca926b scripts: west_commands: runners: Extend jlink timeout
With Rosetta, jlink command runs longer than 0.1 seconds.

Signed-off-by: Jacob Trueb <jtrueb@northwestern.edu>
2020-12-16 14:26:13 +01:00
Martí Bolívar 8fce3004fe runners: mdb: fix imports
Runner implementations are only allowed to unconditionally import
modules in the python standard library. They are not allowed to import
anything that comes from pip or other third party sources unless they
catch the ImportError and gracefully do nothing.

Fix the imports in the mdb runner accordingly, sorting the imports
into sections to make it clearer what's stdlib, what's runners, and
what's third party while we're here.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-12-11 16:49:59 -05:00
Martí Bolívar 6628a16e4d runners: nrfjprog: boilerplate and recover rework
Rework the runner to improve various issues.

Every board.cmake file for an nRF SoC target is repeating boilerplate
needed for the nrfjprog runner's --nrf-family argument. The
information we need to decide the --nrf-family is already available in
Kconfig, so just get it from there instead. Keep the --nrf-family
argument around for compatibility, though.

This cuts boilerplate burden for board maintainers.

We also need to revisit how this runner handles recovery to fix it
in nRF53 and keep things consistent everywhere else.

To cleanly handle additional readback protection features in nRF53,
add a --recover option that does an 'nrfjprog --recover' before
flashing. Keep the behavior consistent across SoCs by supporting it on
those too. Because this is expected to be a bit tricky for users to
understand, check if a --recover is needed if the 'nrfjprog --program'
fails because of protection, and tell the user how to fix it.

Finally, instead of performing a separate 'nrfjprog --eraseall', just
give --chiperase to 'nrfjprog --program' process's arguments instead
of --sectorerase. This is cleaner, resulting in fewer subprocesses and
avoiding an extra chip reset.

Having a separate 'west flash --recover' option doubles the number of
test cases if we want to keep exhaustively enumerating them. That
doesn't feel worthwhile, so update the test cases by picking a
representative subset of the possibilities. Each test now has enough
state that it's worth wrapping it up in a named tuple for readability.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-12-09 15:00:24 -06:00
Gerson Fernando Budke 80d7253a47 scripts: runners: bossac: Fix offset parameter
The current bossac runner have multiple entries for flash offset
parameter.  Remove offset parameter from command line and rework
all infraestructure to get offset from device tree.  Add proper
verification routines to validate configurations on board and
device tree entries to fix SDK compatibility checks.

Fixes #29312.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-12-03 10:50:23 -06:00
Gerson Fernando Budke 94171c0ba2 scripts: runners: bossac: Extract make_bossac_cmd
Move bossac command construction outside do_run method to keep
clean code.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-12-03 10:50:23 -06:00
Gerson Fernando Budke ffed132e82 scripts: runners: bossac: Change speed by protocol
Add is_extended_samba_protocol method to verify if board is using SAM-BA
extended protocol (Arduino/Adafruit UF2).  It allows enforce serial line
speed to 1200 baud automatically.  This avoid add entries on board.cmake
file.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-12-03 10:50:23 -06:00
Gerson Fernando Budke 876d8632a2 scripts: runners: bossac: Extract set_serial_config
Move serial settings outside do_run method to keep clean code.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-12-03 10:50:23 -06:00
Eugeniy Paltsev 9858893ea8 ARC: runner: mdb: tweak searching for cld process pid
mdb binary starts several subproceses and one of them is cld process.
In runners/mdb.py we record process id of cld on each mdb launch
to terminate simulator correctly later. However we can finish test
and terminate mdb before the cld process was found (so cld won't
be terminated correctly by sanitycheck infrastructure). It may happen
if we launch mdb on fast host machine.

That leads to several issues. First of all we get ugly error in
sanitycheck output:
------------------------>8--------------------------------
FileNotFoundError: [Errno 2] No such file or directory: '/xxxx/mdb.pid'
------------------------>8--------------------------------

Secondly (and it's more important) we terminate simulator incorrectly.
We terminate mdb leaving cld process alive, running and consuming one
cpu core permanently (until we kill it manually)

So, let's increase granularity of lookups and don't wait extra 0.5
seconds before the first lookup.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-12-02 14:08:26 -05:00
Martí Bolívar 4ac96079a7 west: flash/debug: try to make --context more prominent
I keep seeing people miss the --context option in the "west flash
--help" output.

This option is very important for understanding the runner-specific
options and state, and missing it means people get confused about what
west flash, debug, etc. can do and are doing.

Try to avoid this problem by adding a big fat banner about the
omission of runner-specific options in the main help output, and
provide more hints about how to use --context.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-11-17 16:38:36 -05:00
Eugeniy Paltsev 0699f38f16 ARC: west: mdb runner: record MDB's CLD process pid to file
Record MDB's CLD process pid to file so this process can be
terminated by sanitycheck infrastructure.
Update mdb runners test to be able to handle changes.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-11-11 08:18:38 -05:00
Eugeniy Paltsev 91d7ec5a35 ARC: west: split mdb runner for mdb-hw & mdb-nsim runners
mdb runner is quite special as it can be used to run Zephyr on
both simulator (nSIM) and real hardware.
However it is really misleading as same command (west flash)
will run Zephyr in simulation for one board and try to run it
on HW for another board. Things are getting worse for boards
supporting both runs in simulation and on real hardware.

Let's split mdb runner for mdb-hw (for runs on HW) and mdb-nsim
(for runs in simulation) runners.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-11-11 08:18:38 -05:00
Gerson Fernando Budke 3fe4c702e7 runners: bossac: Add speed argument
The current stty command uses a hard code value of 1200.  This is not
compliant with SAM-BA specs and may create compatibility problems.  Add
an optional speed argument with 115200 as default value following SAM-BA
specifications.  All boards that needs a different speed should define
board_runner_args(bossac "--speed=<value>") with value as required
speed.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-11-06 12:15:55 -06:00
Gerard Marull-Paretas e066a00d5e runners: stm32cubeprogrammer: add tests
Add tests for the stm32cubeprogrammer runner.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-11-04 14:47:35 -06:00
Gerard Marull-Paretas f98dd24993 runners: add support for stm32cubeprogrammer
Add support for the official ST Microelectronics programming tool (CLI
version).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-11-04 14:47:35 -06:00
Andy Ross 60fb850713 scripts/west_commands: Don't demand non-empty output formats
It's not clear why this error is here.  The "formats" array seems to
be limited to "bin" and "hex" only, but every signing tool is going to
have its own idea of what format to emit and what ingredients need to
be used to do that.

In particular, rimage (used for the Intel Audio DSPs) doesn't use nor
generate zephyr.bin (it's very large), so it trips over this failure.

Just present the possibly-empty list of output formats to the Signer
object and let it make the decision about whether an empty formats
list is an error.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-10-23 22:22:52 -04:00
Anas Nashif 3ac163eae6 boards: rename up_squared_adsp intel_adsp_cavs15
The Audio DSP is not specific to up_squared, so make it more generic.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-10-23 12:56:03 +02:00
Anas Nashif f751dd46b2 west: commands: sign: Add signing support for other CAVS targets
Sign for CAVS15, CAVS18, CAVS20 and CAVS25 SOCs

Originally-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-10-21 06:38:53 -04:00
Martí Bolívar f752c5eeec west build: fix --pristine on early build system failure
The west build command has historically tried not to rm -rf
directories that don't look like zephyr build directories. The way it
does this is by checking for the presence of a CMake cache
with a Zephyr-specific variable (ZEPHYR_TOOLCHAIN_VARIANT) in it.

The problem with this approach is that if the build system fails
before this cache variable is set, the directory doesn't look like a
zephyr build directory, and therefore west build won't make it
pristine even with --pristine=always, even though build directories
resulting from failed runs like that are almost certainly
irrecoverably broken and need to be made pristine before anything will
work.

This leads to users having to rm -rf their directories manually, which
is not so nice.

To avoid this from happening, just check for ZEPHYR_BASE, which is
set early on in ZephyrConfig.cmake in 'modern' zephyr build systems.
Keep the ZEPHYR_TOOLCHAIN_VARIANT check in place for compatibility.

We could consider being less selective and just using shutil.rmtree()
whenever we have --pristine=always, but that would be a bigger
behavioral change than I'm comfortable doing without a good reason.

Fixes: #28876
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-10-14 07:22:32 -05:00
Michael Hope bf04c29c26 runners: bossac: handle --help on the current git version of BOSSA
BOSSA 1.9.1 and before an errror on `--help`, but the current git
version returns 0.  Handle both cases.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-10-09 08:22:38 -05:00
Michael Hope c0055ed392 runners: bossac: calculate the offset instead of absolute address
BOSSA takes the offset within flash memory, not the absolute address.
This doesn't matter on most boards as the flash starts at zero but
does matter on the Due as the flash starts at +512 KiB.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-10-09 08:22:38 -05:00
Martí Bolívar 09b8db4088 nrfjprog.py: handle ImportError
We need to handle ImportErrors on all non-stdlib imports in the
runners package.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-10-06 07:38:58 -04:00