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 west.commands import WestCommand 10 11from run_common import add_parser_common, do_run_common, get_build_dir 12 13from pathlib import Path 14 15 16class Flash(WestCommand): 17 18 def __init__(self): 19 super(Flash, self).__init__( 20 'flash', 21 # Keep this in sync with the string in west-commands.yml. 22 'flash and run a binary on a board', 23 "Permanently reprogram a board's flash with a new binary.", 24 accepts_unknown_args=True) 25 self.runner_key = 'flash-runner' # in runners.yaml 26 27 def do_add_parser(self, parser_adder): 28 return add_parser_common(self, parser_adder) 29 30 def do_run(self, my_args, runner_args): 31 build_dir = get_build_dir(my_args) 32 domains_file = Path(build_dir) / 'domains.yaml' 33 do_run_common(self, my_args, runner_args, domain_file=domains_file) 34