diff options
Diffstat (limited to 'support')
-rw-r--r-- | support/ld/common.inc (renamed from support/ld/common_rom.inc) | 67 | ||||
-rw-r--r-- | support/ld/common_header.inc | 37 | ||||
-rw-r--r-- | support/ld/common_ram.inc | 188 | ||||
-rw-r--r-- | support/ld/maple/flash.ld | 5 | ||||
-rw-r--r-- | support/ld/maple/jtag.ld | 4 | ||||
-rw-r--r-- | support/ld/maple/ram.ld | 3 | ||||
-rw-r--r-- | support/ld/maple_RET6/flash.ld | 4 | ||||
-rw-r--r-- | support/ld/maple_RET6/jtag.ld | 4 | ||||
-rw-r--r-- | support/ld/maple_RET6/ram.ld | 3 | ||||
-rw-r--r-- | support/ld/maple_mini/flash.ld | 4 | ||||
-rw-r--r-- | support/ld/maple_mini/jtag.ld | 4 | ||||
-rw-r--r-- | support/ld/maple_mini/ram.ld | 3 | ||||
-rw-r--r-- | support/ld/maple_native/flash.ld | 4 | ||||
-rw-r--r-- | support/ld/maple_native/jtag.ld | 4 | ||||
-rw-r--r-- | support/ld/maple_native/ram.ld | 3 | ||||
-rw-r--r-- | support/make/target-config.mk | 56 | ||||
-rwxr-xr-x | support/scripts/copy-to-ide | 3 |
17 files changed, 146 insertions, 250 deletions
diff --git a/support/ld/common_rom.inc b/support/ld/common.inc index 7182a4d..b53c4f6 100644 --- a/support/ld/common_rom.inc +++ b/support/ld/common.inc @@ -1,17 +1,53 @@ /* - * Linker script for Flash (ROM) builds. + * Linker script for libmaple. * * Original author "lanchon" from ST forums, with modifications by LeafLabs. */ -INCLUDE common_header.inc +OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +ENTRY(_start) +SEARCH_DIR(.) + +/* + * Link against libgcc, libc, and libm + */ +GROUP(libgcc.a libc.a libm.a) + +/* These force the linker to search for particular symbols from + * the start of the link process and thus ensure the user's + * overrides are picked up + */ +INCLUDE names.inc + +/* STM32 vector table. See stm32_vector_table.S */ +EXTERN(__cs3_stm32_vector_table) + +/* libcs3 C start function. See cs3.h */ +EXTERN(__cs3_start_c) + +/* main entry point */ +EXTERN(main) + +/* Initial stack pointer value. */ +EXTERN(__cs3_stack) +PROVIDE(__cs3_stack = __cs3_region_start_ram + LENGTH(ram)); + +/* Reset vector and chip reset entry point. See start.S */ +EXTERN(_start) +PROVIDE(__cs3_reset = _start); + +/* Heap boundaries, for libmaple */ +EXTERN(_lm_heap_start); +EXTERN(_lm_heap_end); SECTIONS { + /* TODO pull out rodata and stick into separate sections */ .text : { + __text_start = .; /* - * STM32 vector table + * STM32 vector table. Leave this here. Yes, really. */ *(.stm32.interrupt_vector) @@ -23,8 +59,6 @@ SECTIONS *(.gnu.warning) *(.glue_7t) *(.glue_7) *(.vfp11_veneer) - *(.rodata .rodata.* .gnu.linkonce.r.*) - *(.ARM.extab* .gnu.linkonce.armextab.*) *(.gcc_except_table) *(.eh_frame_hdr) @@ -77,13 +111,21 @@ SECTIONS } > REGION_TEXT /* + * Read-only data + */ + .rodata : + { + *(.rodata .rodata.* .gnu.linkonce.r.*) + } > REGION_RODATA + + /* * .ARM.exidx exception unwinding; mandated by ARM's C++ ABI */ __exidx_start = .; .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > REGION_TEXT + } > REGION_RODATA __exidx_end = .; /* @@ -101,19 +143,18 @@ SECTIONS .USER_FLASH : { *(.USER_FLASH) - } > rom + } > REGION_RODATA /* * .data */ .data : { - __cs3_region_start_ram = .; + __cs3_region_start_ram = DEFINED(_FLASH_BUILD) ? . : __text_start; *(.got.plt) *(.got) *(.data .data.* .gnu.linkonce.d.*) - /* * Heap: Linker scripts may choose a custom heap by overriding * _lm_heap_start and _lm_heap_end. Otherwise, the heap is in @@ -144,8 +185,12 @@ SECTIONS * Constants needed for the pieces of CS3 we use during * board startup; see libcs3_stm32_src/. */ - __cs3_region_init_ram = LOADADDR (.data); - __cs3_region_init_size_ram = _edata - ADDR (.data); + __cs3_region_init_ram = (DEFINED(_FLASH_BUILD) ? + LOADADDR(.data) : + LOADADDR(.text)); + __cs3_region_init_size_ram = (DEFINED(_FLASH_BUILD) ? + _edata - ADDR(.data) : + _edata - ADDR(.text)); __cs3_region_zero_size_ram = _end - _edata; __cs3_region_num = 1; diff --git a/support/ld/common_header.inc b/support/ld/common_header.inc deleted file mode 100644 index 1d11ba0..0000000 --- a/support/ld/common_header.inc +++ /dev/null @@ -1,37 +0,0 @@ -/* "Preamble" for linker scripts (such as common_rom.inc) */ - -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -ENTRY(_start) -SEARCH_DIR(.) - -/* - * Link against libgcc, libc, and libm - */ -GROUP(libgcc.a libc.a libm.a) - -/* These force the linker to search for particular symbols from - * the start of the link process and thus ensure the user's - * overrides are picked up - */ -INCLUDE names.inc - -/* STM32 vector table. See stm32_vector_table.S */ -EXTERN(__cs3_stm32_vector_table) - -/* libcs3 C start function. See cs3.h */ -EXTERN(__cs3_start_c) - -/* main entry point */ -EXTERN(main) - -/* Initial stack pointer value. */ -EXTERN(__cs3_stack) -PROVIDE(__cs3_stack = __cs3_region_start_ram + LENGTH(ram)); - -/* Reset vector and chip reset entry point. See start.S */ -EXTERN(_start) -PROVIDE(__cs3_reset = _start); - -/* Heap boundaries, for libmaple */ -EXTERN(_lm_heap_start); -EXTERN(_lm_heap_end); diff --git a/support/ld/common_ram.inc b/support/ld/common_ram.inc deleted file mode 100644 index ea51a9f..0000000 --- a/support/ld/common_ram.inc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Linker script for RAM builds. - * - * Original author "lanchon" from ST forums, with modifications by LeafLabs. - */ - -INCLUDE common_header.inc - -SECTIONS -{ - .text : - { - CREATE_OBJECT_SYMBOLS - __cs3_region_start_ram = .; - - /* - * STM32 vector table - */ - __cs3_interrupt_vector = __cs3_stm32_vector_table; - *(.cs3.interrupt_vector) - /* Make sure we pulled in an interrupt vector. */ - ASSERT (. != __cs3_stm32_vector_table, "No interrupt vector"); - - /* - * Program code and vague linking - */ - *(.text .text.* .gnu.linkonce.t.*) - *(.plt) - *(.gnu.warning) - *(.glue_7t) *(.glue_7) *(.vfp11_veneer) - - *(.rodata .rodata.* .gnu.linkonce.r.*) - - *(.ARM.extab* .gnu.linkonce.armextab.*) - *(.gcc_except_table) - *(.eh_frame_hdr) - *(.eh_frame) - - . = ALIGN(4); - KEEP(*(.init)) - - . = ALIGN(4); - __preinit_array_start = .; - KEEP (*(.preinit_array)) - __preinit_array_end = .; - - . = ALIGN(4); - __init_array_start = .; - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array)) - __init_array_end = .; - - . = ALIGN(0x4); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*crtend.o(.ctors)) - - . = ALIGN(4); - KEEP(*(.fini)) - - . = ALIGN(4); - __fini_array_start = .; - KEEP (*(.fini_array)) - KEEP (*(SORT(.fini_array.*))) - __fini_array_end = .; - - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*crtend.o(.dtors)) - - . = ALIGN(4); - __cs3_regions = .; - LONG (0) - LONG (__cs3_region_init_ram) - LONG (__cs3_region_start_ram) - LONG (__cs3_region_init_size_ram) - LONG (__cs3_region_zero_size_ram) - } > REGION_TEXT - - /* - * .ARM.exidx exception unwinding - */ - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > REGION_TEXT - __exidx_end = .; - - /* - * End of text - */ - .text.align : - { - . = ALIGN(8); - _etext = .; - } > REGION_TEXT - - .cs3.rom : - { - __cs3_region_start_rom = .; - *(.rom) - . = ALIGN (8); - } > ram - - .cs3.rom.bss : - { - *(.rom.b) - . = ALIGN (8); - } > ram - - /* __cs3_region_end_rom is deprecated */ - __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(ram); - __cs3_region_size_rom = LENGTH(ram); - __cs3_region_init_rom = LOADADDR (.cs3.rom); - __cs3_region_init_size_rom = SIZEOF(.cs3.rom); - __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss); - - /* - * Start of data - */ - .data : - { - KEEP(*(.jcr)) - *(.got.plt) *(.got) - *(.shdata) - *(.data .data.* .gnu.linkonce.d.*) - *(.ram) - . = ALIGN (8); - _edata = .; - } > REGION_DATA - - .bss : - { - *(.shbss) - *(.bss .bss.* .gnu.linkonce.b.*) - *(COMMON) - *(.ram.b) - . = ALIGN (8); - _end = .; - __end = .; - } > REGION_BSS - - /* __cs3_region_end_ram is deprecated */ - __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram); - __cs3_region_size_ram = LENGTH(ram); - __cs3_region_init_ram = LOADADDR (.text); - __cs3_region_init_size_ram = _edata - ADDR (.text); - __cs3_region_zero_size_ram = _end - _edata; - __cs3_region_num = 1; - - /* - * Debugging sections - */ - .stab 0 (NOLOAD) : { *(.stab) } - .stabstr 0 (NOLOAD) : { *(.stabstr) } - /* DWARF debug sections. - * Symbols in the DWARF debugging sections are relative to the beginning - * of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - - .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } - .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) } - /DISCARD/ : { *(.note.GNU-stack) } -} diff --git a/support/ld/maple/flash.ld b/support/ld/maple/flash.ld index e9ff4b4..8a179f7 100644 --- a/support/ld/maple/flash.ld +++ b/support/ld/maple/flash.ld @@ -19,8 +19,11 @@ GROUP(libcs3_stm32_med_density.a) 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 */ -INCLUDE common_rom.inc +_FLASH_BUILD = 1; + +INCLUDE common.inc diff --git a/support/ld/maple/jtag.ld b/support/ld/maple/jtag.ld index ed8cc1c..365068f 100644 --- a/support/ld/maple/jtag.ld +++ b/support/ld/maple/jtag.ld @@ -20,8 +20,10 @@ GROUP(libcs3_stm32_med_density.a) 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 */ -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple/ram.ld b/support/ld/maple/ram.ld index 09bcb33..6f237c3 100644 --- a/support/ld/maple/ram.ld +++ b/support/ld/maple/ram.ld @@ -19,8 +19,9 @@ GROUP(libcs3_stm32_med_density.a) 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_ram.inc +INCLUDE common.inc diff --git a/support/ld/maple_RET6/flash.ld b/support/ld/maple_RET6/flash.ld index 524ed71..4cf9c4b 100644 --- a/support/ld/maple_RET6/flash.ld +++ b/support/ld/maple_RET6/flash.ld @@ -14,5 +14,7 @@ GROUP(libcs3_stm32_high_density.a) REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple_RET6/jtag.ld b/support/ld/maple_RET6/jtag.ld index 3a8e41f..6055dfb 100644 --- a/support/ld/maple_RET6/jtag.ld +++ b/support/ld/maple_RET6/jtag.ld @@ -14,5 +14,7 @@ GROUP(libcs3_stm32_high_density.a) REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple_RET6/ram.ld b/support/ld/maple_RET6/ram.ld index 787eb31..a4c273b 100644 --- a/support/ld/maple_RET6/ram.ld +++ b/support/ld/maple_RET6/ram.ld @@ -14,5 +14,6 @@ GROUP(libcs3_stm32_high_density.a) REGION_ALIAS("REGION_TEXT", ram); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", ram); -INCLUDE common_ram.inc +INCLUDE common.inc diff --git a/support/ld/maple_mini/flash.ld b/support/ld/maple_mini/flash.ld index 37d765e..ab03207 100644 --- a/support/ld/maple_mini/flash.ld +++ b/support/ld/maple_mini/flash.ld @@ -19,8 +19,10 @@ GROUP(libcs3_stm32_med_density.a) 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 */ -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple_mini/jtag.ld b/support/ld/maple_mini/jtag.ld index a26e1b6..2f9cf31 100644 --- a/support/ld/maple_mini/jtag.ld +++ b/support/ld/maple_mini/jtag.ld @@ -20,8 +20,10 @@ GROUP(libcs3_stm32_med_density.a) 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 */ -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple_mini/ram.ld b/support/ld/maple_mini/ram.ld index 3bf33c9..0ba0252 100644 --- a/support/ld/maple_mini/ram.ld +++ b/support/ld/maple_mini/ram.ld @@ -19,8 +19,9 @@ GROUP(libcs3_stm32_med_density.a) 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_ram.inc +INCLUDE common.inc diff --git a/support/ld/maple_native/flash.ld b/support/ld/maple_native/flash.ld index 20326e4..b6e10f8 100644 --- a/support/ld/maple_native/flash.ld +++ b/support/ld/maple_native/flash.ld @@ -16,10 +16,12 @@ GROUP(libcs3_stm32_high_density.a) 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; -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple_native/jtag.ld b/support/ld/maple_native/jtag.ld index 73157de..9af2a11 100644 --- a/support/ld/maple_native/jtag.ld +++ b/support/ld/maple_native/jtag.ld @@ -17,9 +17,11 @@ GROUP(libcs3_stm32_high_density.a) 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; -INCLUDE common_rom.inc +_FLASH_BUILD = 1; +INCLUDE common.inc diff --git a/support/ld/maple_native/ram.ld b/support/ld/maple_native/ram.ld index d38e43c..7264316 100644 --- a/support/ld/maple_native/ram.ld +++ b/support/ld/maple_native/ram.ld @@ -16,9 +16,10 @@ GROUP(libcs3_stm32_high_density.a) 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_ram.inc +INCLUDE common.inc diff --git a/support/make/target-config.mk b/support/make/target-config.mk new file mode 100644 index 0000000..a30a5da --- /dev/null +++ b/support/make/target-config.mk @@ -0,0 +1,56 @@ +# Board-specific configuration values. Flash and SRAM sizes in bytes. + +ifeq ($(BOARD), maple) + MCU := STM32F103RB + PRODUCT_ID := 0003 + ERROR_LED_PORT := GPIOA + ERROR_LED_PIN := 5 + DENSITY := STM32_MEDIUM_DENSITY + FLASH_SIZE := 131072 + SRAM_SIZE := 20480 +endif + +ifeq ($(BOARD), maple_native) + MCU := STM32F103ZE + PRODUCT_ID := 0003 + ERROR_LED_PORT := GPIOC + ERROR_LED_PIN := 15 + DENSITY := STM32_HIGH_DENSITY + FLASH_SIZE := 524288 + SRAM_SIZE := 65536 +endif + +ifeq ($(BOARD), maple_mini) + MCU := STM32F103CB + PRODUCT_ID := 0003 + ERROR_LED_PORT := GPIOB + ERROR_LED_PIN := 1 + DENSITY := STM32_MEDIUM_DENSITY + FLASH_SIZE := 131072 + SRAM_SIZE := 20480 +endif + +ifeq ($(BOARD), maple_RET6) + MCU := STM32F103RE + PRODUCT_ID := 0003 + ERROR_LED_PORT := GPIOA + ERROR_LED_PIN := 5 + DENSITY := STM32_HIGH_DENSITY + FLASH_SIZE := 524288 + SRAM_SIZE := 65536 +endif + +# 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 diff --git a/support/scripts/copy-to-ide b/support/scripts/copy-to-ide index 08cb9e3..f7029a5 100755 --- a/support/scripts/copy-to-ide +++ b/support/scripts/copy-to-ide @@ -24,8 +24,7 @@ LMAPLE_SRC="LICENSE ./wirish/comm/*.h ./wirish/boards/*.h ./wirish/boards/*.cpp - ./support/ld/common_ram.inc - ./support/ld/common_rom.inc + ./support/ld/common.inc ./support/ld/libcs3_stm32_high_density.a ./support/ld/libcs3_stm32_med_density.a ./support/ld/maple |