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