2016-08-15 14:11:00 +00:00
|
|
|
###############################################################################
|
|
|
|
# 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
|
2016-08-16 07:33:49 +00:00
|
|
|
# -flto ## behind -ffreestanding
|
2016-08-15 14:11:00 +00:00
|
|
|
|
|
|
|
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 \
|
2016-08-16 07:33:49 +00:00
|
|
|
/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include \
|
|
|
|
source/firmware
|
2016-08-15 14:11:00 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# TOOLS Section
|
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
CXX = $(CROSS_COMPILE)g++
|
|
|
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
|
|
|
|
|
|
|
OBJ_DIR = release/object/debug
|
|
|
|
EXE_DIR = release/execute/debug
|
2016-07-28 19:02:54 +00:00
|
|
|
|
2016-07-29 06:37:13 +00:00
|
|
|
include source/firmware/firmware.mk
|
2016-08-15 14:11:00 +00:00
|
|
|
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 "$@" "$<"
|
2016-07-28 19:02:54 +00:00
|
|
|
|
|
|
|
clean:
|
2016-08-15 14:11:00 +00:00
|
|
|
$(foreach folder, $(SRC_DIR), $(shell rm -f $(OBJ_DIR)/$(folder)/*.o))
|
|
|
|
$(foreach folder, $(SRC_DIR), $(shell rm -f $(OBJ_DIR)/$(folder)/*.d))
|
2016-07-28 19:02:54 +00:00
|
|
|
-rm -f $(OBJ_DIR)/*.o \
|
|
|
|
$(OBJ_DIR)/*.d \
|
2016-08-15 14:11:00 +00:00
|
|
|
$(MAIN_FILE) \
|
|
|
|
$(BIN_FILE)
|
2016-08-02 12:10:11 +00:00
|
|
|
|
2016-08-15 14:11:00 +00:00
|
|
|
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)
|