summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2016-10-20 23:43:29 +0100
committerTomasz Kramkowski <tk@the-tk.com>2016-10-20 23:43:29 +0100
commitc3c5f1e5fe27574220c3e94a79048e066cacc121 (patch)
tree445096a0365cc45c959091355852c9b63d8a338a /Makefile
downloadfmk-c3c5f1e5fe27574220c3e94a79048e066cacc121.tar.gz
fmk-c3c5f1e5fe27574220c3e94a79048e066cacc121.tar.xz
fmk-c3c5f1e5fe27574220c3e94a79048e066cacc121.zip
Init commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile42
1 files changed, 42 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..64ab87d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,42 @@
+CPU = cortex-m4
+MCU = MK20DX256
+TARGET_ARCH = -mcpu=$(CPU) -mthumb
+
+AS = arm-none-eabi-as
+CC = arm-none-eabi-gcc
+OBJCOPY = arm-none-eabi-objcopy
+XXD = xxd
+
+HKTOOL = hktool $(MCU)
+
+WARNINGS = -Wpointer-arith -Wcast-align -Wformat=2 \
+ -Wsuggest-attribute=format -Wall \
+ -Wextra -Wpedantic -Winit-self -Wshadow -Wcast-qual \
+ -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS = -std=c11 $(WARNINGS) -O2 -flto -MMD -MP -ffreestanding -nostdlib -Ilib
+LDFLAGS = -T layout.ld -O2 -flto -ffreestanding -nostdlib
+ASFLAGS = $(TARGET_ARCH)
+
+OBJ := crt0.o vectors.o flashconf.o setup.o fmk.o lib/string.o lib/le.o usb/usb.o usb/endpt0.o usb/endpt1.o
+
+%.bin: %
+ $(OBJCOPY) -O binary $< $@
+%.xxo: %.xxd
+ awk '{print $$1}' $< | $(XXD) -r -p -c1 >$@
+%.xxh: %.xxo
+ $(XXD) -i $< | sed -e 's/_xxo//' >$@
+
+all: fmk.bin
+fmk: $(OBJ)
+
+flash: fmk.bin
+ hktool 0x40000 1024 64 0 $<
+ hktool -r
+
+clean:
+ $(RM) $(OBJ) $(OBJ:.o=.d) $(wildcard usb/*.xxh) fmk fmk.bin
+
+-include $(OBJ:.o=.d)
+usb/endpt0.o: usb/ds_dev.xxh usb/ds_conf.xxh usb/ds_lang.xxh usb/ds_str1.xxh
+
+.PHONY: all flash clean