xref: /btstack/port/stm32-f4discovery-usb/STM32F407VGTx_FLASH.ld (revision a8f7f3fcbcd51f8d2e92aca076b6a9f812db358c)
1*a8f7f3fcSMatthias Ringwald/*
2*a8f7f3fcSMatthias Ringwald******************************************************************************
3*a8f7f3fcSMatthias Ringwald**
4*a8f7f3fcSMatthias Ringwald
5*a8f7f3fcSMatthias Ringwald**  File        : LinkerScript.ld
6*a8f7f3fcSMatthias Ringwald**
7*a8f7f3fcSMatthias Ringwald**  Author		: Auto-generated by System Workbench for STM32
8*a8f7f3fcSMatthias Ringwald**
9*a8f7f3fcSMatthias Ringwald**  Abstract    : Linker script for STM32F407VGTx series
10*a8f7f3fcSMatthias Ringwald**                1024Kbytes FLASH and 192Kbytes RAM
11*a8f7f3fcSMatthias Ringwald**
12*a8f7f3fcSMatthias Ringwald**                Set heap size, stack size and stack location according
13*a8f7f3fcSMatthias Ringwald**                to application requirements.
14*a8f7f3fcSMatthias Ringwald**
15*a8f7f3fcSMatthias Ringwald**                Set memory bank area and size if external memory is used.
16*a8f7f3fcSMatthias Ringwald**
17*a8f7f3fcSMatthias Ringwald**  Target      : STMicroelectronics STM32
18*a8f7f3fcSMatthias Ringwald**
19*a8f7f3fcSMatthias Ringwald**  Distribution: The file is distributed “as is,” without any warranty
20*a8f7f3fcSMatthias Ringwald**                of any kind.
21*a8f7f3fcSMatthias Ringwald**
22*a8f7f3fcSMatthias Ringwald*****************************************************************************
23*a8f7f3fcSMatthias Ringwald** @attention
24*a8f7f3fcSMatthias Ringwald**
25*a8f7f3fcSMatthias Ringwald** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
26*a8f7f3fcSMatthias Ringwald**
27*a8f7f3fcSMatthias Ringwald** Redistribution and use in source and binary forms, with or without modification,
28*a8f7f3fcSMatthias Ringwald** are permitted provided that the following conditions are met:
29*a8f7f3fcSMatthias Ringwald**   1. Redistributions of source code must retain the above copyright notice,
30*a8f7f3fcSMatthias Ringwald**      this list of conditions and the following disclaimer.
31*a8f7f3fcSMatthias Ringwald**   2. Redistributions in binary form must reproduce the above copyright notice,
32*a8f7f3fcSMatthias Ringwald**      this list of conditions and the following disclaimer in the documentation
33*a8f7f3fcSMatthias Ringwald**      and/or other materials provided with the distribution.
34*a8f7f3fcSMatthias Ringwald**   3. Neither the name of STMicroelectronics nor the names of its contributors
35*a8f7f3fcSMatthias Ringwald**      may be used to endorse or promote products derived from this software
36*a8f7f3fcSMatthias Ringwald**      without specific prior written permission.
37*a8f7f3fcSMatthias Ringwald**
38*a8f7f3fcSMatthias Ringwald** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39*a8f7f3fcSMatthias Ringwald** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40*a8f7f3fcSMatthias Ringwald** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41*a8f7f3fcSMatthias Ringwald** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42*a8f7f3fcSMatthias Ringwald** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43*a8f7f3fcSMatthias Ringwald** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44*a8f7f3fcSMatthias Ringwald** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45*a8f7f3fcSMatthias Ringwald** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46*a8f7f3fcSMatthias Ringwald** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47*a8f7f3fcSMatthias Ringwald** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48*a8f7f3fcSMatthias Ringwald**
49*a8f7f3fcSMatthias Ringwald*****************************************************************************
50*a8f7f3fcSMatthias Ringwald*/
51*a8f7f3fcSMatthias Ringwald
52*a8f7f3fcSMatthias Ringwald/* Entry Point */
53*a8f7f3fcSMatthias RingwaldENTRY(Reset_Handler)
54*a8f7f3fcSMatthias Ringwald
55*a8f7f3fcSMatthias Ringwald/* Highest address of the user mode stack */
56*a8f7f3fcSMatthias Ringwald_estack = 0x20020000;    /* end of RAM */
57*a8f7f3fcSMatthias Ringwald/* Generate a link error if heap and stack don't fit into RAM */
58*a8f7f3fcSMatthias Ringwald_Min_Heap_Size = 0x200;      /* required amount of heap  */
59*a8f7f3fcSMatthias Ringwald_Min_Stack_Size = 0x400; /* required amount of stack */
60*a8f7f3fcSMatthias Ringwald
61*a8f7f3fcSMatthias Ringwald/* Specify the memory areas */
62*a8f7f3fcSMatthias RingwaldMEMORY
63*a8f7f3fcSMatthias Ringwald{
64*a8f7f3fcSMatthias RingwaldRAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K
65*a8f7f3fcSMatthias RingwaldCCMRAM (xrw)      : ORIGIN = 0x10000000, LENGTH = 64K
66*a8f7f3fcSMatthias RingwaldFLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 1024K
67*a8f7f3fcSMatthias Ringwald}
68*a8f7f3fcSMatthias Ringwald
69*a8f7f3fcSMatthias Ringwald/* Define output sections */
70*a8f7f3fcSMatthias RingwaldSECTIONS
71*a8f7f3fcSMatthias Ringwald{
72*a8f7f3fcSMatthias Ringwald  /* The startup code goes first into FLASH */
73*a8f7f3fcSMatthias Ringwald  .isr_vector :
74*a8f7f3fcSMatthias Ringwald  {
75*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
76*a8f7f3fcSMatthias Ringwald    KEEP(*(.isr_vector)) /* Startup code */
77*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
78*a8f7f3fcSMatthias Ringwald  } >FLASH
79*a8f7f3fcSMatthias Ringwald
80*a8f7f3fcSMatthias Ringwald  /* The program code and other data goes into FLASH */
81*a8f7f3fcSMatthias Ringwald  .text :
82*a8f7f3fcSMatthias Ringwald  {
83*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
84*a8f7f3fcSMatthias Ringwald    *(.text)           /* .text sections (code) */
85*a8f7f3fcSMatthias Ringwald    *(.text*)          /* .text* sections (code) */
86*a8f7f3fcSMatthias Ringwald    *(.glue_7)         /* glue arm to thumb code */
87*a8f7f3fcSMatthias Ringwald    *(.glue_7t)        /* glue thumb to arm code */
88*a8f7f3fcSMatthias Ringwald    *(.eh_frame)
89*a8f7f3fcSMatthias Ringwald
90*a8f7f3fcSMatthias Ringwald    KEEP (*(.init))
91*a8f7f3fcSMatthias Ringwald    KEEP (*(.fini))
92*a8f7f3fcSMatthias Ringwald
93*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
94*a8f7f3fcSMatthias Ringwald    _etext = .;        /* define a global symbols at end of code */
95*a8f7f3fcSMatthias Ringwald  } >FLASH
96*a8f7f3fcSMatthias Ringwald
97*a8f7f3fcSMatthias Ringwald  /* Constant data goes into FLASH */
98*a8f7f3fcSMatthias Ringwald  .rodata :
99*a8f7f3fcSMatthias Ringwald  {
100*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
101*a8f7f3fcSMatthias Ringwald    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
102*a8f7f3fcSMatthias Ringwald    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
103*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
104*a8f7f3fcSMatthias Ringwald  } >FLASH
105*a8f7f3fcSMatthias Ringwald
106*a8f7f3fcSMatthias Ringwald  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
107*a8f7f3fcSMatthias Ringwald  .ARM : {
108*a8f7f3fcSMatthias Ringwald    __exidx_start = .;
109*a8f7f3fcSMatthias Ringwald    *(.ARM.exidx*)
110*a8f7f3fcSMatthias Ringwald    __exidx_end = .;
111*a8f7f3fcSMatthias Ringwald  } >FLASH
112*a8f7f3fcSMatthias Ringwald
113*a8f7f3fcSMatthias Ringwald  .preinit_array     :
114*a8f7f3fcSMatthias Ringwald  {
115*a8f7f3fcSMatthias Ringwald    PROVIDE_HIDDEN (__preinit_array_start = .);
116*a8f7f3fcSMatthias Ringwald    KEEP (*(.preinit_array*))
117*a8f7f3fcSMatthias Ringwald    PROVIDE_HIDDEN (__preinit_array_end = .);
118*a8f7f3fcSMatthias Ringwald  } >FLASH
119*a8f7f3fcSMatthias Ringwald  .init_array :
120*a8f7f3fcSMatthias Ringwald  {
121*a8f7f3fcSMatthias Ringwald    PROVIDE_HIDDEN (__init_array_start = .);
122*a8f7f3fcSMatthias Ringwald    KEEP (*(SORT(.init_array.*)))
123*a8f7f3fcSMatthias Ringwald    KEEP (*(.init_array*))
124*a8f7f3fcSMatthias Ringwald    PROVIDE_HIDDEN (__init_array_end = .);
125*a8f7f3fcSMatthias Ringwald  } >FLASH
126*a8f7f3fcSMatthias Ringwald  .fini_array :
127*a8f7f3fcSMatthias Ringwald  {
128*a8f7f3fcSMatthias Ringwald    PROVIDE_HIDDEN (__fini_array_start = .);
129*a8f7f3fcSMatthias Ringwald    KEEP (*(SORT(.fini_array.*)))
130*a8f7f3fcSMatthias Ringwald    KEEP (*(.fini_array*))
131*a8f7f3fcSMatthias Ringwald    PROVIDE_HIDDEN (__fini_array_end = .);
132*a8f7f3fcSMatthias Ringwald  } >FLASH
133*a8f7f3fcSMatthias Ringwald
134*a8f7f3fcSMatthias Ringwald  /* used by the startup to initialize data */
135*a8f7f3fcSMatthias Ringwald  _sidata = LOADADDR(.data);
136*a8f7f3fcSMatthias Ringwald
137*a8f7f3fcSMatthias Ringwald  /* Initialized data sections goes into RAM, load LMA copy after code */
138*a8f7f3fcSMatthias Ringwald  .data :
139*a8f7f3fcSMatthias Ringwald  {
140*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
141*a8f7f3fcSMatthias Ringwald    _sdata = .;        /* create a global symbol at data start */
142*a8f7f3fcSMatthias Ringwald    *(.data)           /* .data sections */
143*a8f7f3fcSMatthias Ringwald    *(.data*)          /* .data* sections */
144*a8f7f3fcSMatthias Ringwald
145*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
146*a8f7f3fcSMatthias Ringwald    _edata = .;        /* define a global symbol at data end */
147*a8f7f3fcSMatthias Ringwald  } >RAM AT> FLASH
148*a8f7f3fcSMatthias Ringwald
149*a8f7f3fcSMatthias Ringwald  _siccmram = LOADADDR(.ccmram);
150*a8f7f3fcSMatthias Ringwald
151*a8f7f3fcSMatthias Ringwald  /* CCM-RAM section
152*a8f7f3fcSMatthias Ringwald  *
153*a8f7f3fcSMatthias Ringwald  * IMPORTANT NOTE!
154*a8f7f3fcSMatthias Ringwald  * If initialized variables will be placed in this section,
155*a8f7f3fcSMatthias Ringwald  * the startup code needs to be modified to copy the init-values.
156*a8f7f3fcSMatthias Ringwald  */
157*a8f7f3fcSMatthias Ringwald  .ccmram :
158*a8f7f3fcSMatthias Ringwald  {
159*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
160*a8f7f3fcSMatthias Ringwald    _sccmram = .;       /* create a global symbol at ccmram start */
161*a8f7f3fcSMatthias Ringwald    *(.ccmram)
162*a8f7f3fcSMatthias Ringwald    *(.ccmram*)
163*a8f7f3fcSMatthias Ringwald
164*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
165*a8f7f3fcSMatthias Ringwald    _eccmram = .;       /* create a global symbol at ccmram end */
166*a8f7f3fcSMatthias Ringwald  } >CCMRAM AT> FLASH
167*a8f7f3fcSMatthias Ringwald
168*a8f7f3fcSMatthias Ringwald
169*a8f7f3fcSMatthias Ringwald  /* Uninitialized data section */
170*a8f7f3fcSMatthias Ringwald  . = ALIGN(4);
171*a8f7f3fcSMatthias Ringwald  .bss :
172*a8f7f3fcSMatthias Ringwald  {
173*a8f7f3fcSMatthias Ringwald    /* This is used by the startup in order to initialize the .bss secion */
174*a8f7f3fcSMatthias Ringwald    _sbss = .;         /* define a global symbol at bss start */
175*a8f7f3fcSMatthias Ringwald    __bss_start__ = _sbss;
176*a8f7f3fcSMatthias Ringwald    *(.bss)
177*a8f7f3fcSMatthias Ringwald    *(.bss*)
178*a8f7f3fcSMatthias Ringwald    *(COMMON)
179*a8f7f3fcSMatthias Ringwald
180*a8f7f3fcSMatthias Ringwald    . = ALIGN(4);
181*a8f7f3fcSMatthias Ringwald    _ebss = .;         /* define a global symbol at bss end */
182*a8f7f3fcSMatthias Ringwald    __bss_end__ = _ebss;
183*a8f7f3fcSMatthias Ringwald  } >RAM
184*a8f7f3fcSMatthias Ringwald
185*a8f7f3fcSMatthias Ringwald  /* User_heap_stack section, used to check that there is enough RAM left */
186*a8f7f3fcSMatthias Ringwald  ._user_heap_stack :
187*a8f7f3fcSMatthias Ringwald  {
188*a8f7f3fcSMatthias Ringwald    . = ALIGN(8);
189*a8f7f3fcSMatthias Ringwald    PROVIDE ( end = . );
190*a8f7f3fcSMatthias Ringwald    PROVIDE ( _end = . );
191*a8f7f3fcSMatthias Ringwald    . = . + _Min_Heap_Size;
192*a8f7f3fcSMatthias Ringwald    . = . + _Min_Stack_Size;
193*a8f7f3fcSMatthias Ringwald    . = ALIGN(8);
194*a8f7f3fcSMatthias Ringwald  } >RAM
195*a8f7f3fcSMatthias Ringwald
196*a8f7f3fcSMatthias Ringwald
197*a8f7f3fcSMatthias Ringwald
198*a8f7f3fcSMatthias Ringwald  /* Remove information from the standard libraries */
199*a8f7f3fcSMatthias Ringwald  /DISCARD/ :
200*a8f7f3fcSMatthias Ringwald  {
201*a8f7f3fcSMatthias Ringwald    libc.a ( * )
202*a8f7f3fcSMatthias Ringwald    libm.a ( * )
203*a8f7f3fcSMatthias Ringwald    libgcc.a ( * )
204*a8f7f3fcSMatthias Ringwald  }
205*a8f7f3fcSMatthias Ringwald
206*a8f7f3fcSMatthias Ringwald  .ARM.attributes 0 : { *(.ARM.attributes) }
207*a8f7f3fcSMatthias Ringwald}
208*a8f7f3fcSMatthias Ringwald
209*a8f7f3fcSMatthias Ringwald
210