Commit graph

542 commits

Author SHA1 Message Date
Marti Bolivar 1f5e6d897f scripts: add --cmake-only to west build
This forces CMake to run, but skips running any build system target
afterwards.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-06 16:30:05 -04:00
Marti Bolivar 88fb8bacfb scripts: improve west build's board handling
- Respect the BOARD environment setting.
- Don't require --force if the board can't be figured out: it might be
  set in CMakeLists.txt, for example. Instead, downgrade to a warning
  which can be disabled with "west config build.board_warn false".
- Add a build.board configuration option used as a final BOARD fallback
  after CACHED_BOARD (in the CMake cache), --board (command line), and
  BOARD (environment).
- Keep the config docs up to date.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-06 16:30:05 -04:00
Marti Bolivar d15950353d scripts: add helpers to west build for getting config options
These will be used more in a later patch.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-06 16:30:05 -04:00
Marti Bolivar 69099e3d99 scripts: flake8 cleanup for west build
Clean up coding nits to match west's style.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-06 16:30:05 -04:00
Marti Bolivar acda25716a west: build: use CMAKE_HOME_DIRECTORY to locate source
Rather than relying on APPLICATION_SOURCE_DIR to be in the cache, just
use CMAKE_HOME_DIRECTORY instead.

https://cmake.org/cmake/help/latest/variable/CMAKE_HOME_DIRECTORY.html

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-06 16:30:05 -04:00
Marti Bolivar 4dbf5f1535 scripts: fix and tweak west boards
- This script didn't get fixed when cmake.py was renamed zcmake, so it
  won't run; fix that.
- Change the default format string to '{name}' to keep things simple
- Flake8 lint

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-05-06 16:30:05 -04:00
Maureen Helm fe4b1ff0c3 boards: rv32m1_vega: Use different openocd config file for each core
Adds a new argument to the openocd runner to optionally specify the
config file. Updates the rv32m1_vega board to use different openocd
config files for the ri5cy and zero-riscy cores.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-05-06 14:52:17 -05:00
Carles Cufi 851fa12d51 west: boards: Use the new zcmake module name
Switch to the recently renamed zcmake module when importing the
run_cmake function.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-05 12:58:22 +02:00
Carles Cufi c9f4bb6799 west: build: Construct CalledProcessError with positional args
Since west's main.py relies on the args tuple with the returncode
and the cmd, create the CalledProcessError using the correct
positional args.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-04 20:59:15 +02:00
Jan Van Winkel 4d975dba79 west: Renamed cmake.py to zcmake.py
Renamed cmake.py to zcmake.py to prevent import conflict if cmake is
installed through pip.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-05-04 16:40:06 +02:00
Carles Cufi d6f033e690 west: Add a boards command
Add a new "boards" command that is able to list all the boards in the
upstream tree. There is currently no support for out-of-tree boards.

The command executes cmake to use the built-in CMake script,
boards.cmake, to list the boards, and then stores the information
retrieved and allows the user to present it in a user-definable format.

Fixes https://github.com/zephyrproject-rtos/west/issues/53

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-03 21:55:13 +02:00
Carles Cufi 31bdad5299 west: Implement CMake helpers in scripts/west_commands
Move the existing CMake and build functionality from the west repository
to zephyr. The rationale behind this move is that it's very tightly
coupled with the Zephyr build system and is only used by the extension
commands implemented in the zephyr tree.
If additional extension commands in third-party repos want to use the
functionality they can add $ZEPHYR_BASE/scripts/west_commands to the
Python system path.

The implmentations in the west repo will be deprecated.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-05-03 21:55:13 +02:00
Maureen Helm d6d1e27a97 scripts: west_commands: Print error message when jlink exe not found
Adds a check in the jlink runner to look for the jlink executables and
print a more useful error message if they are not found.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-05-02 22:50:55 -04:00
Carles Cufi 3a88dce9c5 scripts: west: Run pristine.cmake directly instead of the target
When making a build folder pristine until now we were running the
'pristine' build target. The issue with that is that ninja/make or
whatever build tool is being used might decide to re-run CMake itself if
some of the dependencies have changes. This might trigger an error that
is unfriendly and unnecessary, since the user is explicitly asking for
the build folder to be wiped before starting a fresh build.
To avoid this issue restor to running directly the CMake script that the
'pristine' build target itself uses, so as to make sure that the build
folder is wiped unconditionally regardless of changes made to the tree.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-04-23 13:24:41 -07:00
Carles Cufi b7c75915e0 west: build: Add new pristine cmd-line and config option
Add a new command-line and build config option, `pristine`, that the
user can pass to `west build` or set in its configuration file(s) in
order to automatically trigger a pristine build on every build or
whenever west considers it required.

The option can take the following values:

- never: Never run the target
- always: Always run the pristine target before building
- auto: Run the pristine target when required

With `auto`, the pristine target will be run when running
west with an existing build folder containing a build system and:

- Selecting a different board from the one currently in the build system
- Selecting a different application from the one currently in the build
  system

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-04-17 10:02:46 -04:00
Carles Cufi 3c6584d6d5 west: build: Use officially documented CMake options
The -B option has always existed but was first officially documented in
CMake 3.13.0. In that same release the -S option was introduced,
replacing the old undocumented -H. Switch to using the officially
documented options.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-04-17 10:02:46 -04:00
Ulf Magnusson d5b0bd14e3 scripts: Remove unused imports in all Python scripts
Discovered with pylint3.

Upstream open-amp PR: https://github.com/OpenAMP/open-amp/pull/168

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-28 11:06:20 -05:00
Ulf Magnusson ba312fe844 scripts: Remove unnecessary () around if/while conditions in Python
Not needed in Python. Detected by check C0325 in pylint3.

Also replace an

  if len(tag):

with just

  if tag:

Empty strings, byte strings, lists, etc., are falsy in Python.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-26 07:59:59 -05:00
Ulf Magnusson 5c8fd84d12 scripts: Remove extra trailing newlines from Python scripts
Fixing all instances so that it can be flagged in a pylint CI check
later.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-26 07:53:08 -05:00
David B. Kinder 6000a6205a doc: prepare for improving doc API linking
Linking to API material requires knowing the pecularities of how
doxygen, sphinx, and breathe work. In an attempt to hide some of this
we're preparing the current docs to allow use of configuration defaults
that will let us more simply use a default role that will hunt for a
reference target in the various domains that are available by using a
default "role" of "all".  This will let us use the simple notation
`functionname` or `typename` without fully specifying the reference as
:c:func:`functionname`.

This patch cleans up exising docs that were (incorrectly) using single
backtics where double backtics should have been used, and also found
some typos (such as a space between the role name and the reference,
such as :file: `filename`, and a missing colon such as
c:func:`functionname`)

This is a start to address issue #14313

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-03-15 05:47:19 +01:00
Carles Cufi c5daabe190 west_commands: pyocd: Sector erase by default
Due to issues with the implementation of the default auto-erase in
pyocd, sometimes the chip is mass-erased even when not intended. To
avoid this issue, default to forcing sector erasing unless mass erasure
is explicitly requested by the user with additional flash options.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-03-12 16:52:14 +01:00
Carles Cufi b710177a27 west: commands: build: Specify source dir without a flag
In order to simplify the usage of `west build`, take a positional
argument with the source directory instead of requiring the `-s,
--source-dir` flag. This makes it easier and quicker to invoke west when
building, as well as being consistent with CMake.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-03-08 21:19:42 +01:00
Marti Bolivar 4a0f1f2817 west: sign.py: usability fixes
Fix some usability issues with this command.

- add help making it clear that either imgtool must be installed, or
  the path to imgtool.py must be provided using --tool-path.

- in case people don't read that, print a helpful message if imgtool
  is not installed and --tool-path is not provided.

- in case the build directory is not properly set up for an MCUboot
  chain-loaded image, make the BuildConfiguration inspection more
  robust, printing out errors using check_force() when values are
  missing.

- mark the --tool option required to print usage and avoid a
  RuntimeError if it is not provided.

- make sure we search for the default build directory before checking
  for its existence, in case it was not provided

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-15 21:07:10 +01:00
Marti Bolivar f13fa537d7 west: fix issue with sign.py
The arguments have to be saved in self.args for check_force's error
path to work.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-15 21:07:10 +01:00
Kumar Gala 3de6de305f west: sign: Convert FLASH_WRITE_BLOCK_SIZE to DT_
Use DT_FLASH_WRITE_BLOCK_SIZE prefixed defined instead of
FLASH_WRITE_BLOCK_SIZE as the non-DT version is deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Kumar Gala 65cd010fc1 west: sign: Convert FLASH_AREA to DT_FLASH_AREA
Use DT_FLASH_AREA prefixed defined instead of FLASH_AREA as the non-DT
version is deprecated.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 22:39:07 -06:00
Carles Cufi acc82cee00 scripts: west: Tweak west build doc
Clarify what "being in a build directory" exactly means.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-02-08 14:58:28 -05:00
Michael Hope bde3224c91 scripts: bossac: Support flashing at an offset.
The Adafruit SAMD51 boards use a combined BOSSA / U2F bootloader that
resides in the first 16 KiB.  Add support for pulling the application
partition offset from the configuration and using that to offset where
the binary gets flashed.

Signed-off-by: Michael Hope <mlhx@google.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-07 15:13:11 -05:00
Marti Bolivar d1780aac42 scripts: west_commands: add sign command
This command is useful for signing binaries for loading by a
bootloader. At present, only MCUboot's "imgtool" is supported, but it
would be straightforward to add support for additional tools.

Using this command instead of "plain" imgtool avoids looking up any
numbers for the flash write block size, text section offset, or slot
size to get a signed binary. All users need to specify is the location
of the signing key.

This greatly improves usability for those unfamiliar with MCUboot, or
even experienced users who have to deal with multiple flash partition
layouts, boards, etc.

The command works by inspecting state in the Zephyr build system, some
of which is also provided by the runner package.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-07 08:44:19 -05:00
Marti Bolivar 8c095285d1 scripts: west_commands: refactor run_common.py
Pull out some more common functionality we will need elsewhere into a
separate file.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-07 08:44:19 -05:00
Marti Bolivar 8c4479994c scripts: west_commands: refactor build.py
This is a prep work patch for adding another command.  Refactor
build.py to use a new Forceable superclass and find_build_dir() helper
routine. Fix a help string while we are here.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-07 08:44:19 -05:00
Timon Baetz 4cc355d423 boards: hifive1: Added flash runner
HiFive1 flash runner using OpenOCD and GDB

Signed-off-by: Timon Baetz <timon.baetz@gmail.com>
2019-02-05 14:29:16 -06:00
Maureen Helm 987313e102 scripts: west: Update pyocd runner to use unified tool subcommands
pyocd 0.14.0 merged its command-line tools into a unified pyocd tool
with subcommands. The separate command-line tools still remain, but are
deprecated. Update the pyocd runner to use the new unified pyocd tool
with subcommands.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-02-02 10:32:30 -05:00
Carles Cufi 109f80f142 west: runners: nrfjprog: Enable testing of nRF91
Enable the nRF91 suite of tests.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-30 20:16:27 +01:00
Carles Cufi 13ce9d94b9 west: runners: nrfjprog: Correct nRF91 unit test reference data
nRF91 only does `--sectorerase` (no UICR) and does not need to
enable pin reset (`--pinresetenable`).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-30 20:16:27 +01:00
Ioannis Glaropoulos a97dbec8c1 scripts: west: explicitly ask for --sectorerase for nRF9160_pca10090
When flashing nRF9160_pca10090 board with nrfjprog, explicitly
request for --sectorerase, instead of --sectoranduicrerase (used
when flashing boards with nRF52 SOC).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-01-30 20:16:27 +01:00
Marti Bolivar 808028b46f scripts: west commands: add text for "west --help"
Although each of these command implementations has good output for
"west <command> --help", the "west --help" output is missing the
one-line descriptions.

Add them by modifying west-commands.yml to use a new 'help' key in
each command name. These need to be kept in sync with the Python
sources. For now just do that by copy/pasting. We could add fancy
logic to load the help from west-commands.yml later if we want.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-29 10:15:01 +01:00
Marti Bolivar ecae1e9b17 west_commands: add information on running tests
Add information to the README on how to run the tests, and note that
they are part of Zephyr's CI.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-29 10:15:01 +01:00
Carles Cufi 89ee604836 scripts: west: Add support for nRF91 in nrfjprog
Extend the list with the new nRF91 SoC.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-01-29 10:15:01 +01:00
Carles Cufi 6b00bc9357 west: Multiple CI fixes for the topic-west branch
In order to be able to merge the topic branch, we require a few
fixes to CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-29 10:15:01 +01:00
Marti Bolivar 63841df184 scripts: run_ci.sh: add pytest-based testing for west commands
Incorporate these into run_ci.sh the same way that btsim results were
done. This adds a dependency on pytest.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-29 10:15:01 +01:00
Marti Bolivar ab82264ace scripts: add west build, flash, and debug commands
West now supports a mechanism for extension commands. Use it to move
the command implementations that are tightly coupled with boards and
the zephyr build system back into the Zephyr repository.

This patch doesn't include test cases. Those will be moved over in a
subsequent patch.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-01-29 10:15:01 +01:00