-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
195 lines (148 loc) · 4.84 KB
/
Makefile
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# CrazyFlie's Makefile
# Copyright (c) 2011,2012 Bitcraze AB
# This Makefile compiles all the objet file to ./bin/ and the resulting firmware
# image in ./cflie.elf and ./cflie.bin
#Put your personal build config in config.mk and DO NOT COMMIT IT!
-include config.mk
######### JTAG and environment configuration ##########
OPENOCD_INTERFACE ?= interface/jtagkey.cfg
OPENOCD_TARGET ?= target/stm32f1x.cfg
CROSS_COMPILE ?= arm-none-eabi-
PYTHON2 ?= python
CLOAD ?= 1
DEBUG ?= 0
## Flag that can be added to config.mk
# CFLAGS += -DUSE_UART_CRTP # Set CRTP link to UART
# CFLAGS += -DUSE_ESKYLINK # Set CRTP link to E-SKY receiver
# CFLAGS += -DHAS_UART # To enable trace uart
REV ?= E
#OpenOCD conf
RTOS_DEBUG ?= 0
############### Location configuration ################
FREERTOS = lib/FreeRTOS
PORT = $(FREERTOS)/portable/GCC/ARM_CM3
STLIB = lib/
################ Build configuration ##################
# St Lib
VPATH += $(STLIB)/CMSIS/Core/CM3/startup/gcc
CRT0=startup_stm32f10x_md.o
include scripts/st_obj.mk
# FreeRTOS
VPATH += $(PORT)
PORT_OBJ=port.o
VPATH += $(FREERTOS)/portable/MemMang
MEMMANG_OBJ = heap_4.o
VPATH += $(FREERTOS)
FREERTOS_OBJ = list.o tasks.o queue.o timers.o $(MEMMANG_OBJ)
# Crazyflie
VPATH += init hal/src modules/src utils/src drivers/src
############### Source files configuration ################
# Init
PROJ_OBJ = main.o
# Drivers
PROJ_OBJ += led.o uart.o adc.o nrf24l01.o exti.o nvic.o motors.o
PROJ_OBJ += mpu6050.o i2cdev.o i2croutines.o hmc5883l.o
PROJ_OBJ += ms5611.o
# Hal
PROJ_OBJ += crtp.o ledseq.o freeRTOSdebug.o imu.o pm.o radiolink.o eskylink.o
# Modules
PROJ_OBJ += system.o comm.o console.o pid.o crtpservice.o param.o
PROJ_OBJ += commander.o controller.o sensfusion6.o stabilizer.o
PROJ_OBJ += log.o worker.o
# Utilities
PROJ_OBJ += filter.o cpuid.o cfassert.o configblock.o eprintf.o crc.o fp16.o debug.o
PROJ_OBJ += version.o
OBJ = $(CRT0) $(FREERTOS_OBJ) $(PORT_OBJ) $(ST_OBJ) $(PROJ_OBJ)
ifdef P
C_PROFILE = -D P_$(P)
endif
############### Compilation configuration ################
AS = $(CROSS_COMPILE)as
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)gcc
SIZE = $(CROSS_COMPILE)size
OBJCOPY = $(CROSS_COMPILE)objcopy
INCLUDES = -I$(FREERTOS)/include -I$(PORT) -I.
INCLUDES+= -I$(STLIB)/STM32F10x_StdPeriph_Driver/inc
INCLUDES+= -I$(STLIB)/CMSIS/Core/CM3
INCLUDES+= -Iconfig -Ihal/interface -Imodules/interface
INCLUDES+= -Iutils/interface -Idrivers/interface
PROCESSOR = -mcpu=cortex-m3 -mthumb
#Flags required by the ST library
STFLAGS = -DSTM32F10X_MD -include stm32f10x_conf.h
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g3
else
CFLAGS += -Os -g3
endif
ifeq ($(USE_ESKYLINK), 1)
CFLAGS += -DUSE_ESKYLINK
endif
CFLAGS += -DBOARD_REV_$(REV)
CFLAGS += $(PROCESSOR) $(INCLUDES) $(STFLAGS) -Wall -fno-strict-aliasing $(C_PROFILE)
# Compiler flags to generate dependency files:
CFLAGS += -MD -MP -MF $(BIN)/dep/$(@).d -MQ $(@)
#Permits to remove un-used functions and global variables from output file
CFLAGS += -ffunction-sections -fdata-sections
ASFLAGS = $(PROCESSOR) $(INCLUDES)
LDFLAGS = $(PROCESSOR) -Wl,-Map=$(PROG).map,--cref,--gc-sections
ifeq ($(CLOAD), 1)
LDFLAGS += -T scripts/STM32F103_32K_20K_FLASH_CLOAD.ld
else
LDFLAGS += -T scripts/STM32F103_32K_20K_FLASH.ld
endif
#Program name
PROG = cflie
#Where to compile the .o
BIN = bin
VPATH += $(BIN)
#Dependency files to include
DEPS := $(foreach o,$(OBJ),$(BIN)/dep/$(o).d)
##################### Misc. ################################
ifeq ($(SHELL),/bin/sh)
COL_RED=\033[1;31m
COL_GREEN=\033[1;32m
COL_RESET=\033[m
endif
#################### Targets ###############################
all: build
build: clean_version compile print_version size
compile: clean_version $(PROG).hex $(PROG).bin
clean_version:
ifeq ($(SHELL),/bin/sh)
@echo " CLEAN_VERSION"
@rm -f version.c
endif
print_version: compile
ifeq ($(SHELL),/bin/sh)
@./scripts/print_revision.sh
endif
ifeq ($(CLOAD), 1)
@echo "CrazyLoader build!"
endif
size: compile
@$(SIZE) -B $(PROG).elf
#Radio bootloader
cload:
ifeq ($(CLOAD), 1)
$(PYTHON2) ../pc_util/crazyclient/crazyload.py flash cflie.bin
else
@echo "Only cload build can be bootloaded. Launch build and cload with CLOAD=1"
endif
#Flash the stm.
flash:
openocd -d0 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets -c "reset halt" \
-c "flash write_image erase cflie.elf" -c "verify_image cflie.elf" -c "reset run" -c shutdown
#STM utility targets
halt:
openocd -d0 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets -c "halt" -c shutdown
reset:
openocd -d0 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets -c "reset" -c shutdown
openocd:
openocd -d0 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets
#Print preprocessor #defines
prep:
@$(CC) -dD
include scripts/targets.mk
#include dependencies
-include $(DEPS)