zephyr/scripts/support/runner/xtensa.py
Marti Bolivar e33ec242fd scripts: refactor flash/debug scripts to remove "shell"
The Python-based runners have replaced the old shell scripts. Refactor
the build system accordingly:

- FLASH_SCRIPT is now BOARD_FLASH_RUNNER
- DEBUG_SCRIPT is now BOARD_DEBUG_RUNNER

The values, rather than being the names of files, are now the names of
runners in scripts/support/runner. They are still short, descriptive
names like "openocd", "jlink", "em-starterkit", etc.

Adjust the zephyr_flash_debug.py call and runner internals
accordingly. Have each runner class report a name and the commands it
can handle. This lets us move some boilerplate from each do_run()
method into the common run() routine, and enables further improvements
in future patches.

The handles_command() method is temporary, and will be replaced by a
more general mechanism for describing runner capabilities in a
subsequent patch. The initial use case for extending this is to add
device tree awareness to the runners.

To try to avoid user confusion, abort the configuration if an
xxx_SCRIPT is defined.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-12-15 09:57:30 -05:00

46 lines
1.2 KiB
Python

# 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
@classmethod
def name(cls):
return 'xtensa'
@classmethod
def handles_command(cls, command):
return command == 'debug'
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 do_run(self, command, **kwargs):
gdb_cmd = (self.gdb_cmd + [self.elf_name])
self.check_call(gdb_cmd)