build: add DFUProg.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 11 Jun 2020 12:45:50 +0000 (14:45 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 11 Jun 2020 12:45:50 +0000 (14:45 +0200)
litex/build/dfu.py [new file with mode: 0644]

diff --git a/litex/build/dfu.py b/litex/build/dfu.py
new file mode 100644 (file)
index 0000000..9890e1b
--- /dev/null
@@ -0,0 +1,21 @@
+# This file is Copyright (c) 2020 Florent Kermarrec <florent@enjoy-digital.fr>
+# License: BSD
+
+import subprocess
+
+from litex.build.tools import write_to_file
+from litex.build.generic_programmer import GenericProgrammer
+
+# DFUProg ------------------------------------------------------------------------------------------
+
+class DFUProg(GenericProgrammer):
+    needs_bitreverse = False
+
+    def __init__(self, vid, pid):
+        self.vid = vid
+        self.pid = pid
+
+    def load_bitstream(self, bitstream_file):
+        subprocess.call(["cp", bitstream_file, bitstream_file + ".dfu"])
+        subprocess.call(["dfu-suffix", "-v", self.vid, "-p", self.pid, "-a", bitstream_file + ".dfu"])
+        subprocess.call(["dfu-util", "--download", bitstream_file + ".dfu"])