Commit graph

102 commits

Author SHA1 Message Date
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
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
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
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 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 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
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
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
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
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
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
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
Øyvind Rønningstad 7012fdf0b7 nrfjprog.py: Fix snr globbing to allow leading 0s
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>
2020-08-28 11:38:05 +02:00
Øyvind Rønningstad 6cc7ea51e4 nrfjprog.py: Allow passing a glob to --snr
You can now do --snr 6*1* to achieve the same as --snr 683010000

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2020-08-14 13:32:36 +02:00
Michael Hope bb8277962d scripts: bossac: automatically pull the flash offset from the config
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>
2020-07-02 08:23:03 -04:00
Michael Hope 4ac195e0af scripts: bossac: add support for bossac 1.9.1
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>
2020-07-02 08:23:03 -04:00
Wayne Ren 7cbe5c3e18 scripts: add unit test for mdb runner
add unit test for mdb runner

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2020-06-11 10:02:11 -04:00
Wayne Ren 1506db5098 scripts: add the runner script for metaware debugger
* 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>
2020-06-11 10:02:11 -04:00
Henrik Brix Andersen 3c2984d4a9 scripts: west: add CANopen flash runner
Add west flash runner for program download via CANopen.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-05-08 10:53:42 +02:00
Alexey Brodkin 5bd2857c73 board: arc: Switch to generic OpenOCD runner
We used to use "em-starterkit" runner for ARC which is
basically heavy-modified "openocd" runner tweaked to
use GDB for loading and starting Elf files.

Now when loading and running Elf files is possible with generic
"openocd" runner we may us it. So we switch and get rid of
"em-starterkit" as well since we no longer need it.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-13 10:45:44 +02:00
Martí Bolívar 1c80d79fdd scripts: west_commands: skip bossac tests unless on linux
That's the only platform the tool is available.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-02-06 08:34:43 -06:00
Frank Li 59208ac13b runners: pyocd: add --tool-opt parameter
add --tool-opt to support more pyocd parameter

Signed-off-by: Frank Li <lgl88911@163.com>
2020-02-03 13:32:38 -05:00
Kuba Sanak c0e31e7d71 flashing: don't give bossac offset parameter unless explicitly provided
This fixes a problem which appeared after bossac version was downgraded
to 1.7 which no longer accepts the -o/--offset parameter. Now the offset
is fed to bossac executable only if it's explicitly provided and not by
default.

Signed-off-by: Kuba Sanak <contact@kuba.fyi>
2020-01-28 12:53:13 -06:00
Martí Bolívar e4768ad7e7 scripts: runners: nrfjprog: restrict when we guess snr
Right now, the nrfjprog runner will prompt the user for which board to
use if there are multiple possibilities and the --snr command line was
not given to specify one ahead of time.

Tweak this so it only happens if standard input is connected to a
terminal. This should avoid stalling the process on board farms when
this runner is used in automation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-16 10:20:39 -05:00
Martí Bolívar ae2f27cf16 scripts: runners: defer ensure_snr() to run in nrfjprog
The create() classmethod should not be doing any I/O -- its only job
is to create the ZephyrBinaryRunner instance. It's currently trying to
figure out what the serial number of the board is, though. Let's defer
that work to do_run(), so it gets handled by run_common's exception
handler.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-01-16 10:20:39 -05:00
Ioannis Glaropoulos 2293b57638 scripts: west_commands: nrfjprog: extend nrfjprog.py runner for nrf53
This commit extends the nrfjprog.py runner script so it adds
support for nRF53. In the wake of the changes done in the
runner script, we extend the testing done in test_nrfjprog.py,
adding the required coverage for the nRF53.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-11-08 19:26:35 +01:00
Martí Bolívar 50df6f3734 scripts: runners: sort runner lists
This should help avoid merge conflicts in the future.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 17:31:53 -08:00
Martí Bolívar 07a40cbbcf scripts: runners: add misc-flash runner
Some boards require specific sequences of commands to run which aren't
generally useful for other boards. Add a catch-all runner to handle
these cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 17:31:53 -08:00
Thomas Kupper ef0e3ed31d west: runner: add support for stm32flash runner
Add stm32flash runner and 8 stm32flash runner tests

Signed-off-by: Thomas Kupper <thomas.kupper@gmail.com>
2019-11-05 15:02:53 -05:00
Daniel Leung fca4ead397 west: add flash runner for DediProg
This adds a flash runner for DediProg using the dpcmd command.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-11-03 12:30:45 +01:00
Rihards Skuja 6b9f0df7da runners: pyocd: add --telnet-port parameter
With multiple debug probes attached, attempting to launch multiple debug
servers resulted in "OSError: [Errno 98] Address already in use" despite
explicitly setting --gdb-port to unique values.

The issue was caused by the default telnet port: 4444. Adding
--telnet-port parameter allows to explicitly define the address to a
unique value and avoid the socket exception.

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2019-10-03 19:19:39 -05:00
Marti Bolivar f7a4275328 scripts: west flash: fix --board-id for pyocd
Newer pyocd versions (specifically the 0.21.0 we have in our
requirements.txt) no longer support -b and have moved the same option
to -u. Keep up.

Fixes: #17554
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-19 11:03:03 +02:00
Marti Bolivar 08e0d1ff46 scripts: runners: improve hex file detection and output
This is a band-aid to make it more obvious to potential users of 'west
sign' and 'west flash' which hex file they are flashing, when they are
falling back on a binary file, and erroring out when a hex file does
not exist.

Fixes: #18201
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-16 18:42:41 +02:00
Marti Bolivar 7118d084c9 scripts: un-break test_nrfjprog.py
The pytest.raises context manager is now returning an ExceptionInfo
whose str() doesn't contain the str() of the underlying exception
object. Take str(e.value) directly to make sure we're looking at the
exception string.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-05 15:17:45 +02:00
Marti Bolivar ddce583ca2 scripts: west_commands: decouple runners pkg from west
I've had some requests to be able to use code in the runners package
without having west installed.

It turns out to be pretty easy to make this happen, as west is
currently only used for west.log and some trivial helper methods:

- To replace west log, use the standard logging module
- Add an appropriate handler for each runner's logger in
  run_common.py which delegates to west.log, to keep
  output working as expected.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-26 01:25:54 +02:00
Marti Bolivar c24e044c6e scripts: runners: check for required programs
Add self.require() checks before running commands. Increase test
coverage, including for this feature, while we are here.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-17 15:06:21 +02: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 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
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
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
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