forked from Oxbern/CCube_Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
156 lines (122 loc) · 2.92 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
# Binaries will be generated with this name (.elf, .bin, .hex, etc)
PROJ_NAME=CCube_Firmware
BUILD=build
##########
# STLINK
##########
STLINK=/home/elkhadiy/stlink
######## - STLINK
#############
# cross tools
#############
CC=arm-none-eabi-gcc
LD=arm-none-eabi-ld
OBJCOPY=arm-none-eabi-objcopy
######## - cross tools
################
# COMMON CFLAGS
################
CFLAGS = -g -Wall -std=gnu99 #-O3
CFLAGS += -T$(LDSCRIPT)
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += -I.
CFLAGS += -I/usr/arm-none-eabi/lib
CFLAGS += -lrdimon
CFLAGS += $(DEFINES)
######## - COMMON CFLAGS
#########
# ARM DEF
#########
CFLAGS += -Icmsis
######## - ARM DEF
##################
# STM32F4xx Drivers
##################
CFLAGS += -Icmsis/stm32f4xx
SRCS += cmsis/stm32f4xx/system_stm32f4xx.c
CFLAGS += -Ihal/inc
SRCS += $(wildcard hal/src/*.c)
######## - STM32F4xx Drivers
########################
# specific to STM32F429
########################
DEFS = -DSTM32F429xx
SRCS += cmsis/stm32f4xx/startup_stm32f429xx.s
LDSCRIPT = flash.ld
######## - specific to STM32F429
#################
# USB
#################
CFLAGS += -Iusb/core
SRCS += $(wildcard usb/core/*.c)
CFLAGS += -Iusb/class
SRCS += $(wildcard usb/class/*.c)
CFLAGS += -Iusb/user
SRCS += $(wildcard usb/user/*.c)
#################
# LTDC
#################
CFLAGS += -Igui
SRCS += $(wildcard gui/*.c)
#################
# STemWin
#################
CFLAGS += -Igui/stemwin/user
CFLAGS += -Igui/stemwin/inc
LIBS += -Lgui/stemwin/lib
LDFLAGS += -lSTemWin528_CM4_GCC
SRCS += $(wildcard gui/stemwin/user/*.c)
#################
# SDIO
#################
CFLAGS += -Ifs
SRCS += $(wildcard fs/*.c)
#################
# FATFS
#################
CFLAGS += -Ifs/fatfs/inc
SRCS += $(wildcard fs/fatfs/src/*.c)
SRCS += fs/fatfs/src/option/syscall.c
SRCS += fs/fatfs/src/option/unicode.c
#################
# FreeRTOS
#################
CFLAGS += -Ifreertos/inc
SRCS += $(wildcard freertos/src/*.c)
#################
# LED
#################
CFLAGS += -Iled
SRCS += $(wildcard led/*.c)
#################
# System
#################
CFLAGS += -Isystem
SRCS += $(wildcard system/*.c)
##########
# Rules
##########
OBJS = $(SRCS:.c=.o)
.PHONY: proj
all: proj
proj: $(BUILD)/$(PROJ_NAME).elf
$(BUILD)/$(PROJ_NAME).elf: $(SRCS)
@echo "Compiling project..."
@$(CC) $(CFLAGS) $(DEFS) $(LIBS) $^ -o $@ $(LDFLAGS)
@$(OBJCOPY) -O ihex $(BUILD)/$(PROJ_NAME).elf $(BUILD)/$(PROJ_NAME).hex
@$(OBJCOPY) -O binary $(BUILD)/$(PROJ_NAME).elf $(BUILD)/$(PROJ_NAME).bin
@echo "DONE"
dep:
$(CC) $(CFLAGS) $(DEFS) $(LIBS) -M system/main.c $(LDFLAGS)
clean:
@echo "Cleaning object files and binaries..."
@rm -f *.o $(BUILD)/*
@echo "DONE"
# Flash the STM32F4
burn: proj
$(STLINK)/st-flash write $(BUILD)/$(PROJ_NAME).bin 0x8000000
gdb:
arm-none-eabi-gdb --eval-command="target extended-remote localhost:4242" $(BUILD)/$(PROJ_NAME).elf
erase:
$(STLINK)/st-flash erase