scripts: runners: add misc-flash runner

Some boards require specific sequences of commands to run which aren't
generally useful for other boards. Add a catch-all runner to handle
these cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2019-10-30 15:21:52 +08:00 committed by Andrew Boie
commit 07a40cbbcf
4 changed files with 55 additions and 1 deletions

View file

@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
# Please use this sparingly and only when if your setup is exotic and
# you're willing to handle requests for help. E.g. your "board" is a
# core on a special-purpose SoC which requires a complicated script to
# network boot.
board_finalize_runner_args(misc-flasher)

View file

@ -27,6 +27,7 @@ from runners import xtensa
from runners import intel_s1000 from runners import intel_s1000
from runners import blackmagicprobe from runners import blackmagicprobe
from runners import stm32flash from runners import stm32flash
from runners import misc
def get_runner_cls(runner): def get_runner_cls(runner):
'''Get a runner's class object, given its name.''' '''Get a runner's class object, given its name.'''

View file

@ -0,0 +1,45 @@
# Copyright (c) 2019, Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
'''Catch-all module for miscellaneous devices which can't use a
generic or widely used tool like J-Link, OpenOCD, etc.
Please use this sparingly and only when your setup is exotic and
you're willing to handle requests for help. E.g. if your "board" is a
core on a special-purpose SoC which requires a complicated script to
network boot.'''
from runners.core import ZephyrBinaryRunner, RunnerCaps
class MiscFlasher(ZephyrBinaryRunner):
'''Runner for handling special purpose flashing commands.'''
def __init__(self, cfg, args):
super().__init__(cfg)
if not args:
# This is a board definition error, not a user error,
# so we can do it now and not in do_run().
raise ValueError('no command was given')
self.args = args
@classmethod
def name(cls):
return 'misc-flasher'
@classmethod
def capabilities(cls):
return RunnerCaps(commands={'flash'})
@classmethod
def do_add_parser(cls, parser):
parser.add_argument('args', nargs='+',
help='command to run (and any extra arguments)')
@classmethod
def create(cls, cfg, args):
return MiscFlasher(cfg, args.args)
def do_run(self, command, **kwargs):
self.require(self.args[0])
self.check_call(self.args)

View file

@ -15,5 +15,5 @@ def test_runner_imports():
expected = set(('arc-nsim', 'bossac', 'dfu-util', 'em-starterkit', 'esp32', expected = set(('arc-nsim', 'bossac', 'dfu-util', 'em-starterkit', 'esp32',
'hifive1', 'jlink', 'nios2', 'nrfjprog', 'openocd', 'pyocd', 'hifive1', 'jlink', 'nios2', 'nrfjprog', 'openocd', 'pyocd',
'qemu', 'xtensa', 'intel_s1000', 'blackmagicprobe', 'qemu', 'xtensa', 'intel_s1000', 'blackmagicprobe',
'dediprog', 'stm32flash')) 'dediprog', 'stm32flash', 'misc-flasher'))
assert runner_names == expected assert runner_names == expected