-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstm32f401xc.ld
executable file
·138 lines (116 loc) · 3.42 KB
/
stm32f401xc.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
/* Program Entry, set to mark it as "used" and avoid gcc warnings */
ENTRY(Startup_ResetHandler)
/* Memory Spaces Definitions */
MEMORY
{
FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 256K
SRAM1 (RWX) : ORIGIN = 0x20000000, LENGTH = 64K
}
/* code/data sections */
SECTIONS
{
/* basic memory layout: SRAM */
__sram_size = LENGTH(SRAM1);
__sram_addr = ORIGIN(SRAM1);
/* 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))
/* flash code section */
*(.flash_code)
*(.flash_code.*)
/* Program code */
*(.text)
*(.text.*)
*(.stub .gnu.linkonce.t.*)
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.init)
*(.fini)
/* 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.*)
} > SRAM1
/* SRAM memory (uninitialized data) */
.bss (NOLOAD) : ALIGN(4)
{
*(.bss)
*(.bss.*)
*(COMMON)
} > SRAM1
/* 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;
} > SRAM1 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;
} > SRAM1 AT > FLASH
/* bss start-end */
__bss_addr = ADDR(.bss);
__bss_size = SIZEOF(.bss);
/* stack pointer */
__stack = ORIGIN(SRAM1) + LENGTH(SRAM1);
/* 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")
}