-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: runners: Add wrapper for WCHISPTool
`WCHISPTool_CMD` is the commandline version of WCHISPTool, which is a USB flashing tool for WCH series MCUs. Signed-off-by: Chen Xingyu <hi@xingrz.me>
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2023-2024 Chen Xingyu <hi@xingrz.me> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_set_flasher_ifnset(wchisp) | ||
board_finalize_runner_args(wchisp) |
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,43 @@ | ||
# Copyright (c) 2023-2024 Chen Xingyu <hi@xingrz.me> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
'''Runner for flashing WCH devices with WCHISPTool_CMD.''' | ||
|
||
from runners.core import ZephyrBinaryRunner, RunnerCaps | ||
|
||
class WchIspBinaryRunner(ZephyrBinaryRunner): | ||
'''Runner front-end for WCHISPTool_CMD''' | ||
|
||
def __init__(self, cfg, device, cfg_file): | ||
super().__init__(cfg) | ||
self.app_bin = cfg.bin_file | ||
self.device = device | ||
self.cfg_file = cfg_file | ||
|
||
@classmethod | ||
def name(cls): | ||
return 'wchisp' | ||
|
||
@classmethod | ||
def capabilities(cls): | ||
return RunnerCaps(commands={'flash'}) | ||
|
||
@classmethod | ||
def do_add_parser(cls, parser): | ||
parser.add_argument('--device', required=True, | ||
help='port of the USB ISP device') | ||
parser.add_argument('--cfg-file', required=True, | ||
help='configuration file generated by WCHISPTool') | ||
|
||
@classmethod | ||
def do_create(cls, cfg, args): | ||
return WchIspBinaryRunner(cfg, args.device, args.cfg_file) | ||
|
||
def do_run(self, command, **kwargs): | ||
self.check_call([ | ||
'WCHISPTool_CMD', | ||
'--device', self.device, | ||
'--configure', self.cfg_file, | ||
'--operation', 'program', | ||
'--flash', self.app_bin, | ||
]) |
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 |
---|---|---|
|
@@ -49,5 +49,6 @@ def test_runner_imports(): | |
'trace32', | ||
'teensy', | ||
'uf2', | ||
'wchisp', | ||
'xtensa')) | ||
assert runner_names == expected |