Commit graph

20 commits

Author SHA1 Message Date
Martí Bolívar
f8e8e9229d runners: enforce RunnerCaps via create() indirection
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>
2020-06-25 12:14:25 +02:00
Martí Bolívar
7b93bd54d4 scripts: runners: clean up super() calls
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>
2020-06-25 12:14:25 +02:00
Martí Bolívar
0b5c58fcab scripts: runners: handle uninstalled dependencies
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>
2020-05-09 13:05:48 +02:00
Alexey Brodkin
0d5416acc4 runners: openocd: Reset target before running Elf
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>
2020-04-24 19:35:25 +02:00
Alexey Brodkin
83b346edef runners: opeocd: Allow loading Elf-files
In some cases especially for on-going development & debugging of real
application it might be useful to load and run not from flash but
from RAM in that case there's one catch: we cannot reset the board
after loading memory with our app.

That's because:
 a) RAM we use might be either cleared on reset or might enter
    unpredictable state with portion of previously loaded data
    being corrupted.
 b) Reset vector most probably still point to ROM/flash and so
    our current application won't be executed on reset.

So instead of "run reset" command of OpenOCD we'll use
"resume 0x12345678". Where 0x12345678 is our application's
entry-point (which BTW may very well not match beginning of
the .text section or link base).

Now to extract the entry-point we need our application's zephyr.elf
and since we already have a requirement for Elf we may use it for
loading because OpenOCD does it perfectly fine moreover automatically
detecting loaded image type (binary, hex, Elf etc).

And to use that nice feature just add "--use-elf" to west's
command-line for boards that use "openocd" runner. Like that:
----------->8--------------
west flash --use-elf
----------->8--------------

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-13 10:45:44 +02:00
Alexey Brodkin
5a4237ed3b west: openocd: Allow to specify FTDI instance by its serial number
To be used in setups with multiple boards attached to the same one
host we need to have an ability to specify precisely which JTAG probe
to use for a particular board.

This is done by passing "ftdi_serial XXX" command to OpenOCD.
And the serial ("XXX") is supposed to be passed from higher level,
typically via west's options. And exactly for that we add another
"openocd" runner option "--serial=XXX" which sets
a Tcl's "_ZEPHYR_BOARD_SERIAL" variable that later gets passed
to OpenOCD's "ftdi_serial" command.

See more discussions on the matter here:
https://github.com/zephyrproject-rtos/zephyr/issues/22543

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-02-13 10:45:44 +02:00
Rihards Skuja
f59b92b3ee runners: openocd: don't throw when no config is provided
In some cases the config is already provided for us e.g. when setting
OPENOCD_NRF5_SUBFAMILY. Also it looks like config was always supposed to
be optional (there are checks for it on do_run()).

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2020-01-23 10:38:57 -05:00
Christian Taedcke
cac5e8f251 west: openocd: Add config file dir to search path
Use the folder the config file is in as an additional search directory
for openocd. This way additional files, like custom debug interface
files can be put in the support folder of a board and the openocd.cfg
can use them.

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2019-12-09 12:46:10 -05:00
Anas Nashif
c724033acc west: prepend -c to openocd commands
commit 0df4a53107 changed the behavior of
how openocd commands are passed to openocd. We used to add -c to each
command, now the commands are being added without -c causing an error.

This adds "-c" to all commands instead of just passing a list.

Also fixes #20449.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-12 14:37:34 -05:00
Martí Bolívar
0df4a53107 scripts: runners: new openocd fixes and features
Let the user specify these arguments as many times as they want:

--cmd-pre-init
--cmd-pre-load
--cmd-post-verify

This makes it a bit easier to handle scripts that need to do a few
things in a row depending on conditions.

Handle --cmd-pre-init and the port arguments properly in the debug
related targets.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 21:15:39 +01:00
Martí Bolívar
23a5bcc7cc scripts: runners: make $BOARD_DIR/support/openocd.cfg optional
I'd like to support nRF boards in a more generic way, so make it
optional. We can clean up the STM32 files later if there's a lot of
overlap in their .cfg files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 21:15:39 +01:00
Martí Bolívar
c82e8f8923 scripts: runners: whitespace cleanups for openocd.py
This line is meaningless and exists to pacify a commit linter.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-11-06 21:15:39 +01:00
Anas Nashif
b61f86d2c0 west: openocd: support pre init command option
With ST boards it is possible to specify the board ID when flashing using
openocd. This is very useful when having multiple devices connected.

This change allows us to address a device directly:

west flash -- --cmd-pre-init  "hla_serial 066BFF535254887767174558"

This needs to be called before init, hence the new option.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-02 21:44:16 -04: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
Kumar Gala
c484935fe5 scripts: openocd: Add error if hex file is missing when flashing
Add a check to make sure the hex file exists as that is what we utilize
in openocd to flash.  If its missing we report that its likely due to
not having CONFIG_BUILD_OUTPUT_HEX set.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-08-14 07:55:10 -05:00
Marcin Niestroj
b08adcdd7e scripts: openocd: use hex file for flash command
Use hex file for flash command, instead of elf file. This allows to
flash signed firmware, which is not available in elf format, by
specifying --hex-file command line argument.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-08-08 22:16:50 +02:00
Marcin Niestroj
6778468c73 scripts: openocd: allow to overwrite elf file used to flash device
So far zephyr.elf file was hardcoded in cmake files. Remove it from
there and use cfg.elf_file from python, which can be overwritten by
specifying --elf-file command line option.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-08-08 22:16:50 +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
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
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