Skip to content

Commit d3e54de

Browse files
esdenwhitequark
authored andcommitted
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.
1 parent 68d1688 commit d3e54de

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

amaranth_boards/icebreaker_bitsy.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,24 @@ class ICEBreakerBitsyPlatform(LatticeICE40Platform):
4040
)
4141
]
4242

43-
def toolchain_program(self, products, name):
43+
def toolchain_program(self, products, name, run_vid=None, run_pid=None, dfu_vid="1d50", dfu_pid="6146", reset=True):
4444
dfu_util = os.environ.get("DFU_UTIL", "dfu-util")
45+
46+
# Construct the device runtime and DFU vid pid string
47+
dev_str = ""
48+
if run_vid or run_pid:
49+
dev_str = "{}:{}".format(run_vid or "", run_pid or "")
50+
dev_str += ",{}:{}".format(dfu_vid or "", dfu_pid or "")
51+
52+
# Construct the argument list for dfu-util
53+
args = [dfu_util, "-d", dev_str, "-a", "0"]
54+
if reset: args.append("-R")
55+
args.append("-D")
56+
57+
# Run dfu-util
4558
with products.extract("{}.bin".format(name)) as bitstream_filename:
46-
subprocess.check_call([dfu_util, "-d", "1209:6146", "-a", "0", "-D", bitstream_filename])
59+
args.append(bitstream_filename)
60+
subprocess.check_call(args)
4761

4862

4963
if __name__ == "__main__":

0 commit comments

Comments
 (0)