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 /* Storage for the address for the configuration section so we can grab it out of the hex file */
126 KEEP (*(.custom_defaults_start_address))
128 KEEP (*(.custom_defaults_end_address))
130 __custom_defaults_internal_start = .;
131 KEEP (*(.custom_defaults))
133 } >FLASH_CUSTOM_DEFAULTS
135 PROVIDE_HIDDEN (__custom_defaults_start = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) : __custom_defaults_internal_start);
136 PROVIDE_HIDDEN (__custom_defaults_end = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) + LENGTH(FLASH_CUSTOM_DEFAULTS_EXTENDED) : ORIGIN(FLASH_CUSTOM_DEFAULTS) + LENGTH(FLASH_CUSTOM_DEFAULTS));
138 /* used by the startup to initialize data */
139 _sidata = LOADADDR(.data);
141 /* Initialized data sections goes into RAM, load LMA copy after code */
145 _sdata = .; /* create a global symbol at data start */
146 *(.data) /* .data sections */
147 *(.data*) /* .data* sections */
150 _edata = .; /* define a global symbol at data end */
153 /* Uninitialized data section */
157 /* This is used by the startup in order to initialize the .bss secion */
158 _sbss = .; /* define a global symbol at bss start */
159 __bss_start__ = _sbss;
161 *(SORT_BY_ALIGNMENT(.bss*))
165 _ebss = .; /* define a global symbol at bss end */
169 /* used during startup to initialized fastram_data */
170 _sfastram_idata = LOADADDR(.fastram_data);
172 /* Initialized FAST_RAM section for unsuspecting developers */
176 _sfastram_data = .; /* create a global symbol at data start */
177 *(.fastram_data) /* .data sections */
178 *(.fastram_data*) /* .data* sections */
181 _efastram_data = .; /* define a global symbol at data end */
182 } >FASTRAM AT> FLASH1
185 .fastram_bss (NOLOAD) :
188 __fastram_bss_start__ = _sfastram_bss;
190 *(SORT_BY_ALIGNMENT(.fastram_bss*))
193 __fastram_bss_end__ = _efastram_bss;
196 .persistent_data (NOLOAD) :
198 __persistent_data_start__ = .;
201 __persistent_data_end__ = .;
204 .DMA_RAM_R (NOLOAD) :
208 PROVIDE(dma_ram_r_start = .);
209 _dma_ram_r_start__ = _sdma_ram_r;
211 PROVIDE(dma_ram_r_end = .);
213 _dma_ram_r_end__ = _edma_ram_r;
216 .DMA_RAM_W (NOLOAD) :
220 PROVIDE(dma_ram_w_start = .);
221 _dma_ram_w_start__ = _sdma_ram_w;
223 PROVIDE(dma_ram_w_end = .);
225 _dma_ram_w_end__ = _edma_ram_w;
228 .DMA_RAM_RW (NOLOAD) :
232 PROVIDE(dma_ram_rw_start = .);
233 _dma_ram_rw_start__ = _sdma_ram_rw;
235 PROVIDE(dma_ram_rw_end = .);
237 _dma_ram_rw_end__ = _edma_ram_rw;
240 /* User_heap_stack section, used to check that there is enough RAM left */
241 _heap_stack_end = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size;
242 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
243 . = _heap_stack_begin;
248 PROVIDE ( _end = . );
249 . = . + _Min_Heap_Size;
250 . = . + _Min_Stack_Size;
254 /* MEMORY_bank1 section, code must be located here explicitly */
255 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
258 *(.mb1text) /* .mb1text sections (code) */
259 *(.mb1text*) /* .mb1text* sections (code) */
260 *(.mb1rodata) /* read-only data (constants) */
264 /* Remove information from the standard libraries */
272 .ARM.attributes 0 : { *(.ARM.attributes) }