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 = .;
132 } >FLASH_CUSTOM_DEFAULTS
134 PROVIDE_HIDDEN (__custom_defaults_start = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) : __custom_defaults_internal_start);
135 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));
137 /* used by the startup to initialize data */
138 _sidata = LOADADDR(.data);
140 /* Initialized data sections goes into RAM, load LMA copy after code */
144 _sdata = .; /* create a global symbol at data start */
145 *(.data) /* .data sections */
146 *(.data*) /* .data* sections */
149 _edata = .; /* define a global symbol at data end */
152 /* Uninitialized data section */
156 /* This is used by the startup in order to initialize the .bss secion */
157 _sbss = .; /* define a global symbol at bss start */
158 __bss_start__ = _sbss;
160 *(SORT_BY_ALIGNMENT(.bss*))
164 _ebss = .; /* define a global symbol at bss end */
168 /* used during startup to initialized fastram_data */
169 _sfastram_idata = LOADADDR(.fastram_data);
171 /* Initialized FAST_RAM section for unsuspecting developers */
175 _sfastram_data = .; /* create a global symbol at data start */
176 *(.fastram_data) /* .data sections */
177 *(.fastram_data*) /* .data* sections */
180 _efastram_data = .; /* define a global symbol at data end */
181 } >FASTRAM AT> FLASH1
184 .fastram_bss (NOLOAD) :
187 __fastram_bss_start__ = _sfastram_bss;
189 *(SORT_BY_ALIGNMENT(.fastram_bss*))
192 __fastram_bss_end__ = _efastram_bss;
195 .persistent_data (NOLOAD) :
197 __persistent_data_start__ = .;
200 __persistent_data_end__ = .;
203 .DMA_RAM_R (NOLOAD) :
207 PROVIDE(dma_ram_r_start = .);
208 _dma_ram_r_start__ = _sdma_ram_r;
210 PROVIDE(dma_ram_r_end = .);
212 _dma_ram_r_end__ = _edma_ram_r;
215 .DMA_RAM_W (NOLOAD) :
219 PROVIDE(dma_ram_w_start = .);
220 _dma_ram_w_start__ = _sdma_ram_w;
222 PROVIDE(dma_ram_w_end = .);
224 _dma_ram_w_end__ = _edma_ram_w;
227 .DMA_RAM_RW (NOLOAD) :
231 PROVIDE(dma_ram_rw_start = .);
232 _dma_ram_rw_start__ = _sdma_ram_rw;
234 PROVIDE(dma_ram_rw_end = .);
236 _dma_ram_rw_end__ = _edma_ram_rw;
239 /* User_heap_stack section, used to check that there is enough RAM left */
240 _heap_stack_end = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size;
241 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
242 . = _heap_stack_begin;
247 PROVIDE ( _end = . );
248 . = . + _Min_Heap_Size;
249 . = . + _Min_Stack_Size;
253 /* MEMORY_bank1 section, code must be located here explicitly */
254 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
257 *(.mb1text) /* .mb1text sections (code) */
258 *(.mb1text*) /* .mb1text* sections (code) */
259 *(.mb1rodata) /* read-only data (constants) */
263 /* Remove information from the standard libraries */
271 .ARM.attributes 0 : { *(.ARM.attributes) }