-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
67 lines (52 loc) · 1.73 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
# :set noet
PROJ_NAME = steering
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
CFLAGS = -O0 -Wall -Wextra -Wstrict-prototypes -Werror -std=gnu11
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3 -march=armv7-m
CFLAGS += -msoft-float
CFLAGS += -I./inc -nostdlib -fno-builtin
CFLAGS += -T./STM32F205xx/STM32F205xB.ld
CFLAGS += -I./inc/boards -I./inc/stm32 -I./inc/drivers
# debug
CFLAGS += -g
CFLAGS += -DDEBUG_UART
SRC ?=
# CMSIS
CMSIS_DIR = STM32F205xx/CMSIS/STM32F2xx
CFLAGS += -I./$(CMSIS_DIR)/../ARM/inc -I./$(CMSIS_DIR)/inc
CFLAGS += -DSTM32F2 -DSTM32F205xx -DCALL_ARM_SYSTEM_INIT
SRC += ./$(CMSIS_DIR)/src/*.c
# HAL
HAL_DIR = STM32F205xx/HAL/STM32F2xx
CFLAGS += -I./$(HAL_DIR)/inc -DUSE_HAL_DRIVER
#HAL_SRC := $(shell find $(HAL_DIR)/src/*.c ! -name '*_template.c')
#SRC += $(HAL_SRC)
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_cortex.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_rcc.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_gpio.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_flash.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_flash_ex.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_dma.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_dma_ex.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_pwr.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_pwr_ex.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_uart.c
SRC += ./$(HAL_DIR)/src/stm32f2xx_hal_iwdg.c
SRC += ./src/*.c
BIN_FILE = obj/$(PROJ_NAME).bin
ELF_FILE = obj/$(PROJ_NAME).elf
OBJ_FILE = obj/startup_stm32f205xx.o
.PHONY: all
all: obj/$(PROJ_NAME).bin
$(BIN_FILE): $(ELF_FILE)
$(OBJCOPY) -O binary $^ $@
$(ELF_FILE): $(SRC) $(OBJ_FILE)
$(CC) $(CFLAGS) $^ -o $@
$(OBJ_FILE): STM32F205xx/startup/STM32F205xx.s
$(CC) $(CFLAGS) -c $< -o $@
flash:
st-flash write $(BIN_FILE) 0x08000000
clean:
rm -f obj/*