1/*
2*****************************************************************************
3**
4
5**  File        : stm32_flash.ld
6**
7**  Abstract    : Linker script for STM32L4A6RG Device with
8**                1024KByte FLASH, 320KByte 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 = 0x20050000;    /* 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 = 0x10000; /* required amount of stack */
39
40/* Specify the memory areas */
41MEMORY
42{
43RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 320K
44FLASH (rx)      : ORIGIN = 0x8000000,  LENGTH = 1006K
45INTEGRITY (rx)  : ORIGIN = 0x80FB800,  LENGTH = 2K
46NVFILE (rx)     : ORIGIN = 0x80FC000,  LENGTH = 16K
47}
48
49/* Define output sections */
50SECTIONS
51{
52  /* The startup code goes first into FLASH */
53  .isr_vector :
54  {
55    . = ALIGN(4);
56    KEEP(*(.isr_vector)) /* Startup code */
57    . = ALIGN(4);
58  } >FLASH
59
60  /* The program code and other data goes into FLASH */
61  .text :
62  {
63    . = ALIGN(4);
64    *(.text)           /* .text sections (code) */
65    *(.text*)          /* .text* sections (code) */
66    *(.glue_7)         /* glue arm to thumb code */
67    *(.glue_7t)        /* glue thumb to arm code */
68    *(.eh_frame)
69
70    KEEP (*(.init))
71    KEEP (*(.fini))
72
73    . = ALIGN(4);
74    _etext = .;        /* define a global symbols at end of code */
75  } >FLASH
76
77  /* Constant data goes into FLASH */
78  .rodata :
79  {
80    . = ALIGN(4);
81    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
82    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
83    . = ALIGN(4);
84  } >FLASH
85
86  .integrity (NOLOAD):
87  {
88    . = ALIGN(4);
89    *(.integrity)         /* .integrity internal integrity protection of NVFile */
90    *(.integrity*)        /* .integrity* internal integrity protection of NVFile */
91    . = ALIGN(4);
92  } >INTEGRITY
93
94  .nvfile (NOLOAD):
95  {
96    . = ALIGN(4);
97    *(.nvfile)         /* .nvfile persisted NV storage for the TPM */
98    *(.nvfile*)        /* .nvfile* persisted NV storage for the TPM */
99    . = ALIGN(4);
100  } >NVFILE
101
102  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
103  .ARM : {
104    __exidx_start = .;
105    *(.ARM.exidx*)
106    __exidx_end = .;
107  } >FLASH
108
109  .preinit_array     :
110  {
111    PROVIDE_HIDDEN (__preinit_array_start = .);
112    KEEP (*(.preinit_array*))
113    PROVIDE_HIDDEN (__preinit_array_end = .);
114  } >FLASH
115  .init_array :
116  {
117    PROVIDE_HIDDEN (__init_array_start = .);
118    KEEP (*(SORT(.init_array.*)))
119    KEEP (*(.init_array*))
120    PROVIDE_HIDDEN (__init_array_end = .);
121  } >FLASH
122  .fini_array :
123  {
124    PROVIDE_HIDDEN (__fini_array_start = .);
125    KEEP (*(SORT(.fini_array.*)))
126    KEEP (*(.fini_array*))
127    PROVIDE_HIDDEN (__fini_array_end = .);
128  } >FLASH
129
130  /* used by the startup to initialize data */
131  _sidata = LOADADDR(.data);
132
133  /* Initialized data sections goes into RAM, load LMA copy after code */
134  .data :
135  {
136    . = ALIGN(4);
137    _sdata = .;        /* create a global symbol at data start */
138    *(.data)           /* .data sections */
139    *(.data*)          /* .data* sections */
140
141    . = ALIGN(4);
142    _edata = .;        /* define a global symbol at data end */
143  } >RAM AT> FLASH
144
145
146  /* Uninitialized data section */
147  . = ALIGN(4);
148  .bss :
149  {
150    /* This is used by the startup in order to initialize the .bss secion */
151    _sbss = .;         /* define a global symbol at bss start */
152    __bss_start__ = _sbss;
153    *(.bss)
154    *(.bss*)
155    *(COMMON)
156
157    . = ALIGN(4);
158    _ebss = .;         /* define a global symbol at bss end */
159    __bss_end__ = _ebss;
160  } >RAM
161
162  /* User_heap_stack section, used to check that there is enough RAM left */
163  ._user_heap_stack :
164  {
165    . = ALIGN(4);
166    PROVIDE ( end = . );
167    PROVIDE ( _end = . );
168    . = . + _Min_Heap_Size;
169    . = . + _Min_Stack_Size;
170    . = ALIGN(4);
171  } >RAM
172
173
174
175  /* Remove information from the standard libraries */
176  /DISCARD/ :
177  {
178    libc.a ( * )
179    libm.a ( * )
180    libgcc.a ( * )
181  }
182
183  .ARM.attributes 0 : { *(.ARM.attributes) }
184}
185
186
187