aboutsummaryrefslogtreecommitdiffstats
path: root/support/make
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-06 18:06:48 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-07 03:44:31 -0400
commit5838b447f675444b154bacd205ebf9f47d003b2f (patch)
tree004d9d4871e5d70f248646d65450952b2fa79aff /support/make
parent42570013c5266449f7e8512a77fe66b8e852294d (diff)
downloadlibrambutan-5838b447f675444b154bacd205ebf9f47d003b2f.tar.gz
librambutan-5838b447f675444b154bacd205ebf9f47d003b2f.zip
Rework linker scripts.
Having separate linker scripts for all the boards is a bad idea. Most boards really only need to specify MEMORY and the appropriate REGION_ALIASES() so that support/ld/common.inc can do its work. Not having infrastructure for this leads to duplication -- viz. the Maple Mini linker scripts are identical to the Maple's, and the olimex_stm32_h103 linker directory is just a symlink to Maple's. Clearly, the current structure is wrong. To fix it, instead of having per-board subdirectories of support/ld/, add per-MEMORY subdirectories of (new) support/ld/stm32/mem/. The per-board .mk files under support/mk/board-includes/ now reference these directly, and target-config.mk and the Makefile handle this appropriately. We move some other stuff around in target-config.mk to make this all more convenient, and even allow more overriding of the libmaple defaults on a per-board basis. Custom board hacks will be easier now. Unfortunately, lots of duplication under support/ld/stm32/mem/ is necessary, as the LENGTH attribute in a MEMORY region specification doesn't support arithmetic expressions, and ld doesn't seem to have any way to specify MEMORY at the command line (why?!). If we find a better way than this, we should do it. If a board (e.g. Maple Native) _does_ really need special memory-related configuration, you can always put a per-board subdirectory of support/ld/stm32/mem. We do this here to configure the heap. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'support/make')
-rw-r--r--support/make/board-includes/VLDiscovery.mk1
-rw-r--r--support/make/board-includes/maple.mk4
-rw-r--r--support/make/board-includes/maple_RET6.mk1
-rw-r--r--support/make/board-includes/maple_mini.mk1
-rw-r--r--support/make/board-includes/maple_native.mk1
-rw-r--r--support/make/board-includes/olimex_stm32_h103.mk1
-rw-r--r--support/make/board-includes/st_stm3220g_eval.mk1
-rw-r--r--support/make/target-config.mk51
8 files changed, 37 insertions, 24 deletions
diff --git a/support/make/board-includes/VLDiscovery.mk b/support/make/board-includes/VLDiscovery.mk
index 441f078..76cd85a 100644
--- a/support/make/board-includes/VLDiscovery.mk
+++ b/support/make/board-includes/VLDiscovery.mk
@@ -4,3 +4,4 @@ ERROR_LED_PORT := GPIOC
ERROR_LED_PIN := 9
MCU_SERIES := stm32f1
MCU_F1_LINE := value
+LD_MEM_DIR := sram_8k_flash_128k
diff --git a/support/make/board-includes/maple.mk b/support/make/board-includes/maple.mk
index 4de4bab..a2943ce 100644
--- a/support/make/board-includes/maple.mk
+++ b/support/make/board-includes/maple.mk
@@ -4,3 +4,7 @@ ERROR_LED_PORT := GPIOA
ERROR_LED_PIN := 5
MCU_SERIES := stm32f1
MCU_F1_LINE := performance
+# This crap is due to ld-script limitations. If you know of a better
+# way to go about this (like some magic ld switches to specify MEMORY
+# at the command line), please tell us!
+LD_MEM_DIR := sram_20k_flash_128k
diff --git a/support/make/board-includes/maple_RET6.mk b/support/make/board-includes/maple_RET6.mk
index 104ae08..138722f 100644
--- a/support/make/board-includes/maple_RET6.mk
+++ b/support/make/board-includes/maple_RET6.mk
@@ -4,3 +4,4 @@ ERROR_LED_PORT := GPIOA
ERROR_LED_PIN := 5
MCU_SERIES := stm32f1
MCU_F1_LINE := performance
+LD_MEM_DIR := sram_64k_flash_512k
diff --git a/support/make/board-includes/maple_mini.mk b/support/make/board-includes/maple_mini.mk
index 70ef506..b022537 100644
--- a/support/make/board-includes/maple_mini.mk
+++ b/support/make/board-includes/maple_mini.mk
@@ -4,3 +4,4 @@ ERROR_LED_PORT := GPIOB
ERROR_LED_PIN := 1
MCU_SERIES := stm32f1
MCU_F1_LINE := performance
+LD_MEM_DIR := sram_20k_flash_128k
diff --git a/support/make/board-includes/maple_native.mk b/support/make/board-includes/maple_native.mk
index 86746a6..87e58e3 100644
--- a/support/make/board-includes/maple_native.mk
+++ b/support/make/board-includes/maple_native.mk
@@ -4,3 +4,4 @@ ERROR_LED_PORT := GPIOC
ERROR_LED_PIN := 15
MCU_SERIES := stm32f1
MCU_F1_LINE := performance
+LD_MEM_DIR := maple_native # The SRAM chip makes this board special
diff --git a/support/make/board-includes/olimex_stm32_h103.mk b/support/make/board-includes/olimex_stm32_h103.mk
index 31f2c04..a3304a1 100644
--- a/support/make/board-includes/olimex_stm32_h103.mk
+++ b/support/make/board-includes/olimex_stm32_h103.mk
@@ -4,3 +4,4 @@ ERROR_LED_PORT := GPIOC
ERROR_LED_PIN := 12
MCU_SERIES := stm32f1
MCU_F1_LINE := performance
+LD_MEM_DIR := sram_20k_flash_128k
diff --git a/support/make/board-includes/st_stm3220g_eval.mk b/support/make/board-includes/st_stm3220g_eval.mk
index f8073ea..8aaefc9 100644
--- a/support/make/board-includes/st_stm3220g_eval.mk
+++ b/support/make/board-includes/st_stm3220g_eval.mk
@@ -2,3 +2,4 @@ MCU := STM32F207IG
ERROR_LED_PORT := GPIOG
ERROR_LED_PIN := 6
MCU_SERIES := stm32f2
+LD_MEM_DIR := sram_112k_flash_1024k
diff --git a/support/make/target-config.mk b/support/make/target-config.mk
index a04ca38..ea5dfd9 100644
--- a/support/make/target-config.mk
+++ b/support/make/target-config.mk
@@ -1,39 +1,42 @@
# TARGET_FLAGS are to be passed while compiling, assembling, linking.
-
TARGET_FLAGS :=
+# TARGET_LDFLAGS go to the linker
+TARGET_LDFLAGS :=
-# Board-specific configuration values. Punt these to board-specific
-# include files.
+# Configuration derived from $(MEMORY_TARGET)
-include $(BOARD_INCLUDE_DIR)/$(BOARD).mk
+LD_SCRIPT_PATH := $(LDDIR)/$(MEMORY_TARGET).ld
-TARGET_FLAGS += -DBOARD_$(BOARD) -DMCU_$(MCU) \
- -DERROR_LED_PORT=$(ERROR_LED_PORT) \
- -DERROR_LED_PIN=$(ERROR_LED_PIN)
+ifeq ($(MEMORY_TARGET), ram)
+VECT_BASE_ADDR := VECT_TAB_RAM
+endif
+ifeq ($(MEMORY_TARGET), flash)
+VECT_BASE_ADDR := VECT_TAB_FLASH
+endif
+ifeq ($(MEMORY_TARGET), jtag)
+VECT_BASE_ADDR := VECT_TAB_BASE
+endif
+
+# Pull in the board configuration file here, so it can override the
+# above.
+
+include $(BOARD_INCLUDE_DIR)/$(BOARD).mk
-# STM32 series-specific configuration values.
+# Configuration derived from $(BOARD).mk
LD_SERIES_PATH := $(LDDIR)/stm32/series/$(MCU_SERIES)
+LD_MEM_PATH := $(LDDIR)/stm32/mem/$(LD_MEM_DIR)
ifeq ($(MCU_SERIES), stm32f1)
# Due to the Balkanization on F1, we need to specify the line when
# making linker decisions.
LD_SERIES_PATH := $(LD_SERIES_PATH)/$(MCU_F1_LINE)
endif
-LIBMAPLE_MODULE_SERIES := $(LIBMAPLE_PATH)/$(MCU_SERIES)
-
-# Memory target-specific configuration values
-ifeq ($(MEMORY_TARGET), ram)
- LDSCRIPT := $(BOARD)/ram.ld
- VECT_BASE_ADDR := VECT_TAB_RAM
-endif
-ifeq ($(MEMORY_TARGET), flash)
- LDSCRIPT := $(BOARD)/flash.ld
- VECT_BASE_ADDR := VECT_TAB_FLASH
-endif
-ifeq ($(MEMORY_TARGET), jtag)
- LDSCRIPT := $(BOARD)/jtag.ld
- VECT_BASE_ADDR := VECT_TAB_BASE
-endif
+TARGET_LDFLAGS += -T$(LD_SCRIPT_PATH) -L $(LD_SERIES_PATH) \
+ -L $(LD_MEM_PATH) -L$(LDDIR)
+TARGET_FLAGS += -DBOARD_$(BOARD) -DMCU_$(MCU) \
+ -DERROR_LED_PORT=$(ERROR_LED_PORT) \
+ -DERROR_LED_PIN=$(ERROR_LED_PIN) \
+ -D$(VECT_BASE_ADDR)
-TARGET_FLAGS += -D$(VECT_BASE_ADDR)
+LIBMAPLE_MODULE_SERIES := $(LIBMAPLE_PATH)/$(MCU_SERIES)