Skip to content

west: runner: add support for ecpprog #81482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/common/ecpprog.board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 tinyVision.ai Inc.
# SPDX-License-Identifier: Apache-2.0

board_set_flasher_ifnset(ecpprog)
board_finalize_runner_args(ecpprog)
1 change: 1 addition & 0 deletions scripts/west_commands/runners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _import_runner_module(runner_name):
'canopen_program',
'dediprog',
'dfu',
'ecpprog',
'esp32',
'ezflashcli',
'gd32isp',
Expand Down
41 changes: 41 additions & 0 deletions scripts/west_commands/runners/ecpprog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2024 tinyVision.ai Inc.
#
# SPDX-License-Identifier: Apache-2.0

"""Runner for the ecpprog programming tool for Lattice FPGAs."""
# https://github.com/gregdavill/ecpprog

from runners.core import BuildConfiguration, RunnerCaps, ZephyrBinaryRunner


class EcpprogBinaryRunner(ZephyrBinaryRunner):
"""Runner front-end for programming the FPGA flash at some offset."""

def __init__(self, cfg, device=None):
super().__init__(cfg)
self.device = device

@classmethod
def name(cls):
return "ecpprog"

@classmethod
def capabilities(cls):
return RunnerCaps(commands={"flash"})

@classmethod
def do_add_parser(cls, parser):
parser.add_argument(
"--device", dest="device", help="Device identifier such as i:<vid>:<pid>"
)

@classmethod
def do_create(cls, cfg, args):
return EcpprogBinaryRunner(cfg, device=args.device)

def do_run(self, command, **kwargs):
build_conf = BuildConfiguration(self.cfg.build_dir)
load_offset = build_conf.get("CONFIG_FLASH_LOAD_OFFSET", 0)
command = ("ecpprog", "-o", hex(load_offset), self.cfg.bin_file)
self.logger.debug(" ".join(command))
self.check_call(command)
1 change: 1 addition & 0 deletions scripts/west_commands/tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_runner_imports():
'canopen',
'dediprog',
'dfu-util',
'ecpprog',
'esp32',
'ezflashcli',
'gd32isp',
Expand Down
Loading