-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a runner to utilize nrfutil for DFU. It also adds the corresponding ZIP file type to the runner system. Signed-off-by: Maximilian Deubel <[email protected]>
- Loading branch information
1 parent
96aa87c
commit d79a091
Showing
9 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_set_flasher_ifnset(nrfutil_dfu) | ||
board_finalize_runner_args(nrfutil_dfu) # No default arguments to provide. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from runners.core import ZephyrBinaryRunner, RunnerCaps | ||
import subprocess | ||
|
||
class NrfutilDfuRunner(ZephyrBinaryRunner): | ||
"""Runner for dfu-programming devices with nrfutil.""" | ||
|
||
def __init__(self, cfg, dev_id): | ||
super(NrfutilDfuRunner, self).__init__(cfg) | ||
self.cfg = cfg | ||
self.family = None | ||
self.dev_id = dev_id | ||
|
||
@classmethod | ||
def do_create(cls, cfg, args): | ||
return NrfutilDfuRunner(cfg, args.dev_id) | ||
|
||
@classmethod | ||
def name(cls): | ||
return 'nrfutil_dfu' | ||
|
||
@classmethod | ||
def capabilities(cls): | ||
return RunnerCaps(commands={'flash'}, dev_id=True) | ||
|
||
@classmethod | ||
def do_add_parser(cls, parser): | ||
pass | ||
|
||
def ensure_family(self): | ||
# Ensure self.family is set. | ||
|
||
if self.family is not None: | ||
return | ||
|
||
if self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF51X'): | ||
self.family = 'nrf51' | ||
elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF52X'): | ||
self.family = 'nrf52' | ||
elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF53X'): | ||
self.family = 'nrf53' | ||
elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF54LX'): | ||
self.family = 'nrf54l' | ||
elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF54HX'): | ||
self.family = 'nrf54h' | ||
elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF91X'): | ||
self.family = 'nrf91' | ||
elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF92X'): | ||
self.family = 'nrf92' | ||
else: | ||
raise RuntimeError(f'unknown nRF; update {__file__}') | ||
|
||
def do_run(self, command, **kwargs): | ||
self.require('nrfutil') | ||
|
||
self.ensure_output('zip') | ||
|
||
self.ensure_family() | ||
|
||
if self.build_conf.getboolean('CONFIG_SOC_NRF5340_CPUNET'): | ||
self.logger.info('skipping DFU for network core, ' + \ | ||
'this is done as part of the application core DFU') | ||
return | ||
|
||
cmd = ['nrfutil', 'device', 'program', | ||
'--x-family', self.family, | ||
'--firmware', self.cfg.zip_file] | ||
if self.dev_id: | ||
cmd += ['--serial-number', self.dev_id] | ||
|
||
subprocess.Popen(cmd).wait() | ||
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters