Skip to content

Commit 5847e04

Browse files
josuahkartben
authored andcommitted
west: runner: add support for ecpprog
The ecpprog command is an utility written by Greg Davill for flashing FPGAs such as ECP5 or CrossLink-NX series. Devkits typically have an FTDI interface chip to access the external flash. FPGA image is typically at flash offset 0x00000000 flash offset, and the Zephyr image offset can be set via CONFIG_FLASH_LOAD_OFFSET. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 54435e0 commit 5847e04

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

boards/common/ecpprog.board.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 tinyVision.ai Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_set_flasher_ifnset(ecpprog)
5+
board_finalize_runner_args(ecpprog)

scripts/west_commands/runners/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _import_runner_module(runner_name):
3131
'canopen_program',
3232
'dediprog',
3333
'dfu',
34+
'ecpprog',
3435
'esp32',
3536
'ezflashcli',
3637
'gd32isp',
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright (c) 2024 tinyVision.ai Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""Runner for the ecpprog programming tool for Lattice FPGAs."""
6+
# https://github.com/gregdavill/ecpprog
7+
8+
from runners.core import BuildConfiguration, RunnerCaps, ZephyrBinaryRunner
9+
10+
11+
class EcpprogBinaryRunner(ZephyrBinaryRunner):
12+
"""Runner front-end for programming the FPGA flash at some offset."""
13+
14+
def __init__(self, cfg, device=None):
15+
super().__init__(cfg)
16+
self.device = device
17+
18+
@classmethod
19+
def name(cls):
20+
return "ecpprog"
21+
22+
@classmethod
23+
def capabilities(cls):
24+
return RunnerCaps(commands={"flash"})
25+
26+
@classmethod
27+
def do_add_parser(cls, parser):
28+
parser.add_argument(
29+
"--device", dest="device", help="Device identifier such as i:<vid>:<pid>"
30+
)
31+
32+
@classmethod
33+
def do_create(cls, cfg, args):
34+
return EcpprogBinaryRunner(cfg, device=args.device)
35+
36+
def do_run(self, command, **kwargs):
37+
build_conf = BuildConfiguration(self.cfg.build_dir)
38+
load_offset = build_conf.get("CONFIG_FLASH_LOAD_OFFSET", 0)
39+
command = ("ecpprog", "-o", hex(load_offset), self.cfg.bin_file)
40+
self.logger.debug(" ".join(command))
41+
self.check_call(command)

scripts/west_commands/tests/test_imports.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_runner_imports():
2222
'canopen',
2323
'dediprog',
2424
'dfu-util',
25+
'ecpprog',
2526
'esp32',
2627
'ezflashcli',
2728
'gd32isp',

0 commit comments

Comments
 (0)