mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-03 05:43:45 +00:00
Require all implementations to provide a do_create(), a new ZephyrBinaryRunner abstract class method, and make create() itself concrete. This allows us to enforce common conventions related to individual runner capabilities as each runner provides to the core via RunnerCaps. For now, just enforce that: - common options related to capabilities are always added, so runners can't reuse them for different ends - common options provided for runners which don't support them emit sensible error messages that should be easy to diagnose and support Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
# Copyright (c) 2019, Timon Baetz
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
'''HiFive1-specific (flash only) runner.'''
|
|
|
|
from os import path
|
|
|
|
from runners.core import ZephyrBinaryRunner, RunnerCaps
|
|
|
|
|
|
class HiFive1BinaryRunner(ZephyrBinaryRunner):
|
|
'''Runner front-end for the HiFive1 board, using openocd.'''
|
|
|
|
def __init__(self, cfg):
|
|
super().__init__(cfg)
|
|
self.openocd_config = path.join(cfg.board_dir, 'support', 'openocd.cfg')
|
|
|
|
@classmethod
|
|
def name(cls):
|
|
return 'hifive1'
|
|
|
|
@classmethod
|
|
def capabilities(cls):
|
|
return RunnerCaps(commands={'flash'})
|
|
|
|
@classmethod
|
|
def do_add_parser(cls, parser):
|
|
pass
|
|
|
|
@classmethod
|
|
def do_create(cls, cfg, args):
|
|
if cfg.gdb is None:
|
|
raise ValueError('--gdb not provided at command line')
|
|
|
|
return HiFive1BinaryRunner(cfg)
|
|
|
|
def do_run(self, command, **kwargs):
|
|
self.require(self.cfg.openocd)
|
|
self.require(self.cfg.gdb)
|
|
openocd_cmd = ([self.cfg.openocd, '-f', self.openocd_config])
|
|
gdb_cmd = ([self.cfg.gdb, self.cfg.elf_file, '--batch',
|
|
'-ex', 'set remotetimeout 240',
|
|
'-ex', 'target extended-remote localhost:3333',
|
|
'-ex', 'load',
|
|
'-ex', 'quit'])
|
|
self.run_server_and_client(openocd_cmd, gdb_cmd)
|