summaryrefslogtreecommitdiff
path: root/stm32
diff options
context:
space:
mode:
authorLeo C2014-04-13 15:29:22 +0200
committerLeo C2014-04-13 15:29:22 +0200
commit88d31d1177b58a2b2052a837a095b51834a8babf (patch)
treeaeae7c27dd388af93a1fa2be383f1acb149c8fac /stm32
parente64eba003f92992057c5a1c8b5eff902e4ddaaa5 (diff)
downloadz180-stamp-88d31d1177b58a2b2052a837a095b51834a8babf.zip
Add non-recursive make system from Andrzej Ostruszka.
Copyright (C) 2012 Andrzej Ostruszka <andrzej.ostruszka@gmail.com> URL: http://github.com/aostruszka/nonrec-make
Diffstat (limited to 'stm32')
-rw-r--r--stm32/.gitignore1
l---------[-rw-r--r--]stm32/Makefile31
-rw-r--r--stm32/Rules.mk144
-rw-r--r--stm32/stm32vl-discovery.ld31
4 files changed, 177 insertions, 30 deletions
diff --git a/stm32/.gitignore b/stm32/.gitignore
new file mode 100644
index 0000000..28a478f
--- /dev/null
+++ b/stm32/.gitignore
@@ -0,0 +1 @@
+/obj
diff --git a/stm32/Makefile b/stm32/Makefile
index 7833b6d..d0b0e8e 100644..120000
--- a/stm32/Makefile
+++ b/stm32/Makefile
@@ -1,30 +1 @@
-##
-## This file is part of the libopencm3 project.
-##
-## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
-##
-## This library is free software: you can redistribute it and/or modify
-## it under the terms of the GNU Lesser General Public License as published by
-## the Free Software Foundation, either version 3 of the License, or
-## (at your option) any later version.
-##
-## This library is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU Lesser General Public License for more details.
-##
-## You should have received a copy of the GNU Lesser General Public License
-## along with this library. If not, see <http://www.gnu.org/licenses/>.
-##
-
-BINARY = z180-stamp-stm32
-
-OBJS = z80-if.o hdrom.o
-
-PREFIX = /usr/local/gcc-arm-none-eabi-4_8-2014q1/bin/arm-none-eabi
-
-OPENCM3_DIR = ../libopencm3
-LDSCRIPT = ../stm32vl-discovery.ld
-
-include ../libopencm3.target.mk
-
+../Makefile \ No newline at end of file
diff --git a/stm32/Rules.mk b/stm32/Rules.mk
new file mode 100644
index 0000000..4751496
--- /dev/null
+++ b/stm32/Rules.mk
@@ -0,0 +1,144 @@
+
+BINARY := z180-stamp-stm32
+P_BINARY := $(OBJPATH)/$(BINARY)
+
+TARGETS := $(BINARY).elf #$(BINARY).bin
+
+SRCS := z180-stamp-stm32.c z80-if.c hdrom.c
+
+
+LIBNAME = opencm3_stm32f1
+DEFS = -DSTM32F1
+OPENCM3_DIR := $(TOP)/libopencm3
+LDSCRIPT := $(d)/stm32vl-discovery.ld
+
+FP_FLAGS ?= -msoft-float
+ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
+
+STLINK_PORT = :3333
+
+###############################################################################
+# Executables
+
+TOOLCHAINDIR := /usr/local/gcc-arm-none-eabi-4_8-2014q1/bin
+TOOLCHAIN := $(TOOLCHAINDIR)/arm-none-eabi
+
+CC := $(TOOLCHAIN)-gcc
+LD := $(TOOLCHAIN)-gcc
+AR := $(TOOLCHAIN)-ar
+AS := $(TOOLCHAIN)-as
+OBJCOPY := $(TOOLCHAIN)-objcopy
+OBJDUMP := $(TOOLCHAIN)-objdump
+GDB := $(TOOLCHAIN)-gdb
+
+###############################################################################
+# Source files
+
+
+
+ifeq ($(VERBOSE),true)
+$(info Using $(OPENCM3_DIR) path to library)
+endif
+
+INCLUDES_$(d) := $(OPENCM3_DIR)/include
+LIBDIRS_$(d) := $(OPENCM3_DIR)/lib
+
+SCRIPT_DIR = $(OPENCM3_DIR)/scripts
+
+###############################################################################
+# C flags
+
+CFLAGS_$(d) := -Os -g
+CFLAGS_$(d) += -Wextra -Wshadow -Wimplicit-function-declaration
+CFLAGS_$(d) += -Wredundant-decls #-Wstrict-prototypes
+CFLAGS_$(d) += -fno-common -ffunction-sections -fdata-sections
+CFLAGS_$(d) += -std=c99
+CFLAGS_$(d) += $(ARCH_FLAGS)
+
+###############################################################################
+# C & C++ preprocessor common flags
+
+CPPFLAGS_$(d) := $(DEFS)
+
+###############################################################################
+# Linker flags
+
+LDFLAGS += --static -nostartfiles
+LDFLAGS += -T$(LDSCRIPT)
+LDFLAGS += -Wl,-Map=$(*).map
+LDFLAGS += -Wl,--gc-sections
+
+#ifeq ($(VERBOSE),true)
+#LDFLAGS += -Wl,--print-gc-sections
+#endif
+
+###############################################################################
+# Used libraries
+
+LDLIBS += -l$(LIBNAME)
+LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
+
+
+###############################################################################
+###############################################################################
+
+
+$(BINARY).elf_DEPS = z180-stamp-stm32.o z80-if.o hdrom.o
+$(BINARY).elf_CMD = $(call echo_cmd,LINK $@) $(LD) $(LDFLAGS) $(ARCH_FLAGS) $^ $(LDLIBS) -o $@
+
+.SUFFIXES: .elf .bin .hex .srec .list .map .images
+.SECONDEXPANSION:
+
+elf: $(P_BINARY).elf
+bin: $(P_BINARY).bin
+hex: $(P_BINARY).hex
+srec: $(P_BINARY).srec
+list: $(P_BINARY).list
+
+images: $(P_BINARY).images
+flash: $(P_BINARY).flash
+
+%.images: %.bin %.hex %.srec %.list
+ $(call echo_cmd,Images generated: $*)
+
+%.bin: %.elf
+ $(call echo_cmd,OBJCOPY $@) $(OBJCOPY) -Obinary $< $@
+
+%.hex: %.elf
+ $(call echo_cmd,OBJCOPY $@) $(OBJCOPY) -Oihex $< $@
+
+%.srec: %.elf
+ $(call echo_cmd,OBJCOPY $@) $(OBJCOPY) -Osrec $< $@
+
+%.list: %.elf
+ $(call echo_cmd,OBJDUMP $@) $(OBJDUMP) -S $< > $@
+
+#$(OBJPATH)/%.elf: $(OBJS) $(LDSCRIPT) $(LIB_DIR)/lib$(LIBNAME).a
+# @#printf " LD $(*).elf\n"
+# $(LD) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS_$(d)) $(LDLIBS) -o $(*).elf
+
+#%.o: %.c
+# @#printf " CC $(*).c\n"
+# $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).c
+#
+#%.o: %.cxx
+# @#printf " CXX $(*).cxx\n"
+# $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).cxx
+#
+#%.o: %.cpp
+# @#printf " CXX $(*).cpp\n"
+# $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).cpp
+
+#clean:
+# @#printf " CLEAN\n"
+# $(Q)$(RM) *.o *.d *.elf *.bin *.hex *.srec *.list *.map
+
+
+%.flash: %.elf
+ $(call echo_cmd,GDB $< (flash)) $(GDB) --batch \
+ -ex 'target extended-remote $(STLINK_PORT)' \
+ -x $(SCRIPT_DIR)/stlink_flash.scr \
+ $<
+
+.PHONY: images elf bin hex srec list flash
+
diff --git a/stm32/stm32vl-discovery.ld b/stm32/stm32vl-discovery.ld
new file mode 100644
index 0000000..40de3d3
--- /dev/null
+++ b/stm32/stm32vl-discovery.ld
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Linker script for ST STM32VLDISCOVERY (STM32F100RB, 128K flash, 8K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K
+}
+
+/* Include the common ld script. */
+INCLUDE libopencm3_stm32f1.ld
+