From 0fe2477f69ec29d0268cea5b6b2f0948097dc8dd Mon Sep 17 00:00:00 2001 From: Vadim Kaushan Date: Fri, 18 Dec 2020 15:42:18 +0300 Subject: [PATCH] Add ECPDAP programmer --- litex/build/lattice/programmer.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/litex/build/lattice/programmer.py b/litex/build/lattice/programmer.py index a56add8d7..2a2b1c409 100644 --- a/litex/build/lattice/programmer.py +++ b/litex/build/lattice/programmer.py @@ -147,3 +147,30 @@ class UJProg(GenericProgrammer): def load_bitstream(self, bitstream_file): self.call(["ujprog", bitstream_file]) + +# EcpDapProgrammer ------------------------------------------------------------------------------- + +class EcpDapProgrammer(GenericProgrammer): + """ECPDAP allows you to program ECP5 FPGAs and attached SPI flash using CMSIS-DAP probes in JTAG mode. + + You can get `ecpdap` here: https://github.com/adamgreig/ecpdap + """ + needs_bitreverse = False + + def __init__(self, frequency=8_000_000): + self.frequency_khz = frequency // 1000 + + def flash(self, address, bitstream_file): + self.call(["ecpdap", + "flash", "write", + "--freq", str(self.frequency_khz), + "--offset", str(address), + bitstream_file + ]) + + def load_bitstream(self, bitstream_file): + self.call(["ecpdap", + "program", + "--freq", str(self.frequency_khz), + bitstream_file + ])