1# Copyright (c) 2019, Timon Baetz 2# 3# SPDX-License-Identifier: Apache-2.0 4 5'''HiFive1-specific (flash only) runner.''' 6 7from os import path 8 9from runners.core import ZephyrBinaryRunner, RunnerCaps 10 11 12class HiFive1BinaryRunner(ZephyrBinaryRunner): 13 '''Runner front-end for the HiFive1 board, using openocd.''' 14 15 def __init__(self, cfg): 16 super().__init__(cfg) 17 self.openocd_config = path.join(cfg.board_dir, 'support', 'openocd.cfg') 18 19 @classmethod 20 def name(cls): 21 return 'hifive1' 22 23 @classmethod 24 def capabilities(cls): 25 return RunnerCaps(commands={'flash'}) 26 27 @classmethod 28 def do_add_parser(cls, parser): 29 pass 30 31 @classmethod 32 def do_create(cls, cfg, args): 33 if cfg.gdb is None: 34 raise ValueError('--gdb not provided at command line') 35 36 return HiFive1BinaryRunner(cfg) 37 38 def do_run(self, command, **kwargs): 39 self.require(self.cfg.openocd) 40 self.require(self.cfg.gdb) 41 openocd_cmd = ([self.cfg.openocd, '-f', self.openocd_config]) 42 gdb_cmd = ([self.cfg.gdb, self.cfg.elf_file, '--batch', 43 '-ex', 'set remotetimeout 240', 44 '-ex', 'target extended-remote localhost:3333', 45 '-ex', 'load', 46 '-ex', 'quit']) 47 self.run_server_and_client(openocd_cmd, gdb_cmd) 48