2 *****************************************************************************
4 ** File : stm32_flash_g4_split.ld
6 ** Abstract : Common linker script for STM32 devices.
8 *****************************************************************************
14 /* Highest address of the user mode stack */
15 _Hot_Reboot_Flags_Size = 16;
16 _estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size; /* end of RAM */
18 /* Base address where the config is stored. */
19 __config_start = ORIGIN(FLASH_CONFIG);
20 __config_end = ORIGIN(FLASH_CONFIG) + LENGTH(FLASH_CONFIG);
22 /* Generate a link error if heap and stack don't fit into RAM */
23 _Min_Heap_Size = 0; /* required amount of heap */
24 _Min_Stack_Size = 0x800; /* required amount of stack */
26 /* Define output sections */
30 * The ISR vector table is loaded at the beginning of the FLASH,
31 * But it is linked (space reserved) at the beginning of the VECTAB region,
32 * which is aliased either to FLASH or RAM.
33 * When linked to RAM, the table can optionally be copied from FLASH to RAM
34 * for table relocation.
37 _isr_vector_table_flash_base = LOADADDR(.isr_vector);
38 PROVIDE (isr_vector_table_flash_base = _isr_vector_table_flash_base);
43 PROVIDE (isr_vector_table_base = .);
44 KEEP(*(.isr_vector)) /* Startup code */
46 PROVIDE (isr_vector_table_end = .);
49 /* System memory (read-only bootloader) interrupt vector */
50 .system_isr_vector (NOLOAD) :
53 PROVIDE (system_isr_vector_table_base = .);
54 KEEP(*(.system_isr_vector)) /* Bootloader code */
58 /* The program code and other data goes into FLASH */
62 *(.text) /* .text sections (code) */
63 *(.text*) /* .text* sections (code) */
64 *(.rodata) /* .rodata sections (constants, strings, etc.) */
65 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
66 *(.glue_7) /* glue arm to thumb code */
67 *(.glue_7t) /* glue thumb to arm code */
74 _etext = .; /* define a global symbols at end of code */
79 *(.ARM.extab* .gnu.linkonce.armextab.*)
90 PROVIDE_HIDDEN (__preinit_array_start = .);
91 KEEP (*(.preinit_array*))
92 PROVIDE_HIDDEN (__preinit_array_end = .);
96 PROVIDE_HIDDEN (__init_array_start = .);
97 KEEP (*(SORT(.init_array.*)))
98 KEEP (*(.init_array*))
99 PROVIDE_HIDDEN (__init_array_end = .);
103 PROVIDE_HIDDEN (__fini_array_start = .);
104 KEEP (*(.fini_array*))
105 KEEP (*(SORT(.fini_array.*)))
106 PROVIDE_HIDDEN (__fini_array_end = .);
110 PROVIDE_HIDDEN (__pg_registry_start = .);
111 KEEP (*(.pg_registry))
112 KEEP (*(SORT(.pg_registry.*)))
113 PROVIDE_HIDDEN (__pg_registry_end = .);
117 PROVIDE_HIDDEN (__pg_resetdata_start = .);
118 KEEP (*(.pg_resetdata))
119 PROVIDE_HIDDEN (__pg_resetdata_end = .);
122 /* used by the startup to initialize data */
123 _sidata = LOADADDR(.data);
125 /* Initialized data sections goes into RAM, load LMA copy after code */
129 _sdata = .; /* create a global symbol at data start */
130 *(.data) /* .data sections */
131 *(.data*) /* .data* sections */
134 _edata = .; /* define a global symbol at data end */
137 /* Uninitialized data section */
141 /* This is used by the startup in order to initialize the .bss secion */
142 _sbss = .; /* define a global symbol at bss start */
143 __bss_start__ = _sbss;
145 *(SORT_BY_ALIGNMENT(.bss*))
149 _ebss = .; /* define a global symbol at bss end */
153 /* used during startup to initialized fastram_data */
154 _sfastram_idata = LOADADDR(.fastram_data);
156 /* Initialized FAST_RAM section for unsuspecting developers */
160 _sfastram_data = .; /* create a global symbol at data start */
161 *(.fastram_data) /* .data sections */
162 *(.fastram_data*) /* .data* sections */
165 _efastram_data = .; /* define a global symbol at data end */
166 } >FASTRAM AT> FLASH1
169 .fastram_bss (NOLOAD) :
172 __fastram_bss_start__ = _sfastram_bss;
174 *(SORT_BY_ALIGNMENT(.fastram_bss*))
177 __fastram_bss_end__ = _efastram_bss;
180 .persistent_data (NOLOAD) :
182 __persistent_data_start__ = .;
185 __persistent_data_end__ = .;
188 .DMA_RAM_R (NOLOAD) :
192 PROVIDE(dma_ram_r_start = .);
193 _dma_ram_r_start__ = _sdma_ram_r;
195 PROVIDE(dma_ram_r_end = .);
197 _dma_ram_r_end__ = _edma_ram_r;
200 .DMA_RAM_W (NOLOAD) :
204 PROVIDE(dma_ram_w_start = .);
205 _dma_ram_w_start__ = _sdma_ram_w;
207 PROVIDE(dma_ram_w_end = .);
209 _dma_ram_w_end__ = _edma_ram_w;
212 .DMA_RAM_RW (NOLOAD) :
216 PROVIDE(dma_ram_rw_start = .);
217 _dma_ram_rw_start__ = _sdma_ram_rw;
219 PROVIDE(dma_ram_rw_end = .);
221 _dma_ram_rw_end__ = _edma_ram_rw;
224 /* User_heap_stack section, used to check that there is enough RAM left */
225 _heap_stack_end = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size;
226 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
227 . = _heap_stack_begin;
232 PROVIDE ( _end = . );
233 . = . + _Min_Heap_Size;
234 . = . + _Min_Stack_Size;
238 /* MEMORY_bank1 section, code must be located here explicitly */
239 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
242 *(.mb1text) /* .mb1text sections (code) */
243 *(.mb1text*) /* .mb1text* sections (code) */
244 *(.mb1rodata) /* read-only data (constants) */
248 /* Remove information from the standard libraries */
256 .ARM.attributes 0 : { *(.ARM.attributes) }