From 488e7ef39a56a991d034e8a6be3df705c4ee0907 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Tue, 16 Mar 2021 14:02:48 +0100 Subject: [PATCH] west commands: runners: support for including config file in pyocd Add support for including a board-specific config.yaml file in the pyocd flash command. Similary to openOCD, the config file is placed in the board directory under support/. Signed-off-by: Ioannis Glaropoulos --- scripts/west_commands/runners/pyocd.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/west_commands/runners/pyocd.py b/scripts/west_commands/runners/pyocd.py index 7f96e42195d6..53ce04b61029 100644 --- a/scripts/west_commands/runners/pyocd.py +++ b/scripts/west_commands/runners/pyocd.py @@ -5,6 +5,7 @@ '''Runner for pyOCD .''' import os +from os import path from runners.core import ZephyrBinaryRunner, RunnerCaps, \ BuildConfiguration @@ -21,9 +22,17 @@ def __init__(self, cfg, target, flash_addr=0x0, erase=False, flash_opts=None, gdb_port=DEFAULT_PYOCD_GDB_PORT, telnet_port=DEFAULT_PYOCD_TELNET_PORT, tui=False, + pyocd_config=None, board_id=None, daparg=None, frequency=None, tool_opt=None): super().__init__(cfg) + default = path.join(cfg.board_dir, 'support', 'pyocd.yaml') + if path.exists(default): + self.pyocd_config = default + else: + self.pyocd_config = None + + self.target_args = ['-t', target] self.pyocd = pyocd self.flash_addr_args = ['-a', hex(flash_addr)] if flash_addr else [] @@ -36,6 +45,13 @@ def __init__(self, cfg, target, self.bin_name = cfg.bin_file self.elf_name = cfg.elf_file + pyocd_config_args = [] + + if self.pyocd_config is not None: + pyocd_config_args = ['--config', self.pyocd_config] + + self.pyocd_config_args = pyocd_config_args + board_args = [] if board_id is not None: board_args = ['-u', board_id] @@ -145,6 +161,7 @@ def flash(self, **kwargs): cmd = ([self.pyocd] + ['flash'] + + self.pyocd_config_args + ['-e', erase_method] + self.flash_addr_args + self.daparg_args +