aboutsummaryrefslogtreecommitdiffstats
path: root/support/make/target-config.mk
blob: 68cddbf75a0fffc1a0a03eebc4ab593627b8fdde (plain)
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
# TARGET_FLAGS are to be passed while compiling, assembling, linking.
TARGET_FLAGS :=
# TARGET_LDFLAGS go to the linker
TARGET_LDFLAGS :=

# Configuration derived from $(MEMORY_TARGET)

LD_SCRIPT_PATH := $(LDDIR)/$(MEMORY_TARGET).ld

ifeq ($(MEMORY_TARGET), ram)
VECT_BASE_ADDR := VECT_TAB_RAM
endif
ifeq ($(MEMORY_TARGET), flash)
VECT_BASE_ADDR := VECT_TAB_FLASH
endif
ifeq ($(MEMORY_TARGET), jtag)
VECT_BASE_ADDR := VECT_TAB_BASE
endif

# Pull in the board configuration file here, so it can override the
# above.

include $(BOARD_INCLUDE_DIR)/$(BOARD).mk

# Configuration derived from $(BOARD).mk

TARGET_SERIES_MODULE := $(MCU_SERIES)

# Override TARGET_SERIES_MODULE for STM32F2 and STM32F4, which are
# basically the same and thus share a module.
ifeq ($(MCU_SERIES), stm32f2)
TARGET_SERIES_MODULE := stm32f2-f4
endif
ifeq ($(MCU_SERIES), stm32f4)
TARGET_SERIES_MODULE := stm32f2-f4
endif

LIBMAPLE_MODULE_SERIES := $(LIBMAPLE_PATH)/$(TARGET_SERIES_MODULE)
LD_SERIES_PATH := $(LDDIR)/stm32/series/$(TARGET_SERIES_MODULE)
LD_MEM_PATH := $(LDDIR)/stm32/mem/$(LD_MEM_DIR)

ifeq ($(MCU_SERIES), stm32f1)
TARGET_FLAGS += -mcpu=cortex-m3 -march=armv7-m
# Due to the Balkanization on F1, we need to specify the line when
# making linker decisions.
LD_SERIES_PATH := $(LD_SERIES_PATH)/$(MCU_F1_LINE)
endif
ifeq ($(MCU_SERIES), stm32f2)
LD_SERIES_PATH := $(LD_SERIES_PATH)/stm32f2
TARGET_FLAGS += -mcpu=cortex-m3 -march=armv7-m
endif
ifeq ($(MCU_SERIES), stm32f4)
LD_SERIES_PATH := $(LD_SERIES_PATH)/$(MCU_F4_LINE)
TARGET_FLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard \
	-mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
endif

TARGET_LDFLAGS += -Xlinker -T$(LD_SCRIPT_PATH) \
                  -L $(LD_SERIES_PATH) \
                  -L $(LD_MEM_PATH) \
                  -L $(LDDIR) $(TARGET_FLAGS) -mthumb
TARGET_FLAGS += -mthumb -DBOARD_$(BOARD) -DMCU_$(MCU) \
                -DERROR_LED_PORT=$(ERROR_LED_PORT) \
                -DERROR_LED_PIN=$(ERROR_LED_PIN) \
                -D$(VECT_BASE_ADDR)