Add a debug-only global that prevents commands from running, and just
prints what would have been run.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Add the necessary infrastructure to the runner core to support
computing flash addresses based on the devicetree. Specifically, add:
- a new RunnerCaps capability, flash_addr, which lets runners declare
when they support flashing to an arbitrary address
- a common --dt-flash option to all runner command line parsers which
support this capability, which lets users request flash addresses to
be computed from device tree
- a ZephyrBinaryRunner helper method, get_flash_address(), which is
the common code needed to compute a flash address from device
tree (or return a default value if non-DT based flashing is
requested). This relies on the BuildConfiguration parser introduced
in an earlier patch.
Subsequent patches will use this functionality in individual runners.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
The various runners (flash/debug scripts) use environment variables to
take arguments. This is legacy behavior which is not desirable.
Use command line arguments instead.
Note: this leaves more general environment variables with publicly
documented behavior in place for now, for compatibility, e.g.:
ZEPHYR_FLASH_OVER_DFU, OPENSDA_FW, ESP_IDF_PATH, PYOCD_DAPARG
For example, when using dfu-util to flash arduino_101, instead of
setting DFUUTIL_PID, DFUUTIL_ALT, and DFUUTIL_IMG environment
variables, have the script invocation look like this:
python3 .../zephyr_flash_debug.py dfu-util flash \
[common arguments omitted] \
--pid=8087:0aba --alt=x86_app \
--img=.../build/zephyr/zephyr.bin
Make similar changes for other runners (openocd, etc.) and
targets (debug, debugserver).
To implement this in the scripts:
- have the individual scripts/support/runner/some-runner.py files
register their own command line arguments
- teach them to construct instances from arguments, not the
environment
- have zephyr_flash_debug.py request runners to register command
line argument parsers, and handle arguments
In the build system:
- add a new board_runner_args() extension function that board.cmake
files can use to add to the zephyr_flash_debug.py command line
- adjust cmake/flash/CMakeLists.txt to invoke with arguments
- add new helper include files for each runner (like
boards/common/dfu-util.board.cmake, etc.), which add default
options as needed and then add on overrides from
board_runner_args() calls
- update board.cmake files to use the new includes and extension
This implied some tweaking when using openocd to make the CMake string
escaping and unescaping work properly.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Some configuration options or device tree nodes affect the way that
runners ought to behave, but there's no good way for them to report
whether they can handle them.
One motivating example is CONFIG_FLASH_LOAD_OFFSET, as influenced by
the zephyr,code-partition chosen node in the DT for architectures
where CONFIG_HAS_FLASH_LOAD_OFFSET=y.
If CONFIG_FLASH_LOAD_OFFSET is nonzero, the 'flash' command ought to
place the kernel at that address offset from the device flash's start
address. Runners don't support this right now, which should be
fixed. However, we don't want to mandate support for this feature,
since not all targets need it.
We need to let runners declare what their capabilities are. Make it so
by adding a RunnerCaps class to the runner core. This currently just
states which commands a runner can handle, but can be generalized to
implement the above use case.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
The Python-based runners have replaced the old shell scripts. Refactor
the build system accordingly:
- FLASH_SCRIPT is now BOARD_FLASH_RUNNER
- DEBUG_SCRIPT is now BOARD_DEBUG_RUNNER
The values, rather than being the names of files, are now the names of
runners in scripts/support/runner. They are still short, descriptive
names like "openocd", "jlink", "em-starterkit", etc.
Adjust the zephyr_flash_debug.py call and runner internals
accordingly. Have each runner class report a name and the commands it
can handle. This lets us move some boilerplate from each do_run()
method into the common run() routine, and enables further improvements
in future patches.
The handles_command() method is temporary, and will be replaced by a
more general mechanism for describing runner capabilities in a
subsequent patch. The initial use case for extending this is to add
device tree awareness to the runners.
To try to avoid user confusion, abort the configuration if an
xxx_SCRIPT is defined.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Have the subclasses implement a do_run() method instead, which run()
delegates to. This will make it possible to handle common
functionality in the superclass before runner-specific methods are
called. It is a prerequisite for tasks like loading the build time
configuration to add device tree awareness.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Some of the flashing scripts try to be clever about picking unused
ports. That's convenient for the user, so add a helper class to
runner.core to accomplish similar ends portably.
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
Factor the classes which do the work into a new "runner" package. This
package has a core module where ZephyrBinaryRunner and common helpers
will live, and one file per subclass / runner front-end.
The top-level script, zephyr_flash_debug.py, still exists, but just
delegates its work to the core.
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>