~ruther/uni-mam-arm

uni-mam-arm/arm02/Makefile -rw-r--r-- 1.9 KiB
f80d4fd6 — Rutherther chore(arm07): add few image upload commands 3 months ago
                                                                                
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
DEVICE?=stm32f401
TARGET?=stm32f4x
CPU?=cortex-m4

APP=mam-arm02.elf

BINDIR=bin
SRCDIR=src
INCDIR=include
OBJDIR=obj
DEPDIR=$(OBJDIR)/.deps

DEVICEDIR=devices/$(DEVICE)
GENERALDIR=devices/general

PROJSRCS_C=$(wildcard $(SRCDIR)/*.c)
PROJSRCS_S=$(wildcard $(SRCDIR)/*.S)
GENERALSRCS_C=$(wildcard $(GENERALDIR)/*.c)
GENERALSRCS_S=$(wildcard $(GENERALDIR)/*.S)
DEVICESRCS_C=$(wildcard $(DEVICEDIR)/*.c)
DEVICESRCS_S=$(wildcard $(DEVICEDIR)/*.S)

SRCS_C=$(PROJSRCS_C) $(GENERALSRCS_C) $(DEVICESRCS_C)
SRCS_S=$(PROJSRCS_S) $(GENERALSRCS_S) $(DEVICESRCS_S)
OBJS_C=$(patsubst %.c,$(OBJDIR)/%.o,$(SRCS_C))
OBJS_S=$(patsubst %.S,$(OBJDIR)/%.S.o,$(SRCS_S))

SRCS=$(SRCS_C) $(SRCS_S)
OBJS=$(OBJS_C) $(OBJS_S)

DEPFILES=$(patsubst %.c,$(DEPDIR)/%.d,$(SRCS_C))

DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
CFLAGS=-I$(INCDIR) \
				-I$(DEVICEDIR)/$(INCDIR) \
				-mthumb -mcpu=$(CPU) -nostdlib -g \
				-DSTM32F401xx
# TODO use these cflags if you want to run
# with newlib. Also don't forget to rename
# and/or modify syscalls.c.example under
# devices/general
# CFLAGS=-I$(INCDIR) \
# 				-I$(DEVICEDIR)/$(INCDIR) \
# 				-mthumb -mcpu=$(CPU) --specs=nano.specs -g
LDFLAGS=-T$(DEVICEDIR)/linker_script.ld

CC=arm-none-eabi-gcc
LD=arm-none-eabi-ld
OPENOCD=openocd

$(BINDIR)/$(APP): $(OBJS) | $(BINDIR)
	$(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS) $(DEPFLAGS)

%.o : %.c
$(OBJDIR)/%.o: %.c | $(DEPDIR) $(OBJDIR)
	mkdir -p "$(dir $@)"
	mkdir -p $(dir $(DEPDIR)/$*.d)
	$(CC) -c $< -o $@ $(CFLAGS) $(DEPFLAGS)

%.S.o : %.S
$(OBJDIR)/%.S.o: %.S
	mkdir -p "$(dir $@)"
	$(CC) -c $< -o $@ $(CFLAGS)

.PHONY: openocd flash clean
openocd:
	$(OPENOCD) -f interface/stlink.cfg -f target/$(TARGET).cfg

flash: $(BINDIR)/$(APP)
	$(OPENOCD) -f interface/stlink.cfg -f target/$(TARGET).cfg -c "program $(BINDIR)/$(APP) verify reset exit"

clean:
	rm -rf $(OBJDIR) $(BINDIR) $(DEPDIR)

$(BINDIR): ; mkdir -p $@
$(OBJDIR): ; mkdir -p $@
$(DEPDIR): ; mkdir -p $@

$(DEPFILES):
include $(wildcard $(DEPFILES))
Do not follow this link