107 lines
2.7 KiB
Makefile
107 lines
2.7 KiB
Makefile
###############################################################################
|
|
# ARM Section
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
|
GEN_FLAGS := \
|
|
-mcpu=cortex-m4 \
|
|
-mthumb \
|
|
-mfloat-abi=hard \
|
|
-mfpu=fpv4-sp-d16 \
|
|
-Og \
|
|
-fmessage-length=0 \
|
|
-fsigned-char \
|
|
-ffunction-sections \
|
|
-fdata-sections \
|
|
-ffreestanding \
|
|
-fno-move-loop-invariants \
|
|
-Werror \
|
|
-Wunused \
|
|
-Wuninitialized \
|
|
-Wall \
|
|
-Wextra \
|
|
-Wmissing-declarations \
|
|
-Wconversion \
|
|
-Wpointer-arith \
|
|
-Wpadded \
|
|
-Wshadow \
|
|
-Wlogical-op \
|
|
-Waggregate-return \
|
|
-Wfloat-equal \
|
|
-g3
|
|
# -flto ## behind -ffreestanding
|
|
|
|
C_FLAGS = \
|
|
-DDEBUG \
|
|
-DUSE_FULL_ASSERT \
|
|
-DTRACE \
|
|
-DOS_USE_TRACE_SEMIHOSTING_DEBUG \
|
|
-DSTM32F407xx \
|
|
-DUSE_HAL_DRIVER \
|
|
-DHSE_VALUE=8000000 \
|
|
$(addprefix -I, $(INCLUDES)) \
|
|
-std=gnu11 \
|
|
-Wmissing-prototypes \
|
|
-Wstrict-prototypes \
|
|
-Wbad-function-cast \
|
|
-Wno-bad-function-cast \
|
|
-Wno-conversion \
|
|
-Wno-sign-conversion \
|
|
-Wno-unused-parameter \
|
|
-Wno-sign-compare \
|
|
-Wno-missing-prototypes \
|
|
-Wno-missing-declarations
|
|
|
|
L_FLAGS := \
|
|
-T mem.ld \
|
|
-T libs.ld \
|
|
-T sections.ld \
|
|
-nostartfiles \
|
|
-Xlinker --gc-sections \
|
|
-L"config/linker" \
|
|
-Wl,-Map,"template.map" \
|
|
--specs=nano.specs \
|
|
|
|
INCLUDES += \
|
|
/opt/arm-2011.09/arm-none-eabi/include \
|
|
/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include \
|
|
source/firmware
|
|
|
|
###############################################################################
|
|
# TOOLS Section
|
|
CC = $(CROSS_COMPILE)gcc
|
|
CXX = $(CROSS_COMPILE)g++
|
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
|
|
|
OBJ_DIR = release/object/debug
|
|
EXE_DIR = release/execute/debug
|
|
|
|
include source/firmware/firmware.mk
|
|
include source/test/src/src.mk
|
|
|
|
###############################################################################
|
|
C_SOURCES := $(foreach folder, $(SRC_DIR), $(wildcard $(folder)/*.c))
|
|
C_OBJECTS := $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
|
|
MAIN_FILE := $(EXE_DIR)/template.elf
|
|
BIN_FILE := $(EXE_DIR)/template.bin
|
|
OOCD_CFG_FILE := $(EXE_DIR)/openocd.cfg
|
|
|
|
all: $(C_OBJECTS)
|
|
@mkdir -p $(EXE_DIR)
|
|
$(CXX) $(GEN_FLAGS) $(L_FLAGS)-o "$(MAIN_FILE)" $(C_OBJECTS)
|
|
$(OBJCOPY) $(MAIN_FILE) -O binary $(BIN_FILE)
|
|
$(OBJ_DIR)/%.o: %.c
|
|
@mkdir -p $(OBJ_DIR)
|
|
@$(foreach folder, $(SRC_DIR), $(shell mkdir -p $(OBJ_DIR)/$(folder)))
|
|
$(CC) $(GEN_FLAGS) $(C_FLAGS) -MMD -MP -MF"$(subst .o,.d,$@)" -MT"$@" -c -o "$@" "$<"
|
|
|
|
clean:
|
|
$(foreach folder, $(SRC_DIR), $(shell rm -f $(OBJ_DIR)/$(folder)/*.o))
|
|
$(foreach folder, $(SRC_DIR), $(shell rm -f $(OBJ_DIR)/$(folder)/*.d))
|
|
-rm -f $(OBJ_DIR)/*.o \
|
|
$(OBJ_DIR)/*.d \
|
|
$(MAIN_FILE) \
|
|
$(BIN_FILE)
|
|
|
|
install: all
|
|
echo "telnet_port 4444\ninit\nreset halt\nflash write_image erase $(BIN_FILE) 0x08000000 bin\nreset run\n shutdown\n" > $(OOCD_CFG_FILE)
|
|
openocd -f /usr/share/openocd/scripts/board/stm32f4discovery.cfg -f $(OOCD_CFG_FILE)
|