From cc1e64be93277f34bdc9a270910635f94027a76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Tue, 18 May 2021 13:49:50 -0700 Subject: [PATCH] runners: openocd: fix 'debug' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'debug' command isn't reloading the binary. Fix it, keeping 'attach' support as-is. Fixes: #33745 Signed-off-by: Martí Bolívar --- scripts/west_commands/runners/openocd.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/west_commands/runners/openocd.py b/scripts/west_commands/runners/openocd.py index 21698bf8a1a..3f9dd0db4bd 100644 --- a/scripts/west_commands/runners/openocd.py +++ b/scripts/west_commands/runners/openocd.py @@ -124,8 +124,8 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner): self.do_flash_elf(**kwargs) elif command == 'flash': self.do_flash(**kwargs) - elif command == 'debug': - self.do_debug(**kwargs) + elif command in ('attach', 'debug'): + self.do_attach_debug(command, **kwargs) elif command == 'load': self.do_load(**kwargs) else: @@ -194,7 +194,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner): '-c', 'shutdown']) self.check_call(cmd) - def do_debug(self, **kwargs): + def do_attach_debug(self, command, **kwargs): if self.gdb_cmd is None: raise ValueError('Cannot debug; no gdb specified') if self.elf_name is None: @@ -215,6 +215,8 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner): gdb_cmd = (self.gdb_cmd + self.tui_arg + ['-ex', 'target remote :{}'.format(self.gdb_port), self.elf_name]) + if command == 'debug': + gdb_cmd.extend(['-ex', 'load']) self.require(gdb_cmd[0]) self.run_server_and_client(server_cmd, gdb_cmd)