Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BUILD_BASE = build
- FW_DIR = firmware
- TARGET = app
- STARTUP = startup_stm32f10x_ld_vl.S
- TARGET_OUT = $(addprefix $(BUILD_BASE)/,$(TARGET).elf)
- FW_OUT = $(addprefix $(FW_DIR)/,$(TARGET).hex)
- STLINK_FLASH = "C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe"
- STLINK_FLAGS = -c SWD -p $(FW_OUT) -Rst -Run
- MODULES = user SPL SPL/src SPL/inc CoreSupport
- SRC_DIR = $(MODULES)
- BUILD_DIR = $(addprefix build/,$(MODULES))
- SRC = $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
- OBJ = $(patsubst %.c,build/%.o,$(SRC))
- INCLUDES = $(addprefix -I ,$(SRC_DIR))
- LD_SCRIPT = stm32f103c8_flash.ld
- LDFLAGS = -T$(LD_SCRIPT) -Wl,--gc-sections,-Map=$@.map,-cref,-u,Reset_Handler $(INCLUDES)
- CFLAGS = -specs=nano.specs -ffunction-sections -fdata-sections -mcpu=cortex-m3 -mthumb -Wall -g -O2 \
- -fomit-frame-pointer -fverbose-asm -mfloat-abi=soft -D__STACK_SIZE=0x0100 -D__HEAP_SIZE=0x0000 \
- -DSTM32F103C8 -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -DRUN_FROM_FLASH=1
- ASFLAGS = -Wa,-adhlns=$@.lst -c -fmessage-length=0 -mcpu=cortex-m3 -mfloat-abi=soft
- OBJCPFLAGS = -O ihex
- OBJSIZEFLAGS = --format=berkeley
- CC=arm-none-eabi-gcc.exe
- LD=arm-none-eabi-gcc.exe
- AR=arm-none-eabi-ar.exe
- AS=arm-none-eabi-as.exe
- OBJCP=arm-none-eabi-objcopy.exe
- OBJDP=arm-none-eabi-objdump.exe
- OBJSIZE=arm-none-eabi-size.exe
- V ?= $(VERBOSE)
- ifeq ("$(V)","1")
- Q :=
- vecho := @true
- else
- Q := @
- vecho := @echo
- endif
- vpath %.c $(SRC_DIR)
- define compile-objects
- build/%.o: %.c
- $(vecho) $(CC) $(INCLUDES) $(CFLAGS) -c $$< -o $$@
- $(Q) $(CC) $(INCLUDES) $(CFLAGS) -c $$< -o $$@
- endef
- .PHONY: all checkdirs clean flash
- all: checkdirs $(TARGET_OUT) $(FW_OUT)
- checkdirs: $(BUILD_DIR) $(FW_DIR)
- $(TARGET_OUT):$(OBJ)
- $(vecho) $(LD) $(LDFLAGS) $(OBJ) -o $@
- $(Q) $(LD) $(LDFLAGS) $(OBJ) -o $@
- $(FW_OUT):$(TARGET_OUT)
- $(OBJCP) $(OBJCPFLAGS) $< $@
- $(OBJSIZE) $(OBJSIZEFLAGS) $< $@
- $(BUILD_DIR):
- $(Q) md $(subst /,\,$@)
- $(FW_DIR):
- $(Q) md $(subst /,\,$@)
- $(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
- flash: all
- $(STLINK_FLASH) $(STLINK_FLAGS)
- clean:
- $(Q) rm -rf $(BUILD_DIR)
- $(Q) rm -rf $(BUILD_BASE)
- $(Q) rm -rf $(FW_DIR)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement