From 1dc7d758f96dd2b9bd7b03f01ca032d68b696cf0 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 Nov 2014 10:14:39 +0000 Subject: fish --- libopencm3/ld/Makefile.example | 46 +++++ libopencm3/ld/Makefile.linker | 71 +++++++ libopencm3/ld/README | 157 +++++++++++++++ libopencm3/ld/devices.data | 389 ++++++++++++++++++++++++++++++++++++ libopencm3/ld/linker.ld.S | 193 ++++++++++++++++++ libopencm3/ld/tests/dash.data | 1 + libopencm3/ld/tests/dash.result | 1 + libopencm3/ld/tests/longline.data | 2 + libopencm3/ld/tests/longline.result | 1 + libopencm3/ld/tests/single.data | 1 + libopencm3/ld/tests/single.result | 1 + libopencm3/ld/tests/tree1.data | 2 + libopencm3/ld/tests/tree1.result | 1 + libopencm3/ld/tests/tree5.data | 5 + libopencm3/ld/tests/tree5.result | 1 + libopencm3/ld/tests/twomatch.data | 4 + libopencm3/ld/tests/twomatch.result | 1 + 17 files changed, 877 insertions(+) create mode 100644 libopencm3/ld/Makefile.example create mode 100644 libopencm3/ld/Makefile.linker create mode 100644 libopencm3/ld/README create mode 100644 libopencm3/ld/devices.data create mode 100644 libopencm3/ld/linker.ld.S create mode 100644 libopencm3/ld/tests/dash.data create mode 100644 libopencm3/ld/tests/dash.result create mode 100644 libopencm3/ld/tests/longline.data create mode 100644 libopencm3/ld/tests/longline.result create mode 100644 libopencm3/ld/tests/single.data create mode 100644 libopencm3/ld/tests/single.result create mode 100644 libopencm3/ld/tests/tree1.data create mode 100644 libopencm3/ld/tests/tree1.result create mode 100644 libopencm3/ld/tests/tree5.data create mode 100644 libopencm3/ld/tests/tree5.result create mode 100644 libopencm3/ld/tests/twomatch.data create mode 100644 libopencm3/ld/tests/twomatch.result (limited to 'libopencm3/ld') diff --git a/libopencm3/ld/Makefile.example b/libopencm3/ld/Makefile.example new file mode 100644 index 0000000..60b01af --- /dev/null +++ b/libopencm3/ld/Makefile.example @@ -0,0 +1,46 @@ +BINARY = button + +DEVICE = stm32f407vgt6 + +# common Makefile.include from examples directory unpacked and stripped +#include ../../Makefile.include + +CC = arm-none-eabi-gcc +LD = arm-none-eabi-gcc +OBJCOPY = arm-none-eabi-objcopy +OBJDUMP = arm-none-eabi-objdump +GDB = arm-none-eabi-gdb + +TOOLCHAIN_DIR ?= ../../../../../libopencm3 + +CFLAGS += <...> +LDSCRIPT ?= $(BINARY).ld +LDFLAGS += <..> +OBJS += $(BINARY).o + +GENFILES ?= *.o + +all: images + +## This is the place where the translation DEVICE->LDSCRIPT will be executed +include $(TOOLCHAIN_DIR)/ld/Makefile.linker + +images: $(BINARY).images +flash: $(BINARY).flash + +<... comon makefile continues ...> + +clean: + $(Q)rm -f *.o + $(Q)rm -f *.d + $(Q)rm -f *.elf + $(Q)rm -f *.bin + $(Q)rm -f *.hex + $(Q)rm -f *.srec + $(Q)rm -f *.list + $(Q)rm -f $(GENFILES) + +.PHONY: images clean + +-include $(OBJS:.o=.d) + diff --git a/libopencm3/ld/Makefile.linker b/libopencm3/ld/Makefile.linker new file mode 100644 index 0000000..ae730a9 --- /dev/null +++ b/libopencm3/ld/Makefile.linker @@ -0,0 +1,71 @@ +## +## This file is part of the libopencm3 project. +## +## Copyright (C) 2013 Frantisek Burian +## +## Linker script generator feature +## ------------------------------- +## +## This generator will generate .ld linker script file in the project +## directory for the specified device, and this script will be automatically +## used as main linker script during the build process. +## +## WARNING: You must include this file after all shared variables are setup, +## and before the command section begins. Ideal place of the include is exactly +## after the all: rule in Your makefile. +## +## Options +## ------- +## +## This feature is configured by specifying variable DEVICE= +## in the makefile of Your project. +## +## WARNING Please don't forget to specify full name of the chip you are using. +## Many chip families have device specific letters specified on the end of +## device name string. +## +## Example: +## -------- +## +## @code +## DEVICE=stm32f407vgt6 +## <... common makefile code ...> +## all: images +## +## include /ld/Makefile.linker +## +## images: <....> +## @endcode + +## +## 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 . +## + +ifneq ($(DEVICE),) + +LDSCRIPT=$(DEVICE).ld +LD_PARAMS=$(shell awk -v PAT="$(DEVICE)" -f $(SRCLIBDIR)/scripts/genlink.awk $(SRCLIBDIR)/ld/devices.data 2>/dev/null) +CFLAGS+=$(LD_PARAMS) +LDFLAGS+=$(LD_PARAMS) +ARCH_FLAGS= + +$(LDSCRIPT):$(SRCLIBDIR)/ld/linker.ld.S +ifeq ($(LD_PARAMS),) + $(error unknown device $(DEVICE) for the linker. Cannot generate ldscript) +endif + @#printf " GENLNK $(subst $(shell pwd)/,,$(@))\n" + $(Q)$(CC) $(LD_PARAMS) -P -E $< > $@ + +GENFILES += $(LDSCRIPT) +endif diff --git a/libopencm3/ld/README b/libopencm3/ld/README new file mode 100644 index 0000000..f270afb --- /dev/null +++ b/libopencm3/ld/README @@ -0,0 +1,157 @@ +------------------------------------------------------------------------------ +README +------------------------------------------------------------------------------ + +LIBOPENCM3 LINKER SCRIPT GENERATOR +---------------------------------- + +This folder contains files needed for the automatic linker script generation +mechanism developed for libopencm3 library. + +File contents +------------- + +* {ROOT}/ld/tests/* - Prepared tests for the testing of the script +* {ROOT}/ld/devices.data - Device database file +* {ROOT}/ld/Makefile.linker - Common makefile part +* {ROOT}/ld/linker.ld.S - Linker script template +* {ROOT}/scripts/genlink.awk - Device database file search script +* {ROOT}/scripts/genlinktest.sh - Device database file search test script + +Principle of operation +---------------------- + +The user specifies in the project Makefile the device part name the project is +using, in the variable DEVICE. Note that full device part name must be +specified, because the device specific features is usually dependent on the +last characters of device name string. Note that the device name string search +is case insensitive. + +DEVICE=stm32f407vgt6 + +Then, the user includes the file /ld/Makefile.linker exactly after the first +target (usually all) has been defined. + +The script automatically modifies the $(LDSCRIPT) variable to meet the new +generated script with .ld in the project directory, and adds +a rule to make it from the scratch. + +Making the script is done by looking to device database file for the needed +definitions, and applying those definitions to the C preprocessor source +linker.ld.S outputting the preprocessed ld file. + +Device database contains definitions of common sections and its origins for +the linker preprocessor. Every definition is interpreted in the linker script +template as a macro, and it can be used for conditional insertion of the device +dependent stuff. + +The search in the device database is pattern-based, and using awk script +genlink.awk. The awk script traverses the file as a tree, joining the options +for the preprocessor together by single space. The awk script adds -D to each +parameter for you. + +Testing +------- + +The testing of feature is done by executing in the root of libopencm3 library. + +make genlinktests + +The test cases are defined in subdirectory {ROOT}/ld/tests/. Each test contains +two files, the database file *.data and the expected result *.result file. If +the particular test fails, the file *.out containing output of the script is +not deleted to help resolving problem with the script. + +The search pattern for the test is the base filename of particular test. + +The testing stops after all test cases are valid, or at first error found. + +Example of use +-------------- + +* See Makefile.example file + +Device database file structure +------------------------------ + +Line description: + ( ...) + + : is the pattern for the chip description to be searched for. + The case of the pattern string is ignored. + Pattern match symbols: + ? - matches exactly one character + * - matches none or more characters + + - matches single or more characters + + : is the parent group name, where the search will continue. + There are special parents names that controls traversing: + "END" - Exit traversal. + "+" - Don't change the parent. Use for split long line to two. + + : space-separated list of preprocessor symbols supplied to the linker. + -D option name with single underscore is automatically prepended to each + symbol definition + if the symbol starts with dash "-", it is interpreted as parameter to + linker, and no -D or underscore is generated. + +All lines starting with # symbol are treated as Comments + +Recommended tree hierarchy: + + + +- + +- + +- END + +You can split the long line into two or more by using "+" in the parent field, +and defining same regex with appropriate parent on the next line. Example: + + device + PARAM1=aaa PARAM2=bbbb PARAM3=ccc PARAM4=dddd PARAM5=eeee + device parent PARAM6=ffff PARAM7=gggg PARAM8=hhhh + parent END + +The order of the lines is important. After the regex match, its parent will +be used for match on the next line. If two regexp lines matches input, only +the first will be evaluated, except special group definition "+" + +The regex matches entire sym + +Example: + +--- devices.data file --- +stm32f05[01]?4* stm32f0 ROM=16K RAM=4K +stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m0 -mthumb +stm32 END + +--- queried chip name --- +stm32f051c4t6 + +--- output of the awk script --- +-D_ROM=16K -D_RAM=4K -D_ROM_OFF=0x08000000 -D_RAM_OFF=0x20000000 \ +-mcpu=cortex-m0 -mthumb + +The generated linker script file will contain sections rom and ram with +appropriate initialization code, specified in linker file source linker.ld.S + + +Copyright +--------- + +This file is part of the libopencm3 project. + +Copyright (C) 2013 Frantisek Burian +Copyright (C) 2013 Werner Almesberger + +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 . \ No newline at end of file diff --git a/libopencm3/ld/devices.data b/libopencm3/ld/devices.data new file mode 100644 index 0000000..5088098 --- /dev/null +++ b/libopencm3/ld/devices.data @@ -0,0 +1,389 @@ +################################################################################ +# +# Device chip tree definition file. +# +# Copyright (c) 2013 Frantisek Burian +# Copyright (C) 2013 Werner Almesberger +# +# Line description: +# ( ...) +# +# : is the pattern for the chip description to be searched for. +# The case of the pattern string is ignored. +# Pattern match symbols: +# ? - matches exactly one character +# * - matches none or more characters +# + - matches single or more characters +# +# : is the parent group name, where the search will continue. +# There are special parents names that controls traversing: +# "END" - Exit traversal. +# "+" - Don't change the parent. Use for split long line to two. +# +# : space-separated list of preprocessor symbols supplied to the linker. +# -D option name is automatically prepended to each symbol definition +# +# All lines starting with # symbol are treated as Comments +# +# Recommended tree hierarchy: +# +# +# +- +# +- +# +- END +# +# You can split the long line into two or more by using "+" in the parent field, +# and defining same regex with appropriate parent on the next line. Example: +# +# device + PARAM1=aaa PARAM2=bbbb PARAM3=ccc PARAM4=dddd PARAM5=eeee +# device parent PARAM6=ffff PARAM7=gggg PARAM8=hhhh +# parent END +# +# The order of the lines is important. After the regex match, its parent will +# be used for match on the next line. If two regexp lines matches input, only +# the first will be evaluated, except special group definition "+" +# +# The regex matches entire sym +# +# Example: +# +# --- devices.data file --- +# stm32f05[01]?4* stm32f0 ROM=16K RAM=4K +# stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 +# stm32 END +# +# --- queried chip name --- +# stm32f051c8t6 +# +# --- output of the awk script --- +# -DROM=16K -DRAM=4K -DROM_OFF=0x08000000 -DRAM_OFF=0x20000000 +# +# The generated linker script file will contain sections rom and ram with +# appropriate initialization code, specified in linker file source linker.ld.S +# + +################################################################################ +# the STM32 chips + +stm32f03[01]?4* stm32f0 ROM=16K RAM=4K +stm32f03[01]?6* stm32f0 ROM=32K RAM=4K +stm32f030?8* stm32f0 ROM=64K RAM=8K +stm32f050?4* stm32f0 ROM=16K RAM=4K +stm32f050?6* stm32f0 ROM=32K RAM=4K +stm32f051?4* stm32f0 ROM=16K RAM=8K +stm32f051?6* stm32f0 ROM=32K RAM=8K +stm32f051?8* stm32f0 ROM=64K RAM=8K +stm32f072?8* stm32f0 ROM=64K RAM=16K +stm32f07[12]?B* stm32f0 ROM=128K RAM=16K + +stm32f10[012]?4* stm32f1 ROM=16K RAM=4K +stm32f103?4* stm32f1 ROM=16K RAM=6K +stm32f100?6* stm32f1 ROM=32K RAM=4K +stm32f103?6* stm32f1 ROM=32K RAM=10K +stm32f10[12]?6* stm32f1 ROM=32K RAM=6K +stm32f100?8* stm32f1 ROM=64K RAM=8K +stm32f10[12]?8* stm32f1 ROM=64K RAM=10K +stm32f103?8* stm32f1 ROM=64K RAM=20K +stm32f100?b* stm32f1 ROM=128K RAM=8K +stm32f10[12]?b* stm32f1 ROM=128K RAM=16K +stm32f103?b* stm32f1 ROM=128K RAM=20K +stm32f10[57]?b* stm32f1 ROM=128K RAM=64K +stm32f100?c* stm32f1 ROM=256K RAM=24K +stm32f101?c* stm32f1 ROM=256K RAM=32K +stm32f103?c* stm32f1 ROM=256K RAM=48K +stm32f10[57]?c* stm32f1 ROM=256K RAM=64K +stm32f100?d* stm32f1 ROM=384K RAM=32K +stm32f101?d* stm32f1 ROM=384K RAM=48K +stm32f103?d* stm32f1 ROM=384K RAM=64K +stm32f100?e* stm32f1 ROM=512K RAM=32K +stm32f101?e* stm32f1 ROM=512K RAM=48K +stm32f103?e* stm32f1 ROM=512K RAM=64K +stm32f100?f* stm32f1 ROM=768K RAM=80K +stm32f103?f* stm32f1 ROM=768K RAM=96K +stm32f100?g* stm32f1 ROM=1024K RAM=80K +stm32f103?g* stm32f1 ROM=1024K RAM=96K + +stm32f205?b* stm32f2 ROM=128K RAM=64K +stm32f205?c* stm32f2 ROM=256K RAM=96K +stm32f207?c* stm32f2 ROM=256K RAM=128K +stm32f2[01][57]?e* stm32f2 ROM=512K RAM=128K +stm32f20[57]?f* stm32f2 ROM=768K RAM=128K +stm32f2[01][57]?g* stm32f2 ROM=1024K RAM=128K + +stm32f302?b* stm32f3ccm ROM=128K RAM=24K CCM=8K +stm32f302?c* stm32f3ccm ROM=256K RAM=32K CCM=8K +stm32f303?b* stm32f3ccm ROM=128K RAM=40K CCM=8K +stm32f3[01]3?c* stm32f3ccm ROM=256K RAM=48K CCM=8K +stm32f373?8* stm32f3 ROM=64K RAM=16K +stm32f373?b* stm32f3 ROM=128K RAM=24K +stm32f3[78]3?8* stm32f3 ROM=256K RAM=32K + +stm32f401?b* stm32f4 ROM=128K RAM=64K +stm32f401?c* stm32f4 ROM=256K RAM=64K +stm32f401?d* stm32f4 ROM=512K RAM=96K +stm32f401?e* stm32f4 ROM=384K RAM=96K +stm32f4[01][57]?e* stm32f4ccm ROM=512K RAM=128K CCM=64K +stm32f4[01][57]?g* stm32f4ccm ROM=1024K RAM=128K CCM=64K +stm32f4[23][79]?g* stm32f4ccm ROM=1024K RAM=192K CCM=64K +stm32f4[23][79]?i* stm32f4ccm ROM=2048K RAM=192K CCM=64K + +stm32l100?6* stm32l1 ROM=32K RAM=4K +stm32l100?8* stm32l1 ROM=64K RAM=8K +stm32l100?b* stm32l1 ROM=128K RAM=10K +stm32l100?c* stm32l1 ROM=256K RAM=16K +stm32l15[12]?6* stm32l1eep ROM=32K RAM=10K EEP=4K +stm32l15[12]?8* stm32l1eep ROM=64K RAM=10K EEP=4K +stm32l15[12]?b* stm32l1eep ROM=128K RAM=16K EEP=4K +stm32l15[12]?c* stm32l1eep ROM=256K RAM=32K EEP=8K +stm32l15[12]?d* stm32l1eep ROM=384K RAM=48K EEP=12K +stm32l162?c* stm32l1eep ROM=256K RAM=32K EEP=8K +stm32l162?d* stm32l1eep ROM=384K RAM=48K EEP=12K + +stm32ts60 stm32t ROM=32K RAM=10K + +stm32w108c8 stm32w ROM=64K RAM=8K +stm32w108?b stm32w ROM=128K RAM=8K +stm32w108cz stm32w ROM=192K RAM=12K +stm32w108cc stm32w ROM=256K RAM=16K + +################################################################################ +# the SAM3 chips + +sam3a4* sam3a ROM=256K RAM=32K RAM1=32K +sam3a8* sam3a ROM=512K RAM=64K RAM1=32K + +sam3n00* sam3n ROM=16K RAM=4K +sam3n0* sam3n ROM=32K RAM=8K +sam3n1* sam3n ROM=64K RAM=8K +sam3n2* sam3n ROM=128K RAM=16K +sam3n4* sam3n ROM=256K RAM=24K + +sam3s1* sam3s ROM=64K RAM=16K +sam3s2* sam3s ROM=128K RAM=32K +sam3s4* sam3s ROM=256K RAM=48K +sam3s8* sam3s ROM=512K RAM=64K +sam3sd8* sam3s ROM=512K RAM=64K + +sam3u1* sam3u ROM=64K RAM=8K RAM1=8K +sam3u2* sam3u ROM=128K RAM=16K RAM1=16K +sam3u4* sam3u ROM=265K RAM=32K RAM1=16K + +sam3x4c* sam3x ROM=256K RAM=32K RAM1=32K +sam3x4e* sam3xnfc ROM=256K RAM=32K RAM1=32K +sam3x8c* sam3x ROM=512K RAM=64K RAM1=32K +sam3x8e* sam3xnfc ROM=512K RAM=64K RAM1=32K + +################################################################################ +# the lpc chips + +lpc1311* lpc13 ROM=8K RAM=4K +lpc1313* lpc13 ROM=32K RAM=8K +lpc1342* lpc13 ROM=16K RAM=4K +lpc1343* lpc13 ROM=32K RAM=8K +lpc1315* lpc13u ROM=32K RAM=8K +lpc1316* lpc13u ROM=48K RAM=8K +lpc1317* lpc13u ROM=64K RAM=8K RAM1=2K +lpc1345* lpc13u ROM=32K RAM=8K USBRAM=2K +lpc1346* lpc13u ROM=48K RAM=8K USBRAM=2K +lpc1346* lpc13u ROM=64K RAM=8K USBRAM=2K RAM1=2K + +lpc1751* lpc175x ROM=32K RAM=8K +lpc1752* lpc175x ROM=64K RAM=16K +lpc1754* lpc175x ROM=128K RAM=16K RAM1=16K +lpc1756* lpc175x ROM=256K RAM=16K RAM1=16K +lpc1758* lpc175x ROM=512K RAM=32K RAM1=16K RAM2=16K +lpc1759* lpc175x ROM=512K RAM=32K RAM1=16K RAM2=16K +lpc1763* lpc176x ROM=256K RAM=32K RAM1=16K RAM2=16K +lpc1764* lpc176x ROM=128K RAM=16K RAM1=16K +lpc1765* lpc176x ROM=256K RAM=32K RAM1=16K RAM2=16K +lpc1766* lpc176x ROM=256K RAM=32K RAM1=16K RAM2=16K +lpc1767* lpc176x ROM=512K RAM=32K RAM1=16K RAM2=16K +lpc1768* lpc176x ROM=512K RAM=32K RAM1=16K RAM2=16K +lpc1769* lpc176x ROM=512K RAM=32K RAM1=16K RAM2=16K +lpc1774* lpc177x ROM=128K RAM=32K RAM1=8K +lpc1776* lpc177x ROM=256K RAM=64K RAM1=16K +lpc1777* lpc177x ROM=512K RAM=64K RAM1=16K RAM2=16K +lpc1778* lpc177x ROM=512K RAM=64K RAM1=16K RAM2=16K +lpc1785* lpc178x ROM=256K RAM=64K RAM1=16K +lpc1786* lpc178x ROM=256K RAM=64K RAM1=16K +lpc1787* lpc178x ROM=512K RAM=64K RAM1=16K RAM2=16K +lpc1788* lpc178x ROM=512K RAM=64K RAM1=16K RAM2=16K + +################################################################################ +# the efm32 chips + +# Zero Gecko +efm32zg???f4 efm32zg ROM=4K RAM=2K +efm32zg???f8 efm32zg ROM=8K RAM=2K +efm32zg???f16 efm32zg ROM=16K RAM=4K +efm32zg???f32 efm32zg ROM=32K RAM=4K + +# Tiny Gecko +efm32tg108f4 efm32tg ROM=4K RAM=1K +efm32tg110f4 efm32tg ROM=4K RAM=2K +efm32tg???f8 efm32tg ROM=8K RAM=2K +efm32tg???f16 efm32tg ROM=16K RAM=4K +efm32tg???f32 efm32tg ROM=32K RAM=4K + +# Gecko +efm32g200f16 efm32g ROM=16K RAM=8K +efm32g???f32 efm32g ROM=32K RAM=8K +efm32g???f64 efm32g ROM=64K RAM=16K +efm32g???f128 efm32g ROM=128K RAM=16K + +# Large Gecko +efm32lg???f64 efm32lg ROM=64K RAM=32K +efm32lg???f128 efm32lg ROM=128K RAM=32K +efm32lg???f256 efm32lg ROM=256K RAM=32K + +# Giant Gecko +efm32gg???f512 efm32gg ROM=512K RAM=128K +efm32gg???f1024 efm32gg ROM=1024K RAM=128K + +# Wonder Gecko +efm32wg???f64 efm32gg ROM=64K RAM=32K +efm32wg???f128 efm32gg ROM=128K RAM=32K +efm32wg???f256 efm32gg ROM=256K RAM=32K + +################################################################################ +# the TI cortex M3 chips + +lm3s101 lm3sandstorm ROM=8K RAM=2K +lm3s102 lm3sandstorm ROM=8K RAM=2K + +lm3s300 lm3sandstorm ROM=16K RAM=4K +lm3s301 lm3sandstorm ROM=16K RAM=2K +lm3s308 lm3sandstorm ROM=16K RAM=4K +lm3s310 lm3sandstorm ROM=16K RAM=4K +lm3s315 lm3sandstorm ROM=16K RAM=4K +lm3s316 lm3sandstorm ROM=16K RAM=4K +lm3s317 lm3sandstorm ROM=16K RAM=4K +lm3s328 lm3sandstorm ROM=16K RAM=4K +lm3s600 lm3sandstorm ROM=32K RAM=8K +lm3s601 lm3sandstorm ROM=32K RAM=8K +lm3s608 lm3sandstorm ROM=32K RAM=8K +lm3s610 lm3sandstorm ROM=32K RAM=8K +lm3s611 lm3sandstorm ROM=32K RAM=8K +lm3s612 lm3sandstorm ROM=32K RAM=8K +lm3s613 lm3sandstorm ROM=32K RAM=8K +lm3s615 lm3sandstorm ROM=32K RAM=8K +lm3s617 lm3sandstorm ROM=32K RAM=8K +lm3s618 lm3sandstorm ROM=32K RAM=8K +lm3s628 lm3sandstorm ROM=32K RAM=8K +lm3s800 lm3sandstorm ROM=64K RAM=8K +lm3s801 lm3sandstorm ROM=64K RAM=8K +lm3s808 lm3sandstorm ROM=64K RAM=8K +lm3s811 lm3sandstorm ROM=64K RAM=8K +lm3s812 lm3sandstorm ROM=64K RAM=8K +lm3s815 lm3sandstorm ROM=64K RAM=8K +lm3s817 lm3sandstorm ROM=64K RAM=8K +lm3s818 lm3sandstorm ROM=64K RAM=8K +lm3s828 lm3sandstorm ROM=64K RAM=8K + +lm3s1110 lm3fury ROM=64K RAM=16K +lm3s1133 lm3fury ROM=64K RAM=16K +lm3s1138 lm3fury ROM=64K RAM=16K +lm3s1150 lm3fury ROM=64K RAM=16K +lm3s1162 lm3fury ROM=64K RAM=16K +lm3s1165 lm3fury ROM=64K RAM=16K +lm3s1332 lm3fury ROM=96K RAM=16K +lm3s1435 lm3fury ROM=96K RAM=32K +lm3s1439 lm3fury ROM=96K RAM=32K +lm3s1512 lm3fury ROM=96K RAM=64K +lm3s1538 lm3fury ROM=96K RAM=64K +lm3s1601 lm3fury ROM=128K RAM=32K +lm3s1607 lm3fury ROM=128K RAM=32K +lm3s1608 lm3fury ROM=128K RAM=32K +lm3s1620 lm3fury ROM=128K RAM=32K +lm3s8962 lm3fury ROM=256K RAM=64K + +################################################################################ +# the TI cortex R4F chips + +rm46l852* rm46l ROM=1280K RAM=192K + +################################################################################ +################################################################################ +################################################################################ +# the STM32 family groups + +stm32f3ccm stm32f3 CCM_OFF=0x10000000 +stm32f4ccm stm32f4 CCM_OFF=0x10000000 +stm32l1eep stm32l1 EEP_OFF=0x08080000 + +################################################################################ +# the SAM3 family groups +sam3xnfc sam3x NFCRAM=4K NFCRAM_OFF=0x20100000 + +################################################################################ +# the lpc family groups + + +lpc13u lpc13 USBRAM_OFF=0x20004000 + +lpc17[56]x lpc17 RAM1_OFF=0x2007C000 RAM2_OFF=0x20080000 +lpc17[78]x lpc17 RAM1_OFF=0x20000000 RAM2_OFF=0x20040000 + +################################################################################ +################################################################################ +################################################################################ +# the STM32 families + +stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m0 -mthumb -DSTM32F0 -lopencm3_stm32f0 -msoft-float +stm32f1 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb -DSTM32F1 -lopencm3_stm32f1 -msoft-float +stm32f2 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb -DSTM32F2 -lopencm3_stm32f2 -msoft-float +stm32f3 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m4 -mthumb -DSTM32F3 -lopencm3_stm32f3 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +stm32f4 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m4 -mthumb -DSTM32F4 -lopencm3_stm32f4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +stm32l1 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb -DSTM32L1 -lopencm3_stm32l1 -msoft-float +stm32w stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb +stm32t stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m3 -mthumb + +################################################################################ +# the SAM3 families + +sam3a sam3 ROM_OFF=0x00080000 RAM_OFF=0x20000000 RAM1_OFF=0x20080000 +sam3n sam3 ROM_OFF=0x00400000 RAM_OFF=0x20000000 +sam3s sam3 ROM_OFF=0x00400000 RAM_OFF=0x20000000 +sam3u sam3 ROM_OFF=0x00080000 RAM_OFF=0x20000000 RAM1_OFF=0x20080000 NFCRAM=4K NFCRAM_OFF=0x20100000 +sam3x sam3 ROM_OFF=0x00080000 RAM_OFF=0x20000000 RAM1_OFF=0x20080000 + +################################################################################ +# the lpc families + +lpc13 lpc ROM_OFF=0x00000000 RAM_OFF=0x10000000 RAM1_OFF=0x20000000 +lpc17 lpc ROM_OFF=0x00000000 RAM_OFF=0x10000000 + +################################################################################ +# the efm32 Gecko families + +efm32zg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000 +efm32tg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000 +efm32g efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000 +efm32lg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000 +efm32gg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000 +efm32wg efm32 ROM_OFF=0x00000000 RAM_OFF=0x20000000 RAM1_OFF=0x10000000 + +################################################################################ +# Cortex LM3 families + +lm3fury lm3 ROM_OFF=0x00000000 RAM_OFF=0x20000000 +lm3sandstorm lm3 ROM_OFF=0x00000000 RAM_OFF=0x20000000 + + +################################################################################ +# Cortex R4F families + +rm46l rm4 ROM_OFF=0x00000000 RAM_OFF=0x08000000 RAM1_OFF=0x08400000 + +################################################################################ +################################################################################ +################################################################################ +# the architectures + +stm32 END +sam3 END +lpc END +efm32 END +lm3 END +rm4 END + diff --git a/libopencm3/ld/linker.ld.S b/libopencm3/ld/linker.ld.S new file mode 100644 index 0000000..e81ccc0 --- /dev/null +++ b/libopencm3/ld/linker.ld.S @@ -0,0 +1,193 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2009 Uwe Hermann + * Copyright (C) 2013 Frantisek Burian + * + * 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 . + */ + +/* Generic linker script for all targets using libopencm3. */ + +/* Enforce emmition of the vector table. */ +EXTERN(vector_table) + +/* Define the entry point of the output file. */ +ENTRY(reset_handler) + +/* Define memory regions. */ +MEMORY +{ + /* RAM is always used */ + ram (rwx) : ORIGIN = _RAM_OFF, LENGTH = _RAM + +#if defined(_ROM) + rom (rx) : ORIGIN = _ROM_OFF, LENGTH = _ROM +#endif +#if defined(_ROM1) + rom1 (rx) : ORIGIN = _ROM1_OFF, LENGTH = _ROM1 +#endif +#if defined(_ROM2) + rom2 (rx) : ORIGIN = _ROM2_OFF, LENGTH = _ROM2 +#endif +#if defined(_RAM1) + ram1 (rwx) : ORIGIN = _RAM1_OFF, LENGTH = _RAM1 +#endif +#if defined(_RAM2) + ram2 (rwx) : ORIGIN = _RAM2_OFF, LENGTH = _RAM2 +#endif +#if defined(_CCM) + ccm (rwx) : ORIGIN = _CCM_OFF, LENGTH = _CCM +#endif +#if defined(_EEP) + eep (r) : ORIGIN = _EEP_OFF, LENGTH = _EEP +#endif +#if defined(_XSRAM) + xsram (rw) : ORIGIN = _XSRAM_OFF, LENGTH = _XSRAM +#endif +#if defined(_XDRAM) + xdram (rw) : ORIGIN = _XDRAM_OFF, LENGTH = _XDRAM +#endif +#if defined(_NFCRAM) + nfcram (rw) : ORIGIN _NFCRAM_OFF, LENGTH = _NFCRAM +#endif +} + +/* Define sections. */ +SECTIONS +{ + .text : { + *(.vectors) /* Vector table */ + *(.text*) /* Program code */ + . = ALIGN(4); + *(.rodata*) /* Read-only data */ + . = ALIGN(4); + } >rom + + /* C++ Static constructors/destructors, also used for + * __attribute__((constructor)) and the likes. + */ + .preinit_array : { + . = ALIGN(4); + __preinit_array_start = .; + KEEP (*(.preinit_array)) + __preinit_array_end = .; + } >rom + .init_array : { + . = ALIGN(4); + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; + } >rom + .fini_array : { + . = ALIGN(4); + __fini_array_start = .; + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + __fini_array_end = .; + } >rom + + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >rom + + . = ALIGN(4); + _etext = .; + + .data : { + _data = .; + *(.data*) /* Read-write initialized data */ + . = ALIGN(4); + _edata = .; + } >ram AT >rom + _data_loadaddr = LOADADDR(.data); + + .bss : { + *(.bss*) /* Read-write zero initialized data */ + *(COMMON) + . = ALIGN(4); + _ebss = .; + } >ram + +#if defined(_EEP) + .eep : { + *(.eeprom*) + . = ALIGN(4); + } >eep +#endif + +#if defined(_CCM) + .ccm : { + *(.ccmram*) + . = ALIGN(4); + } >ccm +#endif + +#if defined(_RAM1) + .ram1 : { + *(.ram1*) + . = ALIGN(4); + } >ram1 +#endif + +#if defined(_RAM2) + .ram2 : { + *(.ram2*) + . = ALIGN(4); + } >ram2 +#endif + +#if defined(_XSRAM) + .xsram : { + *(.xsram*) + . = ALIGN(4); + } >xsram +#endif + +#if defined(_XDRAM) + .xdram : { + *(.xdram*) + . = ALIGN(4); + } >xdram +#endif + +#if defined(_NFCRAM) + .nfcram : { + *(.nfcram*) + . = ALIGN(4); + } >nfcram +#endif + + /* + * The .eh_frame section appears to be used for C++ exception handling. + * You may need to fix this if you're using C++. + */ + /DISCARD/ : { *(.eh_frame) } + + . = ALIGN(4); + end = .; +} + +PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram)); + diff --git a/libopencm3/ld/tests/dash.data b/libopencm3/ld/tests/dash.data new file mode 100644 index 0000000..eb12e28 --- /dev/null +++ b/libopencm3/ld/tests/dash.data @@ -0,0 +1 @@ +dash END A B C D -mcpu=cortex-m0 \ No newline at end of file diff --git a/libopencm3/ld/tests/dash.result b/libopencm3/ld/tests/dash.result new file mode 100644 index 0000000..8d876a2 --- /dev/null +++ b/libopencm3/ld/tests/dash.result @@ -0,0 +1 @@ +-D_A -D_B -D_C -D_D -mcpu=cortex-m0 \ No newline at end of file diff --git a/libopencm3/ld/tests/longline.data b/libopencm3/ld/tests/longline.data new file mode 100644 index 0000000..5f71d37 --- /dev/null +++ b/libopencm3/ld/tests/longline.data @@ -0,0 +1,2 @@ +longline + A=parameter B=parameter C=parameter D=parameter E==parameter +longline END F=parameter G=parameter \ No newline at end of file diff --git a/libopencm3/ld/tests/longline.result b/libopencm3/ld/tests/longline.result new file mode 100644 index 0000000..78a1477 --- /dev/null +++ b/libopencm3/ld/tests/longline.result @@ -0,0 +1 @@ +-D_A=parameter -D_B=parameter -D_C=parameter -D_D=parameter -D_E==parameter -D_F=parameter -D_G=parameter \ No newline at end of file diff --git a/libopencm3/ld/tests/single.data b/libopencm3/ld/tests/single.data new file mode 100644 index 0000000..027025a --- /dev/null +++ b/libopencm3/ld/tests/single.data @@ -0,0 +1 @@ +single END A B C D \ No newline at end of file diff --git a/libopencm3/ld/tests/single.result b/libopencm3/ld/tests/single.result new file mode 100644 index 0000000..3191ddd --- /dev/null +++ b/libopencm3/ld/tests/single.result @@ -0,0 +1 @@ +-D_A -D_B -D_C -D_D \ No newline at end of file diff --git a/libopencm3/ld/tests/tree1.data b/libopencm3/ld/tests/tree1.data new file mode 100644 index 0000000..7867a61 --- /dev/null +++ b/libopencm3/ld/tests/tree1.data @@ -0,0 +1,2 @@ +tree1 treeparent A B C D +treeparent END E F diff --git a/libopencm3/ld/tests/tree1.result b/libopencm3/ld/tests/tree1.result new file mode 100644 index 0000000..b71bb04 --- /dev/null +++ b/libopencm3/ld/tests/tree1.result @@ -0,0 +1 @@ +-D_A -D_B -D_C -D_D -D_E -D_F \ No newline at end of file diff --git a/libopencm3/ld/tests/tree5.data b/libopencm3/ld/tests/tree5.data new file mode 100644 index 0000000..d51a33a --- /dev/null +++ b/libopencm3/ld/tests/tree5.data @@ -0,0 +1,5 @@ +tree5 tree4 A +tree4 tree3 B +tree3 tree2 C +tree2 tree1 D +tree1 END E F diff --git a/libopencm3/ld/tests/tree5.result b/libopencm3/ld/tests/tree5.result new file mode 100644 index 0000000..b71bb04 --- /dev/null +++ b/libopencm3/ld/tests/tree5.result @@ -0,0 +1 @@ +-D_A -D_B -D_C -D_D -D_E -D_F \ No newline at end of file diff --git a/libopencm3/ld/tests/twomatch.data b/libopencm3/ld/tests/twomatch.data new file mode 100644 index 0000000..e55df61 --- /dev/null +++ b/libopencm3/ld/tests/twomatch.data @@ -0,0 +1,4 @@ +twomatch treeparent A B C D +# the next line will be ignored because previous matches before and no + there +twomatch treeparent P Q R S +treeparent END E F diff --git a/libopencm3/ld/tests/twomatch.result b/libopencm3/ld/tests/twomatch.result new file mode 100644 index 0000000..b71bb04 --- /dev/null +++ b/libopencm3/ld/tests/twomatch.result @@ -0,0 +1 @@ +-D_A -D_B -D_C -D_D -D_E -D_F \ No newline at end of file -- cgit v1.2.3