-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (33 loc) · 923 Bytes
/
Copy pathMakefile
File metadata and controls
45 lines (33 loc) · 923 Bytes
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
#TOOLCHAIN=~/toolchain/gcc-arm-none-eabi-4_9-2014q4/bin
#PREFIX=$(TOOLCHAIN)/arm-none-eabi-
PREFIX=arm-none-eabi-
ARCHFLAGS=-mthumb -mcpu=cortex-m0plus
COMMONFLAGS=-g3 -Og -Wall -Werror $(ARCHFLAGS)
CFLAGS=-I./includes $(COMMONFLAGS)
LDFLAGS=$(COMMONFLAGS) --specs=nano.specs -Wl,--gc-sections,-Map,$(TARGET).map,-Tlink.ld
LDLIBS=
CC=$(PREFIX)gcc
LD=$(PREFIX)gcc
OBJCOPY=$(PREFIX)objcopy
SIZE=$(PREFIX)size
RM=rm -f
TARGET=main
SRC=$(wildcard *.c)
OBJ=$(patsubst %.c, %.o, $(SRC))
all: build size
build: elf srec bin
elf: $(TARGET).elf
srec: $(TARGET).srec
bin: $(TARGET).bin
clean:
$(RM) $(TARGET).srec $(TARGET).elf $(TARGET).bin $(TARGET).map $(OBJ)
$(TARGET).elf: $(OBJ)
$(LD) $(LDFLAGS) $(OBJ) $(LDLIBS) -o $@
%.srec: %.elf
$(OBJCOPY) -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
size:
$(SIZE) $(TARGET).elf
flash: all
openocd -f openocd.cfg -c "program $(TARGET).elf verify reset exit"