flash: support flashing multiple configurations of a single board

Some boards define multiple configuration which all are maintained under
the same board directory. The flasher was looking for an openocd.cfg
based on the board name, which can't be found for such boards.

Use the variable BOARD_DIR provided by cmake instead of trying to
assemble the board directory location on our own.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-11-11 17:24:41 -05:00 committed by Anas Nashif
commit 539d2af654
3 changed files with 12 additions and 20 deletions

View file

@ -12,8 +12,7 @@ list(APPEND ENV_VARS_FORMATTED
KERNEL_ELF_NAME=${KERNEL_ELF_NAME} KERNEL_ELF_NAME=${KERNEL_ELF_NAME}
KERNEL_HEX_NAME=${KERNEL_HEX_NAME} KERNEL_HEX_NAME=${KERNEL_HEX_NAME}
KERNEL_BIN_NAME=${KERNEL_BIN_NAME} KERNEL_BIN_NAME=${KERNEL_BIN_NAME}
ARCH=${ARCH} BOARD_DIR=${BOARD_DIR}
BOARD_NAME=${BOARD}
GDB=${CMAKE_GDB} GDB=${CMAKE_GDB}
OPENOCD_DEFAULT_PATH=${OPENOCD_DEFAULT_PATH} OPENOCD_DEFAULT_PATH=${OPENOCD_DEFAULT_PATH}
OPENOCD=${OPENOCD} OPENOCD=${OPENOCD}

View file

@ -16,7 +16,7 @@ DEFAULT_ARC_GDB_PORT = 3333
class ArcBinaryRunner(ZephyrBinaryRunner): class ArcBinaryRunner(ZephyrBinaryRunner):
'''Runner front-end for the ARC architecture, using openocd.''' '''Runner front-end for the EM Starterkit board, using openocd.'''
# This unusual 'flash' implementation matches the original shell script. # This unusual 'flash' implementation matches the original shell script.
# #
@ -26,7 +26,7 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
# #
# TODO: exit immediately when flashing is done, leaving Zephyr running. # TODO: exit immediately when flashing is done, leaving Zephyr running.
def __init__(self, elf, zephyr_base, arch, board_name, def __init__(self, elf, zephyr_base, board_dir,
gdb, openocd='openocd', extra_init=None, default_path=None, gdb, openocd='openocd', extra_init=None, default_path=None,
tui=None, tcl_port=DEFAULT_ARC_TCL_PORT, tui=None, tcl_port=DEFAULT_ARC_TCL_PORT,
telnet_port=DEFAULT_ARC_TELNET_PORT, telnet_port=DEFAULT_ARC_TELNET_PORT,
@ -34,8 +34,7 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
super(ArcBinaryRunner, self).__init__(debug=debug) super(ArcBinaryRunner, self).__init__(debug=debug)
self.elf = elf self.elf = elf
self.zephyr_base = zephyr_base self.zephyr_base = zephyr_base
self.arch = arch self.board_dir = board_dir
self.board_name = board_name
self.gdb = gdb self.gdb = gdb
search_args = [] search_args = []
if default_path is not None: if default_path is not None:
@ -59,8 +58,7 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
- O: build output directory - O: build output directory
- KERNEL_ELF_NAME: zephyr kernel binary in ELF format - KERNEL_ELF_NAME: zephyr kernel binary in ELF format
- ZEPHYR_BASE: zephyr Git repository base directory - ZEPHYR_BASE: zephyr Git repository base directory
- ARCH: board architecture - BOARD_DIR: board directory
- BOARD_NAME: zephyr name of board
- GDB: gdb executable - GDB: gdb executable
Optional: Optional:
@ -76,8 +74,7 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
elf = path.join(get_env_or_bail('O'), elf = path.join(get_env_or_bail('O'),
get_env_or_bail('KERNEL_ELF_NAME')) get_env_or_bail('KERNEL_ELF_NAME'))
zephyr_base = get_env_or_bail('ZEPHYR_BASE') zephyr_base = get_env_or_bail('ZEPHYR_BASE')
arch = get_env_or_bail('ARCH') board_dir = get_env_or_bail('BOARD_DIR')
board_name = get_env_or_bail('BOARD_NAME')
gdb = get_env_or_bail('GDB') gdb = get_env_or_bail('GDB')
openocd = os.environ.get('OPENOCD', 'openocd') openocd = os.environ.get('OPENOCD', 'openocd')
@ -93,7 +90,7 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
gdb_port = int(os.environ.get('GDB_PORT', gdb_port = int(os.environ.get('GDB_PORT',
str(DEFAULT_ARC_GDB_PORT))) str(DEFAULT_ARC_GDB_PORT)))
return ArcBinaryRunner(elf, zephyr_base, arch, board_name, return ArcBinaryRunner(elf, zephyr_base, board_dir,
gdb, openocd=openocd, extra_init=extra_init, gdb, openocd=openocd, extra_init=extra_init,
default_path=default_path, tui=tui, default_path=default_path, tui=tui,
tcl_port=tcl_port, telnet_port=telnet_port, tcl_port=tcl_port, telnet_port=telnet_port,
@ -103,9 +100,8 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
if command not in {'flash', 'debug', 'debugserver'}: if command not in {'flash', 'debug', 'debugserver'}:
raise ValueError('{} is not supported'.format(command)) raise ValueError('{} is not supported'.format(command))
kwargs['openocd-cfg'] = path.join(self.zephyr_base, 'boards', kwargs['openocd-cfg'] = path.join(self.board_dir, 'support',
self.arch, self.board_name, 'openocd.cfg')
'support', 'openocd.cfg')
if command in {'flash', 'debug'}: if command in {'flash', 'debug'}:
self.flash_debug(command, **kwargs) self.flash_debug(command, **kwargs)

View file

@ -57,8 +57,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
Required: Required:
- ZEPHYR_BASE: zephyr Git repository base directory - ZEPHYR_BASE: zephyr Git repository base directory
- ARCH: board architecture - BOARD_DIR: directory of board definition
- BOARD_NAME: zephyr name of board
Optional: Optional:
@ -92,10 +91,8 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
- GDB_PORT: openocd gdb port, defaults to 3333 - GDB_PORT: openocd gdb port, defaults to 3333
''' '''
zephyr_base = get_env_or_bail('ZEPHYR_BASE') zephyr_base = get_env_or_bail('ZEPHYR_BASE')
arch = get_env_or_bail('ARCH') board_dir = get_env_or_bail('BOARD_DIR')
board_name = get_env_or_bail('BOARD_NAME') openocd_config = path.join(board_dir, 'support', 'openocd.cfg')
openocd_config = path.join(zephyr_base, 'boards', arch,
board_name, 'support', 'openocd.cfg')
openocd = os.environ.get('OPENOCD', 'openocd') openocd = os.environ.get('OPENOCD', 'openocd')
default_path = os.environ.get('OPENOCD_DEFAULT_PATH', None) default_path = os.environ.get('OPENOCD_DEFAULT_PATH', None)