west/ezflashcli: add dev_id capability
Add dev_id capability
Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
diff --git a/scripts/west_commands/runners/ezflashcli.py b/scripts/west_commands/runners/ezflashcli.py
index 384525d..ca3c226 100644
--- a/scripts/west_commands/runners/ezflashcli.py
+++ b/scripts/west_commands/runners/ezflashcli.py
@@ -12,11 +12,12 @@
class EzFlashCliBinaryRunner(ZephyrBinaryRunner):
'''Runner front-end for ezFlashCLI'''
- def __init__(self, cfg, tool, tool_opt=[], erase=False, reset=True):
+ def __init__(self, cfg, tool, dev_id=None, tool_opt=[], erase=False, reset=True):
super().__init__(cfg)
self.bin_ = cfg.bin_file
self.tool = tool
+ self.dev_id = dev_id
self.erase = bool(erase)
self.reset = bool(reset)
@@ -30,7 +31,12 @@
@classmethod
def capabilities(cls):
- return RunnerCaps(commands={'flash'}, tool_opt=True, erase=True, reset=True)
+ return RunnerCaps(commands={'flash'}, dev_id=True, tool_opt=True, erase=True, reset=True)
+
+ @classmethod
+ def dev_id_help(cls) -> str:
+ return '''Device identifier. Use it to select the J-Link Serial Number
+ of the device connected over USB.'''
@classmethod
def tool_opt_help(cls) -> str:
@@ -45,8 +51,8 @@
@classmethod
def do_create(cls, cfg, args):
- return EzFlashCliBinaryRunner(cfg, tool=args.tool, tool_opt=args.tool_opt,
- erase=args.erase)
+ return EzFlashCliBinaryRunner(cfg, tool=args.tool, dev_id=args.dev_id,
+ tool_opt=args.tool_opt, erase=args.erase)
def needs_product_header(self):
# Applications linked to code partition are meant to be run by MCUboot
@@ -58,24 +64,32 @@
return is_mcuboot or not uses_code_partition
+ def get_options(self):
+ device_args = []
+ if self.dev_id is not None:
+ device_args = ['-j', f'{self.dev_id}']
+ return device_args + self.tool_opt
+
def program_bin(self):
+ options = self.get_options()
if self.erase:
self.logger.info("Erasing flash...")
- self.check_call([self.tool] + self.tool_opt + ["erase_flash"])
+ self.check_call([self.tool] + options + ["erase_flash"])
self.logger.info(f"Flashing {self.bin_}...")
if self.needs_product_header():
# Write product header and application image at fixed offset as required
# by internal bootloader.
- self.check_call([self.tool] + self.tool_opt + ["image_flash", self.bin_])
+ self.check_call([self.tool] + options + ["image_flash", self.bin_])
else:
load_offset = self.build_conf['CONFIG_FLASH_LOAD_OFFSET']
- self.check_call([self.tool] + self.tool_opt + ["write_flash", f'0x{load_offset:x}', self.bin_])
+ self.check_call([self.tool] + options + ["write_flash", f'0x{load_offset:x}', self.bin_])
def reset_device(self):
self.logger.info("Resetting...")
- self.check_call([self.tool] + self.tool_opt + ["go"])
+ options = self.get_options()
+ self.check_call([self.tool] + options + ["go"])
def do_run(self, command, **kwargs):
self.require(self.tool)