From 5838b447f675444b154bacd205ebf9f47d003b2f Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Wed, 6 Jun 2012 18:06:48 -0400 Subject: 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 --- support/ld/VLDiscovery/flash.ld | 24 ---------- support/ld/VLDiscovery/jtag.ld | 24 ---------- support/ld/VLDiscovery/ram.ld | 22 ---------- support/ld/flash.ld | 26 +++++++++++ support/ld/jtag.ld | 31 +++++++++++++ support/ld/maple/flash.ld | 24 ---------- support/ld/maple/jtag.ld | 24 ---------- support/ld/maple/ram.ld | 22 ---------- support/ld/maple_RET6/flash.ld | 18 -------- support/ld/maple_RET6/jtag.ld | 18 -------- support/ld/maple_RET6/ram.ld | 17 -------- support/ld/maple_mini/flash.ld | 23 ---------- support/ld/maple_mini/jtag.ld | 24 ---------- support/ld/maple_mini/ram.ld | 22 ---------- support/ld/maple_native/flash.ld | 22 ---------- support/ld/maple_native/jtag.ld | 22 ---------- support/ld/maple_native/ram.ld | 20 --------- support/ld/olimex_stm32_h103 | 1 - support/ld/ram.ld | 25 +++++++++++ support/ld/st_stm3220g_eval/jtag.ld | 17 -------- .../stm32/mem/maple_native/maple_native_heap.inc | 3 ++ support/ld/stm32/mem/maple_native/mem-flash.inc | 7 +++ support/ld/stm32/mem/maple_native/mem-jtag.inc | 7 +++ support/ld/stm32/mem/maple_native/mem-ram.inc | 7 +++ .../stm32/mem/sram_112k_flash_1024k/mem-jtag.inc | 5 +++ .../ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc | 5 +++ .../ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc | 5 +++ .../ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc | 5 +++ .../ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc | 5 +++ .../ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc | 5 +++ .../ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc | 5 +++ .../ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc | 5 +++ .../ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc | 5 +++ .../ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc | 5 +++ .../ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc | 5 +++ support/make/board-includes/VLDiscovery.mk | 1 + support/make/board-includes/maple.mk | 4 ++ support/make/board-includes/maple_RET6.mk | 1 + support/make/board-includes/maple_mini.mk | 1 + support/make/board-includes/maple_native.mk | 1 + support/make/board-includes/olimex_stm32_h103.mk | 1 + support/make/board-includes/st_stm3220g_eval.mk | 1 + support/make/target-config.mk | 51 ++++++++++++---------- 43 files changed, 198 insertions(+), 368 deletions(-) delete mode 100644 support/ld/VLDiscovery/flash.ld delete mode 100644 support/ld/VLDiscovery/jtag.ld delete mode 100644 support/ld/VLDiscovery/ram.ld create mode 100644 support/ld/flash.ld create mode 100644 support/ld/jtag.ld delete mode 100644 support/ld/maple/flash.ld delete mode 100644 support/ld/maple/jtag.ld delete mode 100644 support/ld/maple/ram.ld delete mode 100644 support/ld/maple_RET6/flash.ld delete mode 100644 support/ld/maple_RET6/jtag.ld delete mode 100644 support/ld/maple_RET6/ram.ld delete mode 100644 support/ld/maple_mini/flash.ld delete mode 100644 support/ld/maple_mini/jtag.ld delete mode 100644 support/ld/maple_mini/ram.ld delete mode 100644 support/ld/maple_native/flash.ld delete mode 100644 support/ld/maple_native/jtag.ld delete mode 100644 support/ld/maple_native/ram.ld delete mode 120000 support/ld/olimex_stm32_h103 create mode 100644 support/ld/ram.ld delete mode 100644 support/ld/st_stm3220g_eval/jtag.ld create mode 100644 support/ld/stm32/mem/maple_native/maple_native_heap.inc create mode 100644 support/ld/stm32/mem/maple_native/mem-flash.inc create mode 100644 support/ld/stm32/mem/maple_native/mem-jtag.inc create mode 100644 support/ld/stm32/mem/maple_native/mem-ram.inc create mode 100644 support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc create mode 100644 support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc create mode 100644 support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc create mode 100644 support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc create mode 100644 support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc create mode 100644 support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc create mode 100644 support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc create mode 100644 support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc create mode 100644 support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc create mode 100644 support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc create mode 100644 support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc (limited to 'support') diff --git a/support/ld/VLDiscovery/flash.ld b/support/ld/VLDiscovery/flash.ld deleted file mode 100644 index 44ff8a1..0000000 --- a/support/ld/VLDiscovery/flash.ld +++ /dev/null @@ -1,24 +0,0 @@ -/* - * VLDiscovery (STM32F100RBT6, medium density) linker script for Flash builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* - * Define the rest of the sections - */ -_FLASH_BUILD = 1; - -INCLUDE common.inc diff --git a/support/ld/VLDiscovery/jtag.ld b/support/ld/VLDiscovery/jtag.ld deleted file mode 100644 index b952572..0000000 --- a/support/ld/VLDiscovery/jtag.ld +++ /dev/null @@ -1,24 +0,0 @@ -/* - * VLDiscovery (STM32F100RBT6, medium density) linker script for JTAG (bare - * metal, no bootloader) builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* - * Define the rest of the sections - */ -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/VLDiscovery/ram.ld b/support/ld/VLDiscovery/ram.ld deleted file mode 100644 index d659cd6..0000000 --- a/support/ld/VLDiscovery/ram.ld +++ /dev/null @@ -1,22 +0,0 @@ -/* - * VLDiscovery (STM32F100RBT6, medium density) linker script for RAM builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 0K -} - -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* - * Define the rest of the sections - */ -INCLUDE common.inc diff --git a/support/ld/flash.ld b/support/ld/flash.ld new file mode 100644 index 0000000..9e250cd --- /dev/null +++ b/support/ld/flash.ld @@ -0,0 +1,26 @@ +/* + * libmaple linker script for "Flash" builds. + * + * A Flash build puts .text (and .rodata) in Flash, and + * .data/.bss/heap (of course) in SRAM, but offsets the sections by + * enough space to store the Maple bootloader, which lives in low + * Flash and uses low memory. + */ + +/* + * This pulls in the appropriate MEMORY declaration from the right + * subdirectory of stm32/mem/ (the environment must call ld with the + * right include directory flags to make this happen). Boards can also + * use this file to use any of libmaple's memory-related hooks (like + * where the heap should live). + */ +INCLUDE mem-flash.inc + +/* Provide memory region aliases for common.inc */ +REGION_ALIAS("REGION_TEXT", rom); +REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); + +/* Let common.inc handle the real work. */ +INCLUDE common.inc diff --git a/support/ld/jtag.ld b/support/ld/jtag.ld new file mode 100644 index 0000000..0612f95 --- /dev/null +++ b/support/ld/jtag.ld @@ -0,0 +1,31 @@ +/* + * libmaple linker script for "JTAG" builds. + * + * A "JTAG" build puts .text (and .rodata) in Flash, and + * .data/.bss/heap (of course) in SRAM, but links starting at the + * Flash and SRAM starting addresses (0x08000000 and 0x20000000 + * respectively). This will wipe out a Maple bootloader if there's one + * on the board, so only use this if you know what you're doing. + * + * Of course, a "JTAG" build is perfectly usable for upload over SWD, + * the system memory bootloader, etc. The name is just a historical + * artifact. + */ + +/* + * This pulls in the appropriate MEMORY declaration from the right + * subdirectory of stm32/mem/ (the environment must call ld with the + * right include directory flags to make this happen). Boards can also + * use this file to use any of libmaple's memory-related hooks (like + * where the heap should live). + */ +INCLUDE mem-jtag.inc + +/* Provide memory region aliases for common.inc */ +REGION_ALIAS("REGION_TEXT", rom); +REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); + +/* Let common.inc handle the real work. */ +INCLUDE common.inc diff --git a/support/ld/maple/flash.ld b/support/ld/maple/flash.ld deleted file mode 100644 index 190c187..0000000 --- a/support/ld/maple/flash.ld +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Maple (STM32F103RBT6, medium density) linker script for Flash builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* - * Define the rest of the sections - */ -_FLASH_BUILD = 1; - -INCLUDE common.inc diff --git a/support/ld/maple/jtag.ld b/support/ld/maple/jtag.ld deleted file mode 100644 index c090988..0000000 --- a/support/ld/maple/jtag.ld +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Maple (STM32F103RBT6, medium density) linker script for JTAG (bare - * metal, no bootloader) builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* - * Define the rest of the sections - */ -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/maple/ram.ld b/support/ld/maple/ram.ld deleted file mode 100644 index a5ef621..0000000 --- a/support/ld/maple/ram.ld +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Maple (STM32F103RBT6, medium density) linker script for RAM builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} - -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* - * Define the rest of the sections - */ -INCLUDE common.inc diff --git a/support/ld/maple_RET6/flash.ld b/support/ld/maple_RET6/flash.ld deleted file mode 100644 index 8b529f8..0000000 --- a/support/ld/maple_RET6/flash.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Maple RET6 Edition (STM32F103RET6, high density) linker script for - * Flash builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/maple_RET6/jtag.ld b/support/ld/maple_RET6/jtag.ld deleted file mode 100644 index 4ac9d76..0000000 --- a/support/ld/maple_RET6/jtag.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Maple RET6 Edition (STM32F103RET6, high density) linker script for - * JTAG (bare metal, no bootloader) builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/maple_RET6/ram.ld b/support/ld/maple_RET6/ram.ld deleted file mode 100644 index 65c3a2c..0000000 --- a/support/ld/maple_RET6/ram.ld +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Maple RET6 Edition (STM32F103RET6, high density) linker script for - * RAM builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} - -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -INCLUDE common.inc diff --git a/support/ld/maple_mini/flash.ld b/support/ld/maple_mini/flash.ld deleted file mode 100644 index 52d01dc..0000000 --- a/support/ld/maple_mini/flash.ld +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Maple Mini (STM32F103CBT6, medium density) linker script for Flash builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* - * Define the rest of the sections - */ -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/maple_mini/jtag.ld b/support/ld/maple_mini/jtag.ld deleted file mode 100644 index 28e204f..0000000 --- a/support/ld/maple_mini/jtag.ld +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Maple Mini (STM32F103CBT6, medium density) linker script for JTAG - * (bare metal, no bootloader) builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* - * Define the rest of the sections - */ -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/maple_mini/ram.ld b/support/ld/maple_mini/ram.ld deleted file mode 100644 index 5b0111b..0000000 --- a/support/ld/maple_mini/ram.ld +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Maple Mini (STM32F103CBT6, medium density) linker script for RAM builds. - */ - -/* - * Define memory spaces. - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} - -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* - * Define the rest of the sections - */ -INCLUDE common.inc diff --git a/support/ld/maple_native/flash.ld b/support/ld/maple_native/flash.ld deleted file mode 100644 index aac5325..0000000 --- a/support/ld/maple_native/flash.ld +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Maple Native (STM32F103ZET6, high density) linker script for Flash builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Specify heap boundary addresses on the external SRAM chip */ -_lm_heap_start = 0x60000000; -_lm_heap_end = 0x60100000; - -_FLASH_BUILD = 1; -INCLUDE common.inc - diff --git a/support/ld/maple_native/jtag.ld b/support/ld/maple_native/jtag.ld deleted file mode 100644 index 412348e..0000000 --- a/support/ld/maple_native/jtag.ld +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Maple Native (STM32F103ZET6, high density) linker script for JTAG - * (bare metal, no bootloader) builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Specify heap boundary addresses on the external SRAM chip */ -_lm_heap_start = 0x60000000; -_lm_heap_end = 0x60100000; - -_FLASH_BUILD = 1; -INCLUDE common.inc diff --git a/support/ld/maple_native/ram.ld b/support/ld/maple_native/ram.ld deleted file mode 100644 index eeec761..0000000 --- a/support/ld/maple_native/ram.ld +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Maple Native (STM32F103ZET6, high density) linker script for RAM builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} - -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* Specify heap boundary addresses on the external SRAM chip */ -_lm_heap_start = 0x60000000; -_lm_heap_end = 0x60100000; - -INCLUDE common.inc diff --git a/support/ld/olimex_stm32_h103 b/support/ld/olimex_stm32_h103 deleted file mode 120000 index 2d8bbed..0000000 --- a/support/ld/olimex_stm32_h103 +++ /dev/null @@ -1 +0,0 @@ -maple \ No newline at end of file diff --git a/support/ld/ram.ld b/support/ld/ram.ld new file mode 100644 index 0000000..34b468e --- /dev/null +++ b/support/ld/ram.ld @@ -0,0 +1,25 @@ +/* + * libmaple linker script for RAM builds. + * + * A Flash build puts .text, .rodata, and .data/.bss/heap (of course) + * in SRAM, but offsets the sections by enough space to store the + * Maple bootloader, which uses low memory. + */ + +/* + * This pulls in the appropriate MEMORY declaration from the right + * subdirectory of stm32/mem/ (the environment must call ld with the + * right include directory flags to make this happen). Boards can also + * use this file to use any of libmaple's memory-related hooks (like + * where the heap should live). + */ +INCLUDE mem-ram.inc + +/* Provide memory region aliases for common.inc */ +REGION_ALIAS("REGION_TEXT", ram); +REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", ram); + +/* Let common.inc handle the real work. */ +INCLUDE common.inc diff --git a/support/ld/st_stm3220g_eval/jtag.ld b/support/ld/st_stm3220g_eval/jtag.ld deleted file mode 100644 index 4193f5b..0000000 --- a/support/ld/st_stm3220g_eval/jtag.ld +++ /dev/null @@ -1,17 +0,0 @@ -/* - * STM3220G-EVAL (STM32F207IGH6) linker script for JTAG (bare metal, - * no bootloader) builds. - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K -} - -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -INCLUDE common.inc diff --git a/support/ld/stm32/mem/maple_native/maple_native_heap.inc b/support/ld/stm32/mem/maple_native/maple_native_heap.inc new file mode 100644 index 0000000..34b5a2d --- /dev/null +++ b/support/ld/stm32/mem/maple_native/maple_native_heap.inc @@ -0,0 +1,3 @@ +/* Specify heap boundary addresses on the external SRAM chip */ +_lm_heap_start = 0x60000000; +_lm_heap_end = 0x60100000; diff --git a/support/ld/stm32/mem/maple_native/mem-flash.inc b/support/ld/stm32/mem/maple_native/mem-flash.inc new file mode 100644 index 0000000..bae4f39 --- /dev/null +++ b/support/ld/stm32/mem/maple_native/mem-flash.inc @@ -0,0 +1,7 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K + rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K +} + +INCLUDE maple_native_heap.inc diff --git a/support/ld/stm32/mem/maple_native/mem-jtag.inc b/support/ld/stm32/mem/maple_native/mem-jtag.inc new file mode 100644 index 0000000..508ed44 --- /dev/null +++ b/support/ld/stm32/mem/maple_native/mem-jtag.inc @@ -0,0 +1,7 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K +} + +INCLUDE maple_native_heap.inc diff --git a/support/ld/stm32/mem/maple_native/mem-ram.inc b/support/ld/stm32/mem/maple_native/mem-ram.inc new file mode 100644 index 0000000..6ae11ef --- /dev/null +++ b/support/ld/stm32/mem/maple_native/mem-ram.inc @@ -0,0 +1,7 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K + rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K +} + +INCLUDE maple_native_heap.inc diff --git a/support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc b/support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc new file mode 100644 index 0000000..e0d2da1 --- /dev/null +++ b/support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K +} diff --git a/support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc b/support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc new file mode 100644 index 0000000..d21f17c --- /dev/null +++ b/support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 0K +} diff --git a/support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc b/support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc new file mode 100644 index 0000000..a9091ca --- /dev/null +++ b/support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K + rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K +} diff --git a/support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc b/support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc new file mode 100644 index 0000000..20fbec0 --- /dev/null +++ b/support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K +} diff --git a/support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc b/support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc new file mode 100644 index 0000000..f02453b --- /dev/null +++ b/support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K + rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K +} diff --git a/support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc b/support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc new file mode 100644 index 0000000..ddb8876 --- /dev/null +++ b/support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K + rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K +} diff --git a/support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc b/support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc new file mode 100644 index 0000000..d3ed992 --- /dev/null +++ b/support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K +} diff --git a/support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc b/support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc new file mode 100644 index 0000000..360beaf --- /dev/null +++ b/support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K + rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K +} diff --git a/support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc b/support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc new file mode 100644 index 0000000..19372b7 --- /dev/null +++ b/support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K +} diff --git a/support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc b/support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc new file mode 100644 index 0000000..19372b7 --- /dev/null +++ b/support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K +} diff --git a/support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc b/support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc new file mode 100644 index 0000000..4063ab4 --- /dev/null +++ b/support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc @@ -0,0 +1,5 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 0K +} 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) -- cgit v1.2.3