aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Esden-Tempski <piotr@esden.net>2021-12-11 23:22:25 -0800
committerCatherine <whitequark@whitequark.org>2021-12-12 07:30:17 +0000
commitd3e54de8c53bee2dbf5a1d2b969e70a0278af819 (patch)
treee0f9dba73d50353af7e7f5ccd8cd0f1a08f41fca
parent68d168822fdd4ce0e44b9b11ec96390a10349eaa (diff)
icebreaker-bitsy: Increase the programming routine flexibility.
This adds: * The ability to reset the target after bitstream programming. * The ability to select the Runtime vid:pid that might differ from project to project. * The ability to override the default DFU vid:pid if needed.
-rw-r--r--amaranth_boards/icebreaker_bitsy.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/amaranth_boards/icebreaker_bitsy.py b/amaranth_boards/icebreaker_bitsy.py
index 218a1d1..16c3a1c 100644
--- a/amaranth_boards/icebreaker_bitsy.py
+++ b/amaranth_boards/icebreaker_bitsy.py
@@ -40,10 +40,24 @@ class ICEBreakerBitsyPlatform(LatticeICE40Platform):
)
]
- def toolchain_program(self, products, name):
+ def toolchain_program(self, products, name, run_vid=None, run_pid=None, dfu_vid="1d50", dfu_pid="6146", reset=True):
dfu_util = os.environ.get("DFU_UTIL", "dfu-util")
+
+ # Construct the device runtime and DFU vid pid string
+ dev_str = ""
+ if run_vid or run_pid:
+ dev_str = "{}:{}".format(run_vid or "", run_pid or "")
+ dev_str += ",{}:{}".format(dfu_vid or "", dfu_pid or "")
+
+ # Construct the argument list for dfu-util
+ args = [dfu_util, "-d", dev_str, "-a", "0"]
+ if reset: args.append("-R")
+ args.append("-D")
+
+ # Run dfu-util
with products.extract("{}.bin".format(name)) as bitstream_filename:
- subprocess.check_call([dfu_util, "-d", "1209:6146", "-a", "0", "-D", bitstream_filename])
+ args.append(bitstream_filename)
+ subprocess.check_call(args)
if __name__ == "__main__":