west/ezflashcli: add tool_opt capability
Add tool_opt capability Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
This commit is contained in:
parent
02770ad963
commit
5ad5ac6414
1 changed files with 17 additions and 11 deletions
|
@ -3,6 +3,8 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
'''Runner for flashing with ezFlashCLI.'''
|
'''Runner for flashing with ezFlashCLI.'''
|
||||||
|
import shlex
|
||||||
|
|
||||||
from runners.core import ZephyrBinaryRunner, RunnerCaps
|
from runners.core import ZephyrBinaryRunner, RunnerCaps
|
||||||
|
|
||||||
DEFAULT_EZFLASHCLI = "ezFlashCLI"
|
DEFAULT_EZFLASHCLI = "ezFlashCLI"
|
||||||
|
@ -10,36 +12,40 @@ DEFAULT_EZFLASHCLI = "ezFlashCLI"
|
||||||
class EzFlashCliBinaryRunner(ZephyrBinaryRunner):
|
class EzFlashCliBinaryRunner(ZephyrBinaryRunner):
|
||||||
'''Runner front-end for ezFlashCLI'''
|
'''Runner front-end for ezFlashCLI'''
|
||||||
|
|
||||||
def __init__(self, cfg, tool, sn, erase=False, reset=True):
|
def __init__(self, cfg, tool, tool_opt=[], erase=False, reset=True):
|
||||||
super().__init__(cfg)
|
super().__init__(cfg)
|
||||||
self.bin_ = cfg.bin_file
|
self.bin_ = cfg.bin_file
|
||||||
|
|
||||||
self.tool = tool
|
self.tool = tool
|
||||||
self.sn_arg = ['-j', f'{sn}'] if sn is not None else []
|
|
||||||
self.erase = bool(erase)
|
self.erase = bool(erase)
|
||||||
self.reset = bool(reset)
|
self.reset = bool(reset)
|
||||||
|
|
||||||
|
self.tool_opt = []
|
||||||
|
for opts in [shlex.split(opt) for opt in tool_opt]:
|
||||||
|
self.tool_opt += opts
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def name(cls):
|
def name(cls):
|
||||||
return 'ezflashcli'
|
return 'ezflashcli'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def capabilities(cls):
|
def capabilities(cls):
|
||||||
return RunnerCaps(commands={'flash'}, erase=True, reset=True)
|
return RunnerCaps(commands={'flash'}, tool_opt=True, erase=True, reset=True)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tool_opt_help(cls) -> str:
|
||||||
|
return "Additional options for ezFlashCLI e.g. '--verbose'"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_add_parser(cls, parser):
|
def do_add_parser(cls, parser):
|
||||||
parser.add_argument('--tool', default=DEFAULT_EZFLASHCLI,
|
parser.add_argument('--tool', default=DEFAULT_EZFLASHCLI,
|
||||||
help='ezFlashCLI path, default is '
|
help='ezFlashCLI path, default is '
|
||||||
f'{DEFAULT_EZFLASHCLI}')
|
f'{DEFAULT_EZFLASHCLI}')
|
||||||
parser.add_argument('--sn', default=None, required=False,
|
|
||||||
help='J-Link probe serial number')
|
|
||||||
|
|
||||||
parser.set_defaults(reset=True)
|
parser.set_defaults(reset=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_create(cls, cfg, args):
|
def do_create(cls, cfg, args):
|
||||||
return EzFlashCliBinaryRunner(cfg, tool=args.tool, sn=args.sn,
|
return EzFlashCliBinaryRunner(cfg, tool=args.tool, tool_opt=args.tool_opt,
|
||||||
erase=args.erase)
|
erase=args.erase)
|
||||||
|
|
||||||
def needs_product_header(self):
|
def needs_product_header(self):
|
||||||
|
@ -56,20 +62,20 @@ class EzFlashCliBinaryRunner(ZephyrBinaryRunner):
|
||||||
|
|
||||||
if self.erase:
|
if self.erase:
|
||||||
self.logger.info("Erasing flash...")
|
self.logger.info("Erasing flash...")
|
||||||
self.check_call([self.tool] + self.sn_arg + ["erase_flash"])
|
self.check_call([self.tool] + self.tool_opt + ["erase_flash"])
|
||||||
|
|
||||||
self.logger.info(f"Flashing {self.bin_}...")
|
self.logger.info(f"Flashing {self.bin_}...")
|
||||||
if self.needs_product_header():
|
if self.needs_product_header():
|
||||||
# Write product header and application image at fixed offset as required
|
# Write product header and application image at fixed offset as required
|
||||||
# by internal bootloader.
|
# by internal bootloader.
|
||||||
self.check_call([self.tool] + self.sn_arg + ["image_flash", self.bin_])
|
self.check_call([self.tool] + self.tool_opt + ["image_flash", self.bin_])
|
||||||
else:
|
else:
|
||||||
load_offset = self.build_conf['CONFIG_FLASH_LOAD_OFFSET']
|
load_offset = self.build_conf['CONFIG_FLASH_LOAD_OFFSET']
|
||||||
self.check_call([self.tool] + self.sn_arg + ["write_flash", f'0x{load_offset:x}', self.bin_])
|
self.check_call([self.tool] + self.tool_opt + ["write_flash", f'0x{load_offset:x}', self.bin_])
|
||||||
|
|
||||||
def reset_device(self):
|
def reset_device(self):
|
||||||
self.logger.info("Resetting...")
|
self.logger.info("Resetting...")
|
||||||
self.check_call([self.tool] + self.sn_arg + ["go"])
|
self.check_call([self.tool] + self.tool_opt + ["go"])
|
||||||
|
|
||||||
def do_run(self, command, **kwargs):
|
def do_run(self, command, **kwargs):
|
||||||
self.require(self.tool)
|
self.require(self.tool)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue