1
+ # #############################################################################
2
+ # Build global options
3
+ # NOTE: Can be overridden externally.
4
+ #
5
+
6
+ # Compiler options here.
7
+ ifeq ($(USE_OPT ) ,)
8
+ USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99
9
+ USE_OPT += -DSTM32F40_41xxx
10
+ endif
11
+
12
+ # C specific options here (added to USE_OPT).
13
+ ifeq ($(USE_COPT ) ,)
14
+ USE_COPT =
15
+ endif
16
+
17
+ # C++ specific options here (added to USE_OPT).
18
+ ifeq ($(USE_CPPOPT ) ,)
19
+ USE_CPPOPT = -fno-rtti
20
+ endif
21
+
22
+ # Enable this if you want the linker to remove unused code and data
23
+ ifeq ($(USE_LINK_GC ) ,)
24
+ USE_LINK_GC = yes
25
+ endif
26
+
27
+ # If enabled, this option allows to compile the application in THUMB mode.
28
+ ifeq ($(USE_THUMB ) ,)
29
+ USE_THUMB = yes
30
+ endif
31
+
32
+ # Enable this if you want to see the full log while compiling.
33
+ ifeq ($(USE_VERBOSE_COMPILE ) ,)
34
+ USE_VERBOSE_COMPILE = yes
35
+ endif
36
+
37
+ #
38
+ # Build global options
39
+ # #############################################################################
40
+
41
+ # #############################################################################
42
+ # Architecture or project specific options
43
+ #
44
+
45
+ # Enables the use of FPU on Cortex-M4.
46
+ ifeq ($(USE_FPU ) ,)
47
+ USE_FPU = yes
48
+ endif
49
+
50
+ # Enable this if you really want to use the STM FWLib.
51
+ ifeq ($(USE_FWLIB ) ,)
52
+ USE_FWLIB = yes
53
+ endif
54
+
55
+ #
56
+ # Architecture or project specific options
57
+ # #############################################################################
58
+
59
+ # #############################################################################
60
+ # Project, sources and paths
61
+ #
62
+
63
+ # Define project name here
64
+ PROJECT = BLDC_4_ChibiOS
65
+
66
+ # Imported source files and paths
67
+ CHIBIOS = ../../ChibiOS-RT-master
68
+ include $(CHIBIOS ) /boards/ST_STM32F4_DISCOVERY/board.mk
69
+ include $(CHIBIOS ) /os/hal/platforms/STM32F4xx/platform.mk
70
+ include $(CHIBIOS ) /os/hal/hal.mk
71
+ include $(CHIBIOS ) /os/ports/GCC/ARMCMx/STM32F4xx/port.mk
72
+ include $(CHIBIOS ) /os/kernel/kernel.mk
73
+
74
+ # Define linker script file here
75
+ LDSCRIPT = $(PORTLD ) /STM32F407xG.ld
76
+ # LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
77
+
78
+ # C sources that can be compiled in ARM or THUMB mode depending on the global
79
+ # setting.
80
+ CSRC = $(PORTSRC ) \
81
+ $(KERNSRC ) \
82
+ $(TESTSRC ) \
83
+ $(HALSRC ) \
84
+ $(PLATFORMSRC ) \
85
+ $(BOARDSRC ) \
86
+ $(CHIBIOS ) /os/various/chprintf.c \
87
+ $(CHIBIOS ) /os/various/shell.c \
88
+ $(CHIBIOS ) /os/various/syscalls.c \
89
+ main.c \
90
+ myUSB.c \
91
+ irq_handlers.c \
92
+ buffer.c \
93
+ comm.c \
94
+ crc.c \
95
+ digital_filter.c \
96
+ ledpwm.c \
97
+ mcpwm.c \
98
+ servo_dec.c \
99
+ utils.c \
100
+ servo.c \
101
+ packet.c \
102
+ terminal.c
103
+
104
+ # C++ sources that can be compiled in ARM or THUMB mode depending on the global
105
+ # setting.
106
+ CPPSRC =
107
+
108
+ # C sources to be compiled in ARM mode regardless of the global setting.
109
+ # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
110
+ # option that results in lower performance and larger code size.
111
+ ACSRC =
112
+
113
+ # C++ sources to be compiled in ARM mode regardless of the global setting.
114
+ # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
115
+ # option that results in lower performance and larger code size.
116
+ ACPPSRC =
117
+
118
+ # C sources to be compiled in THUMB mode regardless of the global setting.
119
+ # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
120
+ # option that results in lower performance and larger code size.
121
+ TCSRC =
122
+
123
+ # C sources to be compiled in THUMB mode regardless of the global setting.
124
+ # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
125
+ # option that results in lower performance and larger code size.
126
+ TCPPSRC =
127
+
128
+ # List ASM source files here
129
+ ASMSRC = $(PORTASM )
130
+
131
+ INCDIR = $(PORTINC ) $(KERNINC ) $(TESTINC ) \
132
+ $(HALINC ) $(PLATFORMINC ) $(BOARDINC ) \
133
+ $(CHIBIOS ) /os/various/devices_lib/accel \
134
+ $(CHIBIOS ) /os/various \
135
+ $(CHIBIOS ) /os/various $(CC2520INC )
136
+
137
+ #
138
+ # Project, sources and paths
139
+ # #############################################################################
140
+
141
+ # #############################################################################
142
+ # Compiler settings
143
+ #
144
+
145
+ MCU = cortex-m4
146
+
147
+ # TRGT = arm-elf-
148
+ # TRGT = ~/sat/bin/arm-none-eabi-
149
+ TRGT = arm-none-eabi-
150
+ CC = $(TRGT ) gcc
151
+ CPPC = $(TRGT ) g++
152
+ # Enable loading with g++ only if you need C++ runtime support.
153
+ # NOTE: You can use C++ even without C++ support if you are careful. C++
154
+ # runtime support makes code size explode.
155
+ LD = $(TRGT ) gcc
156
+ # LD = $(TRGT)g++
157
+ CP = $(TRGT ) objcopy
158
+ AS = $(TRGT ) gcc -x assembler-with-cpp
159
+ OD = $(TRGT ) objdump
160
+ SIZE = $(TRGT ) size
161
+ HEX = $(CP ) -O ihex
162
+ BIN = $(CP ) -O binary
163
+
164
+ # ARM-specific options here
165
+ AOPT =
166
+
167
+ # THUMB-specific options here
168
+ TOPT = -mthumb -DTHUMB
169
+
170
+ # Define C warning options here
171
+ CWARN = -Wall -Wextra -Wstrict-prototypes
172
+
173
+ # Define C++ warning options here
174
+ CPPWARN = -Wall -Wextra
175
+
176
+ #
177
+ # Compiler settings
178
+ # #############################################################################
179
+
180
+ # #############################################################################
181
+ # Start of default section
182
+ #
183
+
184
+ # List all default C defines here, like -D_DEBUG=1
185
+ DDEFS =
186
+
187
+ # List all default ASM defines here, like -D_DEBUG=1
188
+ DADEFS =
189
+
190
+ # List all default directories to look for include files here
191
+ DINCDIR =
192
+
193
+ # List the default directory to look for the libraries here
194
+ DLIBDIR =
195
+
196
+ # List all default libraries here
197
+ DLIBS =
198
+
199
+ #
200
+ # End of default section
201
+ # #############################################################################
202
+
203
+ # #############################################################################
204
+ # Start of user section
205
+ #
206
+
207
+ # List all user C define here, like -D_DEBUG=1
208
+ UDEFS =
209
+
210
+ # Define ASM defines here
211
+ UADEFS =
212
+
213
+ # List all user directories here
214
+ UINCDIR =
215
+
216
+ # List the user directory to look for the libraries here
217
+ ULIBDIR =
218
+
219
+ # List all user libraries here
220
+ ULIBS = -lm
221
+
222
+ #
223
+ # End of user defines
224
+ # #############################################################################
225
+
226
+ ifeq ($(USE_FPU ) ,yes)
227
+ USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
228
+ DDEFS += -DCORTEX_USE_FPU=TRUE
229
+ else
230
+ DDEFS += -DCORTEX_USE_FPU=FALSE
231
+ endif
232
+
233
+ ifeq ($(USE_FWLIB ) ,yes)
234
+ include $(CHIBIOS ) /ext/stdperiph_stm32f4/stm32lib.mk
235
+ CSRC += $(STM32SRC )
236
+ INCDIR += $(STM32INC )
237
+ USE_OPT += -DUSE_STDPERIPH_DRIVER
238
+ endif
239
+
240
+ include $(CHIBIOS ) /os/ports/GCC/ARMCMx/rules.mk
241
+
242
+ # Print size
243
+ all :
244
+ $(SIZE ) build/$(PROJECT ) .elf
245
+
246
+ build/$(PROJECT ) .bin : build/$(PROJECT ) .elf
247
+ $(BIN ) build/$(PROJECT ) .elf build/$(PROJECT ) .bin
248
+
249
+ # Program
250
+ upload : build/$(PROJECT ) .bin
251
+ qstlink2 --cli --erase --write build/$(PROJECT ) .bin
252
+
253
+ debug-start :
254
+ openocd -f stm32-bv_openocd.cfg
255
+
256
+
0 commit comments