• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2*****************************************************************************
3**
4
5**  File        : stm32_flash.ld
6**
7**  Abstract    : Linker script for STM32L476RG Device with
8**                1024KByte FLASH, 128KByte RAM
9**
10**                Set heap size, stack size and stack location according
11**                to application requirements.
12**
13**                Set memory bank area and size if external memory is used.
14**
15**  Target      : STMicroelectronics STM32
16**
17**  Environment : Atollic TrueSTUDIO(R)
18**
19**  Distribution: The file is distributed as is, without any warranty
20**                of any kind.
21**
22**  (c)Copyright Atollic AB.
23**  You may use this file as-is or modify it according to the needs of your
24**  project. This file may only be built (assembled or compiled and linked)
25**  using the Atollic TrueSTUDIO(R) product. The use of this file together
26**  with other tools than Atollic TrueSTUDIO(R) is not permitted.
27**
28*****************************************************************************
29*/
30
31/* Entry Point */
32ENTRY(Reset_Handler)
33
34/* Highest address of the user mode stack */
35_estack = 0x20018000;    /* end of RAM */
36/* Generate a link error if heap and stack don't fit into RAM */
37_Min_Heap_Size = 0x200;      /* required amount of heap  */
38_Min_Stack_Size = 0xf000; /* required amount of stack */
39
40/* Specify the memory areas */
41MEMORY
42{
43RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 96K
44RAM2 (xrw)      : ORIGIN = 0x10000000, LENGTH = 32K
45FLASH (rx)      : ORIGIN = 0x8000000,  LENGTH = 1006K
46INTEGRITY (rx)  : ORIGIN = 0x80FB800,  LENGTH = 2K
47NVFILE (rx)     : ORIGIN = 0x80FC000,  LENGTH = 16K
48}
49
50/* Define output sections */
51SECTIONS
52{
53  /* The startup code goes first into FLASH */
54  .isr_vector :
55  {
56    . = ALIGN(4);
57    KEEP(*(.isr_vector)) /* Startup code */
58    . = ALIGN(4);
59  } >FLASH
60
61  /* The program code and other data goes into FLASH */
62  .text :
63  {
64    . = ALIGN(4);
65    *(.text)           /* .text sections (code) */
66    *(.text*)          /* .text* sections (code) */
67    *(.glue_7)         /* glue arm to thumb code */
68    *(.glue_7t)        /* glue thumb to arm code */
69    *(.eh_frame)
70
71    KEEP (*(.init))
72    KEEP (*(.fini))
73
74    . = ALIGN(4);
75    _etext = .;        /* define a global symbols at end of code */
76  } >FLASH
77
78  /* Constant data goes into FLASH */
79  .rodata :
80  {
81    . = ALIGN(4);
82    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
83    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
84    . = ALIGN(4);
85  } >FLASH
86
87  .integrity (NOLOAD):
88  {
89    . = ALIGN(4);
90    *(.integrity)         /* .integrity internal integrity protection of NVFile */
91    *(.integrity*)        /* .integrity* internal integrity protection of NVFile */
92    . = ALIGN(4);
93  } >INTEGRITY
94
95  .nvfile (NOLOAD):
96  {
97    . = ALIGN(4);
98    *(.nvfile)         /* .nvfile persisted NV storage for the TPM */
99    *(.nvfile*)        /* .nvfile* persisted NV storage for the TPM */
100    . = ALIGN(4);
101  } >NVFILE
102
103  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
104  .ARM : {
105    __exidx_start = .;
106    *(.ARM.exidx*)
107    __exidx_end = .;
108  } >FLASH
109
110  .preinit_array     :
111  {
112    PROVIDE_HIDDEN (__preinit_array_start = .);
113    KEEP (*(.preinit_array*))
114    PROVIDE_HIDDEN (__preinit_array_end = .);
115  } >FLASH
116  .init_array :
117  {
118    PROVIDE_HIDDEN (__init_array_start = .);
119    KEEP (*(SORT(.init_array.*)))
120    KEEP (*(.init_array*))
121    PROVIDE_HIDDEN (__init_array_end = .);
122  } >FLASH
123  .fini_array :
124  {
125    PROVIDE_HIDDEN (__fini_array_start = .);
126    KEEP (*(SORT(.fini_array.*)))
127    KEEP (*(.fini_array*))
128    PROVIDE_HIDDEN (__fini_array_end = .);
129  } >FLASH
130
131  /* used by the startup to initialize data */
132  _sidata = LOADADDR(.data);
133
134  /* Initialized data sections goes into RAM, load LMA copy after code */
135  .data :
136  {
137    . = ALIGN(4);
138    _sdata = .;        /* create a global symbol at data start */
139    *(.data)           /* .data sections */
140    *(.data*)          /* .data* sections */
141
142    . = ALIGN(4);
143    _edata = .;        /* define a global symbol at data end */
144  } >RAM AT> FLASH
145
146
147  /* Uninitialized data section */
148  . = ALIGN(4);
149  .bss2 :
150  {
151    . = ALIGN(4);
152    *(.ram2)
153    *(.ram2*)
154    Middlewares\Platform\Cancel.o
155    Middlewares\Platform\Clock.o
156    Middlewares\Platform\Entropy.o
157/*    Middlewares\Platform\LocalityPlat.o*/
158/*    Middlewares\Platform\NVMem.o*/
159    Middlewares\Platform\PlatformData.o
160/*    Middlewares\Platform\PowerPlat.o*/
161/*    Middlewares\Platform\PPPlat.o*/
162/*    Middlewares\Platform\RunCommand.o*/
163/*    Middlewares\Platform\Unique.o*/
164    . = ALIGN(4);
165  } >RAM2
166  .bss :
167  {
168    /* This is used by the startup in order to initialize the .bss secion */
169    _sbss = .;         /* define a global symbol at bss start */
170    __bss_start__ = _sbss;
171    *(.bss)
172    *(.bss*)
173    *(COMMON)
174
175    . = ALIGN(4);
176    _ebss = .;         /* define a global symbol at bss end */
177    __bss_end__ = _ebss;
178  } >RAM
179
180  /* User_heap_stack section, used to check that there is enough RAM left */
181  ._user_heap_stack :
182  {
183    . = ALIGN(4);
184    PROVIDE ( end = . );
185    PROVIDE ( _end = . );
186    . = . + _Min_Heap_Size;
187    . = . + _Min_Stack_Size;
188    . = ALIGN(4);
189  } >RAM
190
191
192
193  /* Remove information from the standard libraries */
194  /DISCARD/ :
195  {
196    libc.a ( * )
197    libm.a ( * )
198    libgcc.a ( * )
199  }
200
201  .ARM.attributes 0 : { *(.ARM.attributes) }
202}
203
204
205