Skip to content

Commit 9b71b9d

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 3adffa0 commit 9b71b9d

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@
619619
/scripts/twister @nashif
620620
/scripts/series-push-hook.sh @erwango
621621
/scripts/west_commands/ @mbolivar-nordic
622+
/scripts/west_commands/runners/blflash.py @mbolivar-nordic @nandojve
622623
/scripts/west-commands.yml @mbolivar-nordic
623624
/scripts/zephyr_module.py @tejlmand
624625
/scripts/uf2conv.py @petejohanson

boards/common/blflash.board.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
board_set_flasher_ifnset(blflash)
4+
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
@@ -26,6 +26,7 @@ def _import_runner_module(runner_name):
2626

2727
_names = [
2828
'blackmagicprobe',
29+
'blflash',
2930
'bossac',
3031
'canopen_program',
3132
'dediprog',
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (c) 2021 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 ZephyrBinaryRunner, RunnerCaps
8+
9+
DEFAULT_BLFLASH_PORT = '/dev/ttyUSB0'
10+
DEFAULT_BLFLASH_SPEED = '2000000'
11+
12+
class BlFlashBinaryRunner(ZephyrBinaryRunner):
13+
'''Runner front-end for blflash.'''
14+
15+
def __init__(self, cfg, blflash='blflash',
16+
port=DEFAULT_BLFLASH_PORT,
17+
speed=DEFAULT_BLFLASH_SPEED):
18+
super().__init__(cfg)
19+
self.blflash = blflash
20+
self.port = port
21+
self.speed = speed
22+
23+
@classmethod
24+
def name(cls):
25+
return 'blflash'
26+
27+
@classmethod
28+
def capabilities(cls):
29+
return RunnerCaps(commands={'flash'})
30+
31+
@classmethod
32+
def do_add_parser(cls, parser):
33+
parser.add_argument('--blflash', default='blflash',
34+
help='path to blflash, default is blflash')
35+
parser.add_argument('--port', default=DEFAULT_BLFLASH_PORT,
36+
help='serial port to use, default is ' +
37+
str(DEFAULT_BLFLASH_PORT))
38+
parser.add_argument('--speed', default=DEFAULT_BLFLASH_SPEED,
39+
help='serial port speed to use, default is ' +
40+
DEFAULT_BLFLASH_SPEED)
41+
42+
@classmethod
43+
def do_create(cls, cfg, args):
44+
return BlFlashBinaryRunner(cfg,
45+
blflash=args.blflash,
46+
port=args.port,
47+
speed=args.speed)
48+
49+
def do_run(self, command, **kwargs):
50+
self.require(self.blflash)
51+
self.ensure_output('bin')
52+
53+
cmd_flash = [self.blflash,
54+
'flash',
55+
'-s', self.speed,
56+
self.cfg.bin_file,
57+
'-p', self.port]
58+
59+
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
@@ -16,6 +16,7 @@ def test_runner_imports():
1616
# Please keep this sorted alphabetically.
1717
expected = set(('arc-nsim',
1818
'blackmagicprobe',
19+
'blflash',
1920
'bossac',
2021
'canopen',
2122
'dediprog',

0 commit comments

Comments
 (0)