Skip to content

Commit

Permalink
west commands: runners: support for including config file in pyocd
Browse files Browse the repository at this point in the history
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 <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information
ioannisg authored and nashif committed Mar 17, 2021
1 parent d7049b5 commit 488e7ef
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/west_commands/runners/pyocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'''Runner for pyOCD .'''

import os
from os import path

from runners.core import ZephyrBinaryRunner, RunnerCaps, \
BuildConfiguration
Expand All @@ -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 []
Expand All @@ -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]
Expand Down Expand Up @@ -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 +
Expand Down

0 comments on commit 488e7ef

Please sign in to comment.