1- /* *
2- ******************************************************************************
3- * @file LinkerScript.ld
4- * @author Auto-generated by STM32CubeIDE
5- * @brief Linker script for STM32L412RBxP Device from STM32L4 series
6- * 128Kbytes FLASH
7- * 40Kbytes RAM
8- *
9- * Set heap size, stack size and stack location according
10- * to application requirements.
11- *
12- * Set memory bank area and size if external memory is used
13- ******************************************************************************
14- * @attention
15- *
16- * <h2><center>© Copyright (c) 2020 STMicroelectronics.
17- * All rights reserved.</center></h2>
18- *
19- * This software component is licensed by ST under BSD 3-Clause license,
20- * the "License"; You may not use this file except in compliance with the
21- * License. You may obtain a copy of the License at:
22- * opensource.org/licenses/BSD-3-Clause
23- *
24- ******************************************************************************
25- */
1+ /*
2+ ******************************************************************************
3+ **
4+
5+ ** File : LinkerScript.ld
6+ **
7+ ** Author : STM32CubeMX
8+ **
9+ ** Abstract : Linker script for STM32L412RBTxP series
10+ ** 128Kbytes FLASH and 40Kbytes RAM
11+ **
12+ ** Set heap size, stack size and stack location according
13+ ** to application requirements.
14+ **
15+ ** Set memory bank area and size if external memory is used.
16+ **
17+ ** Target : STMicroelectronics STM32
18+ ** Distribution: The file is distributed “as is,” without any warranty
19+ ** of any kind.
20+ **
21+ *****************************************************************************
22+ ** @attention
23+ **
24+ ** <h2><center>© COPYRIGHT(c) 2025 STMicroelectronics</center></h2>
25+ **
26+ ** Redistribution and use in source and binary forms, with or without modification,
27+ ** are permitted provided that the following conditions are met:
28+ ** 1. Redistributions of source code must retain the above copyright notice,
29+ ** this list of conditions and the following disclaimer.
30+ ** 2. Redistributions in binary form must reproduce the above copyright notice,
31+ ** this list of conditions and the following disclaimer in the documentation
32+ ** and/or other materials provided with the distribution.
33+ ** 3. Neither the name of STMicroelectronics nor the names of its contributors
34+ ** may be used to endorse or promote products derived from this software
35+ ** without specific prior written permission.
36+ **
37+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38+ ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39+ ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40+ ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
41+ ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42+ ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43+ ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
44+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45+ ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47+ **
48+ *****************************************************************************
49+ */
2650
2751/* Entry Point */
2852ENTRY (Reset_Handler)
2953
3054/* Highest address of the user mode stack */
31- _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
55+ _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
56+ /* Generate a link error if heap and stack don't fit into RAM */
57+ _Min_Heap_Size = 0x200 ; /* required amount of heap */
58+ _Min_Stack_Size = 0x400 ; /* required amount of stack */
3259
33- _Min_Heap_Size = 0x200 ; /* required amount of heap */
34- _Min_Stack_Size = 0x400 ; /* required amount of stack */
35-
36- /* Memories definition */
60+ /* Specify the memory areas */
3761MEMORY
3862{
39- RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = LD_MAX_DATA_SIZE
40- FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
63+ RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = 32K
64+ RAM2 (xrw) : ORIGIN = 0x10000000 , LENGTH = 8K
65+ FLASH (rx) : ORIGIN = 0x8000000 , LENGTH = 128K
4166}
4267
43- /* Sections */
68+ /* Define output sections */
4469SECTIONS
4570{
46- /* The startup code into "FLASH" Rom type memory */
71+ /* The startup code goes first into FLASH */
4772 .isr_vector :
4873 {
49- . = ALIGN (4 );
74+ . = ALIGN (8 );
5075 KEEP (*(.isr_vector )) /* Startup code */
51- . = ALIGN (4 );
76+ . = ALIGN (8 );
5277 } >FLASH
5378
54- /* The program code and other data into " FLASH" Rom type memory */
79+ /* The program code and other data goes into FLASH */
5580 .text :
5681 {
57- . = ALIGN (4 );
82+ . = ALIGN (8 );
5883 *(.text ) /* .text sections (code) */
5984 *(.text *) /* .text* sections (code) */
6085 *(.glue_7 ) /* glue arm to thumb code */
@@ -64,83 +89,88 @@ SECTIONS
6489 KEEP (*(.init ))
6590 KEEP (*(.fini ))
6691
67- . = ALIGN (4 );
92+ . = ALIGN (8 );
6893 _etext = .; /* define a global symbols at end of code */
6994 } >FLASH
7095
71- /* Constant data into " FLASH" Rom type memory */
96+ /* Constant data goes into FLASH */
7297 .rodata :
7398 {
74- . = ALIGN (4 );
99+ . = ALIGN (8 );
75100 *(.rodata ) /* .rodata sections (constants, strings, etc.) */
76101 *(.rodata *) /* .rodata* sections (constants, strings, etc.) */
77- . = ALIGN (4 );
102+ . = ALIGN (8 );
78103 } >FLASH
79104
80- .ARM .extab (READONLY) : {
81- . = ALIGN (4 );
82- *(.ARM .extab * .gnu .linkonce .armextab .*)
83- . = ALIGN (4 );
105+ .ARM .extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
106+ {
107+ . = ALIGN (8 );
108+ *(.ARM .extab * .gnu .linkonce .armextab .*)
109+ . = ALIGN (8 );
84110 } >FLASH
85111
86- .ARM (READONLY) : {
87- . = ALIGN (4 );
112+ .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
113+ {
114+ . = ALIGN (8 );
88115 __exidx_start = .;
89116 *(.ARM .exidx *)
90117 __exidx_end = .;
91- . = ALIGN (4 );
118+ . = ALIGN (8 );
92119 } >FLASH
93120
94- .preinit_array (READONLY) :
121+ .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
95122 {
96- . = ALIGN (4 );
123+ . = ALIGN (8 );
97124 PROVIDE_HIDDEN (__preinit_array_start = .);
98125 KEEP (*(.preinit_array *))
99126 PROVIDE_HIDDEN (__preinit_array_end = .);
100- . = ALIGN (4 );
127+ . = ALIGN (8 );
101128 } >FLASH
102-
103- .init_array (READONLY) :
129+
130+ .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
104131 {
105- . = ALIGN (4 );
132+ . = ALIGN (8 );
106133 PROVIDE_HIDDEN (__init_array_start = .);
107134 KEEP (*(SORT (.init_array .*)))
108135 KEEP (*(.init_array *))
109136 PROVIDE_HIDDEN (__init_array_end = .);
110- . = ALIGN (4 );
137+ . = ALIGN (8 );
111138 } >FLASH
112139
113- .fini_array (READONLY) :
140+ .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
141+
114142 {
115- . = ALIGN (4 );
143+ . = ALIGN (8 );
116144 PROVIDE_HIDDEN (__fini_array_start = .);
117145 KEEP (*(SORT (.fini_array .*)))
118146 KEEP (*(.fini_array *))
119147 PROVIDE_HIDDEN (__fini_array_end = .);
120- . = ALIGN (4 );
148+ . = ALIGN (8 );
121149 } >FLASH
122150
123- /* Used by the startup to initialize data */
151+ /* used by the startup to initialize data */
124152 _sidata = LOADADDR (.data );
125153
126- /* Initialized data sections into " RAM" Ram type memory */
127- .data :
154+ /* Initialized data sections goes into RAM, load LMA copy after code */
155+ .data :
128156 {
129- . = ALIGN (4 );
157+ . = ALIGN (8 );
130158 _sdata = .; /* create a global symbol at data start */
131159 *(.data ) /* .data sections */
132160 *(.data *) /* .data* sections */
161+ *(.RamFunc ) /* .RamFunc sections */
162+ *(.RamFunc *) /* .RamFunc* sections */
133163
134- . = ALIGN (4 );
164+ . = ALIGN (8 );
135165 _edata = .; /* define a global symbol at data end */
136-
137166 } >RAM AT> FLASH
138167
139- /* Uninitialized data section into "RAM" Ram type memory */
168+
169+ /* Uninitialized data section */
140170 . = ALIGN (4 );
141171 .bss :
142172 {
143- /* This is used by the startup in order to initialize the .bss section */
173+ /* This is used by the startup in order to initialize the .bss secion */
144174 _sbss = .; /* define a global symbol at bss start */
145175 __bss_start__ = _sbss;
146176 *(.bss )
@@ -152,7 +182,7 @@ SECTIONS
152182 __bss_end__ = _ebss;
153183 } >RAM
154184
155- /* User_heap_stack section, used to check that there is enough " RAM" Ram type memory left */
185+ /* User_heap_stack section, used to check that there is enough RAM left */
156186 ._user_heap_stack :
157187 {
158188 . = ALIGN (8 );
@@ -163,13 +193,16 @@ SECTIONS
163193 . = ALIGN (8 );
164194 } >RAM
165195
166- /* Remove information from the compiler libraries */
196+
197+
198+ /* Remove information from the standard libraries */
167199 /DISCARD/ :
168200 {
169201 libc.a ( * )
170202 libm.a ( * )
171203 libgcc.a ( * )
172204 }
173205
174- .ARM .attributes 0 : { *(.ARM .attributes ) }
175206}
207+
208+
0 commit comments