Continue better integration of the runner subpackage into west by moving the common runner configuration options into the command core. This allows commands like "west flash -h" to display help for common overrides like --kernel-hex. Adjustments needed to make this happen are: - Change the build system to separate common configuration values from runner-specific options and arguments - Prepare the runner core by defining a new RunnerConfig class that represents the common configuration, and accepting that from a new create() method, which replaces create_from_args(). - Convert all concrete runner classes to use the new style of argument parsing and initialization. - Group the command options appropriately for help output readability There's still a bit of tool-specific stuff in the common configuration (gdb and openocd configuration in particular); a more generic way to deal with that will be necessary to better support things like non-GDB debuggers, but that's out of scope of this patch. All the runner-specific options are still in the runner packge, which currently prevents them from being included in "west flash -h" etc. Fixing that is also out of scope of this patch. This has the ancillary benefit of getting rid of the legacy 'debug' argument to ZephyrBinaryRunner, which is no longer appropriate since verbose debug logging is handled by log.py in west. Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
# Copyright (c) 2017 Linaro Limited.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
'''bossac-specific runner (flash only) for Atmel SAM microcontrollers.'''
|
|
|
|
import platform
|
|
|
|
from .core import ZephyrBinaryRunner, RunnerCaps
|
|
|
|
DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'
|
|
|
|
|
|
class BossacBinaryRunner(ZephyrBinaryRunner):
|
|
'''Runner front-end for bossac.'''
|
|
|
|
def __init__(self, cfg, bossac='bossac', port=DEFAULT_BOSSAC_PORT):
|
|
super(BossacBinaryRunner, self).__init__(cfg)
|
|
self.bossac = bossac
|
|
self.port = port
|
|
|
|
@classmethod
|
|
def name(cls):
|
|
return 'bossac'
|
|
|
|
@classmethod
|
|
def capabilities(cls):
|
|
return RunnerCaps(commands={'flash'})
|
|
|
|
@classmethod
|
|
def do_add_parser(cls, parser):
|
|
parser.add_argument('--bossac', default='bossac',
|
|
help='path to bossac, default is bossac')
|
|
parser.add_argument('--bossac-port', default='/dev/ttyACM0',
|
|
help='serial port to use, default is /dev/ttyACM0')
|
|
|
|
@classmethod
|
|
def create(cls, cfg, args):
|
|
return BossacBinaryRunner(cfg, bossac=args.bossac,
|
|
port=args.bossac_port)
|
|
|
|
def do_run(self, command, **kwargs):
|
|
if platform.system() != 'Linux':
|
|
msg = 'CAUTION: No flash tool for your host system found!'
|
|
raise NotImplementedError(msg)
|
|
|
|
cmd_stty = ['stty', '-F', self.port, 'raw', 'ispeed', '1200',
|
|
'ospeed', '1200', 'cs8', '-cstopb', 'ignpar', 'eol', '255',
|
|
'eof', '255']
|
|
cmd_flash = [self.bossac, '-p', self.port, '-R', '-e', '-w', '-v',
|
|
'-b', self.cfg.kernel_bin]
|
|
|
|
self.check_call(cmd_stty)
|
|
self.check_call(cmd_flash)
|