-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstm32l476rgt6.ld
163 lines (137 loc) · 3.89 KB
/
stm32l476rgt6.ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* Program Entry, set to mark it as "used" and avoid gcc warnings */
ENTRY(Startup_ResetHandler)
/* Memory Spaces Definitions */
MEMORY
{
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 96K
SRAM2 (RWX) : ORIGIN = 0x10000000, LENGTH = 32K
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 512K
}
/* code/data sections */
SECTIONS
{
/* basic memory layout: SRAM */
__sram_size = LENGTH(SRAM);
__sram_addr = ORIGIN(SRAM);
/* basic memory layout: SRAM2 */
__sram2_size = LENGTH(SRAM2);
__sram2_addr = ORIGIN(SRAM2);
/* basic memory layout: FLASH */
__flash_size = LENGTH(FLASH);
__flash_addr = ORIGIN(FLASH);
/*
* FLASH MEMORY AREA
*/
/* code */
.flash_code :
{
/* flash code starts here */
__flash_code_addr = ABSOLUTE(.);
/* exception & interrupt vectors */
__flash_vectors = ABSOLUTE(.);
/* make sure that these stay in the output file */
KEEP(*(.flash_vectors))
/* Program code */
*(.text)
*(.text.*)
*(.stub .gnu.linkonce.t.*)
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
/* read-only data */
*(.rodata .rodata.*)
/* align code to 4 bytes */
. = ALIGN(4);
} > FLASH
/* flash data */
.flash_data :
{
*(.flash_data)
*(.flash_data.*)
. = ALIGN(4);
} > FLASH
/* needed for 64 bit division */
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
.ARM.extab : {
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
/* flash code ends here */
__flash_code_size = . - __flash_code_addr;
/* all data/code to be initialized from flash will go here */
__flash_sram_init_src_addr = .;
/*
* SRAM MEMORY AREA
*/
/* SRAM memory (not initialized data) */
.no_init (NOLOAD) : ALIGN(4)
{
*(.no_init)
*(.no_init.*)
} > SRAM
/* SRAM memory (uninitialized data) */
.bss (NOLOAD) : ALIGN(4)
{
*(.bss)
*(.bss.*)
*(COMMON)
} > SRAM
/* code in sram memory */
.ram_code ALIGN(4) :
{
/* start of the ram_code section address */
__ram_code_addr = ABSOLUTE(.);
/* ram code */
*(.ram_code)
*(.ram_code.*)
/* size of the ram code section */
__ram_code_size = ABSOLUTE(.) - __ram_code_addr;
} > SRAM AT > FLASH
/* initialized data in sram memory */
.data ALIGN(4) :
{
/* start of the data section address */
__data_addr = ABSOLUTE(.);
/* data memory */
*(.data)
*(.data.*)
/* put a memory guard here */
*(.mem_guard)
KEEP(*(.mem_guard))
/* data section size */
__data_size = ABSOLUTE(.) - __data_addr;
} > SRAM AT > FLASH
/*
* SRAM2 MEMORY AREA
*/
/* sram2 memory (uninitialized data) */
.bss2 (NOLOAD) : ALIGN(4)
{
*(.bss2)
*(.bss2.*)
} > SRAM2
/* sram2 memory (initialized data) */
.data2 ALIGN(4) :
{
/* start of the data section address */
__data2_addr = ABSOLUTE(.);
*(.data2)
*(.data2.*)
/* data section size */
__data2_size = ABSOLUTE(.) - __data2_addr;
} > SRAM2 AT > FLASH
/* bss start-end */
__bss_addr = ADDR(.bss);
__bss_size = SIZEOF(.bss);
/* bss2 start-end */
__bss2_addr = ADDR(.bss2);
__bss2_size = SIZEOF(.bss2);
/* stack pointer */
__stack = ORIGIN(SRAM) + LENGTH(SRAM);
/* complete flash image size */
__flash_image_size = __flash_code_size + __ram_code_size + __data_size;
/* sanity check */
ASSERT(__flash_image_size <= LENGTH(FLASH),
"FLASH MEMORY LIMIT EXCEEDED")
}