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