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