diff --git a/make/mcu-defs.mk b/make/mcu-defs.mk index 427925ed..5ddb6fb1 100644 --- a/make/mcu-defs.mk +++ b/make/mcu-defs.mk @@ -6,6 +6,8 @@ # endif #endef +include $(MODDIR)/make/mcu-tags.mk + ifeq ($(MCU_BOARD_MODEL),) error MCU_BOARD_MODEL not specified endif @@ -18,6 +20,8 @@ ifeq ($(MCU_FLASH_SIZE),) error MCU_FLASH_SIZE not specified endif +MCU_PRODUCT_TMPL_DIR ?= $(MODDIR)/tmpl/products + MCU_BOARD_MODEL_LC ?= $(shell echo $(MCU_BOARD_MODEL) | tr '[A-Z]' '[a-z]') MCU_BOARD ?= $(MCU_BOARD_MODEL) MCU_BOARD_LC ?= $(shell echo $(MCU_BOARD) | tr '[A-Z]' '[a-z]') diff --git a/make/mcu-exe.mk b/make/mcu-exe.mk new file mode 100644 index 00000000..85c0f43b --- /dev/null +++ b/make/mcu-exe.mk @@ -0,0 +1,22 @@ +DIR_BASENAME = $(notdir $(CWD)) + +ifeq ($(EXE_BASENAME),) + ifneq ($(DIR_BASENAME),test) + EXE_BASENAME = $(DIR_BASENAME).elf + else + EXE_BASENAME = test-$(notdir $(shell cd ..; $(PWD))).elf + endif +endif + +MCU_FLASH_PUSH_FILE_HEX ?= $(patsubst %.elf,%.hex,$(EXE_BASENAME)) +EXE_MAP ?= $(patsubst %.elf,%.map,$(EXE_BASENAME)) +PROJECT_LDFLAGS += -static +LD_DEFINE_SYMBOLS += _sbrk + +PROJECT_LDFLAGS += $(addprefix -u ,$(LD_DEFINE_SYMBOLS)) + +include $(MODDIR)/make/mcu-defs.mk +include $(MODDIR)/make/exe.mk +include $(MODDIR)/make/mcu-flash.mk + +all: $(MCU_FLASH_PUSH_FILE_HEX) diff --git a/make/mcu-flash.mk b/make/mcu-flash.mk new file mode 100644 index 00000000..68981600 --- /dev/null +++ b/make/mcu-flash.mk @@ -0,0 +1,27 @@ +.PHONY: flash-fetch flash-push flash-clean-fetch flash-clean-push + +all: + +flash-fetch: $(MCU_FLASH_FETCH_FILE_HEX) +clean: flash-clean-fetch +flash-clean-fetch: + rm -f $(MCU_FLASH_FETCH_FILE_BIN) $(MCU_FLASH_FETCH_FILE_HEX) *.tmp +flash-clean-push: + rm -f $(MCU_FLASH_PUSH_FILE_BIN) $(MCU_FLASH_PUSH_FILE_HEX) *.tmp +$(MCU_FLASH_FETCH_FILE_BIN): + $(MCU_OPENOCD) -c "init" -c "reset init" -c "flash read_bank $(MCU_FLASH_FETCH_BANK) $@.tmp $(MCU_FLASH_FETCH_OFFSET) $(MCU_FLASH_FETCH_SIZE)" -c "exit" + mv $@.tmp $@ +%.hex: %.elf + $(MCU_OBJCOPY) -O ihex $< $@.tmp + mv $@.tmp $@ +clean: flash-clean-hex +flash-clean-hex: + rm -rf $(MCU_FLASH_PUSH_FILE_HEX) +%.hex: %.bin + $(MCU_OBJCOPY) $(MCU_OBJCOPY_FETCH_OPTS) -I binary -O ihex $< $@.tmp + mv $@.tmp $@ +flash-push: + # see http://openocd.org/doc/html/Flash-Programming.html + $(MCU_OPENOCD) -c "program $(MCU_FLASH_PUSH_FILE_HEX) verify reset exit $(MCU_FLASH_PUSH_OFFSET)" +%-flash-push: + MCU_FLASH_PUSH_FILE_HEX=$* make flash-push diff --git a/make/mcu-tags.mk b/make/mcu-tags.mk new file mode 100644 index 00000000..ebb8763e --- /dev/null +++ b/make/mcu-tags.mk @@ -0,0 +1,56 @@ +# ----- product specific part + +ifneq ($(findstring cortex-m3,$(TAGGED_TMPL_TAGS)),) + + # -- set jw-build mcu choices + MCU_CPU ?= cortex-m3 + + # -- set flags + + # don't wrap error message lines + #PROJECT_LDFLAGS += -fmessage-length=0 + + # don't know what kind of optimization that is + #PROJECT_LDFLAGS += -Og + + # stick with what janware code tends to expect + PROJECT_LDFLAGS += -fsigned-char + + # I have no clue which part would evaluate these names + PROJECT_LDFLAGS += -ffunction-sections + PROJECT_LDFLAGS += -fdata-sections + PROJECT_LDFLAGS += -ffreestanding + PROJECT_LDFLAGS += -fno-move-loop-invariants + + # skip any automatic initialization + PROJECT_LDFLAGS += -nostartfiles + + # garbage collect unused input sections + PROJECT_LDFLAGS += -Xlinker --gc-sections + + # create map file + PROJECT_LDFLAGS += -Wl,-Map,"$(EXE_MAP)" + + # use newlib-nano (TODO: No -Wl necessary?) + PROJECT_LDFLAGS += --specs=nano.specs + +endif + +# ----- build options based on product choices + +ifneq ($(findstring $(MCU_CPU),cortex-m3),) + + PROJECT_LDFLAGS += -mcpu=cortex-m3 + PROJECT_LDFLAGS += -mthumb + +endif + +# ----- tagged templates +#MCU_LD_DIR = $(wildcard $(firstword $(call $(TAGGED_TMPL_DIRS),ld))) +#MCU_LD_DIR = $(firstword $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(wildcard $(repo)/$(tag)/ld)))) +#MCU_LD_DIR = $(firstword $(wildcard $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(repo)/$(tag)/ld)))) +MCU_LD_CHECK_DIRS = $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(repo)/$(tag)/ld)) +MCU_LD_DIRS = $(wildcard $(MCU_LD_CHECK_DIRS)) +MCU_LD_DIR = $(firstword $(MCU_LD_DIRS)) + +PROJECT_LDFLAGS += -L$(MCU_LD_DIR) $(addprefix -T ,$(sort $(notdir $(wildcard $(MCU_LD_DIR)/*.ld)))) diff --git a/make/mcu-topdir.mk b/make/mcu-topdir.mk index 92412391..e418576c 100644 --- a/make/mcu-topdir.mk +++ b/make/mcu-topdir.mk @@ -1,24 +1,3 @@ include $(MODDIR)/make/mcu-defs.mk include $(MODDIR)/make/topdir.mk - -.PHONY: flash-fetch flash-push flash-clean-fetch flash-clean-push - -all: - -flash-fetch: $(MCU_FLASH_FETCH_FILE_HEX) -clean: flash-clean-fetch -flash-clean-fetch: - rm -f $(MCU_FLASH_FETCH_FILE_BIN) $(MCU_FLASH_FETCH_FILE_HEX) *.tmp -flash-clean-push: - rm -f $(MCU_FLASH_PUSH_FILE_BIN) $(MCU_FLASH_PUSH_FILE_HEX) *.tmp -$(MCU_FLASH_FETCH_FILE_BIN): - $(MCU_OPENOCD) -c "init" -c "reset init" -c "flash read_bank $(MCU_FLASH_FETCH_BANK) $@.tmp $(MCU_FLASH_FETCH_OFFSET) $(MCU_FLASH_FETCH_SIZE)" -c "exit" - mv $@.tmp $@ -%.hex: %.bin - $(MCU_OBJCOPY) $(MCU_OBJCOPY_FETCH_OPTS) -I binary -O ihex $< $@.tmp - mv $@.tmp $@ -flash-push: - # see http://openocd.org/doc/html/Flash-Programming.html - $(MCU_OPENOCD) -c "program $(MCU_FLASH_PUSH_FILE_HEX) verify reset exit $(MCU_FLASH_PUSH_OFFSET)" -%-flash-push: - MCU_FLASH_PUSH_FILE_HEX=$* make flash-push +include $(MODDIR)/make/mcu-flash.mk diff --git a/make/tagged-tmpl-repo.mk b/make/tagged-tmpl-repo.mk new file mode 100644 index 00000000..ddd610c7 --- /dev/null +++ b/make/tagged-tmpl-repo.mk @@ -0,0 +1,5 @@ +TAGGED_TMPL_TAG ?= $(notdir $(CWD)) +TAGGED_TMPL_EXTS ?= $(TAGGED_TMPL_TAG) +LOCAL_TMPL += $(foreach e,$(TAGGED_TMPL_EXTS),$(wildcard *.$(TAGGED_TMPL_EXTS))) + +include $(MODDIR)/make/tmpl.mk diff --git a/make/tagged-tmpl.mk b/make/tagged-tmpl.mk new file mode 100644 index 00000000..0f5e652a --- /dev/null +++ b/make/tagged-tmpl.mk @@ -0,0 +1,23 @@ +#TAGGED_TMPL_TMPLS ?= $(wildcard $(addprefix $(TAGGED_TMPL_REPO_DIR)/ld/,$(TAGGED_TMPL_TAGS)/*.ld)) +TAGGED_TMPL_TYPE ?= $(notdir $(CWD)) +TAGGED_TMPL_EXTS ?= $(TAGGED_TMPL_TYPE) +TAGGED_TMPL_TAG_DIR ?= $(TAGGED_TMPL_REPO_DIR)/$(1)/$2 # call with repodir, tag and type arguments +TAGGED_TMPL_TAG_DIRS ?= $(foreach tag,$(TAGGED_TMPL_TAGS),$(wildcard $(call $(TAGGED_TMPL_TAG_DIR),$(tag),$(1)))) # call with repodir + type argument +TAGGED_TMPL_FIRST_DIR ?= $(firstword $(call $(TAGGED_TMPL_TAG_DIRS),$(1))) # call with repodir + type argument + +#TAGGED_TMPL_ORIGIN ?= $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach e,$(TAGGED_TMPL_EXTS),$(wildcard $(call $(TAGGED_TMPL_TAG_DIR),$(tag))/*.$(e)))) +#TAGGED_TMPL_LOCAL = $(notdir $(TAGGED_TMPL_ORIGIN)) +#TAGGED_TMPL_GENERATED = $(patsubst %.tmpl,%,$(TAGGED_TMPL_LOCAL)) + +#TAGGED_TMPL_UNTEMPLATE = cat + +include $(MODDIR)/make/defs.mk + +#all: $(TAGGED_TMPL_GENERATED) +#clean: tmpl.clean +# +#tmpl.clean: +# /bin/bash $(MOD_SCRIPT_DIR)/scm.sh -f $(TAGGED_TMPL_GENERATED) +# +#%: %.tmpl +# cat %< | $(TAGGED_TMPL_UNTEMPLATE) > $@.tmp diff --git a/tmpl/tagged/Makefile b/tmpl/tagged/Makefile new file mode 100644 index 00000000..a5f21879 --- /dev/null +++ b/tmpl/tagged/Makefile @@ -0,0 +1,4 @@ +TOPDIR = ../.. + +include $(TOPDIR)/make/proj.mk +include $(MODDIR)/make/dirs.mk diff --git a/tmpl/tagged/cortex-m/Makefile b/tmpl/tagged/cortex-m/Makefile new file mode 100644 index 00000000..ff529b71 --- /dev/null +++ b/tmpl/tagged/cortex-m/Makefile @@ -0,0 +1,4 @@ +TOPDIR = ../../.. + +include $(TOPDIR)/make/proj.mk +include $(MODDIR)/make/dirs.mk diff --git a/tmpl/tagged/cortex-m/ld/30-mem.ld.tmpl b/tmpl/tagged/cortex-m/ld/30-mem.ld.tmpl new file mode 100644 index 00000000..6d84b45b --- /dev/null +++ b/tmpl/tagged/cortex-m/ld/30-mem.ld.tmpl @@ -0,0 +1,59 @@ +/* + * This file is part of the µOS++ distribution. + * (https://github.com/micro-os-plus) + * Copyright (c) 2014 Liviu Ionescu. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Memory Spaces Definitions. + * + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + * + * The values below can be addressed in further linker scripts + * using functions like 'ORIGIN(RAM)' or 'LENGTH(RAM)'. + */ + +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K + CCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0 + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K + FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + MEMORY_ARRAY (xrw) : ORIGIN = 0x00000000, LENGTH = 0 +} + +/* + * For external ram use something like: + + RAM (xrw) : ORIGIN = 0x68000000, LENGTH = 20K + + */ diff --git a/tmpl/tagged/cortex-m/ld/50-cortex-m-sections.ld.tmpl b/tmpl/tagged/cortex-m/ld/50-cortex-m-sections.ld.tmpl new file mode 100644 index 00000000..6651667e --- /dev/null +++ b/tmpl/tagged/cortex-m/ld/50-cortex-m-sections.ld.tmpl @@ -0,0 +1,473 @@ +/* + * This file is part of the µOS++ distribution. + * (https://github.com/micro-os-plus) + * Copyright (c) 2014 Liviu Ionescu. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Default linker script for Cortex-M (it includes specifics for + * STM32F[34]xx). + * + * To make use of the multi-region initialisations, define + * OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.c file. + */ + +/* + * The '__stack' definition is required by crt0, do not remove it. + */ +__stack = ORIGIN(RAM) + LENGTH(RAM); + +_estack = __stack; /* STM specific definition */ + +/* + * Default stack sizes. + * These are used by the startup in order to allocate stacks + * for the different modes. + */ + +__Main_Stack_Size = 1024 ; + +PROVIDE ( _Main_Stack_Size = __Main_Stack_Size ) ; + +__Main_Stack_Limit = __stack - __Main_Stack_Size ; + +/* "PROVIDE" allows to easily override these values from an + * object file or the command line. */ +PROVIDE ( _Main_Stack_Limit = __Main_Stack_Limit ) ; + +/* + * There will be a link error if there is not this amount of + * RAM free at the end. + */ +_Minimum_Stack_Size = 256 ; + +/* + * Default heap definitions. + * The heap start immediately after the last statically allocated + * .sbss/.noinit section, and extends up to the main stack limit. + */ +PROVIDE ( _Heap_Begin = _end_noinit ) ; +PROVIDE ( _Heap_Limit = __stack - __Main_Stack_Size ) ; + +/* + * The entry point is informative, for debuggers and simulators, + * since the Cortex-M vector points to it anyway. + */ +ENTRY(_start) + + +/* Sections Definitions */ + +SECTIONS +{ + /* + * For Cortex-M devices, the beginning of the startup code is stored in + * the .isr_vector section, which goes to FLASH. + */ + .isr_vector : ALIGN(4) + { + FILL(0xFF) + + __vectors_start = ABSOLUTE(.) ; + __vectors_start__ = ABSOLUTE(.) ; /* STM specific definition */ + KEEP(*(.isr_vector)) /* Interrupt vectors */ + + KEEP(*(.cfmconfig)) /* Freescale configuration words */ + + /* + * This section is here for convenience, to store the + * startup code at the beginning of the flash area, hoping that + * this will increase the readability of the listing. + */ + *(.after_vectors .after_vectors.*) /* Startup code and ISR */ + + } >FLASH + + .inits : ALIGN(4) + { + /* + * Memory regions initialisation arrays. + * + * Thee are two kinds of arrays for each RAM region, one for + * data and one for bss. Each is iterrated at startup and the + * region initialisation is performed. + * + * The data array includes: + * - from (LOADADDR()) + * - region_begin (ADDR()) + * - region_end (ADDR()+SIZEOF()) + * + * The bss array includes: + * - region_begin (ADDR()) + * - region_end (ADDR()+SIZEOF()) + * + * WARNING: It is mandatory that the regions are word aligned, + * since the initialisation code works only on words. + */ + + __data_regions_array_start = .; + + LONG(LOADADDR(.data)); + LONG(ADDR(.data)); + LONG(ADDR(.data)+SIZEOF(.data)); + + LONG(LOADADDR(.data_CCMRAM)); + LONG(ADDR(.data_CCMRAM)); + LONG(ADDR(.data_CCMRAM)+SIZEOF(.data_CCMRAM)); + + __data_regions_array_end = .; + + __bss_regions_array_start = .; + + LONG(ADDR(.bss)); + LONG(ADDR(.bss)+SIZEOF(.bss)); + + LONG(ADDR(.bss_CCMRAM)); + LONG(ADDR(.bss_CCMRAM)+SIZEOF(.bss_CCMRAM)); + + __bss_regions_array_end = .; + + /* End of memory regions initialisation arrays. */ + + /* + * These are the old initialisation sections, intended to contain + * naked code, with the prologue/epilogue added by crti.o/crtn.o + * when linking with startup files. The standalone startup code + * currently does not run these, better use the init arrays below. + */ + KEEP(*(.init)) + KEEP(*(.fini)) + + . = ALIGN(4); + + /* + * The preinit code, i.e. an array of pointers to initialisation + * functions to be performed before constructors. + */ + PROVIDE_HIDDEN (__preinit_array_start = .); + + /* + * Used to run the SystemInit() before anything else. + */ + KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*)) + + /* + * Used for other platform inits. + */ + KEEP(*(.preinit_array_platform .preinit_array_platform.*)) + + /* + * The application inits. If you need to enforce some order in + * execution, create new sections, as before. + */ + KEEP(*(.preinit_array .preinit_array.*)) + + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + + /* + * The init code, i.e. an array of pointers to static constructors. + */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + + /* + * The fini code, i.e. an array of pointers to static destructors. + */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + } >FLASH + + /* + * For some STRx devices, the beginning of the startup code + * is stored in the .flashtext section, which goes to FLASH. + */ + .flashtext : ALIGN(4) + { + *(.flashtext .flashtext.*) /* Startup code */ + } >FLASH + + + /* + * The program code is stored in the .text section, + * which goes to FLASH. + */ + .text : ALIGN(4) + { + *(.text .text.*) /* all remaining code */ + + /* read-only data (constants) */ + *(.rodata .rodata.* .constdata .constdata.*) + + *(vtable) /* C++ virtual tables */ + + KEEP(*(.eh_frame*)) + + /* + * Stub sections generated by the linker, to glue together + * ARM and Thumb code. .glue_7 is used for ARM code calling + * Thumb code, and .glue_7t is used for Thumb code calling + * ARM code. Apparently always generated by the linker, for some + * architectures, so better leave them here. + */ + *(.glue_7) + *(.glue_7t) + + } >FLASH + + /* ARM magic sections */ + .ARM.extab : ALIGN(4) + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + . = ALIGN(4); + __exidx_start = .; + .ARM.exidx : ALIGN(4) + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + . = ALIGN(4); + _etext = .; + __etext = .; + + /* MEMORY_ARRAY */ + /* + .ROarraySection : + { + *(.ROarraySection .ROarraySection.*) + } >MEMORY_ARRAY + */ + + /* + * The secondary initialised data section. + */ + .data_CCMRAM : ALIGN(4) + { + FILL(0xFF) + *(.data.CCMRAM .data.CCMRAM.*) + . = ALIGN(4) ; + } > CCMRAM AT>FLASH + + /* + * This address is used by the startup code to + * initialise the .data section. + */ + _sidata = LOADADDR(.data); + + /* + * The initialised data section. + * + * The program executes knowing that the data is in the RAM + * but the loader puts the initial values in the FLASH (inidata). + * It is one task of the startup to copy the initial values from + * FLASH to RAM. + */ + .data : ALIGN(4) + { + FILL(0xFF) + /* This is used by the startup code to initialise the .data section */ + _sdata = . ; /* STM specific definition */ + __data_start__ = . ; + *(.data_begin .data_begin.*) + + *(.data .data.*) + + *(.data_end .data_end.*) + . = ALIGN(4); + + /* This is used by the startup code to initialise the .data section */ + _edata = . ; /* STM specific definition */ + __data_end__ = . ; + + } >RAM AT>FLASH + + /* + * The uninitialised data sections. NOLOAD is used to avoid + * the "section `.bss' type changed to PROGBITS" warning + */ + + /* The secondary uninitialised data section. */ + .bss_CCMRAM (NOLOAD) : ALIGN(4) + { + *(.bss.CCMRAM .bss.CCMRAM.*) + } > CCMRAM + + /* The primary uninitialised data section. */ + .bss (NOLOAD) : ALIGN(4) + { + __bss_start__ = .; /* standard newlib definition */ + _sbss = .; /* STM specific definition */ + *(.bss_begin .bss_begin.*) + + *(.bss .bss.*) + *(COMMON) + + *(.bss_end .bss_end.*) + . = ALIGN(4); + __bss_end__ = .; /* standard newlib definition */ + _ebss = . ; /* STM specific definition */ + } >RAM + + .noinit_CCMRAM (NOLOAD) : ALIGN(4) + { + *(.noinit.CCMRAM .noinit.CCMRAM.*) + } > CCMRAM + + .noinit (NOLOAD) : ALIGN(4) + { + _noinit = .; + + *(.noinit .noinit.*) + + . = ALIGN(4) ; + _end_noinit = .; + } > RAM + + /* Mandatory to be word aligned, _sbrk assumes this */ + PROVIDE ( end = _end_noinit ); /* was _ebss */ + PROVIDE ( _end = _end_noinit ); + PROVIDE ( __end = _end_noinit ); + PROVIDE ( __end__ = _end_noinit ); + + /* + * Used for validation only, do not allocate anything here! + * + * This is just to check that there is enough RAM left for the Main + * stack. It should generate an error if it's full. + */ + ._check_stack : ALIGN(4) + { + . = . + _Minimum_Stack_Size ; + } >RAM + + /* + * The FLASH Bank1. + * The C or assembly source must explicitly place the code + * or data there using the "section" attribute. + */ + .b1text : ALIGN(4) + { + *(.b1text) /* remaining code */ + *(.b1rodata) /* read-only data (constants) */ + *(.b1rodata.*) + } >FLASHB1 + + /* + * The EXTMEM. + * The C or assembly source must explicitly place the code or data there + * using the "section" attribute. + */ + + /* EXTMEM Bank0 */ + .eb0text : ALIGN(4) + { + *(.eb0text) /* remaining code */ + *(.eb0rodata) /* read-only data (constants) */ + *(.eb0rodata.*) + } >EXTMEMB0 + + /* EXTMEM Bank1 */ + .eb1text : ALIGN(4) + { + *(.eb1text) /* remaining code */ + *(.eb1rodata) /* read-only data (constants) */ + *(.eb1rodata.*) + } >EXTMEMB1 + + /* EXTMEM Bank2 */ + .eb2text : ALIGN(4) + { + *(.eb2text) /* remaining code */ + *(.eb2rodata) /* read-only data (constants) */ + *(.eb2rodata.*) + } >EXTMEMB2 + + /* EXTMEM Bank0 */ + .eb3text : ALIGN(4) + { + *(.eb3text) /* remaining code */ + *(.eb3rodata) /* read-only data (constants) */ + *(.eb3rodata.*) + } >EXTMEMB3 + + + /* After that there are only debugging sections. */ + + /* This can remove the debugging information from the standard libraries */ + /* + DISCARD : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + */ + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* + * 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) } +} diff --git a/tmpl/tagged/cortex-m/ld/Makefile b/tmpl/tagged/cortex-m/ld/Makefile new file mode 100644 index 00000000..8b04c5f4 --- /dev/null +++ b/tmpl/tagged/cortex-m/ld/Makefile @@ -0,0 +1,4 @@ +TOPDIR = ../../../.. + +include $(TOPDIR)/make/proj.mk +include $(MODDIR)/make/tagged-tmpl-repo.mk