-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile.stm32f0
160 lines (126 loc) · 3.58 KB
/
Makefile.stm32f0
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#
# Copyright (c) Riverdi Sp. z o.o. sp. k. <[email protected]>
# Copyright (c) Skalski Embedded Technologies <[email protected]>
#
# Project name
PROJECT = riverdi-demo
# List all C defines here
DEFS = -DSTM32
DEFS += -DSTM32F0
DEFS += -DSTM32F031C6Tx
DEFS += -DSTM32F031x6
DEFS += -DUSE_HAL_DRIVER
DEFS += -DSTM32_PLATFORM
DEFS += -DSTM32_PLATFORM_COCMD_BURST
#DEFS += -DEVE_1
#DEFS += -DEVE_2
#DEFS += -DEVE_3
DEFS += -DEVE_4
#DEFS += -DEVE_4_INTERNAL_OSC
DEFS += -DEVE_4_EXTERNAL_OSC
#DEFS += -DNTP_35
#DEFS += -DRTP_35
#DEFS += -DCTP_35
#DEFS += -DNTP_43
#DEFS += -DRTP_43
#DEFS += -DCTP_43
#DEFS += -DNTP_50
#DEFS += -DRTP_50
#DEFS += -DCTP_50
#DEFS += -DNTP_70
#DEFS += -DRTP_70
#DEFS += -DCTP_70
#DEFS += -DIPS_35
#DEFS += -DIPS_43
#DEFS += -DIPS_50
#DEFS += -DIPS_70
DEFS += -DIPS_101
# Define optimisation level here
OPT = -Os
# MCU type
MCU = cortex-m0
# Tools
PREFIX = arm-none-eabi-
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
GDB = $(PREFIX)gdb
CP = $(PREFIX)objcopy
AS = $(PREFIX)gcc -x assembler-with-cpp
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#Path to Texane's stlink tools (hardcoded!)
STLINK = /home/lskalski/Programs/stlink/build/Release
# List of source files
SRC = ./$(PROJECT).c
SRC += ./host_layer/stm32f0/src/syscalls.c
SRC += ./host_layer/stm32f0/src/stm32f0xx_it.c
SRC += ./host_layer/stm32f0/src/system_stm32f0xx.c
SRC += ./host_layer/stm32f0/hal/src/stm32f0xx_hal.c
SRC += ./host_layer/stm32f0/hal/src/stm32f0xx_hal_cortex.c
SRC += ./host_layer/stm32f0/hal/src/stm32f0xx_hal_rcc.c
SRC += ./host_layer/stm32f0/hal/src/stm32f0xx_hal_gpio.c
SRC += ./host_layer/stm32f0/hal/src/stm32f0xx_hal_spi.c
SRC += ./host_layer/stm32f0/platform.c
SRC += ./eve_layer/Gpu_Hal.c
SRC += ./eve_layer/CoPro_Cmds.c
SRC += ./eve_layer/Hal_Utils.c
SRC += ./app_layer/App_Common.c
# List assembly startup source file here
STARTUP = ./host_layer/stm32f0/startup/startup_stm32.s
# List all include directories here
INCDIRS = ./
INCDIRS += ./host_layer/stm32f0
INCDIRS += ./host_layer/stm32f0/inc
INCDIRS += ./host_layer/stm32f0/cmsis/core
INCDIRS += ./host_layer/stm32f0/cmsis/device
INCDIRS += ./host_layer/stm32f0/hal/inc
INCDIRS += ./host_layer/stm32f0/hal/legacy
INCDIRS += ./eve_layer
INCDIRS += ./app_layer
INCDIRS += ./riverdi_modules
# List the user directory to look for the libraries here
LIBDIRS +=
# List all user libraries here
LIBS =
# Define linker script file here
LINKER_SCRIPT = ./host_layer/stm32f0/linker/LinkerScript.ld
# Dirs
OBJS = $(STARTUP:.s=.o) $(SRC:.c=.o)
INCDIR = $(patsubst %,-I%, $(INCDIRS))
LIBDIR = $(patsubst %,-L%, $(LIBDIRS))
LIB = $(patsubst %,-l%, $(LIBS))
# Flags
COMMONFLAGS = -mcpu=$(MCU) -mthumb -mfloat-abi=soft
ASFLAGS = $(COMMONFLAGS)
CPFLAGS = $(COMMONFLAGS) $(OPT) $(DEFS) -flto -g -Wall -ffunction-sections -fdata-sections
LDFLAGS = $(COMMONFLAGS) -T$(LINKER_SCRIPT) -g -Wl,-Map=$(PROJECT).map -Wl,--gc-sections $(LIBDIR) $(LIB)
#
# Makefile Rules
#
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin
$(PREFIX)size $(PROJECT).elf
%.o: %.c
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
%.o: %.s
$(AS) -c $(ASFLAGS) $< -o $@
%.elf: $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
%.hex: %.elf
$(HEX) $< $@
%.bin: %.elf
$(BIN) $< $@
flash: $(PROJECT).bin
$(STLINK)/st-flash write $(PROJECT).bin 0x8000000
erase:
$(STLINK)/st-flash erase
debug: $(PROJECT).elf
$(GDB) --eval-command="target remote localhost:4242" $(PROJECT).elf -ex 'load'
clean:
-rm -rf $(OBJS)
-rm -rf $(PROJECT).elf
-rm -rf $(PROJECT).map
-rm -rf $(PROJECT).hex
-rm -rf $(PROJECT).bin
-rm -rf $(SRC:.c=.lst)
-rm -rf $(ASRC:.s=.lst)
-rm -rf $(STARTUP:.s=.lst)