fix Makefile

This commit is contained in:
eddyem 2018-11-05 13:33:03 +03:00
parent 4defefb860
commit e9c8e716a1
4 changed files with 16 additions and 32 deletions

View File

@ -22,7 +22,6 @@ ARCH_FLAGS = $(ASM_FLAGS) $(FP_FLAGS)
###############################################################################
# Executables
OPREFIX ?= /opt/bin/arm-none-eabi
#PREFIX ?= /usr/x86_64-pc-linux-gnu/arm-none-eabi/gcc-bin/7.3.0/arm-none-eabi
PREFIX ?= $(OPREFIX)
RM := rm -f

View File

@ -7,26 +7,26 @@ FAMILY ?= F1
MCU ?= F103xB
# density (stm32f10x.h, lines 70-84)
DENSITY ?= MD
DEFS = -DEBUG
# change this linking script depending on particular MCU model,
# for example, if you have STM32F103VBT6, you should write:
LDSCRIPT ?= ld/stm32f103xB.ld
#LDSCRIPT = STM32F103C8.ld
# debug
DEFS = -DEBUG
INDEPENDENT_HEADERS=
FP_FLAGS ?= -msoft-float
ASM_FLAGS ?= -mthumb -mcpu=cortex-m3
#-mfix-cortex-m3-ldrd
ARCH_FLAGS = $(ASM_FLAGS) $(FP_FLAGS)
###############################################################################
# Executables
PREFIX ?= arm-none-eabi
#PREFIX ?= arm-none-eabi
# gcc from arm web site
PREFIX ?= /opt/bin/arm-none-eabi
RM := rm -f
RMDIR := rmdir
CC := $(PREFIX)-gcc
# don't replace ld with gcc: the binary size would be much greater!!
LD := $(PREFIX)-ld
AR := $(PREFIX)-ar
AS := $(PREFIX)-as
@ -36,15 +36,16 @@ OBJDUMP := $(PREFIX)-objdump
GDB := $(PREFIX)-gdb
STFLASH := $(shell which st-flash)
STBOOT := $(shell which stm32flash)
DFUUTIL := $(shell which dfu-util)
###############################################################################
# Source files
OBJDIR = mk
LDSCRIPT ?= $(BINARY).ld
SRC := $(wildcard *.c)
OBJS := $(addprefix $(OBJDIR)/, $(SRC:%.c=%.o))
STARTUP = $(OBJDIR)/startup.o
OBJS += $(STARTUP)
# dependencies: we need them to recompile files if their headers-dependencies changed
DEPS := $(OBJS:.o=.d)
INC_DIR ?= ../inc
@ -54,35 +55,22 @@ LIB_DIR := $(INC_DIR)/ld
###############################################################################
# C flags
CFLAGS += -O0 -g
# -MD -D__thumb2__=1
#CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
#CFLAGS += -Wredundant-decls
# -Wmissing-prototypes -Wstrict-prototypes
CFLAGS += -fno-common
#-ffunction-sections -fdata-sections
CFLAGS += -O2 -g -D__thumb2__=1 -MD
CFLAGS += -Wall -Werror -Wextra -Wshadow
CFLAGS += -fno-common -ffunction-sections -fdata-sections
###############################################################################
# Linker flags
LDFLAGS += -nostartfiles
# --static
#--specs=nano.specs
LDFLAGS += -nostartfiles --static
LDFLAGS += -L$(LIB_DIR)
LDFLAGS += -T$(LDSCRIPT)
#LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
#LDFLAGS += -Wl,--gc-sections
###############################################################################
# Used libraries
#LDLIBS += -Wl,--start-group -lc -lgcc -Wl,--end-group
#LDLIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LDLIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
DEFS += -DSTM32$(FAMILY) -DSTM32$(MCU) -DSTM32F10X_$(DENSITY)
#.SUFFIXES: .elf .bin .hex .srec .list .map .images
#.SECONDEXPANSION:
#.SECONDARY:
ELF := $(OBJDIR)/$(BINARY).elf
LIST := $(OBJDIR)/$(BINARY).list
BIN := $(BINARY).bin
@ -109,9 +97,6 @@ $(OBJDIR)/%.o: %.c
@echo " CC $<"
$(CC) $(CFLAGS) $(DEFS) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
#$(OBJDIR)/%.d: %.c $(OBJDIR)
# $(CC) -MM -MG $< | sed -e 's,^\([^:]*\)\.o[ ]*:,$(@D)/\1.o $(@D)/\1.d:,' >$@
$(BIN): $(ELF)
@echo " OBJCOPY $(BIN)"
$(OBJCOPY) -Obinary $(ELF) $(BIN)
@ -133,7 +118,7 @@ size: $(ELF)
clean:
@echo " CLEAN"
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST) $(OBJDIR)/*.map
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST)
@rmdir $(OBJDIR) 2>/dev/null || true

Binary file not shown.

View File

@ -29,7 +29,7 @@ void sys_tick_handler(void){
}
// SysTick is 24 bit counter, so 16777215 - max value!!!
// After HSE is ON it works @9MHz (????)
// After HSE is ON it works @72MHz (or remove SysTick_CTRL_CLKSOURCE_Msk @ SysTick_Config for 8MHz)
static void systick_setup(uint32_t xms){
static uint32_t curms = 0;
if(curms == xms) return;