[STM32F3xx] linker script reorganisation

pull/743/head
Olaf Hagendorf 2014-11-26 12:31:02 +01:00
parent c3208fe6f4
commit 0737130e57
5 changed files with 183 additions and 189 deletions

View File

@ -1,5 +1,3 @@
/* Linker script for STM32F */
/* Linker script to configure memory regions. */ /* Linker script to configure memory regions. */
MEMORY MEMORY
{ {
@ -33,6 +31,7 @@ MEMORY
* __StackLimit * __StackLimit
* __StackTop * __StackTop
* __stack * __stack
* _estack
*/ */
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
@ -42,7 +41,6 @@ SECTIONS
{ {
KEEP(*(.isr_vector)) KEEP(*(.isr_vector))
*(.text*) *(.text*)
/* KEEP(.ioview) */
KEEP(*(.init)) KEEP(*(.init))
KEEP(*(.fini)) KEEP(*(.fini))
@ -78,12 +76,12 @@ SECTIONS
__exidx_end = .; __exidx_end = .;
__etext = .; __etext = .;
_sidata = .; _sidata = .;
.data : AT (__etext) .data : AT (__etext)
{ {
__data_start__ = .; __data_start__ = .;
_sdata = .; _sdata = .;
*(vtable) *(vtable)
*(.data*) *(.data*)
@ -112,7 +110,7 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
/* All data end */ /* All data end */
__data_end__ = .; __data_end__ = .;
_edata = .; _edata = .;
} > RAM } > RAM
@ -120,12 +118,12 @@ SECTIONS
{ {
. = ALIGN(4); . = ALIGN(4);
__bss_start__ = .; __bss_start__ = .;
_sbss = .; _sbss = .;
*(.bss*) *(.bss*)
*(COMMON) *(COMMON)
. = ALIGN(4); . = ALIGN(4);
__bss_end__ = .; __bss_end__ = .;
_ebss = .; _ebss = .;
} > RAM } > RAM
.heap (COPY): .heap (COPY):
@ -147,7 +145,7 @@ SECTIONS
/* Set stack top to end of RAM, and stack limit move down by /* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */ * size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM); __StackTop = ORIGIN(RAM) + LENGTH(RAM);
_estack = __StackTop; _estack = __StackTop;
__StackLimit = __StackTop - SIZEOF(.stack_dummy); __StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop); PROVIDE(__stack = __StackTop);

View File

@ -1,11 +1,9 @@
/* Linker script for STM32F407 */
/* Linker script to configure memory regions. */ /* Linker script to configure memory regions. */
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x10000 FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000188, LENGTH = 0x3000 - 0x0188 CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 4K
/* CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0x1000 */ RAM (xrw) : ORIGIN = 0x20000188, LENGTH = 12K - 0x0188
} }
/* Linker script to place sections and symbol values. Should be used together /* Linker script to place sections and symbol values. Should be used together
@ -33,6 +31,7 @@ MEMORY
* __StackLimit * __StackLimit
* __StackTop * __StackTop
* __stack * __stack
* _estack
*/ */
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
@ -42,7 +41,6 @@ SECTIONS
{ {
KEEP(*(.isr_vector)) KEEP(*(.isr_vector))
*(.text*) *(.text*)
KEEP(*(.init)) KEEP(*(.init))
KEEP(*(.fini)) KEEP(*(.fini))
@ -78,10 +76,12 @@ SECTIONS
__exidx_end = .; __exidx_end = .;
__etext = .; __etext = .;
_sidata = .;
.data : AT (__etext) .data : AT (__etext)
{ {
__data_start__ = .; __data_start__ = .;
_sdata = .;
*(vtable) *(vtable)
*(.data*) *(.data*)
@ -110,6 +110,7 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
/* All data end */ /* All data end */
__data_end__ = .; __data_end__ = .;
_edata = .;
} > RAM } > RAM
@ -117,10 +118,12 @@ SECTIONS
{ {
. = ALIGN(4); . = ALIGN(4);
__bss_start__ = .; __bss_start__ = .;
_sbss = .;
*(.bss*) *(.bss*)
*(COMMON) *(COMMON)
. = ALIGN(4); . = ALIGN(4);
__bss_end__ = .; __bss_end__ = .;
_ebss = .;
} > RAM } > RAM
.heap (COPY): .heap (COPY):
@ -142,6 +145,7 @@ SECTIONS
/* Set stack top to end of RAM, and stack limit move down by /* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */ * size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM); __StackTop = ORIGIN(RAM) + LENGTH(RAM);
_estack = __StackTop;
__StackLimit = __StackTop - SIZEOF(.stack_dummy); __StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop); PROVIDE(__stack = __StackTop);

View File

@ -1,11 +1,8 @@
/* Linker script for STM32F407 */
/* Linker script to configure memory regions. */ /* Linker script to configure memory regions. */
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x10000 FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000188, LENGTH = 0x3000 - 0x0188 RAM (xrw) : ORIGIN = 0x20000188, LENGTH = 16K - 0x188
/* CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 0x1000 */
} }
/* Linker script to place sections and symbol values. Should be used together /* Linker script to place sections and symbol values. Should be used together
@ -33,6 +30,7 @@ MEMORY
* __StackLimit * __StackLimit
* __StackTop * __StackTop
* __stack * __stack
* _estack
*/ */
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
@ -78,10 +76,12 @@ SECTIONS
__exidx_end = .; __exidx_end = .;
__etext = .; __etext = .;
_sidata = .;
.data : AT (__etext) .data : AT (__etext)
{ {
__data_start__ = .; __data_start__ = .;
_sdata = .;
*(vtable) *(vtable)
*(.data*) *(.data*)
@ -110,6 +110,7 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
/* All data end */ /* All data end */
__data_end__ = .; __data_end__ = .;
_edata = .;
} > RAM } > RAM
@ -117,10 +118,12 @@ SECTIONS
{ {
. = ALIGN(4); . = ALIGN(4);
__bss_start__ = .; __bss_start__ = .;
_sbss = .;
*(.bss*) *(.bss*)
*(COMMON) *(COMMON)
. = ALIGN(4); . = ALIGN(4);
__bss_end__ = .; __bss_end__ = .;
_ebss = .;
} > RAM } > RAM
.heap (COPY): .heap (COPY):
@ -142,6 +145,7 @@ SECTIONS
/* Set stack top to end of RAM, and stack limit move down by /* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */ * size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM); __StackTop = ORIGIN(RAM) + LENGTH(RAM);
_estack = __StackTop;
__StackLimit = __StackTop - SIZEOF(.stack_dummy); __StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop); PROVIDE(__stack = __StackTop);

View File

@ -1,167 +0,0 @@
/*
*****************************************************************************
**
** File : STM32F302X8_FLASH.ld
**
** Abstract : Linker script for STM32F302x8 device with
** 64-KByte FLASH, 16-KByte RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Environment : Atollic TrueSTUDIO(R)
**
** Distribution: The file is distributed “as is,” without any warranty
** of any kind.
**
** (c)Copyright Atollic AB.
** You may use this file as-is or modify it according to the needs of your
** project. This file may only be built (assembled or compiled and linked)
** using the Atollic TrueSTUDIO(R) product. The use of this file together
** with other tools than Atollic TrueSTUDIO(R) is not permitted.
**
*****************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20003FFF; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000188, LENGTH = 16K - 0x188
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
PROVIDE ( __end__ = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}

View File

@ -0,0 +1,155 @@
/* Linker script to configure memory regions. */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 4K
RAM (xrw) : ORIGIN = 0x20000188, LENGTH = 12K - 0x0188
}
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
* __etext
* __data_start__
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* __data_end__
* __bss_start__
* __bss_end__
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* __stack
* _estack
*/
ENTRY(Reset_Handler)
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
_sidata = .;
.data : AT (__etext)
{
__data_start__ = .;
_sdata = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
_edata = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
_sbss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
_ebss = .;
} > RAM
.heap (COPY):
{
__end__ = .;
end = __end__;
*(.heap*)
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
_estack = __StackTop;
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
}