From d4d7cc72ee305e656bcd9d9184e0ab4d5854af3f Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 26 Oct 2017 11:04:32 -0400 Subject: [PATCH] scripts: runner: add xtensa.py, with debug support This is debug only, not debugserver. Signed-off-by: Marti Bolivar --- scripts/support/runner/__init__.py | 1 + scripts/support/runner/xtensa.py | 44 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 scripts/support/runner/xtensa.py diff --git a/scripts/support/runner/__init__.py b/scripts/support/runner/__init__.py index 35a2bde95b1..665e2a5c833 100644 --- a/scripts/support/runner/__init__.py +++ b/scripts/support/runner/__init__.py @@ -19,5 +19,6 @@ from . import nios2 from . import nrfjprog from . import openocd from . import pyocd +from . import xtensa __all__ = ['ZephyrBinaryRunner'] diff --git a/scripts/support/runner/xtensa.py b/scripts/support/runner/xtensa.py new file mode 100644 index 00000000000..c86d2a23446 --- /dev/null +++ b/scripts/support/runner/xtensa.py @@ -0,0 +1,44 @@ +# Copyright (c) 2017 Linaro Limited. +# +# SPDX-License-Identifier: Apache-2.0 + +'''Runner for debugging with xt-gdb.''' + +from os import path + +from .core import ZephyrBinaryRunner, get_env_or_bail + + +class XtensaBinaryRunner(ZephyrBinaryRunner): + '''Runner front-end for xt-gdb.''' + + def __init__(self, gdb, elf_name, debug=False): + super(XtensaBinaryRunner, self).__init__(debug=debug) + self.gdb_cmd = [gdb] + self.elf_name = elf_name + + def replaces_shell_script(shell_script, command): + return command == 'debug' and shell_script == 'xt-gdb.sh' + + def create_from_env(command, debug): + '''Create runner from environment. + + Required: + + - XCC_TOOLS: path to Xtensa tools + - O: build output directory + - KERNEL_ELF_NAME: zephyr kernel binary in ELF format + ''' + xt_gdb = path.join(get_env_or_bail('XCC_TOOLS'), 'bin', 'xt-gdb') + elf_name = path.join(get_env_or_bail('O'), + get_env_or_bail('KERNEL_ELF_NAME')) + + return XtensaBinaryRunner(xt_gdb, elf_name) + + def run(self, command, **kwargs): + if command != 'debug': + raise ValueError('Only debug is supported') + + gdb_cmd = (self.gdb_cmd + [self.elf_name]) + + self.check_call(gdb_cmd)