switch to using devices.data linker generation

Still using my own private rules, but now using the linker script generator so
no need to keep expanding on including .ld files in core libopencm3
This commit is contained in:
Karl Palsson 2016-04-08 00:00:02 +00:00
parent 835fafe270
commit c5c33a4600
6 changed files with 25 additions and 49 deletions

View file

@ -18,14 +18,20 @@
# This version of rules.mk expects the following to be defined before
# inclusion..
### REQUIRED ###
# DEVICE=xxxx - this tree uses the genlink-config.mk and genlink-rules.mk!
# OPENCM3_DIR - duh
# OPENCM3_LIB - the basename, eg: opencm3_stm32f4
# OPENCM3_DEFS - the target define eg: -DSTM32F4
# ARCH_FLAGS - eg, -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
# (ie, the full set of cpu arch flags, _none_ are defined in this file)
# PROJECT - will be the basename of the output elf, eg usb-gadget0-stm32f4disco
# CFILES - basenames only, eg main.c blah.c
# LDSCRIPT - full path, eg ../../examples/stm32/f4/stm32f4-discovery/stm32f4-discovery.ld
# The follow vars are assumed to have been created via genlink.mk
# xOPENCM3_LIB - the basename, eg: opencm3_stm32f4
# SOURCED VIA devices.data!
# xOPENCM3_DEFS - the target define eg: -DSTM32F4
# SOURCED VIA devices.data!
# xARCH_FLAGS - eg, -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
# (ie, the full set of cpu arch flags, _none_ are defined in this file)
# SOURCED VIA devices.data!
# xLDSCRIPT - full path, eg ../../examples/stm32/f4/stm32f4-discovery/stm32f4-discovery.ld
# SOURCED VIA devices.data!
#
### OPTIONAL ###
# INCLUDES - fully formed -I paths, if you want extra, eg -I../shared
@ -65,16 +71,14 @@ OBJCOPY = $(PREFIX)objcopy
OBJDUMP = $(PREFIX)objdump
OOCD ?= openocd
OPENCM3_INC = $(OPENCM3_DIR)/include
# Inclusion of library header files
INCLUDES += $(patsubst %,-I%, . $(OPENCM3_INC) )
include $(OPENCM3_DIR)/mk/genlink-config.mk
OBJS = $(CFILES:%.c=$(BUILD_DIR)/%.o)
TGT_CPPFLAGS += -MD
TGT_CPPFLAGS += -Wall -Wundef $(INCLUDES)
TGT_CPPFLAGS += $(INCLUDES) $(OPENCM3_DEFS)
TGT_CPPFLAGS += -Wall -Wundef
TGT_CPPFLAGS += $(INCLUDES)
TGT_CFLAGS += $(OPT) $(CSTD) -ggdb3
TGT_CFLAGS += $(ARCH_FLAGS)
@ -100,7 +104,6 @@ ifeq ($(V),99)
TGT_LDFLAGS += -Wl,--print-gc-sections
endif
LDLIBS += -l$(OPENCM3_LIB)
# nosys is only in newer gcc-arm-embedded...
LDLIBS += -specs=nosys.specs
#LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
@ -119,11 +122,6 @@ LDLIBS += -specs=nosys.specs
all: $(PROJECT).elf $(PROJECT).bin
flash: $(PROJECT).flash
$(LDSCRIPT):
ifeq (,$(wildcard $(LDSCRIPT)))
$(error Unable to find specified linker script: $(LDSCRIPT))
endif
# Need a special rule to have a bin dir
$(BUILD_DIR)/%.o: %.c
@printf " CC\t$<\n"
@ -165,7 +163,9 @@ else
endif
clean:
rm -rf $(BUILD_DIR) $(PROJECT).{elf,bin} $(PROJECT).{list,lss,map}
rm -rf $(BUILD_DIR) $(PROJECT).{elf,bin} $(PROJECT).{list,lss,map} $(LDSCRIPT)
include $(OPENCM3_DIR)/mk/genlink-rules.mk
.PHONY: all clean flash
-include $(OBJS:.o=.d)

View file

@ -1,9 +0,0 @@
LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f0/stm32f07xzb.ld
OPENCM3_LIB = opencm3_stm32f0
OPENCM3_DEFS = -DSTM32F0
#FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS = -mthumb -mcpu=cortex-m0 $(FP_FLAGS)
#OOCD_INTERFACE = stlink-v2
#OOCD_TARGET = stm32f4x
OOCD_FILE = ../../openocd/openocd.stm32f072-disco.cfg

View file

@ -15,5 +15,9 @@ VPATH += $(SHARED_DIR)
INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
OPENCM3_DIR=../../libopencm3
include ../../rules.stm32f0.mk
DEVICE=stm32f072rb
#OOCD_INTERFACE = stlink-v2
#OOCD_TARGET = stm32f0x
OOCD_FILE = ../../openocd/openocd.stm32f072-disco.cfg
include ../../rules.mk

View file

@ -14,13 +14,7 @@ VPATH += $(SHARED_DIR)
INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
OPENCM3_DIR=../../libopencm3/
### This section can go to an arch shared rules eventually...
LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f3/stm32f303xc.ld
OPENCM3_LIB = opencm3_stm32f3
OPENCM3_DEFS = -DSTM32F3
FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
DEVICE=stm32f303vct6
#OOCD_INTERFACE = stlink-v2
#OOCD_TARGET = stm32f3x
OOCD_FILE = ../../openocd/openocd.stm32f3-disco.cfg

View file

@ -32,11 +32,7 @@ INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
OPENCM3_DIR=../../libopencm3/
### This section can go to an arch shared rules eventually...
LDSCRIPT = $(OPENCM3_DIR)/lib/stm32/f4/stm32f405x6.ld
OPENCM3_LIB = opencm3_stm32f4
OPENCM3_DEFS = -DSTM32F4
FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
DEVICE=stm32f405xg
#OOCD_INTERFACE = stlink-v2
#OOCD_TARGET = stm32f4x
OOCD_FILE = ../../openocd/openocd.stm32f4-disco.cfg

View file

@ -16,17 +16,8 @@ INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
OPENCM3_DIR=../../libopencm3/
### This section can go to an arch shared rules eventually...
#DEVICE=stm32l476vgt6
#SRCLIBDIR=$(OPENCM3_DIR)
#include $(OPENCM3_DIR)/ld/Makefile.linker
LDSCRIPT=$(OPENCM3_DIR)/lib/stm32/l4/stm32l4xxg.ld
OPENCM3_LIB = opencm3_stm32l4
OPENCM3_DEFS = -DSTM32L4
FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
DEVICE=stm32l476vgt6
#OOCD_INTERFACE = stlink-v2-1
#OOCD_TARGET = stm32l4x
OOCD_FILE = ../../openocd/openocd.stm32l4-disco.cfg
include ../../rules.mk