Browse Source

scripts: west_commands: runners: Fix f-string (UP032)

Replace .format() calls with f-strings.

See https://docs.astral.sh/ruff/rules/f-string/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
pull/81768/head
Pieter De Gendt 8 months ago committed by Benjamin Cabé
parent
commit
775db0e63a
  1. 2
      scripts/west_commands/runners/__init__.py
  2. 20
      scripts/west_commands/runners/blackmagicprobe.py
  3. 10
      scripts/west_commands/runners/canopen_program.py
  4. 5
      scripts/west_commands/runners/core.py
  5. 6
      scripts/west_commands/runners/dfu.py
  6. 3
      scripts/west_commands/runners/esp32.py
  7. 10
      scripts/west_commands/runners/intel_cyclonev.py
  8. 7
      scripts/west_commands/runners/jlink.py
  9. 5
      scripts/west_commands/runners/linkserver.py
  10. 6
      scripts/west_commands/runners/mdb.py
  11. 5
      scripts/west_commands/runners/native.py
  12. 7
      scripts/west_commands/runners/nios2.py
  13. 9
      scripts/west_commands/runners/nrf_common.py
  14. 6
      scripts/west_commands/runners/nsim.py
  15. 18
      scripts/west_commands/runners/pyocd.py
  16. 2
      scripts/west_commands/runners/silabs_commander.py
  17. 14
      scripts/west_commands/runners/stm32flash.py
  18. 4
      scripts/west_commands/runners/teensy.py

2
scripts/west_commands/runners/__init__.py

@ -73,6 +73,6 @@ def get_runner_cls(runner): @@ -73,6 +73,6 @@ def get_runner_cls(runner):
for cls in ZephyrBinaryRunner.get_runners():
if cls.name() == runner:
return cls
raise ValueError('unknown runner "{}"'.format(runner))
raise ValueError(f'unknown runner "{runner}"')
__all__ = ['ZephyrBinaryRunner', 'get_runner_cls']

20
scripts/west_commands/runners/blackmagicprobe.py

@ -170,12 +170,11 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner): @@ -170,12 +170,11 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner):
command = (self.gdb +
['-ex', "set confirm off",
'-ex', "target extended-remote {}".format(
self.gdb_serial)] +
'-ex', f"target extended-remote {self.gdb_serial}"] +
self.connect_rst_enable_arg +
['-ex', "monitor swdp_scan",
'-ex', "attach 1",
'-ex', "load {}".format(flash_file),
'-ex', f"load {flash_file}",
'-ex', "kill",
'-ex', "quit",
'-silent'])
@ -192,20 +191,18 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner): @@ -192,20 +191,18 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner):
if self.elf_file is None:
command = (self.gdb +
['-ex', "set confirm off",
'-ex', "target extended-remote {}".format(
self.gdb_serial)] +
'-ex', f"target extended-remote {self.gdb_serial}"] +
self.connect_rst_disable_arg +
['-ex', "monitor swdp_scan",
'-ex', "attach 1"])
else:
command = (self.gdb +
['-ex', "set confirm off",
'-ex', "target extended-remote {}".format(
self.gdb_serial)] +
'-ex', f"target extended-remote {self.gdb_serial}"] +
self.connect_rst_disable_arg +
['-ex', "monitor swdp_scan",
'-ex', "attach 1",
'-ex', "file {}".format(self.elf_file)])
'-ex', f"file {self.elf_file}"])
self.check_call_ignore_sigint(command)
def bmp_debug(self, command, **kwargs):
@ -213,13 +210,12 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner): @@ -213,13 +210,12 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner):
raise ValueError('Cannot debug; elf file is missing')
command = (self.gdb +
['-ex', "set confirm off",
'-ex', "target extended-remote {}".format(
self.gdb_serial)] +
'-ex', f"target extended-remote {self.gdb_serial}"] +
self.connect_rst_enable_arg +
['-ex', "monitor swdp_scan",
'-ex', "attach 1",
'-ex', "file {}".format(self.elf_file),
'-ex', "load {}".format(self.elf_file)])
'-ex', f"file {self.elf_file}",
'-ex', f"load {self.elf_file}"])
self.check_call_ignore_sigint(command)
def do_run(self, command, **kwargs):

10
scripts/west_commands/runners/canopen_program.py

@ -151,8 +151,8 @@ class CANopenBinaryRunner(ZephyrBinaryRunner): @@ -151,8 +151,8 @@ class CANopenBinaryRunner(ZephyrBinaryRunner):
if status == 0:
self.downloader.swid()
else:
self.logger.warning('Flash status 0x{:02x}, '
'skipping software identification'.format(status))
self.logger.warning(f'Flash status 0x{status:02x}, '
'skipping software identification')
self.downloader.enter_pre_operational()
@ -172,7 +172,7 @@ class CANopenBinaryRunner(ZephyrBinaryRunner): @@ -172,7 +172,7 @@ class CANopenBinaryRunner(ZephyrBinaryRunner):
status = self.downloader.wait_for_flash_status_ok(self.timeout)
if status != 0:
raise ValueError('Program download failed: '
'flash status 0x{:02x}'.format(status))
f'flash status 0x{status:02x}')
self.downloader.swid()
self.downloader.start_program()
@ -234,7 +234,7 @@ class CANopenProgramDownloader: @@ -234,7 +234,7 @@ class CANopenProgramDownloader:
try:
self.ctrl_sdo.raw = cmd
except Exception as err:
raise ValueError('Unable to write control command 0x{:02x}'.format(cmd)) from err
raise ValueError(f'Unable to write control command 0x{cmd:02x}') from err
def stop_program(self):
'''Write stop control command to CANopen object dictionary (0x1f51)'''
@ -262,7 +262,7 @@ class CANopenProgramDownloader: @@ -262,7 +262,7 @@ class CANopenProgramDownloader:
swid = self.swid_sdo.raw
except Exception as err:
raise ValueError('Failed to read software identification') from err
self.logger.info('Program software identification: 0x{:08x}'.format(swid))
self.logger.info(f'Program software identification: 0x{swid:08x}')
return swid
def flash_status(self):

5
scripts/west_commands/runners/core.py

@ -481,7 +481,7 @@ class ZephyrBinaryRunner(abc.ABC): @@ -481,7 +481,7 @@ class ZephyrBinaryRunner(abc.ABC):
self.cfg = cfg
'''RunnerConfig for this instance.'''
self.logger = logging.getLogger('runners.{}'.format(self.name()))
self.logger = logging.getLogger(f'runners.{self.name()}')
'''logging.Logger for this instance.'''
@staticmethod
@ -709,8 +709,7 @@ class ZephyrBinaryRunner(abc.ABC): @@ -709,8 +709,7 @@ class ZephyrBinaryRunner(abc.ABC):
This is the main entry point to this runner.'''
caps = self.capabilities()
if command not in caps.commands:
raise ValueError('runner {} does not implement command {}'.format(
self.name(), command))
raise ValueError(f'runner {self.name()} does not implement command {command}')
self.do_run(command, **kwargs)
@abc.abstractmethod

6
scripts/west_commands/runners/dfu.py

@ -23,11 +23,11 @@ class DfuUtilBinaryRunner(ZephyrBinaryRunner): @@ -23,11 +23,11 @@ class DfuUtilBinaryRunner(ZephyrBinaryRunner):
self.dev_id = dev_id # Used only for error checking in do_run
self.alt = alt
self.img = img
self.cmd = [exe, '-d,{}'.format(dev_id)]
self.cmd = [exe, f'-d,{dev_id}']
try:
self.list_pattern = ', alt={},'.format(int(self.alt))
self.list_pattern = f', alt={int(self.alt)},'
except ValueError:
self.list_pattern = ', name="{}",'.format(self.alt)
self.list_pattern = f', name="{self.alt}",'
if dfuse_config is None:
self.dfuse = False

3
scripts/west_commands/runners/esp32.py

@ -132,6 +132,5 @@ class Esp32BinaryRunner(ZephyrBinaryRunner): @@ -132,6 +132,5 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
else:
cmd_flash.extend([self.app_address, self.app_bin])
self.logger.info("Flashing esp32 chip on {} ({}bps)".
format(self.device, self.baud))
self.logger.info(f"Flashing esp32 chip on {self.device} ({self.baud}bps)")
self.check_call(cmd_flash)

10
scripts/west_commands/runners/intel_cyclonev.py

@ -240,10 +240,10 @@ class IntelCycloneVBinaryRunner(ZephyrBinaryRunner): @@ -240,10 +240,10 @@ class IntelCycloneVBinaryRunner(ZephyrBinaryRunner):
pre_init_cmd)
temp_str = '--cd=' + os.environ.get('ZEPHYR_BASE') #Go to Zephyr base Dir
gdb_cmd = (self.gdb_cmd + self.tui_arg +
[temp_str,'-ex', 'target extended-remote localhost:{}'.format(self.gdb_port) , '-batch']) #Execute First Script in Zephyr Base Dir
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute First Script in Zephyr Base Dir
gdb_cmd2 = (self.gdb_cmd + self.tui_arg +
['-ex', 'target extended-remote localhost:{}'.format(self.gdb_port) , '-batch']) #Execute Second Script in Build Dir
['-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute Second Script in Build Dir
echo = ['echo']
if self.gdb_init is not None:
for i in self.gdb_init:
@ -295,16 +295,16 @@ class IntelCycloneVBinaryRunner(ZephyrBinaryRunner): @@ -295,16 +295,16 @@ class IntelCycloneVBinaryRunner(ZephyrBinaryRunner):
pre_init_cmd)
gdb_attach = (self.gdb_cmd + self.tui_arg +
['-ex', 'target extended-remote :{}'.format(self.gdb_port),
['-ex', f'target extended-remote :{self.gdb_port}',
self.elf_name, '-q'])
temp_str = '--cd=' + os.environ.get('ZEPHYR_BASE') #Go to Zephyr base Dir
gdb_cmd = (self.gdb_cmd + self.tui_arg +
[temp_str,'-ex', 'target extended-remote localhost:{}'.format(self.gdb_port) , '-batch']) #Execute First Script in Zephyr Base Dir
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute First Script in Zephyr Base Dir
gdb_cmd2 = (self.gdb_cmd + self.tui_arg +
['-ex', 'target extended-remote :{}'.format(self.gdb_port) , '-batch']) #Execute Second Script in Build Dir
['-ex', f'target extended-remote :{self.gdb_port}' , '-batch']) #Execute Second Script in Build Dir
if self.gdb_init is not None:

7
scripts/west_commands/runners/jlink.py

@ -128,8 +128,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner): @@ -128,8 +128,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner):
help='custom gdb host, defaults to the empty string '
'and runs a gdb server')
parser.add_argument('--gdb-port', default=DEFAULT_JLINK_GDB_PORT,
help='pyocd gdb port, defaults to {}'.format(
DEFAULT_JLINK_GDB_PORT))
help=f'pyocd gdb port, defaults to {DEFAULT_JLINK_GDB_PORT}')
parser.add_argument('--commander', default=DEFAULT_JLINK_EXE,
help=f'''J-Link Commander, default is
{DEFAULT_JLINK_EXE}''')
@ -314,7 +313,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner): @@ -314,7 +313,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner):
client_cmd = (self.gdb_cmd +
self.tui_arg +
[elf_name] +
['-ex', 'target remote {}:{}'.format(self.gdb_host, self.gdb_port)])
['-ex', f'target remote {self.gdb_host}:{self.gdb_port}'])
if command == 'debug':
client_cmd += ['-ex', 'monitor halt',
'-ex', 'monitor reset',
@ -423,7 +422,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner): @@ -423,7 +422,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner):
(['-nogui', '1'] if self.supports_nogui else []) +
self.tool_opt)
self.logger.info('Flashing file: {}'.format(flash_file))
self.logger.info(f'Flashing file: {flash_file}')
kwargs = {}
if not self.logger.isEnabledFor(logging.DEBUG):
kwargs['stdout'] = subprocess.DEVNULL

5
scripts/west_commands/runners/linkserver.py

@ -78,8 +78,7 @@ class LinkServerBinaryRunner(ZephyrBinaryRunner): @@ -78,8 +78,7 @@ class LinkServerBinaryRunner(ZephyrBinaryRunner):
help='if given, GDB uses -tui')
parser.add_argument('--gdb-port', default=DEFAULT_LINKSERVER_GDB_PORT,
help='gdb port to open, defaults to {}'.format(
DEFAULT_LINKSERVER_GDB_PORT))
help=f'gdb port to open, defaults to {DEFAULT_LINKSERVER_GDB_PORT}')
parser.add_argument('--semihost-port', default=DEFAULT_LINKSERVER_SEMIHOST_PORT,
help='semihost port to open, defaults to the empty string '
@ -147,7 +146,7 @@ class LinkServerBinaryRunner(ZephyrBinaryRunner): @@ -147,7 +146,7 @@ class LinkServerBinaryRunner(ZephyrBinaryRunner):
gdb_cmd = ([self.gdb_cmd] +
self.tui_arg +
[self.elf_name] +
['-ex', 'target remote {}:{}'.format(self.gdb_host, self.gdb_port)])
['-ex', f'target remote {self.gdb_host}:{self.gdb_port}'])
if command == 'debug':
gdb_cmd += [ '-ex', 'load', '-ex', 'monitor reset']

6
scripts/west_commands/runners/mdb.py

@ -67,7 +67,7 @@ def mdb_do_run(mdb_runner, command): @@ -67,7 +67,7 @@ def mdb_do_run(mdb_runner, command):
mdb_target += [mdb_runner.dig_device]
else:
# \todo: add support of other debuggers
raise ValueError('unsupported jtag adapter {}'.format(mdb_runner.jtag))
raise ValueError(f'unsupported jtag adapter {mdb_runner.jtag}')
if command == 'flash':
if is_flash_cmd_need_exit_immediately(mdb_runner):
@ -84,7 +84,7 @@ def mdb_do_run(mdb_runner, command): @@ -84,7 +84,7 @@ def mdb_do_run(mdb_runner, command):
elif 1 < mdb_runner.cores <= 12:
mdb_multifiles = '-multifiles='
for i in range(mdb_runner.cores):
mdb_sub_cmd = [commander] + ['-pset={}'.format(i + 1), '-psetname=core{}'.format(i)]
mdb_sub_cmd = [commander] + [f'-pset={i + 1}', f'-psetname=core{i}']
# -prop=download=2 is used for SMP application debug, only the 1st core
# will download the shared image.
if i > 0:
@ -100,7 +100,7 @@ def mdb_do_run(mdb_runner, command): @@ -100,7 +100,7 @@ def mdb_do_run(mdb_runner, command):
mdb_cmd = [commander] + [mdb_multifiles] + mdb_run
else:
raise ValueError('unsupported cores {}'.format(mdb_runner.cores))
raise ValueError(f'unsupported cores {mdb_runner.cores}')
mdb_runner.call(mdb_cmd, cwd=mdb_runner.build_dir)

5
scripts/west_commands/runners/native.py

@ -44,8 +44,7 @@ class NativeSimBinaryRunner(ZephyrBinaryRunner): @@ -44,8 +44,7 @@ class NativeSimBinaryRunner(ZephyrBinaryRunner):
parser.add_argument('--tui', default=False, action='store_true',
help='if given, GDB uses -tui')
parser.add_argument('--gdb-port', default=DEFAULT_GDB_PORT,
help='gdb port, defaults to {}'.format(
DEFAULT_GDB_PORT))
help=f'gdb port, defaults to {DEFAULT_GDB_PORT}')
@classmethod
def do_create(cls, cfg: RunnerConfig, args: argparse.Namespace) -> ZephyrBinaryRunner:
@ -77,6 +76,6 @@ class NativeSimBinaryRunner(ZephyrBinaryRunner): @@ -77,6 +76,6 @@ class NativeSimBinaryRunner(ZephyrBinaryRunner):
self.check_call(cmd)
def do_debugserver(self, **kwargs):
cmd = (['gdbserver', ':{}'.format(self.gdb_port), self.cfg.exe_file])
cmd = (['gdbserver', f':{self.gdb_port}', self.cfg.exe_file])
self.check_call(cmd)

7
scripts/west_commands/runners/nios2.py

@ -62,7 +62,7 @@ class Nios2BinaryRunner(ZephyrBinaryRunner): @@ -62,7 +62,7 @@ class Nios2BinaryRunner(ZephyrBinaryRunner):
raise ValueError('Cannot flash; --cpu-sof not given.')
self.ensure_output('hex')
self.logger.info('Flashing file: {}'.format(self.hex_name))
self.logger.info(f'Flashing file: {self.hex_name}')
cmd = [self.quartus_py,
'--sof', self.cpu_sof,
'--kernel', self.hex_name]
@ -70,8 +70,7 @@ class Nios2BinaryRunner(ZephyrBinaryRunner): @@ -70,8 +70,7 @@ class Nios2BinaryRunner(ZephyrBinaryRunner):
self.check_call(cmd)
def print_gdbserver_message(self, gdb_port):
self.logger.info('Nios II GDB server running on port {}'.
format(gdb_port))
self.logger.info(f'Nios II GDB server running on port {gdb_port}')
def debug_debugserver(self, command, **kwargs):
# Per comments in the shell script, the NIOSII GDB server
@ -100,7 +99,7 @@ class Nios2BinaryRunner(ZephyrBinaryRunner): @@ -100,7 +99,7 @@ class Nios2BinaryRunner(ZephyrBinaryRunner):
gdb_cmd = (self.gdb_cmd +
self.tui_arg +
[self.elf_name,
'-ex', 'target remote :{}'.format(gdb_port)])
'-ex', f'target remote :{gdb_port}'])
self.require(gdb_cmd[0])
self.print_gdbserver_message(gdb_port)

9
scripts/west_commands/runners/nrf_common.py

@ -177,7 +177,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner): @@ -177,7 +177,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
elif len(snrs) == 1:
board_snr = snrs[0]
self.verify_snr(board_snr)
print("Using board {}".format(board_snr))
print(f"Using board {board_snr}")
return board_snr
elif not sys.stdin.isatty():
raise RuntimeError(
@ -190,10 +190,9 @@ class NrfBinaryRunner(ZephyrBinaryRunner): @@ -190,10 +190,9 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
print('There are multiple boards connected{}.'.format(
f" matching '{glob}'" if glob != "*" else ""))
for i, snr in enumerate(snrs, 1):
print('{}. {}'.format(i, snr))
print(f'{i}. {snr}')
p = 'Please select one with desired serial number (1-{}): '.format(
len(snrs))
p = f'Please select one with desired serial number (1-{len(snrs)}): '
while True:
try:
value = input(p)
@ -299,7 +298,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner): @@ -299,7 +298,7 @@ class NrfBinaryRunner(ZephyrBinaryRunner):
def program_hex(self):
# Get the command use to actually program self.hex_.
self.logger.info('Flashing file: {}'.format(self.hex_))
self.logger.info(f'Flashing file: {self.hex_}')
# What type of erase/core arguments should we pass to the tool?
core = None

6
scripts/west_commands/runners/nsim.py

@ -83,10 +83,10 @@ class NsimBinaryRunner(ZephyrBinaryRunner): @@ -83,10 +83,10 @@ class NsimBinaryRunner(ZephyrBinaryRunner):
config = kwargs['nsim-cfg']
server_cmd = (self.nsim_cmd + ['-gdb',
'-port={}'.format(self.gdb_port),
f'-port={self.gdb_port}',
'-propsfile', config])
gdb_cmd = (self.gdb_cmd +
['-ex', 'target remote :{}'.format(self.gdb_port),
['-ex', f'target remote :{self.gdb_port}',
'-ex', 'load', self.cfg.elf_file])
self.require(gdb_cmd[0])
@ -96,7 +96,7 @@ class NsimBinaryRunner(ZephyrBinaryRunner): @@ -96,7 +96,7 @@ class NsimBinaryRunner(ZephyrBinaryRunner):
config = kwargs['nsim-cfg']
cmd = (self.nsim_cmd +
['-gdb', '-port={}'.format(self.gdb_port),
['-gdb', f'-port={self.gdb_port}',
'-propsfile', config])
self.check_call(cmd)

18
scripts/west_commands/runners/pyocd.py

@ -100,11 +100,9 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner): @@ -100,11 +100,9 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
parser.add_argument('--frequency',
help='SWD clock frequency in Hz')
parser.add_argument('--gdb-port', default=DEFAULT_PYOCD_GDB_PORT,
help='pyocd gdb port, defaults to {}'.format(
DEFAULT_PYOCD_GDB_PORT))
help=f'pyocd gdb port, defaults to {DEFAULT_PYOCD_GDB_PORT}')
parser.add_argument('--telnet-port', default=DEFAULT_PYOCD_TELNET_PORT,
help='pyocd telnet port, defaults to {}'.format(
DEFAULT_PYOCD_TELNET_PORT))
help=f'pyocd telnet port, defaults to {DEFAULT_PYOCD_TELNET_PORT}')
parser.add_argument('--tui', default=False, action='store_true',
help='if given, GDB uses -tui')
parser.add_argument('--board-id', dest='dev_id',
@ -132,7 +130,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner): @@ -132,7 +130,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
daparg = os.environ.get('PYOCD_DAPARG')
if not ret.daparg_args and daparg:
ret.logger.warning('PYOCD_DAPARG is deprecated; use --daparg')
ret.logger.debug('--daparg={} via PYOCD_DAPARG'.format(daparg))
ret.logger.debug(f'--daparg={daparg} via PYOCD_DAPARG')
ret.daparg_args = ['-da', daparg]
return ret
@ -161,8 +159,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner): @@ -161,8 +159,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
fname = self.elf_name
else:
raise ValueError(
'Cannot flash; no hex ({}), bin ({}) or elf ({}) files found. '.format(
self.hex_name, self.bin_name, self.elf_name))
f'Cannot flash; no hex ({self.hex_name}), bin ({self.bin_name}) or elf ({self.elf_name}) files found. ')
erase_method = 'chip' if self.erase else 'sector'
@ -179,12 +176,11 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner): @@ -179,12 +176,11 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
self.flash_extra +
[fname])
self.logger.info('Flashing file: {}'.format(fname))
self.logger.info(f'Flashing file: {fname}')
self.check_call(cmd)
def log_gdbserver_message(self):
self.logger.info('pyOCD GDB server running on port {}'.
format(self.gdb_port))
self.logger.info(f'pyOCD GDB server running on port {self.gdb_port}')
def debug_debugserver(self, command, **kwargs):
server_cmd = ([self.pyocd] +
@ -207,7 +203,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner): @@ -207,7 +203,7 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
client_cmd = (self.gdb_cmd +
self.tui_args +
[self.elf_name] +
['-ex', 'target remote :{}'.format(self.gdb_port)])
['-ex', f'target remote :{self.gdb_port}'])
if command == 'debug':
client_cmd += ['-ex', 'monitor halt',
'-ex', 'monitor reset',

2
scripts/west_commands/runners/silabs_commander.py

@ -123,5 +123,5 @@ class SiLabsCommanderBinaryRunner(ZephyrBinaryRunner): @@ -123,5 +123,5 @@ class SiLabsCommanderBinaryRunner(ZephyrBinaryRunner):
args = [self.commander, 'flash'] + opts + self.tool_opt + flash_args
self.logger.info('Flashing file: {}'.format(flash_file))
self.logger.info(f'Flashing file: {flash_file}')
self.check_call(args)

14
scripts/west_commands/runners/stm32flash.py

@ -98,19 +98,19 @@ class Stm32flashBinaryRunner(ZephyrBinaryRunner): @@ -98,19 +98,19 @@ class Stm32flashBinaryRunner(ZephyrBinaryRunner):
if action == 'info':
# show device information and exit
msg_text = "get device info from {}".format(self.device)
msg_text = f"get device info from {self.device}"
elif action == 'erase':
# erase flash
#size_aligned = (int(bin_size) >> 12) + 1 << 12
size_aligned = (int(bin_size) & 0xfffff000) + 4096
msg_text = "erase {} bit starting at {}".format(size_aligned, self.start_addr)
msg_text = f"erase {size_aligned} bit starting at {self.start_addr}"
cmd_flash.extend([
'-S', str(self.start_addr) + ":" + str(size_aligned), '-o'])
elif action == 'start':
# start execution
msg_text = "start code execution at {}".format(self.exec_addr)
msg_text = f"start code execution at {self.exec_addr}"
if self.exec_addr:
if self.exec_addr == 0 or self.exec_addr.lower() == '0x0':
msg_text += " (flash start)"
@ -121,7 +121,7 @@ class Stm32flashBinaryRunner(ZephyrBinaryRunner): @@ -121,7 +121,7 @@ class Stm32flashBinaryRunner(ZephyrBinaryRunner):
elif action == 'write':
# flash binary file
msg_text = "write {} bytes starting at {}".format(bin_size, self.start_addr)
msg_text = f"write {bin_size} bytes starting at {self.start_addr}"
cmd_flash.extend([
'-S', str(self.start_addr) + ":" + str(bin_size),
'-w', bin_name])
@ -139,11 +139,11 @@ class Stm32flashBinaryRunner(ZephyrBinaryRunner): @@ -139,11 +139,11 @@ class Stm32flashBinaryRunner(ZephyrBinaryRunner):
cmd_flash.extend(['-v'])
else:
msg_text = "invalid action \'{}\' passed!".format(action)
self.logger.error('Invalid action \'{}\' passed!'.format(action))
msg_text = f"invalid action \'{action}\' passed!"
self.logger.error(f'Invalid action \'{action}\' passed!')
return -1
cmd_flash.extend([self.device])
self.logger.info("Board: " + msg_text)
self.check_call(cmd_flash)
self.logger.info('Board: finished \'{}\' .'.format(action))
self.logger.info(f'Board: finished \'{action}\' .')

4
scripts/west_commands/runners/teensy.py

@ -48,13 +48,13 @@ class TeensyBinaryRunner(ZephyrBinaryRunner): @@ -48,13 +48,13 @@ class TeensyBinaryRunner(ZephyrBinaryRunner):
fname = self.hex_name
else:
raise ValueError(
'Cannot flash; no hex ({}) file found. '.format(self.hex_name))
f'Cannot flash; no hex ({self.hex_name}) file found. ')
cmd = ([self.teensy_loader] +
self.mcu_args +
[fname])
self.logger.info('Flashing file: {}'.format(fname))
self.logger.info(f'Flashing file: {fname}')
try:
self.check_output(cmd)

Loading…
Cancel
Save