Skip to content

Commit 95c80b8

Browse files
committed
scripts: west_commands: runners: remove '--dt-flash' option
Most runners that support the '--dt-flash' option set it to True by default. When the option is not set, runners either produce errors, or default to a value of 0, which doesn't make much sense. Only the 'spi_burn' runner appears to have two legitimate behaviors depending on whether '--dt-flash' is set to True or not. Removes the '--dt-flash' option from all runners where it doesn't make sense. Moves the handling of the option to the spi_burn runner. Signed-off-by: Miguel Gazquez <[email protected]>
1 parent aec9c29 commit 95c80b8

17 files changed

+44
-106
lines changed

boards/common/jlink.board.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
board_set_flasher_ifnset(jlink)
44
board_set_debugger_ifnset(jlink)
5-
board_finalize_runner_args(jlink "--dt-flash=y")
5+
board_finalize_runner_args(jlink)

boards/common/linkserver.board.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
board_set_flasher_ifnset(linkserver)
55
board_set_debugger_ifnset(linkserver)
6-
board_finalize_runner_args(linkserver "--dt-flash=y")
6+
board_finalize_runner_args(linkserver)

boards/common/pyocd.board.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ board_set_debugger_ifnset(pyocd)
55
if(CONFIG_SEMIHOST_CONSOLE)
66
board_runner_args(pyocd "--tool-opt=-S")
77
endif()
8-
board_finalize_runner_args(pyocd "--dt-flash=y")
8+
board_finalize_runner_args(pyocd)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
board_set_flasher_ifnset(silabs_commander)
4-
board_finalize_runner_args(silabs_commander "--dt-flash=y")
4+
board_finalize_runner_args(silabs_commander)

scripts/west_commands/runners/canopen_program.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def name(cls):
8383

8484
@classmethod
8585
def capabilities(cls):
86-
return RunnerCaps(commands={'flash'}, dev_id=True, flash_addr=False)
86+
return RunnerCaps(commands={'flash'}, dev_id=True)
8787

8888
@classmethod
8989
def dev_id_help(cls) -> str:

scripts/west_commands/runners/core.py

-49
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ class RunnerCaps:
271271
- mult_dev_ids: whether the runner supports multiple device identifiers
272272
for a single operation, allowing for bulk flashing of devices.
273273
274-
- flash_addr: whether the runner supports flashing to an
275-
arbitrary address. Default is False. If true, the runner
276-
must honor the --dt-flash option.
277-
278274
- erase: whether the runner supports an --erase option, which
279275
does a mass-erase of the entire addressable flash on the target
280276
before flashing. On multi-core SoCs, this may only erase portions of
@@ -309,7 +305,6 @@ class RunnerCaps:
309305
commands: set[str] = field(default_factory=lambda: set(_RUNNERCAPS_COMMANDS))
310306
dev_id: bool = False
311307
mult_dev_ids: bool = False
312-
flash_addr: bool = False
313308
erase: bool = False
314309
reset: bool = False
315310
extload: bool = False
@@ -362,19 +357,6 @@ class RunnerConfig(NamedTuple):
362357
openocd_search: list[str] = [] # add these paths to the openocd search path
363358
rtt_address: int | None = None # address of the rtt control block
364359

365-
366-
_YN_CHOICES = ['Y', 'y', 'N', 'n', 'yes', 'no', 'YES', 'NO']
367-
368-
369-
class _DTFlashAction(argparse.Action):
370-
371-
def __call__(self, parser, namespace, values, option_string=None):
372-
if values.lower().startswith('y'):
373-
namespace.dt_flash = True
374-
else:
375-
namespace.dt_flash = False
376-
377-
378360
class _ToggleAction(argparse.Action):
379361

380362
def __call__(self, parser, args, ignored, option):
@@ -533,10 +515,6 @@ def add_parser(cls, parser):
533515
argparse module. For more details, refer to the documentation
534516
for argparse.ArgumentParser.add_subparsers().
535517
536-
The lone common optional argument is:
537-
538-
* --dt-flash (if the runner capabilities includes flash_addr)
539-
540518
Runner-specific options are added through the do_add_parser()
541519
hook.'''
542520
# Unfortunately, the parser argument's type is not documented
@@ -557,15 +535,6 @@ def add_parser(cls, parser):
557535
else:
558536
parser.add_argument('-i', '--dev-id', help=argparse.SUPPRESS)
559537

560-
if caps.flash_addr:
561-
parser.add_argument('--dt-flash', default=False, choices=_YN_CHOICES,
562-
action=_DTFlashAction,
563-
help='''If 'yes', try to use flash address
564-
information from devicetree when flash
565-
addresses are unknown (e.g. when flashing a .bin)''')
566-
else:
567-
parser.add_argument('--dt-flash', help=argparse.SUPPRESS)
568-
569538
if caps.file:
570539
parser.add_argument('-f', '--file',
571540
dest='file',
@@ -658,8 +627,6 @@ def create(cls, cfg: RunnerConfig,
658627
caps = cls.capabilities()
659628
if args.dev_id and not caps.dev_id:
660629
_missing_cap(cls, '--dev-id')
661-
if args.dt_flash and not caps.flash_addr:
662-
_missing_cap(cls, '--dt-flash')
663630
if args.erase and not caps.erase:
664631
_missing_cap(cls, '--erase')
665632
if args.reset and not caps.reset:
@@ -690,22 +657,6 @@ def do_create(cls, cfg: RunnerConfig,
690657
args: argparse.Namespace) -> 'ZephyrBinaryRunner':
691658
'''Hook for instance creation from command line arguments.'''
692659

693-
@staticmethod
694-
def get_flash_address(args: argparse.Namespace,
695-
build_conf: BuildConfiguration,
696-
default: int = 0x0) -> int:
697-
'''Helper method for extracting a flash address.
698-
699-
If args.dt_flash is true, returns the address obtained from
700-
ZephyrBinaryRunner.flash_address_from_build_conf(build_conf).
701-
702-
Otherwise (when args.dt_flash is False), the default value is
703-
returned.'''
704-
if args.dt_flash:
705-
return ZephyrBinaryRunner.flash_address_from_build_conf(build_conf)
706-
else:
707-
return default
708-
709660
@staticmethod
710661
def flash_address_from_build_conf(build_conf: BuildConfiguration):
711662
'''If CONFIG_HAS_FLASH_LOAD_OFFSET is n in build_conf,

scripts/west_commands/runners/dfu.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def name(cls):
4242

4343
@classmethod
4444
def capabilities(cls):
45-
return RunnerCaps(commands={'flash'}, dev_id=True, flash_addr=True)
45+
return RunnerCaps(commands={'flash'}, dev_id=True)
4646

4747
@classmethod
4848
def dev_id_help(cls) -> str:
@@ -82,9 +82,8 @@ def do_create(cls, cfg, args):
8282
args.img = cfg.bin_file
8383

8484
if args.dfuse:
85-
args.dt_flash = True # --dfuse implies --dt-flash.
8685
build_conf = BuildConfiguration(cfg.build_dir)
87-
dcfg = DfuSeConfig(address=cls.get_flash_address(args, build_conf),
86+
dcfg = DfuSeConfig(address=cls.flash_address_from_build_conf(build_conf),
8887
options=args.dfuse_modifiers)
8988
else:
9089
dcfg = None

scripts/west_commands/runners/intel_cyclonev.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def name(cls):
9898
@classmethod
9999
def capabilities(cls):
100100
return RunnerCaps(commands={'flash', 'debug', 'attach'},
101-
dev_id=False, flash_addr=False, erase=False)
101+
dev_id=False, erase=False)
102102

103103
@classmethod
104104
def do_add_parser(cls, parser):

scripts/west_commands/runners/jlink.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class JLinkBinaryRunner(ZephyrBinaryRunner):
8282

8383
def __init__(self, cfg, device, dev_id=None,
8484
commander=DEFAULT_JLINK_EXE,
85-
dt_flash=True, erase=True, reset=False,
85+
erase=True, reset=False,
8686
iface='swd', speed='auto', flash_script = None,
8787
loader=None,
8888
gdbserver='JLinkGDBServer',
@@ -101,7 +101,6 @@ def __init__(self, cfg, device, dev_id=None,
101101
self.dev_id = dev_id
102102
self.commander = commander
103103
self.flash_script = flash_script
104-
self.dt_flash = dt_flash
105104
self.erase = erase
106105
self.reset = reset
107106
self.gdbserver = gdbserver
@@ -125,7 +124,7 @@ def name(cls):
125124
@classmethod
126125
def capabilities(cls):
127126
return RunnerCaps(commands={'flash', 'debug', 'debugserver', 'attach', 'rtt'},
128-
dev_id=True, flash_addr=True, erase=True, reset=True,
127+
dev_id=True, erase=True, reset=True,
129128
tool_opt=True, file=True, rtt=True)
130129

131130
@classmethod
@@ -182,7 +181,6 @@ def do_create(cls, cfg, args):
182181
return JLinkBinaryRunner(cfg, args.device,
183182
dev_id=args.dev_id,
184183
commander=args.commander,
185-
dt_flash=args.dt_flash,
186184
erase=args.erase,
187185
reset=args.reset,
188186
iface=args.iface, speed=args.speed,
@@ -386,10 +384,7 @@ def get_default_flash_commands(self):
386384
if self.file_type == FileType.HEX:
387385
flash_cmd = f'loadfile "{self.file}"'
388386
elif self.file_type == FileType.BIN:
389-
if self.dt_flash:
390-
flash_addr = self.flash_address_from_build_conf(self.build_conf)
391-
else:
392-
flash_addr = 0
387+
flash_addr = self.flash_address_from_build_conf(self.build_conf)
393388
flash_cmd = f'loadfile "{self.file}" 0x{flash_addr:x}'
394389
else:
395390
err = 'Cannot flash; jlink runner only supports hex and bin files'
@@ -403,10 +398,7 @@ def get_default_flash_commands(self):
403398
flash_cmd = f'loadfile "{self.hex_name}"'
404399
# Preferring .bin over .elf
405400
elif self.bin_name is not None and os.path.isfile(self.bin_name):
406-
if self.dt_flash:
407-
flash_addr = self.flash_address_from_build_conf(self.build_conf)
408-
else:
409-
flash_addr = 0
401+
flash_addr = self.flash_address_from_build_conf(self.build_conf)
410402
flash_file = self.bin_name
411403
flash_cmd = f'loadfile "{self.bin_name}" 0x{flash_addr:x}'
412404
elif self.elf_name is not None and os.path.isfile(self.elf_name):

scripts/west_commands/runners/linkserver.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LinkServerBinaryRunner(ZephyrBinaryRunner):
2323
'''Runner front-end for NXP Linkserver'''
2424
def __init__(self, cfg, device, core,
2525
linkserver=DEFAULT_LINKSERVER_EXE,
26-
dt_flash=True, erase=True,
26+
erase=True,
2727
probe='#1',
2828
gdb_host='',
2929
gdb_port=DEFAULT_LINKSERVER_GDB_PORT,
@@ -40,7 +40,6 @@ def __init__(self, cfg, device, core,
4040
self.device = device
4141
self.core = core
4242
self.linkserver = linkserver
43-
self.dt_flash = dt_flash
4443
self.erase = erase
4544
self.probe = probe
4645
self.gdb_host = gdb_host
@@ -62,8 +61,7 @@ def name(cls):
6261
@classmethod
6362
def capabilities(cls):
6463
return RunnerCaps(commands={'flash', 'debug', 'debugserver', 'attach'},
65-
dev_id=True, flash_addr=True, erase=True,
66-
tool_opt=True, file=True)
64+
dev_id=True, erase=True, tool_opt=True, file=True)
6765

6866
@classmethod
6967
def do_add_parser(cls, parser):
@@ -98,7 +96,6 @@ def do_create(cls, cfg, args):
9896
print(f"RUNNER - gdb_port = {args.gdb_port}, semih port = {args.semihost_port}")
9997
return LinkServerBinaryRunner(cfg, args.device, args.core,
10098
linkserver=args.linkserver,
101-
dt_flash=args.dt_flash,
10299
erase=args.erase,
103100
probe=args.probe,
104101
semihost_port=args.semihost_port,
@@ -198,12 +195,7 @@ def flash(self, **kwargs):
198195
flash_cmd = (["load", self.hex_name])
199196
# Preferring .bin over .elf
200197
elif self.bin_name is not None and os.path.isfile(self.bin_name):
201-
if self.dt_flash:
202-
load_addr = self.flash_address_from_build_conf(self.build_conf)
203-
else:
204-
self.logger.critical("no load flash address could be found...")
205-
raise RuntimeError("no load flash address could be found...")
206-
198+
load_addr = self.flash_address_from_build_conf(self.build_conf)
207199
flash_cmd = (["load", "--addr", str(load_addr), self.bin_name])
208200
elif self.elf_name is not None and os.path.isfile(self.elf_name):
209201
flash_cmd = (["load", self.elf_name])

scripts/west_commands/runners/minichlink.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ def __init__(
1818
minichlink: str,
1919
erase: bool,
2020
reset: bool,
21-
dt_flash: bool,
2221
terminal: bool,
2322
):
2423
super().__init__(cfg)
2524

2625
self.minichlink = minichlink
2726
self.erase = erase
2827
self.reset = reset
29-
self.dt_flash = dt_flash
3028
self.terminal = terminal
3129

3230
@classmethod
@@ -35,7 +33,7 @@ def name(cls):
3533

3634
@classmethod
3735
def capabilities(cls) -> RunnerCaps:
38-
return RunnerCaps(commands={"flash"}, flash_addr=True, erase=True, reset=True)
36+
return RunnerCaps(commands={"flash"}, erase=True, reset=True)
3937

4038
@classmethod
4139
def do_add_parser(cls, parser: argparse.ArgumentParser):
@@ -57,7 +55,6 @@ def do_create(cls, cfg: RunnerConfig, args: argparse.Namespace):
5755
minichlink=args.minichlink,
5856
erase=args.erase,
5957
reset=args.reset,
60-
dt_flash=args.dt_flash,
6158
terminal=args.terminal,
6259
)
6360

@@ -77,9 +74,7 @@ def flash(self):
7774
if self.erase:
7875
cmd.append("-E")
7976

80-
flash_addr = 0
81-
if self.dt_flash:
82-
flash_addr = self.flash_address_from_build_conf(self.build_conf)
77+
flash_addr = self.flash_address_from_build_conf(self.build_conf)
8378

8479
cmd.extend(["-w", self.cfg.bin_file or "", f"0x{flash_addr:x}"])
8580

scripts/west_commands/runners/pyocd.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ def name(cls):
7777
@classmethod
7878
def capabilities(cls):
7979
return RunnerCaps(commands={'flash', 'debug', 'debugserver', 'attach', 'rtt'},
80-
dev_id=True, flash_addr=True, erase=True,
81-
tool_opt=True, rtt=True)
80+
dev_id=True, erase=True, tool_opt=True, rtt=True)
8281

8382
@classmethod
8483
def dev_id_help(cls) -> str:
@@ -116,7 +115,7 @@ def tool_opt_help(cls) -> str:
116115
@classmethod
117116
def do_create(cls, cfg, args):
118117
build_conf = BuildConfiguration(cfg.build_dir)
119-
flash_addr = cls.get_flash_address(args, build_conf)
118+
flash_addr = cls.flash_address_from_build_conf(build_conf)
120119

121120
ret = PyOcdBinaryRunner(
122121
cfg, args.target,

scripts/west_commands/runners/silabs_commander.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
class SiLabsCommanderBinaryRunner(ZephyrBinaryRunner):
21-
def __init__(self, cfg, device, dev_id, commander, dt_flash, erase, speed, tool_opt):
21+
def __init__(self, cfg, device, dev_id, commander, erase, speed, tool_opt):
2222
super().__init__(cfg)
2323
self.file = cfg.file
2424
self.file_type = cfg.file_type
@@ -28,7 +28,6 @@ def __init__(self, cfg, device, dev_id, commander, dt_flash, erase, speed, tool_
2828
self.device = device
2929
self.dev_id = dev_id
3030
self.commander = commander
31-
self.dt_flash = dt_flash
3231
self.erase = erase
3332
self.speed = speed
3433

@@ -43,8 +42,7 @@ def name(cls):
4342
@classmethod
4443
def capabilities(cls):
4544
return RunnerCaps(commands={'flash'},
46-
dev_id=True, flash_addr=True, erase=True,
47-
tool_opt=True, file=True)
45+
dev_id=True, erase=True, tool_opt=True, file=True)
4846

4947
@classmethod
5048
def dev_id_help(cls) -> str:
@@ -73,7 +71,6 @@ def do_create(cls, cfg, args):
7371
cfg, args.device,
7472
dev_id=args.dev_id,
7573
commander=args.commander,
76-
dt_flash=args.dt_flash,
7774
erase=args.erase,
7875
speed=args.speed,
7976
tool_opt=args.tool_opt)
@@ -91,10 +88,7 @@ def do_run(self, command, **kwargs):
9188

9289
# Get the build artifact to flash
9390

94-
if self.dt_flash:
95-
flash_addr = self.flash_address_from_build_conf(self.build_conf)
96-
else:
97-
flash_addr = 0
91+
flash_addr = self.flash_address_from_build_conf(self.build_conf)
9892

9993
if self.file is not None:
10094
# use file provided by the user

0 commit comments

Comments
 (0)