forked from aabitria-adi/FREERTOS_Handson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (100 loc) · 3.05 KB
/
Copy pathMakefile
File metadata and controls
130 lines (100 loc) · 3.05 KB
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
PROJECT := freertos
FREERTOS := ThirdParty/FreeRTOS
VPATH := \
$(FREERTOS) \
$(FREERTOS)/portable/GCC/ARM_CM3 \
$(FREERTOS)/portable/MemMang \
./Core/Src \
./Core/Startup \
./Drivers/STM32F1xx_HAL_Driver/Src
INCLUDES := \
-ICore/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
-IDrivers/CMSIS/Include \
-I$(FREERTOS)/include \
-I$(FREERTOS)/portable/GCC/ARM_CM3
ASM_SRCS := \
startup_stm32f103c8tx.s
CORE_SRCS := \
display.c \
gpio.c \
main.c \
serial_print.c \
stm32f1xx_hal_msp.c \
stm32f1xx_hal_timebase_tim.c \
stm32f1xx_it.c \
syscalls.c \
system_common.c \
system_stm32f1xx.c \
usart.c
HAL_DRIVER_SRCS := \
stm32f1xx_hal_cortex.c \
stm32f1xx_hal_dma.c \
stm32f1xx_hal_exti.c \
stm32f1xx_hal_flash_ex.c \
stm32f1xx_hal_flash.c \
stm32f1xx_hal_gpio_ex.c \
stm32f1xx_hal_gpio.c \
stm32f1xx_hal_pwr.c \
stm32f1xx_hal_rcc_ex.c \
stm32f1xx_hal_rcc.c \
stm32f1xx_hal_tim_ex.c \
stm32f1xx_hal_tim.c \
stm32f1xx_hal_uart.c \
stm32f1xx_hal.c
FREERTOS_SRCS := \
croutine.c \
event_groups.c \
list.c \
queue.c \
stream_buffer.c \
tasks.c \
timers.c \
port.c \
heap_4.c
ASM_DEFS:=-DDEBUG
C_DEFS:=-DDEBUG \
-DUSE_HAL_DRIVER \
-DSTM32F103xB
OUTPUT:=$(PROJECT)
LD_SCRIPT:=STM32F103C8TX_FLASH.ld
ARM_CPU:=-mcpu=cortex-m3
C_SRCS:=$(CORE_SRCS) \
$(HAL_DRIVER_SRCS) \
$(FREERTOS_SRCS)
GNU_TOOLS_DIR := /usr
CC := $(GNU_TOOLS_DIR)/bin/arm-none-eabi-gcc
AS := $(GNU_TOOLS_DIR)/bin/arm-none-eabi-gcc
LINK := $(GNU_TOOLS_DIR)/bin/arm-none-eabi-gcc
BIN := $(GNU_TOOLS_DIR)/bin/arm-none-eabi-objcopy
BIN_DIR := Debug
ASM_OBJS := $(patsubst %.s,%.o,$(ASM_SRCS))
C_OBJS := $(patsubst %.c,%.o,$(C_SRCS))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
TARGET_MAP := $(BIN_DIR)/$(OUTPUT).map
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
ASFLAGS := $(ARM_CPU) -mfloat-abi=soft -mthumb -g3 -c -x assembler-with-cpp --specs=nano.specs $(ASM_DEFS)
CFLAGS := -g $(ARM_CPU) -mfloat-abi=soft -mthumb -std=gnu11 -g3 -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage $(INCLUDES) $(C_DEFS)
LINKFLAGS := $(ARM_CPU) -T"./$(LD_SCRIPT)" -Wl,-Map="$(TARGET_MAP)" -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -static -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell mkdir $(BIN_DIR))
endif
# rules
all: $(TARGET_BIN)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(C_OBJS_EXT) $(ASM_OBJS_EXT)
$(CC) $(CFLAGS) $(LINKFLAGS) -o $@ $^
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.o : %.c
@echo CC $(notdir $<)
$(CC) -c $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.s
@echo AS $(notdir $<)
$(AS) $(ASFLAGS) $< -o $@