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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
#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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Inspect the hex file with intelhex, and fail if the hex file has any
contents in the UICR area(s).
family == 'NRF52' still always does --sectoranduicrerase, but this
option is not available on other families.
Add --force command line option to proceed with flashing instead of
failing.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
Commit 3124c02 ("cmake: flash/debug: refactor runner configuration")
changed the way the hex_file and elf_file inputs in the RunnerConfig
object are created. In particular, they are now host-style paths.
This breaks flashing with openocd on Windows, which doesn't handle that
properly. Fix that by "casting" the internal hex_file and elf_file
attributes to POSIX paths.
Fixes: #28138
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
I've repeatedly seen that people are not aware of the existence of
this configuration option.
I've been using build.pristine=auto daily for years and never had any
problems. I've also asked around on Slack a couple of times over
various points to see if anybody objects to making this change. Nobody
has, so let's just turn it on by default.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit message is a bit of a novel mostly:
- because the issues involved are longstanding
- as evidence this is not a capricious refactoring
The runners.core.RunnerConfig Python class holds common configuration
values used by multiple runners, such as the location of the build
outputs and board directory.
The runners code, first written in 2017-ish, replaced various shell
scripts that got this information from the environment. Avoiding
environment variables was a requirement, however. It's ghastly to set
environment variables for a single command invocation on Windows, and
the whole thing was part of a larger push to make Zephyr development
on Windows better.
I had a hammer (the argparse module). Finding a replacement naturally
looked like a nail, so the information that ends up in RunnerConfig
got shunted from the build system to Python in the form of 'west
flash' / 'west debug' command line options like '--board-dir',
'--elf-file', etc.
I initially stored the options and their values in the CMake cache.
This was chosen in hopes the build system maintainer would like
the strategy (which worked).
I knew the command line arguments approach was a bit hacky (this
wasn't a nail), but I also honestly didn't have a better idea at the
time.
It did indeed cause issues:
- users don't know that just because they specify --bin-file on the
command line doesn't mean that their runner respects the option, and
have gotten confused trying to flash alternate files, usually for
chain-loading by MCUboot (for example, see #15961)
- common options weren't possible to pass via board.cmake files
(#22563, fixed partly via introduction of runners.yaml and the west
flash/debug commands no longer relying on the cache)
- it is confusing that "west flash --help" prints information about
openocd related options even when the user's board has no openocd
support. The same could be said about gdb in potential future use
cases where debugging occurs via some other tool.
Over time, they've caused enough users enough problems that
improvements are a priority.
To work towards this, put these values into runners.yaml using a new
'config: ...' key/value instead of command line options.
For example, instead of this in the generated runners.yaml file:
args:
common:
- --hex-file=.../zephyr.hex
we now have:
config:
hex_file: zephyr.hex
and similarly for other values.
In Python, we still support the command line options, but they are not
generated by the build system for any in-tree boards. Further work is
needed to deprecate the confusing ones (like --hex-file) and move the
runner-specific host tool related options (like --openocd) to the
runners that need them.
Individual board.cmake files should now influence these values by
overriding the relevant target properties of the
runners_yaml_props_target.
For example, instead of:
board_runner_args(foo "--hex-file=bar.hex")
Do this:
set_target_properties(runners_yaml_props_target PROPERTIES
hex_file bar.hex)
This change additionally allows us to stitch cmake/mcuboot.cmake and
the runners together easily by having mcuboot.cmake override the
properties that set the hex or bin file to flash. (The command line
arguments are still supported as-is.)
Combined with 98e0c95d91ae16f14e4997fb64ccdf0956595712 ("build:
auto-generate signed mcuboot binaries"), this will allow users to
build and flash images to be chain loaded by mcuboot in a way that
avoids calling 'west sign' and passing 'west flash' its output files
entirely.
While we are here, rename runner_yml_write to runners_yaml_append().
This function doesn't actually write anything, and we're here
refactoring this file anyway, so we might as well improve the
situation while we're at it.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The 'runner_config' variable name is particularly misleading because
there is a class called RunnerConfig, and that variable does not
contain one.
Rename it to 'runners_yaml' since it contains the parsed contents of
the runners.yaml file. Rename the variable that refers to the path
itself to 'runners_yaml_path'. No functional changes expected.
This is prep work for redoing how actual RunnerConfig objects get
made.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Before venturing off into refactoring land, let's make sure we have a
type checker running on the main APIs used by the various runners so
we don't miss anything obvious.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Use mypy to type check the runners package.
The test procedure is now annoying enough to replicate locally that
I'm going to wrap it in a script. Do this for both UNIX and Windows
environments by writing that script in Python.
Keep the GitHub workflow up to date so we now get mypy results in CI.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is needed for sanitycheck hardware maps which take the serial
number directly from USB metadata.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
When MCUBoot is built using the swap-move strategy, the secondary slot
can be one sector smaller than the primary slot, because the primary
slot's last "useful" image sector must be "reserved" for the move
operation; this impacts the generation of padded images, so when
signing an image, the proper size to use is the secondary slot's,
unless a secondary image is not defined which is the case when using
single image DFU.
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
Add support for the J-Link Commander "-NoGui 1" command line parameter
in the West J-Link runner.
This command line parameter suppresses GUI dialogs (except for license
dialogs) in J-Link Commander starting from v6.80.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
If a runner supports the --erase option, make it so that the user can
add --no-erase to the command line to explicitly disable it.
Add a diagnostic at info() level whenever this option is requested.
The intent of this commit is to make it more obvious when a mass erase
was requested, especially in situations (like MCUboot with
CONFIG_MCUBOOT_TRY_MASS_ERASE=y) where this option may be turned on by
default.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fixes: #27375
This is a cleanup of the Zephyr CMake package export.
The code has been simplified so that the export now happens through a
CMake script. This avoids several generated CMake build files compared
to previous export mode, and thus removes the need for a CMake pristine
script.
A benefit of this cleanup is that it also fixes#27375.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Avoid use of the cached_runner_config() helper, which we have a TODO
item to get rid of. Adjust the output and do some other minor
improvements.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Rolling yet another parser turns out to be the best way to let west
extensions respond to Kconfig values. See source code comments in the
patch for details.
The sanitylib library has some similar functionality but it isn't
exactly the same, and it gets strings wrong. For example, that parser
can't handle this option:
CONFIG_FOO="he said \"no\" to me"
This one can, and it has a couple of other features we'll find useful
for west extensions eventually besides.
(Not to mention that sanitylib also rolled its own CMake cache parser,
which also exists in west_commands.)
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Consolidate creation of edtlib.EDT objects from a build directory's
devicetree into one place by loading it from build/zephyr/edt.pickle
everywhere. A previous commit creates edt.pickle from gen_defines.py.
In addition to probably speeding things up slightly by not reparsing
the devicetree, the main benefit of this approach is creating a single
point of truth for the bindings directories and warnings
configuration, meaning we don't have to worry about them getting out
of sync while being passed around between devicetree creation and
usage time.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The `TEXT_SECTION_OFFSET` symbol is used to specify the offset between
the beginning of the ROM area and the address of the first ROM section.
This commit renames `TEXT_SECTION_OFFSET` to `ROM_START_OFFSET` because
the first ROM section is not always the `.text` section.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
When running CMake, then Python3 will be used.
This is detected through FindPython3, with a preference for using the
python or python3 in path, if any of those matches the required Python
minimal version in Zephyr.
It is also possible for users to specify a different Python, as example
by using:
`cmake -DPYTHON_PREFER=/usr/bin/python3.x`
However, when running `west` as native command, then west will be
invoked on linux based on the python defined in:
`west` launcher, which could be: `#!/usr/bin/python3.y`
Thus there could be mismatch in Pythons used for `west` and the python
used for other scripts.
This is even worse on windows, where a user might experience:
```
>.\opt\bin\Scripts\west.exe --version
Traceback (most recent call last):
File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
...
File "C:\Python37\lib\socket.py", line 49, in <module>
import _socket
ImportError: Module use of python38.dll conflicts with this version of
Python.
```
when testing out a newer Python, but the python in path is still a 3.7.
By importing `west` into zephyr_module.py and by using, as example
`python -c "from west.util import west_topdir; print(topdir())"`
we ensure the same python is used in all python scripts.
Also it allows the user to control the python to use for west.
It also ensures that the west version being tested, is also the version
being used, where old code would test the version imported by python,
but using the west in path (which could be a different version)
If the west version installed in the current Python, and west invocation
is using a different Python interpreter, then an additional help text
is printed, to easier assist users with debugging.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
BOSSAC uses a bootloader, so pull the flash address from DeviceTree or
the config and use if the version of BOSSAC supports offsets.
Signed-off-by: Michael Hope <mlhx@google.com>
BOSSA 1.7 has built-in bootloader offset handling while 1.9.1
requires the user to supply the offset. Add support for both by
sniffing the help output and warn the user if the flags needs adding.
Related to #22062
Signed-off-by: Michael Hope <mlhx@google.com>
This commit creates a list of a phony targets for each runner, that is:
`west_flash_depends`, `west_debug_depends`, and so on.
Those targets has identical dependencies as CMake runner target.
flash, debug, debugserver, attach targets.
As example `ninja flash` correctly ensures dependencies are taken into
consideration before calling `west flash`.
Unfortunately, calling `west flash` directly would not re-run the flash
dependencies, cause `west flash` would only build the default CMake
target.
Now, `west flash` calls the phony `west_flash_depends` target, ensuring
all deps are up-to-date before flashing (unless --skip-rebuild is given)
The same is true for the other mentioned runners.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Just changes to the west help output; no functional changes expected.
Make option descriptions lowercase to match the argparse module's
conventions. When multiple sentences are required, move them to parser
prolog/epilog or argument group description sections.
Clarify some points that have confused multiple people.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Move the --erase option to core.py from nrfjprog.py and jlink.py,
where it is currently supported.
Using the RunnerCaps option enforcement mechanism introduced earlier,
enforce that it will only be given to runners that support it.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Require all implementations to provide a do_create(), a new
ZephyrBinaryRunner abstract class method, and make create() itself
concrete.
This allows us to enforce common conventions related to individual
runner capabilities as each runner provides to the core via
RunnerCaps.
For now, just enforce that:
- common options related to capabilities are always added, so runners
can't reuse them for different ends
- common options provided for runners which don't support them emit
sensible error messages that should be easy to diagnose and support
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
We can just call super() instead of super(MyClassName, self). The
original extra verbosity is likely due to old habits of mine from
Python 2 which are no longer necessary, but got copy/pasted around.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The argparse module, by default, complains about non-defined
arguments. This prevents passing arguments prefixed with '-'
or '--' to the target script (e.g. calling another Python
script using argparse). This changes the misc-flasher script
so that any arguments not recognized by west will be passed
to the target script.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The start_addr attribute of Stm32flashBinaryRunner is an integer. It
must be converted to a string before being concatenated with a colon and
the (already converted to a string) size to erase or write.
Signed-off-by: Grzegorz Szymaszek <gszymaszek@short.pl>
Disables the Debug-Access-Port of the microcontroller after flashing.
If not disabled, the DAP consumes ~1.6mA until the debugger disables it
or a hard power cycle is applied.
The DAP is typically automatically disabled after flashing, but if other
instances of JLink software are running (not connected), it will not be.
The added command resets the value of the CTRL/STAT register of the DAP.
This clears the CSYSPWRUPREQ and CDBGPRWUPREQ bits, leaving the debug
hardware free to power off the appropriate hardware. In no way does it
hinder the ability to later connect to the device for debugging.
This resolves the jlink portion of #26139
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
* add the runner script for metaware debugger(mdb).
* mdb is required for SMP case
* mdb also can provides a GUI interface
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Catch ImportError whenever a non-standard module import fails from any
runners that do one. Complain at runtime about it if the user actually
needs the runner.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
OSX compatibility added bossac runner.
Linux behvaiour is unchanged.
Window is now explicity mentioned as incompatible
Signed-off-by: Brendon Le Comte <brendon.lecomte@gmail.com>
In case of flashing (which is typically used with OpenOCD)
we do reset of the target after programming application binary
in the non-volatile memory.
In case of Elf execution we need to reset the target before
loading Elf sections so that we might be sure our target
is in sane & expected state before we start execution.
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
The variables with the STATIC type aren't read.
The commit 877fc59e30 introduce the read of CMAKE_PROJECT_NAME
which could be defined in CMakeCache.txt file like that:
CMAKE_PROJECT_NAME:STATIC=MyProject
If STATIC type is not managed, the CMAKE_PROJECT_NAME isn't set and
CMake is always force to run again
Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
Fix two issues:
1. The script assumes the default CMake generator build tool
platform is installed. On Linux at least, that's Make instead
of Ninja, but Make might not be installed since Zephyr recommends
Ninja. On Windows, that might be VS Code or nmake.
Calling `cmake -P pristine` instead of `cmake --build <path>
--target pristine` has the benefit of removing the dependency on a
build command, and hence the default generator is not relevant.
2. It also assumes run_cmake() returns control, and therefore pristine
can be run.
However, if the cmake command fails hard (say, due to issue #1
before this patch), run_cmake() throws an exception instead.
Fix that by trying to run the pristine target in a finally block
instead, and adding some manual cleanup steps in case the build
system is in a bad state and pristine fails too.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
If there is an error in the CMake configuration phase (this can happen
if a script run using execute_process() fails, for instance), the
build system is incompletely generated and future attempts to run
'west build' will fail. This manifests in the following error:
Error: could not find CMAKE_PROJECT_NAME in Cache
Whenever we see that the cache exists but this variable is missing,
let's just force CMake to run again. This avoids the error in my
testing and is a bit more user friendly. I've seen multiple users
asking what to do in this situation; the answer is always "just build
it again", so we might as well do it for them.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The board name for the nRF52 DK, so far known as nrf52_pca10040, is
renamed to nrf52dk_nrf52832. Its documentation and all references
to its name in the tree are updated accordingly. Overlay and
configuration files specific to this board are also renamed, to
match the new board name.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixes: #23872
Relocating Zephyr Unittest CMake package to ensure that
HINTS ${ZEPHYR_BASE} in
find_package(ZephyrUnittest HINTS ${ZEPHYR_BASE}) works correctly when
the package has not been exported to CMake user package registry.
This ensure that the new package functionality is fully backwards
compatible on systems where the package is not exported and ZEPHYR_BASE
is set.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit includes the following fixes in order to remove environment
setting of ZEPHYR_BASE is west extension commands.
- Build command
west build --pristine will now use the ZEPHYR_BASE variable found
in CMakeCache.txt in the build folder.
This ensures that the pristine command is executed from the same
Zephyr that was used for compilation.
- Board command
The west boards command no longer sets Zephyr base before invoking
cmake -P cmake/boards.cmake
Instead boards.cmake uses find_package(Zephyr) to ensure consistent
behavior with Zephyr samples, so that the detection of Zephyr base is
uniform across CMake commands.
It also changes BOARD_ROOT_SPACE_SEPARATED to BOARD_ROOT in order to
be consistent with existing user documentation.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This command make it possible to use west for first time registration
of a Zephyr config package in CMake.
To register Zephyr as a CMake config package, invoke:
west zephyr-export
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Originally reported in #23539 (though that seems to have been another
problem), west flash and friends are dumping stack when used with an
unconfigured runner.
Let's just promote the warning about this to an error. The idea that
this ever could have worked without explicit support has not worked
out in practice, to my knowledge.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The header printed at the beginning of every west build is kind of
annoying. Let's remove it and just print the application source
directory at cmake time instead. The build directory and board are
already printed there, anyway, and that's all IDE users will see.
Let's clean up the BOARD to make it say "board" instead. That matches
the west build --board option name a bit more closely and is still
legible.
Likewise, let's not print any west build messages if we're just
incrementally recompiling. That's noisy.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
When checking build directory against cache on windows, certain
corner cases can end up failing the comparison because of case
difference on an otherwise identical path. This can be avoided
by ignoring case on windows.
Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
The 'command' command line argument for this flasher is now being
overridden by common code, which attaches the west subcommand name to
this.
Let's just hotfix this by renaming the argument in misc-flasher.
We can revisit the boundary between run_common.py arguments and
runners package arguments after the release.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Try to make it clearer what's going on here.
Suggested-by: Lucian Copeland <hierophect@gmail.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is yet another bug introduced by the move to runners.yaml.
Sigh. I should have tested this better.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This will also make the reason for a following bug fix easier to see.
Update a comment block to include all the work that needs doing.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>