Skip to content
Browse files

runners/jlink: Add --tool-opt option for more args

Adds the --tool-opt option to allow additional arguments to be
passed to JLink Commander

Signed-off-by: Nathaniel Graff <>
  • Loading branch information...
nategraff-sifive authored and nashif committed Mar 19, 2019
1 parent 2af4c15 commit bd2919dcf1da6bef26087283a4e47f28f24bbc4f
Showing with 16 additions and 6 deletions.
  1. +16 −6 scripts/west_commands/runners/
@@ -6,9 +6,10 @@

import argparse
import os
import tempfile
import sys
import shlex
import shutil
import sys
import tempfile

from west import log
from runners.core import ZephyrBinaryRunner, RunnerCaps, \
@@ -30,7 +31,7 @@ def __init__(self, cfg, device,
flash_addr=0x0, erase=True, reset_after_load=False,
iface='swd', speed='auto',
gdbserver='JLinkGDBServer', gdb_port=DEFAULT_JLINK_GDB_PORT,
tui=False, tool_opt=[]):
super(JLinkBinaryRunner, self).__init__(cfg)
self.bin_name = cfg.bin_file
self.elf_name = cfg.elf_file
@@ -46,6 +47,10 @@ def __init__(self, cfg, device,
self.gdb_port = gdb_port
self.tui_arg = ['-tui'] if tui else []

self.tool_opt = []
for opts in [shlex.split(opt) for opt in tool_opt]:
self.tool_opt += opts

def name(cls):
return 'jlink'
@@ -72,6 +77,9 @@ def do_add_parser(cls, parser):
parser.add_argument('--gdb-port', default=DEFAULT_JLINK_GDB_PORT,
help='pyocd gdb port, defaults to {}'.format(
parser.add_argument('--tool-opt', default=[], action='append',
help='''Additional options for JLink Commander,
e.g. \'-autoconnect 1\' ''')
parser.add_argument('--commander', default=DEFAULT_JLINK_EXE,
help='J-Link Commander, default is JLinkExe')
parser.add_argument('--erase', default=False, action='store_true',
@@ -94,7 +102,7 @@ def create(cls, cfg, args):
iface=args.iface, speed=args.speed,
gdb_port=args.gdb_port,, tool_opt=args.tool_opt)

def print_gdbserver_message(self):
log.inf('J-Link GDB server running on port {}'.format(self.gdb_port))
@@ -111,7 +119,8 @@ def do_run(self, command, **kwargs):
'-speed', self.speed,
'-device', self.device,
'-singlerun'] +

if command == 'flash':
@@ -171,7 +180,8 @@ def flash(self, **kwargs):
['-if', self.iface,
'-speed', self.speed,
'-device', self.device,
'-CommanderScript', fname])
'-CommanderScript', fname] +

log.inf('Flashing Target Device')

0 comments on commit bd2919d

Please sign in to comment.
You can’t perform that action at this time.