summaryrefslogtreecommitdiffstats
path: root/blink/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'blink/Makefile')
-rw-r--r--blink/Makefile43
1 files changed, 43 insertions, 0 deletions
diff --git a/blink/Makefile b/blink/Makefile
new file mode 100644
index 0000000..ad38b9b
--- /dev/null
+++ b/blink/Makefile
@@ -0,0 +1,43 @@
+PROJ=blink
+
+# Add Windows and Unix support
+RM = rm -rf
+COPY = cp -a
+PATH_SEP = /
+ifeq ($(OS),Windows_NT)
+# When SHELL=sh.exe and this actually exists, make will silently
+# switch to using that instead of cmd.exe. Unfortunately, there's
+# no way to tell which environment we're running under without either
+# (1) printing out an error message, or (2) finding something that
+# works everywhere.
+# As a result, we force the shell to be cmd.exe, so it works both
+# under cygwin and normal Windows.
+SHELL = cmd.exe
+COPY = copy
+RM = del
+PATH_SEP = \\
+endif
+
+
+all: ${PROJ}.dfu
+
+dfu: ${PROJ}.dfu
+ dfu-util --alt 0 --download $< --reset
+
+%.json: %.v
+ yosys -p "read_verilog $<; synth_ecp5 -json $@"
+
+%_out.config: %.json
+ nextpnr-ecp5 --json $< --textcfg $@ --um5g-85k --speed 8 --package CABGA381 --lpf ButterStick_r1.0.pcf
+
+%.bit: %_out.config
+ ecppack --compress --freq 38.8 --input $< --bit $@
+
+%.dfu : %.bit
+ $(COPY) $< $@
+ dfu-suffix -v 1209 -p 5af1 -a $@
+
+clean:
+ $(RM) -f ${PROJ}.bit ${PROJ}_out.config ${PROJ}.json ${PROJ}.dfu
+
+.PHONY: prog clean