aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKarl Palsson2012-10-20 19:37:46 +0000
committerKarl Palsson2012-11-07 21:50:27 +0000
commit49412864544c3b7c5ab321098c419b61dfc05b3b (patch)
tree341e28d8f49ed347f5dd0cbcea4964d7238296b1 /examples
parente4f84278f2b62dee7b4e0ac718c7c6ce998240ba (diff)
STM32L1 support, rebased onto upstream generalizations branch.
Working example again.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32/l1/Makefile.include43
-rw-r--r--examples/stm32/l1/stm32l-discovery/miniblink/Makefile2
2 files changed, 23 insertions, 22 deletions
diff --git a/examples/stm32/l1/Makefile.include b/examples/stm32/l1/Makefile.include
index f152b2a..32c3cee 100644
--- a/examples/stm32/l1/Makefile.include
+++ b/examples/stm32/l1/Makefile.include
@@ -25,27 +25,32 @@ LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
GDB = $(PREFIX)-gdb
-# If you are copying this file to use in your own project,
-# You will need to change this... (Leave unset to assume installed
-# in the toolchain itself)
-#OPENCM3_DIR ?= /opt/libopencm3/$(PREFIX)
-OPENCM3_DIR ?= ../../../../..
-
-ARCH_FLAGS = -mcpu=cortex-m3 -mthumb -msoft-float
-CFLAGS += -g -Os -Wall -Wextra \
+
+TOOLCHAIN_DIR ?= ../../../../..
+ifeq ($(wildcard ../../../../../lib/libopencm3_stm32l1.a),)
+ifneq ($(strip $(shell which $(CC))),)
+TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
+endif
+else
+ifeq ($(V),1)
+$(info We seem to be building the example in the source directory. Using local library!)
+endif
+endif
+
+$(info GAHHHH toolchain: $(TOOLCHAIN_DIR))
+
+ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float
+CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \
-fno-common $(ARCH_FLAGS) -MD -DSTM32L1
LDSCRIPT ?= $(BINARY).ld
-LDFLAGS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
+LDFLAGS += --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
+ -L$(TOOLCHAIN_DIR)/lib \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
$(ARCH_FLAGS) -mfix-cortex-m3-ldrd
-ifneq ($(OPENCM3_DIR),)
-CFLAGS += -I$(OPENCM3_DIR)/include
-LDFLAGS += -L$(OPENCM3_DIR)/lib -L$(OPENCM3_DIR)/lib/stm32/l1
-SCRIPT_DIR = $(OPENCM3_DIR)/share
-else
-SCRIPT_DIR = $(shell dirname $(shell readlink -f $(shell which $(PREFIX)-gcc)))/../$(PREFIX)/share
-endif
+CFLAGS += -I$(TOOLCHAIN_DIR)/include
+LDFLAGS += -L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/stm32/l1
+SCRIPT_DIR = $(TOOLCHAIN_DIR)/share
OBJS += $(BINARY).o
@@ -95,11 +100,7 @@ flash: $(BINARY).flash
@#printf " OBJDUMP $(*).list\n"
$(Q)$(OBJDUMP) -S $(*).elf > $(*).list
-ifeq ($(OPENCM3_DIR),)
-%.elf: $(OBJS) $(LDSCRIPT)
-else
-%.elf: $(OBJS) $(LDSCRIPT) $(OPENCM3_DIR)/lib/stm32/l1/libopencm3_stm32l1.a
-endif
+%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_stm32l1.a
@#printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -o $(*).elf $(OBJS) -lopencm3_stm32l1 $(LDFLAGS)
diff --git a/examples/stm32/l1/stm32l-discovery/miniblink/Makefile b/examples/stm32/l1/stm32l-discovery/miniblink/Makefile
index 8c88be0..b0586e5 100644
--- a/examples/stm32/l1/stm32l-discovery/miniblink/Makefile
+++ b/examples/stm32/l1/stm32l-discovery/miniblink/Makefile
@@ -19,7 +19,7 @@
BINARY = miniblink
-LDSCRIPT = ../stm32l15xxB.ld
+LDSCRIPT = ../../../../../lib/stm32/l1/stm32l15xxb.ld
include ../../Makefile.include