forked from AlkaMotors/AM32_Bootloader_F051
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
59 lines (53 loc) · 1.7 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
CC = $(ARM_SDK_PREFIX)gcc
CP = $(ARM_SDK_PREFIX)objcopy
MCU := -mcpu=cortex-m0 -mthumb
LDSCRIPT := STM32F051K6TX_FLASH.ld
LIBS := -lc -lm -lnosys
LDFLAGS := -specs=nano.specs -T$(LDSCRIPT) $(LIBS) -Wl,--gc-sections -Wl,--print-memory-usage
MAIN_SRC_DIR := Src
SRC_DIR := Core/Startup \
Core/Src \
Drivers/STM32F0xx_HAL_Driver/Src
SRC := $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*.[cs]))
OBJ := $(SRC:%.[cs]=%.o)
INCLUDES := \
-ICore/Inc \
-IDrivers/STM32F0xx_HAL_Driver/Inc \
-IDrivers/CMSIS/Include \
-IDrivers/CMSIS/Device/ST/STM32F0xx/Include
VALUES := \
-DUSE_MAKE \
-DHSE_VALUE=8000000 \
-DSTM32F051x8 \
-DHSE_STARTUP_TIMEOUT=100 \
-DLSE_STARTUP_TIMEOUT=5000 \
-DLSE_VALUE=32768 \
-DDATA_CACHE_ENABLE=0 \
-DINSTRUCTION_CACHE_ENABLE=0 \
-DVDD_VALUE=3300 \
-DLSI_VALUE=40000 \
-DHSI_VALUE=8000000 \
-DUSE_FULL_LL_DRIVER \
-DPREFETCH_ENABLE=1
CFLAGS = $(MCU) $(VALUES) $(INCLUDES) -Os -Wall -fdata-sections -ffunction-sections
CFLAGS += -DUSE_$(TARGET)
CFLAGS += -MMD -MP -MF $(@:%.bin=%.d)
ARM_SDK_PREFIX ?= arm-none-eabi-
# Targets by signal input pin:
# PB4: iFlight
# PA2: all others
TARGETS := PA2 PB4
TARGET_PREFIX := BOOTLOADER_
VERSION := $(shell grep "\#define BOOTLOADER_VERSION" Core/Src/main.c | awk '{print $$3}' )
.PHONY : clean all version
all : $(TARGETS)
clean :
rm -f Src/*.o
version :
@echo $(VERSION)
$(TARGETS) :
$(MAKE) TARGET=$@ $(TARGET_PREFIX)[email protected]
$(TARGETS:%=$(TARGET_PREFIX)%.bin) : clean $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(TARGET_PREFIX)$(TARGET)_$(VERSION).elf $(OBJ)
$(CP) -O binary $(TARGET_PREFIX)$(TARGET)_$(VERSION).elf $(TARGET_PREFIX)$(TARGET)_$(VERSION).bin
$(CP) $(TARGET_PREFIX)$(TARGET)_$(VERSION).elf -O ihex $(TARGET_PREFIX)$(TARGET)_$(VERSION).hex