zephyr/scripts/meta/west/cmd/flash.py

26 lines
701 B
Python
Raw Normal View History

scripts: west: add flash, debug, debugserver commands When run without any arguments, the commands work the same way that their CMake equivalents do. For example, if using the Ninja CMake generator, these are equivalent: west flash <----> ninja flash west debug <----> ninja debug west debugserver <----> ninja debugserver Like CMake's build tool mode, you can also run them from any directory in the system by passing the path to the build directory using --build-dir (-d): west flash -d build/my-board The commands will run the CMake-generated build system, so they keep dependencies up to date and users don't have to manually compile binaries between running CMake and using this tool. The commands also support important use cases that CMake can't: 1) Any arguments not handled by 'west flash' et al. are passed to the underlying runner. For example, if the runner supports --gdb-port, the default can be overridden like so: west debugserver --gdb-port=1234 Command processing by the 'west' command can also be halted using '--'; anything after that point (even if it's an option recognized by the west command) will be passed to the runner. Example: west debug -- --this-option-goes-to-the-debug-runner=foo 2) Any runner supported by the board can be selected at runtime using the -r (--runner) option. For example, if the board's flash runner defaults to nrfjprog but jlink is supported as well, it can be selected with: west flash -r jlink 3) The runner configuration can be persisted elsewhere, edited offline, and selected at runtime, using --cmake-cache (-c): west flash -c /home/me/some/other/CMakeCache.txt Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-05-10 06:16:30 +08:00
# Copyright (c) 2018 Open Source Foundries Limited.
#
# SPDX-License-Identifier: Apache-2.0
'''west "flash" command'''
from .run_common import desc_common, add_parser_common, do_run_common
from . import WestCommand
class Flash(WestCommand):
def __init__(self):
super(Flash, self).__init__(
'flash',
'Flash and run a binary onto a board.\n\n' +
desc_common('flash'),
accepts_unknown_args=True)
def do_add_parser(self, parser_adder):
return add_parser_common(parser_adder, self)
def do_run(self, my_args, runner_args):
do_run_common(self, my_args, runner_args,
'ZEPHYR_BOARD_FLASH_RUNNER')