Skip to content

Commit 6a590e4

Browse files
pdgendttomchy
authored andcommitted
[nrf fromtree] scripts: west_commands: runners: Fix line-too-long (E501)
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]>
1 parent 50570b0 commit 6a590e4

File tree

17 files changed

+148
-70
lines changed

17 files changed

+148
-70
lines changed

scripts/west_commands/runners/bossac.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def get_image_offset(self, supports_offset):
151151

152152
def is_gnu_coreutils_stty(self):
153153
try:
154-
result = subprocess.run(['stty', '--version'], capture_output=True, text=True, check=True)
154+
result = subprocess.run(
155+
['stty', '--version'], capture_output=True, text=True, check=True
156+
)
155157
return 'coreutils' in result.stdout
156158
except subprocess.CalledProcessError:
157159
return False

scripts/west_commands/runners/canopen_program.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ def do_add_parser(cls, parser):
112112
parser.add_argument('--sdo-timeout', type=float, default=DEFAULT_SDO_TIMEOUT,
113113
help=f'''CANopen SDO response timeout in seconds
114114
(default: {DEFAULT_SDO_TIMEOUT})''')
115-
parser.add_argument('--download-buffer-size', type=int, default=DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE,
116-
help=f'Program download buffer size in bytes (default: {DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE})')
115+
parser.add_argument('--download-buffer-size', type=int,
116+
default=DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE,
117+
help=f'''Program download buffer size in bytes
118+
(default: {DEFAULT_PROGRAM_DOWNLOAD_BUFFER_SIZE})''')
117119
parser.add_argument('--block-transfer', default=False, action='store_true',
118120
help='Use SDO block transfers (experimental, default: no)')
119121

scripts/west_commands/runners/core.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,16 +577,22 @@ def add_parser(cls, parser):
577577
else:
578578
parser.add_argument('--elf-file',
579579
metavar='FILE',
580-
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),
581-
help='path to zephyr.elf' if not caps.file else 'Deprecated, use -f/--file instead.')
580+
action=(partial(depr_action, cls=cls,
581+
replacement='-f/--file') if caps.file else None),
582+
help='path to zephyr.elf'
583+
if not caps.file else 'Deprecated, use -f/--file instead.')
582584
parser.add_argument('--hex-file',
583585
metavar='FILE',
584-
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),
585-
help='path to zephyr.hex' if not caps.file else 'Deprecated, use -f/--file instead.')
586+
action=(partial(depr_action, cls=cls,
587+
replacement='-f/--file') if caps.file else None),
588+
help='path to zephyr.hex'
589+
if not caps.file else 'Deprecated, use -f/--file instead.')
586590
parser.add_argument('--bin-file',
587591
metavar='FILE',
588-
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),
589-
help='path to zephyr.bin' if not caps.file else 'Deprecated, use -f/--file instead.')
592+
action=(partial(depr_action, cls=cls,
593+
replacement='-f/--file') if caps.file else None),
594+
help='path to zephyr.bin'
595+
if not caps.file else 'Deprecated, use -f/--file instead.')
590596

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

scripts/west_commands/runners/ezflashcli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def program_bin(self):
8484
self.check_call([self.tool] + options + ["image_flash", self.bin_])
8585
else:
8686
load_offset = self.build_conf['CONFIG_FLASH_LOAD_OFFSET']
87-
self.check_call([self.tool] + options + ["write_flash", f'0x{load_offset:x}', self.bin_])
87+
self.check_call(
88+
[self.tool] + options + ["write_flash", f'0x{load_offset:x}', self.bin_]
89+
)
8890

8991
def reset_device(self):
9092
self.logger.info("Resetting...")

scripts/west_commands/runners/intel_adsp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def do_add_parser(cls, parser):
6060

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

6566
@classmethod
6667
def tool_opt_help(cls) -> str:

scripts/west_commands/runners/intel_cyclonev.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def do_add_parser(cls, parser):
107107
help='''if given, override default config file;
108108
may be given multiple times''')
109109
parser.add_argument('--serial', default="",
110-
help='if given, selects FTDI instance by its serial number, defaults to empty')
110+
help='''if given, selects FTDI instance by its serial number,
111+
defaults to empty''')
111112
parser.add_argument('--use-elf', default=False, action='store_true',
112113
help='if given, Elf file will be used for loading instead of HEX image')
113114
# Options for flashing:
@@ -242,11 +243,12 @@ def do_flash_elf(self, **kwargs):
242243
server_cmd = (self.openocd_cmd + self.serial + self.cfg_cmd + #added mevalver
243244
pre_init_cmd)
244245
temp_str = '--cd=' + os.environ.get('ZEPHYR_BASE') #Go to Zephyr base Dir
246+
# Execute First Script in Zephyr Base Dir
245247
gdb_cmd = (self.gdb_cmd + self.tui_arg +
246-
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute First Script in Zephyr Base Dir
247-
248+
[temp_str,'-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch'])
249+
# Execute Second Script in Build Dir
248250
gdb_cmd2 = (self.gdb_cmd + self.tui_arg +
249-
['-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch']) #Execute Second Script in Build Dir
251+
['-ex', f'target extended-remote localhost:{self.gdb_port}' , '-batch'])
250252
echo = ['echo']
251253
if self.gdb_init is not None:
252254
for i in self.gdb_init:
@@ -303,11 +305,13 @@ def do_attach_debug(self, command, **kwargs):
303305

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

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

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

312316

313317
if self.gdb_init is not None:

scripts/west_commands/runners/jlink.py

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,25 @@ def do_run(self, command, **kwargs):
247247
'RTOSPlugin_Zephyr')
248248
big_endian = self.build_conf.getboolean('CONFIG_BIG_ENDIAN')
249249

250-
server_cmd = ([self.gdbserver] +
251-
['-select',
252-
('ip' if (is_ip(self.dev_id) or is_tunnel(self.dev_id)) else 'usb') +
253-
(f'={self.dev_id}' if self.dev_id else ''),
254-
'-port', str(self.gdb_port),
255-
'-if', self.iface,
256-
'-speed', self.speed,
257-
'-device', self.device,
258-
'-silent',
259-
'-endian', 'big' if big_endian else 'little',
260-
'-singlerun'] +
261-
(['-nogui'] if self.supports_nogui else []) +
262-
(['-rtos', plugin_dir] if rtos else []) +
263-
['-rtttelnetport', str(self.rtt_port)] +
264-
self.tool_opt)
250+
server_cmd = (
251+
[self.gdbserver]
252+
+ [
253+
'-select',
254+
('ip' if (is_ip(self.dev_id) or is_tunnel(self.dev_id)) else 'usb')
255+
+ (f'={self.dev_id}' if self.dev_id else ''),
256+
]
257+
+ ['-port', str(self.gdb_port)]
258+
+ ['-if', self.iface]
259+
+ ['-speed', self.speed]
260+
+ ['-device', self.device]
261+
+ ['-silent']
262+
+ ['-endian' 'big' if big_endian else 'little']
263+
+ ['-singlerun']
264+
+ (['-nogui'] if self.supports_nogui else [])
265+
+ (['-rtos', plugin_dir] if rtos else [])
266+
+ ['-rtttelnetport', str(self.rtt_port)]
267+
+ self.tool_opt
268+
)
265269

266270
if command == 'flash':
267271
self.flash(**kwargs)
@@ -405,15 +409,21 @@ def flash(self, **kwargs):
405409
if self.supports_loader and self.loader:
406410
loader_details = "?" + self.loader
407411

408-
cmd = ([self.commander] +
409-
(['-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 [])) +
410-
(['-nogui', '1'] if self.supports_nogui else []) +
411-
['-if', self.iface,
412-
'-speed', self.speed,
413-
'-device', self.device + loader_details,
414-
'-CommanderScript', fname] +
415-
(['-nogui', '1'] if self.supports_nogui else []) +
416-
self.tool_opt)
412+
cmd = (
413+
[self.commander]
414+
+ (
415+
['-IP', f'{self.dev_id}']
416+
if (is_ip(self.dev_id) or is_tunnel(self.dev_id))
417+
else (['-USB', f'{self.dev_id}'] if self.dev_id else [])
418+
)
419+
+ (['-nogui', '1'] if self.supports_nogui else [])
420+
+ ['-if', self.iface]
421+
+ ['-speed', self.speed]
422+
+ ['-device', self.device + loader_details]
423+
+ ['-CommanderScript', fname]
424+
+ (['-nogui', '1'] if self.supports_nogui else [])
425+
+ self.tool_opt
426+
)
417427

418428
self.logger.info(f'Flashing file: {flash_file}')
419429
kwargs = {}

scripts/west_commands/runners/linkserver.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ def do_add_parser(cls, parser):
8989
{DEFAULT_LINKSERVER_EXE}''')
9090
# user may need to override settings.
9191
parser.add_argument('--override', required=False, action='append',
92-
help='''configuration overrides as defined bylinkserver. Example: /device/memory/0/location=0xcafecafe''')
92+
help='''configuration overrides as defined bylinkserver.
93+
Example: /device/memory/0/location=0xcafecafe''')
9394

9495
@classmethod
9596
def do_create(cls, cfg, args):
9697

97-
print("RUNNER - gdb_port = " + str(args.gdb_port) + ", semih port = " + str(args.semihost_port))
98+
print(f"RUNNER - gdb_port = {args.gdb_port}, semih port = {args.semihost_port}")
9899
return LinkServerBinaryRunner(cfg, args.device, args.core,
99100
linkserver=args.linkserver,
100101
dt_flash=args.dt_flash,
@@ -180,8 +181,12 @@ def _build_override_cli(self):
180181
return override_cli
181182

182183
def flash(self, **kwargs):
183-
184-
linkserver_cmd = ([self.linkserver, "flash"] + ["--probe", str(self.probe)] + self.override_cli + [self.device])
184+
linkserver_cmd = (
185+
[self.linkserver, "flash"]
186+
+ ["--probe", str(self.probe)]
187+
+ self.override_cli
188+
+ [self.device]
189+
)
185190
self.logger.debug(f'LinkServer cmd: + {linkserver_cmd}')
186191

187192
if self.erase:

scripts/west_commands/runners/mdb.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ def is_flash_cmd_need_exit_immediately(mdb_runner):
3636

3737
def smp_core_order(mdb_runner, id):
3838
if is_simulation_run(mdb_runner):
39-
# for simulation targets we start cores in direct order (core 0 first, core 1 second, etc...)
40-
# otherwise we face mismatch arcnum (code ID) with ARConnect ID and core ID in instruction traces
39+
# for simulation targets we start cores in direct order
40+
# (core 0 first, core 1 second, etc...)
41+
# otherwise we face mismatch arcnum (code ID) with ARConnect ID
42+
# and core ID in instruction traces
4143
return id
4244
else:
43-
# for HW targets we want to start the primary core last, to avoid ARConnect initialization interfere
45+
# for HW targets we want to start the primary core last,
46+
# to avoid ARConnect initialization interfere
4447
# with secondary cores startup - so we reverse start order
4548
return mdb_runner.cores - 1 - id
4649

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

9699
# to enable multi-core aware mode for use with the MetaWare debugger,
97100
# need to set the NSIM_MULTICORE environment variable to a non-zero value

scripts/west_commands/runners/nrf_common.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,26 +278,49 @@ def program_hex(self):
278278

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

285288
# Handle Manifest Provisioning Information
286289
if self.build_conf.getboolean('CONFIG_SUIT_MPI_GENERATE'):
287290
app_mpi_hex_file = os.fspath(
288291
mpi_hex_dir / self.build_conf.get('CONFIG_SUIT_MPI_APP_AREA_PATH'))
289292
rad_mpi_hex_file = os.fspath(
290-
mpi_hex_dir / self.build_conf.get('CONFIG_SUIT_MPI_RAD_AREA_PATH'))
291-
self.op_program(app_mpi_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_APPLICATION')
292-
self.op_program(rad_mpi_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_NETWORK')
293+
mpi_hex_dir / self.build_conf.get('CONFIG_SUIT_MPI_RAD_AREA_PATH')
294+
)
295+
self.op_program(
296+
app_mpi_hex_file,
297+
'ERASE_NONE',
298+
None,
299+
defer=True,
300+
core='NRFDL_DEVICE_CORE_APPLICATION',
301+
)
302+
self.op_program(
303+
rad_mpi_hex_file,
304+
'ERASE_NONE',
305+
None,
306+
defer=True,
307+
core='NRFDL_DEVICE_CORE_NETWORK',
308+
)
293309

294310
# Handle SUIT root manifest if application manifests are not used.
295-
# If an application firmware is built, the root envelope is merged with other application manifests
296-
# as well as the output HEX file.
311+
# If an application firmware is built, the root envelope is merged
312+
# with other application manifests as well as the output HEX file.
297313
if not cpuapp and self.sysbuild_conf.get('SB_CONFIG_SUIT_ENVELOPE'):
298314
app_root_envelope_hex_file = os.fspath(
299-
mpi_hex_dir / 'suit_installed_envelopes_application_merged.hex')
300-
self.op_program(app_root_envelope_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_APPLICATION')
315+
mpi_hex_dir / 'suit_installed_envelopes_application_merged.hex'
316+
)
317+
self.op_program(
318+
app_root_envelope_hex_file,
319+
'ERASE_NONE',
320+
None,
321+
defer=True,
322+
core='NRFDL_DEVICE_CORE_APPLICATION',
323+
)
301324

302325
if cpuapp:
303326
core = 'NRFDL_DEVICE_CORE_APPLICATION'

0 commit comments

Comments
 (0)