summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 846d4639068f27548490f6beb48f1c60b584ca9e (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
CC = arm-none-eabi-gcc
CPU = cortex-m3
TARGET = due

SRC = main.c
OBJ = $(SRC:.c=.o)

CFLAGS = -std=gnu99
CFLAGS += -Os
CFLAGS += -Wall
CFLAGS += -mcpu=$(CPU)
CFLAGS += -mthumb

LDFLAGS = -mcpu=$(CPU)
LDFLAGS += -Wl,--gc-sections

HEX_FLAGS = -O ihex
HEX_FLAGS += -j .text -j .data

%.o: %.c
	 $(CC) $(CFLAGS) -c -o $@ $<

elf: $(OBJ)
	 $(CC) $(LDFLAGS) $(OBJ) -o $(TARGET).elf

hex: elf
	 arm-none-eabi-objcopy $(HEX_FLAGS) $(TARGET).elf $(TARGET).hex

#upload: hex
#     openocd -f openocd-due.cfg -c "program $(TARGET) verify reset exit"

.PHONY: clean

clean:
	 rm *.o *.elf *.hex