From d3e54de8c53bee2dbf5a1d2b969e70a0278af819 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Sat, 11 Dec 2021 23:22:25 -0800 Subject: 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. --- amaranth_boards/icebreaker_bitsy.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'amaranth_boards') 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__": -- cgit v1.2.3