1# Copyright (c) 2018 Open Source Foundries Limited. 2# Copyright 2019 Foundries.io 3# Copyright (c) 2020 Nordic Semiconductor ASA 4# 5# SPDX-License-Identifier: Apache-2.0 6 7'''west "flash" command''' 8 9from pathlib import Path 10 11from run_common import add_parser_common, do_run_common, get_build_dir 12from west.commands import WestCommand 13 14 15class Flash(WestCommand): 16 17 def __init__(self): 18 super().__init__( 19 'flash', 20 # Keep this in sync with the string in west-commands.yml. 21 'flash and run a binary on a board', 22 "Permanently reprogram a board's flash with a new binary.", 23 accepts_unknown_args=True) 24 self.runner_key = 'flash-runner' # in runners.yaml 25 26 def do_add_parser(self, parser_adder): 27 return add_parser_common(self, parser_adder) 28 29 def do_run(self, my_args, runner_args): 30 build_dir = get_build_dir(my_args) 31 domains_file = Path(build_dir) / 'domains.yaml' 32 do_run_common(self, my_args, runner_args, domain_file=domains_file) 33