-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·77 lines (56 loc) · 2.25 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
PROJ_NAME=vcof
PROJ_DIR=/home/sig/stmprojects/vcof
PROJ_BUILD_DIR=/home/sig/stmprojects/vcof/bin
STM_DIR=$(PROJ_DIR)/lib
STM_SRC=$(STM_DIR)/STM32F4xx_StdPeriph_Driver/src
vpath %.c $(STM_SRC)
SRC_DIR = $(PROJ_DIR)/src
SRCS = $(SRC_DIR)/main.c
SRCS += $(STM_DIR)/STM32F4-Discovery/stm32f4_discovery.c
SRCS += $(SRC_DIR)/system_stm32f4xx.c
SRCS += $(STM_SRC)/stm32f4xx_rcc.c
SRCS += $(STM_SRC)/stm32f4xx_gpio.c
SRCS += $(STM_SRC)/stm32f4xx_dac.c
SRCS += $(STM_SRC)/stm32f4xx_tim.c
SRCS += $(STM_SRC)/stm32f4xx_dma.c
SRCS += $(STM_SRC)/stm32f4xx_exti.c
SRCS += $(STM_SRC)/stm32f4xx_syscfg.c
SRCS += $(STM_SRC)/misc.c
SRCS += $(STM_DIR)/CMSIS/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s
INC_DIRS = $(STM_DIR)/STM32F4-Discovery
INC_DIRS += $(PROJ_DIR)/include
INC_DIRS += $(STM_DIR)/CMSIS/Include
INC_DIRS += $(STM_DIR)/CMSIS/ST/STM32F4xx/Include
INC_DIRS += $(STM_DIR)/STM32F4xx_StdPeriph_Driver/inc
INC_DIRS += .
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
GDB = arm-none-eabi-gdb
INCLUDE = $(addprefix -I,$(INC_DIRS))
DEFS = -DUSE_STDPERIPH_DRIVER
#DEFS += -DUSE_FULL_ASSERT
CFLAGS = -ggdb
CFLAGS += -O0
CFLAGS += -Wall -Wextra -Warray-bounds
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += -lc -lm -specs=nosys.specs
LFLAGS = -T$(STM_DIR)/stm32_flash.ld
######################################################################
# SETUP TARGETS #
######################################################################
.PHONY: $(PROJ_NAME)
$(PROJ_NAME): $(PROJ_BUILD_DIR)/$(PROJ_NAME).elf
$(PROJ_BUILD_DIR)/$(PROJ_NAME).elf: $(SRCS)
$(CC) $(INCLUDE) $(DEFS) $(CFLAGS) $(LFLAGS) $^ -o $@
$(OBJCOPY) -O ihex $(PROJ_BUILD_DIR)/$(PROJ_NAME).elf $(PROJ_BUILD_DIR)/$(PROJ_NAME).hex
$(OBJCOPY) -O binary $(PROJ_BUILD_DIR)/$(PROJ_NAME).elf $(PROJ_BUILD_DIR)/$(PROJ_NAME).bin
clean:
rm -f $(PROJ_BUILD_DIR)/*.o $(PROJ_BUILD_DIR)/$(PROJ_NAME).elf $(PROJ_BUILD_DIR)/$(PROJ_NAME).hex $(PROJ_BUILD_DIR)/$(PROJ_NAME).bin
# Flash the STM32F4
flash:
/home/sig/stlink/build/st-flash write $(PROJ_BUILD_DIR)/$(PROJ_NAME).bin 0x8000000
.PHONY: debug
debug:
# before you start gdb, you must start st-util
$(GDB) $(PROJ_BUILD_DIR)/$(PROJ_NAME).elf