-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
180 lines (154 loc) · 5.62 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
PROJECT = player
EXECUTABLE = $(PROJECT).elf
BIN_IMAGE = $(PROJECT).bin
HEX_IMAGE = $(PROJECT).hex
# set the path to STM32F429I-Discovery firmware package
STDP ?= ../STM32F429I-Discovery_FW_V1.0.1
# Toolchain configurations
CROSS_COMPILE ?= arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
SIZE = $(CROSS_COMPILE)size
# Cortex-M4 implements the ARMv7E-M architecture
CPU = cortex-m4
CFLAGS = -mcpu=$(CPU) -march=armv7e-m -mtune=cortex-m4
CFLAGS += -mlittle-endian -mthumb
# Need study
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -O0
define get_library_path
$(shell dirname $(shell $(CC) $(CFLAGS) -print-file-name=$(1)))
endef
LDFLAGS += -L $(call get_library_path,libc.a)
LDFLAGS += -L $(call get_library_path,libgcc.a)
# Basic configurations
CFLAGS += -g -std=c99
CFLAGS += -Wall
CFLAGS += -DUSER_NAME=\"$(USER)\"
# Optimizations
CFLAGS += -g -std=c99 -O3 -ffast-math
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -Wl,--gc-sections
CFLAGS += -fno-common
CFLAGS += --param max-inline-insns-single=1000
# specify STM32F429
CFLAGS += -DSTM32F429_439xx
# to run from FLASH
CFLAGS += -DVECT_TAB_FLASH
LDFLAGS += -T $(PWD)/CORTEX_M4F_STM32F4/stm32f429zi_flash.ld
# STARTUP FILE
OBJS += $(PWD)/CORTEX_M4F_STM32F4/startup_stm32f429_439xx.o
# STM32F4xx_StdPeriph_Driver
CFLAGS += -DUSE_STDPERIPH_DRIVER
CFLAGS += -D"assert_param(expr)=((void)0)"
#My restart
OBJS += \
$(PWD)/src/main.o \
$(PWD)/CORTEX_M4F_STM32F4/startup/system_stm32f4xx.o
#$(PWD)/CORTEX_M4F_STM32F4/stm32f4xx_it.o \
OBJS += \
$(PWD)/FreeRTOS/croutine.o \
$(PWD)/FreeRTOS/event_groups.o \
$(PWD)/FreeRTOS/list.o \
$(PWD)/FreeRTOS/queue.o \
$(PWD)/FreeRTOS/tasks.o \
$(PWD)/FreeRTOS/timers.o \
$(PWD)/FreeRTOS/portable/GCC/ARM_CM4F/port.o \
$(PWD)/FreeRTOS/portable/MemMang/heap_1.o
OBJS += \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.o \
$(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.o \
$(PWD)/Utilities/STM32F429I-Discovery/stm32f429i_discovery.o \
$(PWD)/Utilities/STM32F429I-Discovery/stm32f429i_discovery_sdram.o \
$(PWD)/Utilities/STM32F429I-Discovery/stm32f429i_discovery_lcd.o \
$(PWD)/Utilities/STM32F429I-Discovery/stm32f429i_discovery_ioe.o
# shell
OBJS += \
$(PWD)/src/host.o \
$(PWD)/src/stm32_init.o \
$(PWD)/src/hash-djb2.o \
$(PWD)/src/osdebug.o \
$(PWD)/src/gui.o \
$(PWD)/src/pwm.o \
$(PWD)/src/diskio.o \
$(PWD)/src/ff.o \
$(PWD)/src/tm_stm32f4_fatfs.o \
$(PWD)/src/fatfs_sd.o \
$(PWD)/src/syscall.o \
$(PWD)/src/unicode.o \
$(PWD)/src/tm_stm32f4_spi.o \
$(PWD)/src/tm_stm32f4_delay.o \
$(PWD)/src/mp3/__STD_LIB_sbrk.o \
$(PWD)/src/mp3/bitstream.o \
$(PWD)/src/mp3/buffers.o \
$(PWD)/src/mp3/dct32.o \
$(PWD)/src/mp3/dequant.o \
$(PWD)/src/mp3/dqchan.o \
$(PWD)/src/mp3/imdct.o \
$(PWD)/src/mp3/mp3dec.o \
$(PWD)/src/mp3/mp3tabs.o \
$(PWD)/src/mp3/huffman.o \
$(PWD)/src/mp3/hufftabs.o \
$(PWD)/src/mp3/polyphase.o \
$(PWD)/src/mp3/stproc.o \
$(PWD)/src/mp3/subband.o \
$(PWD)/src/mp3/trigtabs.o \
$(PWD)/src/mp3/scalfact.o \
$(PWD)/src/mp3/asmmisc.o \
$(PWD)/src/mp3/asmpoly.o
CFLAGS += -I $(PWD)/include
CFLAGS += -DUSE_STDPERIPH_DRIVER
CFLAGS += -I $(PWD)/CORTEX_M4F_STM32F4 \
-I $(PWD)/FreeRTOS/include \
-I $(PWD)/FreeRTOS/portable/GCC/ARM_CM4F \
-I $(PWD)/CORTEX_M4F_STM32F4/board \
-I $(PWD)/CORTEX_M4F_STM32F4/Libraries/CMSIS/Device/ST/STM32F4xx/Include \
-I $(PWD)/CORTEX_M4F_STM32F4/Libraries/CMSIS/Include \
-I $(PWD)/CORTEX_M4F_STM32F4/Libraries/STM32F4xx_StdPeriph_Driver/inc \
-I $(PWD)/Utilities/STM32F429I-Discovery
all: $(BIN_IMAGE)
$(BIN_IMAGE): $(EXECUTABLE)
$(OBJCOPY) -O binary $^ $@
$(OBJCOPY) -O ihex $^ $(HEX_IMAGE)
$(OBJDUMP) -h -S -D $(EXECUTABLE) > $(PROJECT).lst
$(SIZE) $(EXECUTABLE)
$(EXECUTABLE): $(OBJS)
$(LD) -o $@ $(OBJS) \
--start-group $(LIBS) --end-group \
$(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S
$(CC) $(CFLAGS) -c $< -o $@
flash:
st-flash write $(BIN_IMAGE) 0x8000000
openocd_flash:
openocd \
-f board/stm32f429discovery.cfg \
-c "init" \
-c "reset init" \
-c "flash probe 0" \
-c "flash info 0" \
-c "flash write_image erase $(BIN_IMAGE) 0x08000000" \
-c "reset run" -c shutdown
.PHONY: clean
clean:
rm -rf $(EXECUTABLE)
rm -rf $(BIN_IMAGE)
rm -rf $(HEX_IMAGE)
rm -f $(OBJS)
rm -f $(PROJECT).lst