-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
executable file
·158 lines (116 loc) · 4.56 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
PROJ_NAME=bruteforceandroid
################################################################################
# SETUP TOOLS #
################################################################################
#UPDATE this if you do not have the arm toolchain in your path
#https://launchpad.net/gcc-arm-embedded is currently the recommended
#toolchain for getting up to date tools it is recommended by the older
#summon arm toolchain which would not compile for me on ubuntu 13.10
TOOLS_DIR =
#If necessary change this to reflect where you have unzipped the
# STM32F4DISCOVERY board firmware package http://www.st.com/web/en/catalog/tools/PF257904
STM_ROOT =../STM32F4-Discovery_FW_V1.1.0
CC = $(TOOLS_DIR)arm-none-eabi-gcc
OBJCOPY = $(TOOLS_DIR)arm-none-eabi-objcopy
GDB = $(TOOLS_DIR)arm-none-eabi-gdb
AS = $(TOOLS_DIR)arm-none-eabi-as
##### Preprocessor options
# directories to be searched for header files
INCLUDE = $(addprefix -I,$(INC_DIRS))
# #defines needed when working with the STM peripherals library
DEFS = -DUSE_STDPERIPH_DRIVER
# DEFS += -DUSE_FULL_ASSERT
##### Assembler options
AFLAGS = -mcpu=cortex-m4
AFLAGS += -mthumb
AFLAGS += -mthumb-interwork
AFLAGS += -mlittle-endian
AFLAGS += -mfloat-abi=hard
AFLAGS += -mfpu=fpv4-sp-d16
##### Compiler options
CFLAGS = -ggdb
CFLAGS += -O0
CFLAGS += -Wall -Wextra -Warray-bounds
CFLAGS += $(AFLAGS)
##### Linker options
# tell ld which linker file to use
# (this file is in the current directory)
LFLAGS = -Tstm32_flash.ld
################################################################################
# SOURCE FILES DIRECTORIES #
################################################################################
STM_SRC_DIR = $(STM_ROOT)/Libraries/STM32F4xx_StdPeriph_Driver/src
STM_SRC_DIR += $(STM_ROOT)/Utilities/STM32F4-Discovery
STM_SRC_DIR += $(STM_ROOT)/Libraries/STM32_USB_Device_Library/Core/src
STM_SRC_DIR += $(STM_ROOT)/Libraries/STM32_USB_OTG_Driver/src
STM_STARTUP_DIR += $(STM_ROOT)/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO
vpath %.c $(STM_SRC_DIR)
vpath %.s $(STM_STARTUP_DIR)
################################################################################
# HEADER FILES DIRECTORIES #
################################################################################
# The header files we use are located here
INC_DIRS = $(STM_ROOT)/Utilities/STM32F4-Discovery
INC_DIRS += $(STM_ROOT)/Libraries/CMSIS/Include
INC_DIRS += $(STM_ROOT)/Libraries/CMSIS/ST/STM32F4xx/Include
INC_DIRS += $(STM_ROOT)/Libraries/STM32F4xx_StdPeriph_Driver/inc
INC_DIRS += $(STM_ROOT)/Libraries/STM32_USB_Device_Library/Core/inc
INC_DIRS += $(STM_ROOT)/Libraries/STM32_USB_OTG_Driver/inc
INC_DIRS += .
################################################################################
# SOURCE FILES TO COMPILE #
################################################################################
SRCS += main.c
SRCS += system_stm32f4xx.c
SRCS += stm32f4_discovery.c
SRCS += stm32f4xx_rcc.c
SRCS += stm32f4xx_gpio.c
SRCS += stm32f4xx_tim.c
SRCS += stm32f4xx_exti.c
SRCS += stm32f4xx_syscfg.c
SRCS += misc.c
SRCS +=usb_bsp.c
SRCS +=usbd_usr.c
SRCS +=usbd_desc.c
SRCS +=stm32f4xx_it.c
SRCS +=keyboard.c
SRCS +=permute.c
#usb drivers
SRCS += usbd_hid_core.c
SRCS +=usbd_core.c
SRCS +=usbd_ioreq.c
SRCS +=usbd_req.c
#SRCS +=usb_bsp_template.c
SRCS +=usb_core.c
SRCS +=usb_dcd.c
SRCS +=usb_dcd_int.c
#SRCS +=usb_hcd.c
#SRCS +=usb_hcd_int.c
#SRCS +=usb_otg.c
# startup file, calls main
ASRC = startup_stm32f4xx.s
OBJS = $(SRCS:.c=.o)
OBJS += $(ASRC:.s=.o)
######################################################################
# SETUP TARGETS #
######################################################################
.PHONY: all
all: $(PROJ_NAME).elf
%.o : %.c
@echo "[Compiling ] $^"
@$(CC) -c -o $@ $(INCLUDE) $(DEFS) $(CFLAGS) $^
%.o : %.s
@echo "[Assembling ]" $^
@$(AS) $(AFLAGS) $< -o $@
$(PROJ_NAME).elf: $(OBJS)
@echo "[Linking ] $@"
@$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
@$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
@$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
clean:
rm -f *.o $(PROJ_NAME).elf $(PROJ_NAME).hex $(PROJ_NAME).bin
flash: all
st-flash write $(PROJ_NAME).bin 0x8000000
debug:
# before you start gdb, you must start st-util
$(GDB) -tui $(PROJ_NAME).elf