-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.common
99 lines (62 loc) · 1.83 KB
/
Makefile.common
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# name of executable
ELF=$(notdir $(CURDIR)).elf
BIN=$(notdir $(CURDIR)).bin
# Tool path
# TOOLROOT=/l/arm/arm-none-eabi/bin
# Library path
LIBROOT=$(HOME)/Src/STM32F0xx_StdPeriph_Lib_V1.5.0/Libraries
# Tools
# CC=$(TOOLROOT)/arm-none-eabi-gcc
# LD=$(TOOLROOT)/arm-none-eabi-gcc
# AR=$(TOOLROOT)/arm-none-eabi-ar
# AS=$(TOOLROOT)/arm-none-eabi-as
CC=arm-none-eabi-gcc
LD=arm-none-eabi-gcc
AR=arm-none-eabi-ar
AS=arm-none-eabi-as
SIZE=arm-none-eabi-size
OBJCOPY=arm-none-eabi-objcopy
# Code Paths
CORE=$(LIBROOT)/CMSIS
DEVICE=$(LIBROOT)/CMSIS/Device/ST/STM32F0xx
PERIPH=$(LIBROOT)/STM32F0xx_StdPeriph_Driver
# Search path for standard files
vpath %.c $(TEMPLATEROOT)
# Search path for perpheral library
vpath %.c $(DEVICE)/Source/Templates
vpath %.c $(PERIPH)/src
vpath %.c $(DEVICE)
# Processor specific
#PTYPE = STM32F0XX_MD
PTYPE = STM32F030
LDSCRIPT = $(TEMPLATEROOT)/stm32f0xx-$(notdir $(CURDIR)).ld
#STARTUP= startup_stm32f0xx.o system_stm32f0xx.o
STARTUP= startup_stm32f0xx.o
# Compilation Flags
FULLASSERT = -DUSE_FULL_ASSERT
LDFLAGS+= -T$(LDSCRIPT) -mthumb -mcpu=cortex-m0
CFLAGS+= -mcpu=cortex-m0 -mthumb
CFLAGS+= -I$(TEMPLATEROOT) -I. -I$(CORE)/Include -I$(DEVICE)/Include -I$(CORE) -I$(PERIPH)/inc
CFLAGS+= -DUSE_STDPERIPH_DRIVER $(FULLASSERT) -D$(PTYPE)
# Build executable
$(ELF): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
$(BIN): $(ELF)
$(OBJCOPY) -O binary $< $@
# compile and generate dependency info
%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(CC) -MM $(CFLAGS) $< > $*.d
%.o: %.s
$(AS) $< -o $@
clean:
rm -f $(OBJS) $(OBJS:.o=.d) $(ELF) startup_stm32f* $(CLEANOTHER)
bin: $(BIN)
debug: $(ELF)
arm-none-eabi-gdb -iex "target extended-remote localhost:4242" $(ELF)
size: $(ELF)
$(SIZE) $<
flash: $(BIN)
st-flash write $(BIN) 0x8000000
# pull in dependencies
-include $(OBJS:.o=.d)