Skip to content

Commit

Permalink
[nrf fromtree] scripts: west_commands: runners: Fix line-too-long (E501)
Browse files Browse the repository at this point in the history
Wrap long lines to max 100 characters.

See https://docs.astral.sh/ruff/rules/line-too-long/

Signed-off-by: Pieter De Gendt <[email protected]>
(cherry picked from commit 336c7da)

Signed-off-by: Tomasz Chyrowicz <[email protected]>
  • Loading branch information
pdgendt authored and tomchy committed Dec 2, 2024
1 parent 65c4c04 commit 56f9942
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 70 deletions.
4 changes: 3 additions & 1 deletion scripts/west_commands/runners/bossac.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ def get_image_offset(self, supports_offset):

def is_gnu_coreutils_stty(self):
try:
result = subprocess.run(['stty', '--version'], capture_output=True, text=True, check=True)
result = subprocess.run(
['stty', '--version'], capture_output=True, text=True, check=True
)
return 'coreutils' in result.stdout
except subprocess.CalledProcessError:
return False
Expand Down
6 changes: 4 additions & 2 deletions scripts/west_commands/runners/canopen_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def do_add_parser(cls, parser):
parser.add_argument('--sdo-timeout', type=float, default=DEFAULT_SDO_TIMEOUT,
help=f'''CANopen SDO response timeout in seconds
(default: {DEFAULT_SDO_TIMEOUT})''')
parser.add_argument('--download-buffer-size', type=int, default=DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE,
help=f'Program download buffer size in bytes (default: {DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE})')
parser.add_argument('--download-buffer-size', type=int,
default=DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE,
help=f'''Program download buffer size in bytes
(default: {DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE})''')
parser.add_argument('--block-transfer', default=False, action='store_true',
help='Use SDO block transfers (experimental, default: no)')

Expand Down
21 changes: 14 additions & 7 deletions scripts/west_commands/runners/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,16 +577,22 @@ def add_parser(cls, parser):
else:
parser.add_argument('--elf-file',
metavar='FILE',
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),
help='path to zephyr.elf' if not caps.file else 'Deprecated, use -f/--file instead.')
action=(partial(depr_action, cls=cls,
replacement='-f/--file') if caps.file else None),
help='path to zephyr.elf'
if not caps.file else 'Deprecated, use -f/--file instead.')
parser.add_argument('--hex-file',
metavar='FILE',
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),
help='path to zephyr.hex' if not caps.file else 'Deprecated, use -f/--file instead.')
action=(partial(depr_action, cls=cls,
replacement='-f/--file') if caps.file else None),
help='path to zephyr.hex'
if not caps.file else 'Deprecated, use -f/--file instead.')
parser.add_argument('--bin-file',
metavar='FILE',
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),
help='path to zephyr.bin' if not caps.file else 'Deprecated, use -f/--file instead.')
action=(partial(depr_action, cls=cls,
replacement='-f/--file') if caps.file else None),
help='path to zephyr.bin'
if not caps.file else 'Deprecated, use -f/--file instead.')

parser.add_argument('--erase', '--no-erase', nargs=0,
action=_ToggleAction,
Expand All @@ -612,7 +618,8 @@ def add_parser(cls, parser):
if caps.rtt:
parser.add_argument('--rtt-address', dest='rtt_address',
type=lambda x: int(x, 0),
help="address of RTT control block. If not supplied, it will be autodetected if possible")
help="""address of RTT control block. If not supplied,
it will be autodetected if possible""")
else:
parser.add_argument('--rtt-address', help=argparse.SUPPRESS)

Expand Down
4 changes: 3 additions & 1 deletion scripts/west_commands/runners/ezflashcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def program_bin(self):
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] + options + ["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...")
Expand Down
3 changes: 2 additions & 1 deletion scripts/west_commands/runners/intel_adsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def do_add_parser(cls, parser):

for old_sign_param in [ '--rimage-tool', '--config-dir', '--default-key', '--key']:
parser.add_argument(old_sign_param, action=SignParamError,
help='do not use, "west sign" is now called from CMake, see "west sign -h"')
help='''do not use, "west sign" is now called from CMake,
see "west sign -h"''')

@classmethod
def tool_opt_help(cls) -> str:
Expand Down
16 changes: 10 additions & 6 deletions scripts/west_commands/runners/intel_cyclonev.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def do_add_parser(cls, parser):
help='''if given, override default config file;
may be given multiple times''')
parser.add_argument('--serial', default="",
help='if given, selects FTDI instance by its serial number, defaults to empty')
help='''if given, selects FTDI instance by its serial number,
defaults to empty''')
parser.add_argument('--use-elf', default=False, action='store_true',
help='if given, Elf file will be used for loading instead of HEX image')
# Options for flashing:
Expand Down Expand Up @@ -242,11 +243,12 @@ def do_flash_elf(self, **kwargs):
server_cmd = (self.openocd_cmd + self.serial + self.cfg_cmd + #added mevalver
pre_init_cmd)
temp_str = '--cd=' + os.environ.get('ZEPHYR_BASE') #Go to Zephyr base Dir
# Execute First Script in Zephyr Base Dir
gdb_cmd = (self.gdb_cmd + self.tui_arg +
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute First Script in Zephyr Base Dir

[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch'])
# Execute Second Script in Build Dir
gdb_cmd2 = (self.gdb_cmd + self.tui_arg +
['-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute Second Script in Build Dir
['-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch'])
echo = ['echo']
if self.gdb_init is not None:
for i in self.gdb_init:
Expand Down Expand Up @@ -303,11 +305,13 @@ def do_attach_debug(self, command, **kwargs):

temp_str = '--cd=' + os.environ.get('ZEPHYR_BASE') #Go to Zephyr base Dir

# Execute First Script in Zephyr Base Dir
gdb_cmd = (self.gdb_cmd + self.tui_arg +
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute First Script in Zephyr Base Dir
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch'])

# Execute Second Script in Build Dir
gdb_cmd2 = (self.gdb_cmd + self.tui_arg +
['-ex', f'target extended-remote :{self.gdb_port}' , '-batch']) #Execute Second Script in Build Dir
['-ex', f'target extended-remote :{self.gdb_port}' , '-batch'])


if self.gdb_init is not None:
Expand Down
58 changes: 34 additions & 24 deletions scripts/west_commands/runners/jlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,25 @@ def do_run(self, command, **kwargs):
'RTOSPlugin_Zephyr')
big_endian = self.build_conf.getboolean('CONFIG_BIG_ENDIAN')

server_cmd = ([self.gdbserver] +
['-select',
('ip' if (is_ip(self.dev_id) or is_tunnel(self.dev_id)) else 'usb') +
(f'={self.dev_id}' if self.dev_id else ''),
'-port', str(self.gdb_port),
'-if', self.iface,
'-speed', self.speed,
'-device', self.device,
'-silent',
'-endian', 'big' if big_endian else 'little',
'-singlerun'] +
(['-nogui'] if self.supports_nogui else []) +
(['-rtos', plugin_dir] if rtos else []) +
['-rtttelnetport', str(self.rtt_port)] +
self.tool_opt)
server_cmd = (
[self.gdbserver]
+ [
'-select',
('ip' if (is_ip(self.dev_id) or is_tunnel(self.dev_id)) else 'usb')
+ (f'={self.dev_id}' if self.dev_id else ''),
]
+ ['-port', str(self.gdb_port)]
+ ['-if', self.iface]
+ ['-speed', self.speed]
+ ['-device', self.device]
+ ['-silent']
+ ['-endian' 'big' if big_endian else 'little']
+ ['-singlerun']
+ (['-nogui'] if self.supports_nogui else [])
+ (['-rtos', plugin_dir] if rtos else [])
+ ['-rtttelnetport', str(self.rtt_port)]
+ self.tool_opt
)

if command == 'flash':
self.flash(**kwargs)
Expand Down Expand Up @@ -405,15 +409,21 @@ def flash(self, **kwargs):
if self.supports_loader and self.loader:
loader_details = "?" + self.loader

cmd = ([self.commander] +
(['-IP', f'{self.dev_id}'] if (is_ip(self.dev_id) or is_tunnel(self.dev_id)) else (['-USB', f'{self.dev_id}'] if self.dev_id else [])) +
(['-nogui', '1'] if self.supports_nogui else []) +
['-if', self.iface,
'-speed', self.speed,
'-device', self.device + loader_details,
'-CommanderScript', fname] +
(['-nogui', '1'] if self.supports_nogui else []) +
self.tool_opt)
cmd = (
[self.commander]
+ (
['-IP', f'{self.dev_id}']
if (is_ip(self.dev_id) or is_tunnel(self.dev_id))
else (['-USB', f'{self.dev_id}'] if self.dev_id else [])
)
+ (['-nogui', '1'] if self.supports_nogui else [])
+ ['-if', self.iface]
+ ['-speed', self.speed]
+ ['-device', self.device + loader_details]
+ ['-CommanderScript', fname]
+ (['-nogui', '1'] if self.supports_nogui else [])
+ self.tool_opt
)

self.logger.info(f'Flashing file: {flash_file}')
kwargs = {}
Expand Down
13 changes: 9 additions & 4 deletions scripts/west_commands/runners/linkserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ def do_add_parser(cls, parser):
{DEFAULT_LINKSERVER_EXE}''')
# user may need to override settings.
parser.add_argument('--override', required=False, action='append',
help='''configuration overrides as defined bylinkserver. Example: /device/memory/0/location=0xcafecafe''')
help='''configuration overrides as defined bylinkserver.
Example: /device/memory/0/location=0xcafecafe''')

@classmethod
def do_create(cls, cfg, args):

print("RUNNER - gdb_port = " + str(args.gdb_port) + ", semih port = " + str(args.semihost_port))
print(f"RUNNER - gdb_port = {args.gdb_port}, semih port = {args.semihost_port}")
return LinkServerBinaryRunner(cfg, args.device, args.core,
linkserver=args.linkserver,
dt_flash=args.dt_flash,
Expand Down Expand Up @@ -180,8 +181,12 @@ def _build_override_cli(self):
return override_cli

def flash(self, **kwargs):

linkserver_cmd = ([self.linkserver, "flash"] + ["--probe", str(self.probe)] + self.override_cli + [self.device])
linkserver_cmd = (
[self.linkserver, "flash"]
+ ["--probe", str(self.probe)]
+ self.override_cli
+ [self.device]
)
self.logger.debug(f'LinkServer cmd: + {linkserver_cmd}')

if self.erase:
Expand Down
11 changes: 7 additions & 4 deletions scripts/west_commands/runners/mdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ def is_flash_cmd_need_exit_immediately(mdb_runner):

def smp_core_order(mdb_runner, id):
if is_simulation_run(mdb_runner):
# for simulation targets we start cores in direct order (core 0 first, core 1 second, etc...)
# otherwise we face mismatch arcnum (code ID) with ARConnect ID and core ID in instruction traces
# for simulation targets we start cores in direct order
# (core 0 first, core 1 second, etc...)
# otherwise we face mismatch arcnum (code ID) with ARConnect ID
# and core ID in instruction traces
return id
else:
# for HW targets we want to start the primary core last, to avoid ARConnect initialization interfere
# for HW targets we want to start the primary core last,
# to avoid ARConnect initialization interfere
# with secondary cores startup - so we reverse start order
return mdb_runner.cores - 1 - id

Expand Down Expand Up @@ -91,7 +94,7 @@ def mdb_do_run(mdb_runner, command):
if i > 0: mdb_sub_cmd += ['-prop=download=2']
mdb_sub_cmd += mdb_basic_options + mdb_target + [mdb_runner.elf_name]
mdb_runner.check_call(mdb_sub_cmd, cwd=mdb_runner.build_dir)
mdb_multifiles += ('core{}' if i == 0 else ',core{}').format(smp_core_order(mdb_runner, i))
mdb_multifiles += f'{"" if i == 0 else ","}core{smp_core_order(mdb_runner, i)}'

# to enable multi-core aware mode for use with the MetaWare debugger,
# need to set the NSIM_MULTICORE environment variable to a non-zero value
Expand Down
41 changes: 32 additions & 9 deletions scripts/west_commands/runners/nrf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,26 +278,49 @@ def program_hex(self):

# Manage SUIT artifacts.
# This logic should be executed only once per build.
# Use sysbuild board qualifiers to select the context, with which the artifacts will be programmed.
if self.build_conf.get('CONFIG_BOARD_QUALIFIERS') == self.sysbuild_conf.get('SB_CONFIG_BOARD_QUALIFIERS'):
# Use sysbuild board qualifiers to select the context,
# with which the artifacts will be programmed.
if self.build_conf.get('CONFIG_BOARD_QUALIFIERS') == self.sysbuild_conf.get(
'SB_CONFIG_BOARD_QUALIFIERS'
):
mpi_hex_dir = Path(os.path.join(self.cfg.build_dir, 'zephyr'))

# Handle Manifest Provisioning Information
if self.build_conf.getboolean('CONFIG_SUIT_MPI_GENERATE'):
app_mpi_hex_file = os.fspath(
mpi_hex_dir / self.build_conf.get('CONFIG_SUIT_MPI_APP_AREA_PATH'))
rad_mpi_hex_file = os.fspath(
mpi_hex_dir / self.build_conf.get('CONFIG_SUIT_MPI_RAD_AREA_PATH'))
self.op_program(app_mpi_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_APPLICATION')
self.op_program(rad_mpi_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_NETWORK')
mpi_hex_dir / self.build_conf.get('CONFIG_SUIT_MPI_RAD_AREA_PATH')
)
self.op_program(
app_mpi_hex_file,
'ERASE_NONE',
None,
defer=True,
core='NRFDL_DEVICE_CORE_APPLICATION',
)
self.op_program(
rad_mpi_hex_file,
'ERASE_NONE',
None,
defer=True,
core='NRFDL_DEVICE_CORE_NETWORK',
)

# Handle SUIT root manifest if application manifests are not used.
# If an application firmware is built, the root envelope is merged with other application manifests
# as well as the output HEX file.
# If an application firmware is built, the root envelope is merged
# with other application manifests as well as the output HEX file.
if not cpuapp and self.sysbuild_conf.get('SB_CONFIG_SUIT_ENVELOPE'):
app_root_envelope_hex_file = os.fspath(
mpi_hex_dir / 'suit_installed_envelopes_application_merged.hex')
self.op_program(app_root_envelope_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_APPLICATION')
mpi_hex_dir / 'suit_installed_envelopes_application_merged.hex'
)
self.op_program(
app_root_envelope_hex_file,
'ERASE_NONE',
None,
defer=True,
core='NRFDL_DEVICE_CORE_APPLICATION',
)

if cpuapp:
core = 'NRFDL_DEVICE_CORE_APPLICATION'
Expand Down
3 changes: 2 additions & 1 deletion scripts/west_commands/runners/openocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def do_add_parser(cls, parser):
help='''if given, override default config file;
may be given multiple times''')
parser.add_argument('--serial', default="",
help='if given, selects FTDI instance by its serial number, defaults to empty')
help='''if given, selects FTDI instance by its serial number,
defaults to empty''')
parser.add_argument('--use-elf', default=False, action='store_true',
help='if given, Elf file will be used for loading instead of HEX image')
# Options for flashing:
Expand Down
3 changes: 2 additions & 1 deletion scripts/west_commands/runners/pyocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def flash(self, **kwargs):
fname = self.elf_name
else:
raise ValueError(
f'Cannot flash; no hex ({self.hex_name}), bin ({self.bin_name}) or elf ({self.elf_name}) files found. ')
f'Cannot flash; no hex ({self.hex_name}), bin ({self.bin_name}) '
f'or elf ({self.elf_name}) files found. ')

erase_method = 'chip' if self.erase else 'sector'

Expand Down
3 changes: 2 additions & 1 deletion scripts/west_commands/runners/renode-robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ def run_test(self, **kwargs):
for suite in self.testsuite:
cmd.append(suite)
else:
self.logger.error("No Robot testsuite passed to renode-test! Use the `--testsuite` argument to provide one.")
self.logger.error("No Robot testsuite passed to renode-test! "
"Use the `--testsuite` argument to provide one.")
subprocess.run(cmd, check=True)
3 changes: 2 additions & 1 deletion scripts/west_commands/runners/renode.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def do_add_parser(cls, parser):
parser.add_argument('--renode-arg',
metavar='ARG',
action='append',
help='additional argument passed to Renode; `--help` will print all possible arguments')
help='''additional argument passed to Renode;
`--help` will print all possible arguments''')
parser.add_argument('--renode-command',
metavar='COMMAND',
action='append',
Expand Down
3 changes: 2 additions & 1 deletion scripts/west_commands/runners/silabs_commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def do_run(self, command, **kwargs):
flash_file = self.bin_name
flash_args = ['--binary', '--address', f'0x{flash_addr:x}', flash_file]
else:
raise ValueError(f'Cannot flash; no hex ({self.hex_name}) or bin ({self.bin_name}) files found.')
raise ValueError(f'Cannot flash; no hex ({self.hex_name}) or '
f'bin ({self.bin_name}) files found.')

args = [self.commander, 'flash'] + opts + self.tool_opt + flash_args

Expand Down
Loading

0 comments on commit 56f9942

Please sign in to comment.