1 | /*
|
2 | *****************************************************************************
|
3 | **
|
4 | ** File : stm32_flash.ld
|
5 | **
|
6 | ** Abstract : Linker script for STM32F103VB Device with
|
7 | ** 128KByte FLASH, 20KByte 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 | ** Target : STMicroelectronics STM32
|
15 | **
|
16 | ** Environment : Atollic TrueSTUDIO(R)
|
17 | **
|
18 | ** Distribution: The file is distributed “as is,” without any warranty
|
19 | ** of any kind.
|
20 | **
|
21 | ** (c)Copyright Atollic AB.
|
22 | ** You may use this file as-is or modify it according to the needs of your
|
23 | ** project. Distribution of this file (unmodified or modified) is not
|
24 | ** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
|
25 | ** rights to distribute the assembled, compiled & linked contents of this
|
26 | ** file as part of an application binary file, provided that it is built
|
27 | ** using the Atollic TrueSTUDIO(R) toolchain.
|
28 | **
|
29 | *****************************************************************************
|
30 | */
|
31 |
|
32 | /* Entry Point */
|
33 | ENTRY(Reset_Handler)
|
34 |
|
35 | /* Highest address of the user mode stack */
|
36 | _estack = 0x20005000; /* end of 20K RAM */
|
37 |
|
38 | /* Generate a link error if heap and stack don't fit into RAM */
|
39 | _Min_Heap_Size = 0; /* required amount of heap */
|
40 | _Min_Stack_Size = 0x100; /* required amount of stack */
|
41 |
|
42 | /* Specify the memory areas */
|
43 | MEMORY
|
44 | {
|
45 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
46 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
|
47 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
48 | }
|
49 |
|
50 | /* Define output sections */
|
51 | SECTIONS
|
52 | {
|
53 |
|
54 |
|
55 |
|
56 | /* The startup code goes first into FLASH */
|
57 | .isr_vector :
|
58 | {
|
59 | . = ALIGN(4);
|
60 | KEEP(*(.isr_vector)) /* Startup code */
|
61 | . = ALIGN(4);
|
62 | } >FLASH
|
63 |
|
64 | /* The program code and other data goes into FLASH */
|
65 | .text :
|
66 | {
|
67 | . = ALIGN(4);
|
68 | *(.text) /* .text sections (code) */
|
69 | *(.text*) /* .text* sections (code) */
|
70 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
|
71 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
72 | *(.glue_7) /* glue arm to thumb code */
|
73 | *(.glue_7t) /* glue thumb to arm code */
|
74 |
|
75 | KEEP (*(.init))
|
76 | KEEP (*(.fini))
|
77 |
|
78 | . = ALIGN(4);
|
79 | _etext = .; /* define a global symbols at end of code */
|
80 | } >FLASH
|
81 |
|
82 |
|
83 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
84 | .ARM : {
|
85 | __exidx_start = .;
|
86 | *(.ARM.exidx*)
|
87 | __exidx_end = .;
|
88 | } >FLASH
|
89 |
|
90 | .ARM.attributes : { *(.ARM.attributes) } > FLASH
|
91 |
|
92 | .preinit_array :
|
93 | {
|
94 | PROVIDE_HIDDEN (__preinit_array_start = .);
|
95 | KEEP (*(.preinit_array*))
|
96 | PROVIDE_HIDDEN (__preinit_array_end = .);
|
97 | } >FLASH
|
98 | .init_array :
|
99 | {
|
100 | PROVIDE_HIDDEN (__init_array_start = .);
|
101 | KEEP (*(SORT(.init_array.*)))
|
102 | KEEP (*(.init_array*))
|
103 | PROVIDE_HIDDEN (__init_array_end = .);
|
104 | } >FLASH
|
105 | .fini_array :
|
106 | {
|
107 | PROVIDE_HIDDEN (__fini_array_start = .);
|
108 | KEEP (*(.fini_array*))
|
109 | KEEP (*(SORT(.fini_array.*)))
|
110 | PROVIDE_HIDDEN (__fini_array_end = .);
|
111 | } >FLASH
|
112 |
|
113 | /* used by the startup to initialize data */
|
114 | _sidata = .;
|
115 |
|
116 | /* Initialized data sections goes into RAM, load LMA copy after code */
|
117 | .data : AT ( _sidata )
|
118 | {
|
119 | . = ALIGN(4);
|
120 | _sdata = .; /* create a global symbol at data start */
|
121 | *(.data) /* .data sections */
|
122 | *(.data*) /* .data* sections */
|
123 |
|
124 | . = ALIGN(4);
|
125 | _edata = .; /* define a global symbol at data end */
|
126 | } >RAM
|
127 |
|
128 | /* Uninitialized data section */
|
129 | . = ALIGN(4);
|
130 | .bss :
|
131 | {
|
132 | /* This is used by the startup in order to initialize the .bss secion */
|
133 | _sbss = .; /* define a global symbol at bss start */
|
134 | __bss_start__ = _sbss;
|
135 | *(.bss)
|
136 | *(.bss*)
|
137 | *(COMMON)
|
138 |
|
139 | . = ALIGN(4);
|
140 | _ebss = .; /* define a global symbol at bss end */
|
141 | __bss_end__ = _ebss;
|
142 | } >RAM
|
143 |
|
144 | PROVIDE ( end = _ebss );
|
145 | PROVIDE ( _end = _ebss );
|
146 |
|
147 | /* User_heap_stack section, used to check that there is enough RAM left */
|
148 | ._user_heap_stack :
|
149 | {
|
150 | . = ALIGN(4);
|
151 | . = . + _Min_Heap_Size;
|
152 | . = . + _Min_Stack_Size;
|
153 | . = ALIGN(4);
|
154 | } >RAM
|
155 |
|
156 | /* MEMORY_bank1 section, code must be located here explicitly */
|
157 | /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
158 | .memory_b1_text :
|
159 | {
|
160 | *(.mb1text) /* .mb1text sections (code) */
|
161 | *(.mb1text*) /* .mb1text* sections (code) */
|
162 | *(.mb1rodata) /* read-only data (constants) */
|
163 | *(.mb1rodata*)
|
164 | } >MEMORY_B1
|
165 |
|
166 | /* Remove information from the standard libraries */
|
167 | /DISCARD/ :
|
168 | {
|
169 | libc.a ( * )
|
170 | libm.a ( * )
|
171 | libgcc.a ( * )
|
172 | libgcc.a
|
173 | libg.a
|
174 | libnosys.a
|
175 | }
|
176 | }
|