scripts: west: runner: openocd: Add gdb-client-port
The gdb-port defines the GDB port and the openocd runner passes
this value to openocd as well as gdb. However, the TI AM62x board
provides multiple ports for each subsystem. For example, systick
appears at 3333, A53 as 3334-3337, R5F as 3338 and M4F as 3339.
If we want to connect to the M4F, we need to add another port which
is different to the to the gdb-port value.
This patch adds an additional argument --gdb-client-port to define
the port which GDB should connect to. It defaults to 3333, identical
to gdb-port.
Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
diff --git a/scripts/west_commands/runners/openocd.py b/scripts/west_commands/runners/openocd.py
index 5619c58..6af2b70 100644
--- a/scripts/west_commands/runners/openocd.py
+++ b/scripts/west_commands/runners/openocd.py
@@ -37,6 +37,7 @@
tcl_port=DEFAULT_OPENOCD_TCL_PORT,
telnet_port=DEFAULT_OPENOCD_TELNET_PORT,
gdb_port=DEFAULT_OPENOCD_GDB_PORT,
+ gdb_client_port=DEFAULT_OPENOCD_GDB_PORT,
gdb_init=None, no_load=False,
target_handle=DEFAULT_OPENOCD_TARGET_HANDLE):
super().__init__(cfg)
@@ -85,6 +86,7 @@
self.tcl_port = tcl_port
self.telnet_port = telnet_port
self.gdb_port = gdb_port
+ self.gdb_client_port = gdb_client_port
self.gdb_cmd = [cfg.gdb] if cfg.gdb else None
self.tui_arg = ['-tui'] if tui else []
self.halt_arg = [] if no_halt else ['-c halt']
@@ -146,6 +148,9 @@
help='openocd telnet port, defaults to 4444')
parser.add_argument('--gdb-port', default=DEFAULT_OPENOCD_GDB_PORT,
help='openocd gdb port, defaults to 3333')
+ parser.add_argument('--gdb-client-port', default=DEFAULT_OPENOCD_GDB_PORT,
+ help='''openocd gdb client port if multiple ports come
+ up, defaults to 3333''')
parser.add_argument('--gdb-init', action='append',
help='if given, add GDB init commands')
parser.add_argument('--no-halt', action='store_true',
@@ -174,8 +179,8 @@
use_elf=args.use_elf, no_halt=args.no_halt, no_init=args.no_init,
no_targets=args.no_targets, tcl_port=args.tcl_port,
telnet_port=args.telnet_port, gdb_port=args.gdb_port,
- gdb_init=args.gdb_init, no_load=args.no_load,
- target_handle=args.target_handle)
+ gdb_client_port=args.gdb_client_port, gdb_init=args.gdb_init,
+ no_load=args.no_load, target_handle=args.target_handle)
def print_gdbserver_message(self):
if not self.thread_info_enabled:
@@ -351,7 +356,7 @@
pre_init_cmd + self.init_arg + self.targets_arg +
self.halt_arg)
gdb_cmd = (self.gdb_cmd + self.tui_arg +
- ['-ex', 'target extended-remote :{}'.format(self.gdb_port),
+ ['-ex', 'target extended-remote :{}'.format(self.gdb_client_port),
self.elf_name])
if command == 'debug':
gdb_cmd.extend(self.load_arg)