blob: 45758aa83fef4318cc35d5e05058ee15146b430d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
CPU = cortex-m4
MCU = MK20DX256
MK20DX256 = ../mk20dx256
# Change this to suit
TARGET_ARCH = -mcpu=$(CPU) -mthumb
AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
WARNINGS = -Wpointer-arith -Wcast-align -Wformat=2 \
-Wsuggest-attribute=format -Wall \
-Wextra -Wpedantic -Winit-self -Wshadow -Wcast-qual \
-Wstrict-prototypes -Wmissing-prototypes
CPPFLAGS = -Ilib
CFLAGS = -std=c11 $(WARNINGS) -O2 -flto -MMD -MP -ffreestanding -nostdlib
LDFLAGS = -T layout.ld -O2 -flto -ffreestanding -nostdlib
ASFLAGS = $(TARGET_ARCH)
OBJ := vectors.o flashconf.o crt0.o setup.o fmk.o lib/le.o pit.o \
usb/endpt0.o usb/endpt1.o usb/txhandler.o usb/usb.o weak.o
include $(MK20DX256)/mk20dx256.mk
CPPFLAGS += $(mk20dx256_CPPFLAGS)
ifeq ("$(WITH_UART)", "yes")
CPPFLAGS += -DWITH_UART
OBJ += uart.o
endif
%.bin: %
$(OBJCOPY) -O binary $< $@
debug: all
debug: CFLAGS += -Og -ggdb
debug: LDFLAGS += -Og -ggdb
small: all
small: CFLAGS += -Os
small: LDFLAGS += -Os
all: fmk.bin
fmk: $(OBJ)
flash: fmk.bin
hktool -f $< -r $(MCU)
clean:
$(RM) $(OBJ) $(OBJ:.o=.d) fmk fmk.bin
-include $(OBJ:.o=.d)
.PHONY: all flash clean
|