runners: pyocd: add --tool-opt parameter

add --tool-opt to support more pyocd parameter

Signed-off-by: Frank Li <lgl88911@163.com>
This commit is contained in:
Frank Li 2019-11-24 17:10:07 +08:00 committed by Anas Nashif
commit 59208ac13b
2 changed files with 24 additions and 7 deletions

View file

@ -21,7 +21,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
flash_addr=0x0, flash_opts=None,
gdb_port=DEFAULT_PYOCD_GDB_PORT,
telnet_port=DEFAULT_PYOCD_TELNET_PORT, tui=False,
board_id=None, daparg=None, frequency=None):
board_id=None, daparg=None, frequency=None, tool_opt=None):
super(PyOcdBinaryRunner, self).__init__(cfg)
self.target_args = ['-t', target]
@ -50,6 +50,11 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
frequency_args = ['-f', frequency]
self.frequency_args = frequency_args
tool_opt_args = []
if tool_opt is not None:
tool_opt_args = [tool_opt]
self.tool_opt_args = tool_opt_args
self.flash_extra = flash_opts if flash_opts else []
@classmethod
@ -85,6 +90,9 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
help='if given, GDB uses -tui')
parser.add_argument('--board-id',
help='ID of board to flash, default is to prompt')
parser.add_argument('--tool-opt',
help='''Additional options for pyocd Commander,
e.g. \'--script=user.py\' ''')
@classmethod
def create(cls, cfg, args):
@ -97,7 +105,8 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
flash_addr=flash_addr, flash_opts=args.flash_opt,
gdb_port=args.gdb_port, telnet_port=args.telnet_port, tui=args.tui,
board_id=args.board_id, daparg=args.daparg,
frequency=args.frequency)
frequency=args.frequency,
tool_opt=args.tool_opt)
daparg = os.environ.get('PYOCD_DAPARG')
if not ret.daparg_args and daparg:
@ -139,6 +148,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
self.target_args +
self.board_args +
self.frequency_args +
self.tool_opt_args +
self.flash_extra +
[fname])
@ -156,7 +166,8 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
self.port_args() +
self.target_args +
self.board_args +
self.frequency_args)
self.frequency_args +
self.tool_opt_args)
if command == 'debugserver':
self.log_gdbserver_message()

View file

@ -25,6 +25,7 @@ TEST_TARGET = 'test-target'
TEST_FLASH_OPTS = ['--test-flash', 'args']
TEST_GDB_PORT = 1
TEST_TELNET_PORT = 2
TEST_TOOL_OPT = 'test-opt'
TEST_ALL_KWARGS = {
'pyocd': TEST_PYOCD,
@ -36,6 +37,7 @@ TEST_ALL_KWARGS = {
'board_id': TEST_BOARD_ID,
'frequency': TEST_FREQUENCY,
'daparg': TEST_DAPARG,
'tool_opt': TEST_TOOL_OPT,
}
TEST_DEF_KWARGS = {}
@ -48,7 +50,8 @@ TEST_ALL_PARAMS = (['--target', TEST_TARGET,
['--gdb-port', str(TEST_GDB_PORT),
'--telnet-port', str(TEST_TELNET_PORT),
'--board-id', TEST_BOARD_ID,
'--frequency', str(TEST_FREQUENCY)])
'--frequency', str(TEST_FREQUENCY),
'--tool-opt', TEST_TOOL_OPT])
TEST_DEF_PARAMS = ['--target', TEST_TARGET]
@ -69,7 +72,8 @@ FLASH_ALL_EXPECTED_CALL = ([TEST_PYOCD,
'-e', 'sector',
'-a', hex(TEST_ADDR), '-da', TEST_DAPARG,
'-t', TEST_TARGET, '-u', TEST_BOARD_ID,
'-f', TEST_FREQUENCY] +
'-f', TEST_FREQUENCY,
TEST_TOOL_OPT] +
TEST_FLASH_OPTS +
[RC_KERNEL_HEX])
FLASH_DEF_EXPECTED_CALL = ['pyocd', 'flash', '-e', 'sector',
@ -83,7 +87,8 @@ DEBUG_ALL_EXPECTED_SERVER = [TEST_PYOCD,
'-T', str(TEST_TELNET_PORT),
'-t', TEST_TARGET,
'-u', TEST_BOARD_ID,
'-f', TEST_FREQUENCY]
'-f', TEST_FREQUENCY,
TEST_TOOL_OPT]
DEBUG_ALL_EXPECTED_CLIENT = [RC_GDB, RC_KERNEL_ELF,
'-ex', 'target remote :{}'.format(TEST_GDB_PORT),
'-ex', 'monitor halt',
@ -108,7 +113,8 @@ DEBUGSERVER_ALL_EXPECTED_CALL = [TEST_PYOCD,
'-T', str(TEST_TELNET_PORT),
'-t', TEST_TARGET,
'-u', TEST_BOARD_ID,
'-f', TEST_FREQUENCY]
'-f', TEST_FREQUENCY,
TEST_TOOL_OPT]
DEBUGSERVER_DEF_EXPECTED_CALL = ['pyocd',
'gdbserver',
'-p', '3333',