Skip to content

Commit 8378f06

Browse files
committed
scripts: runner: Introduce blflash runner
Add Bouffalo Lab ISP console flash runner. This tool enable bootloader to flash devices using serial port. The blflash Rust tool can be found at https://github.com/spacemeowx2/blflash Signed-off-by: Gerson Fernando Budke <[email protected]>
1 parent b0f865b commit 8378f06

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

boards/common/blflash.board.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2021-2025 Gerson Fernando Budke <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_set_flasher_ifnset(blflash)
5+
board_finalize_runner_args(blflash)

scripts/west_commands/runners/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def _import_runner_module(runner_name):
2727
_names = [
2828
# zephyr-keep-sorted-start
2929
'blackmagicprobe',
30+
'blflash',
3031
'bossac',
3132
'canopen_program',
3233
'dediprog',
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2021-2025 Gerson Fernando Budke <[email protected]>
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
'''Bouffalo Lab flash tool (blflash) runner for serial boot ROM'''
6+
7+
from runners.core import RunnerCaps, ZephyrBinaryRunner
8+
9+
DEFAULT_BLFLASH_PORT = '/dev/ttyUSB0'
10+
DEFAULT_BLFLASH_SPEED = '2000000'
11+
12+
13+
class BlFlashBinaryRunner(ZephyrBinaryRunner):
14+
'''Runner front-end for blflash.'''
15+
16+
def __init__(
17+
self, cfg, blflash='blflash', port=DEFAULT_BLFLASH_PORT, speed=DEFAULT_BLFLASH_SPEED
18+
):
19+
super().__init__(cfg)
20+
self.blflash = blflash
21+
self.port = port
22+
self.speed = speed
23+
24+
@classmethod
25+
def name(cls):
26+
return 'blflash'
27+
28+
@classmethod
29+
def capabilities(cls):
30+
return RunnerCaps(commands={'flash'})
31+
32+
@classmethod
33+
def do_add_parser(cls, parser):
34+
parser.add_argument(
35+
'--blflash', default='blflash', help='path to blflash, default is blflash'
36+
)
37+
parser.add_argument(
38+
'--port',
39+
default=DEFAULT_BLFLASH_PORT,
40+
help='serial port to use, default is ' + str(DEFAULT_BLFLASH_PORT),
41+
)
42+
parser.add_argument(
43+
'--speed',
44+
default=DEFAULT_BLFLASH_SPEED,
45+
help='serial port speed to use, default is ' + DEFAULT_BLFLASH_SPEED,
46+
)
47+
48+
@classmethod
49+
def do_create(cls, cfg, args):
50+
return BlFlashBinaryRunner(cfg, blflash=args.blflash, port=args.port, speed=args.speed)
51+
52+
def do_run(self, command, **kwargs):
53+
self.require(self.blflash)
54+
self.ensure_output('bin')
55+
56+
cmd_flash = [self.blflash, 'flash', self.cfg.bin_file, '-p', self.port, '-b', self.speed]
57+
58+
self.check_call(cmd_flash)

scripts/west_commands/tests/test_imports.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_runner_imports():
1818
# zephyr-keep-sorted-start
1919
'arc-nsim',
2020
'blackmagicprobe',
21+
'blflash',
2122
'bossac',
2223
'canopen',
2324
'dediprog',

0 commit comments

Comments
 (0)