2 *****************************************************************************
4 ** File : at32_flash_f4_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 = 0x200; /* required amount of heap */
24 _Min_Stack_Size = 0x400; /* 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 = .);
51 /* System memory (read-only bootloader) interrupt vector */
52 .system_isr_vector (NOLOAD) :
55 PROVIDE (system_isr_vector_table_base = .);
56 KEEP(*(.system_isr_vector)) /* Bootloader code */
60 /* The program code and other data goes into FLASH */
64 *(.text) /* .text sections (code) */
65 *(.text*) /* .text* sections (code) */
66 *(.rodata) /* .rodata sections (constants, strings, etc.) */
67 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
68 *(.glue_7) /* glue arm to thumb code */
69 *(.glue_7t) /* glue thumb to arm code */
76 _etext = .; /* define a global symbols at end of code */
80 /* Critical program code goes into ZW RAM1 */
81 /* Copy specific fast-executing code to ITCM RAM */
82 tcm_code = LOADADDR(.tcm_code);
94 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
103 PROVIDE_HIDDEN (__busdev_registry_start = .);
104 KEEP (*(.busdev_registry))
105 KEEP (*(SORT(.busdev_registry.*)))
106 PROVIDE_HIDDEN (__busdev_registry_end = .);
110 PROVIDE_HIDDEN (__preinit_array_start = .);
111 KEEP (*(.preinit_array*))
112 PROVIDE_HIDDEN (__preinit_array_end = .);
116 PROVIDE_HIDDEN (__init_array_start = .);
117 KEEP (*(SORT(.init_array.*)))
118 KEEP (*(.init_array*))
119 PROVIDE_HIDDEN (__init_array_end = .);
123 PROVIDE_HIDDEN (__fini_array_start = .);
124 KEEP (*(.fini_array*))
125 KEEP (*(SORT(.fini_array.*)))
126 PROVIDE_HIDDEN (__fini_array_end = .);
130 PROVIDE_HIDDEN (__pg_registry_start = .);
131 KEEP (*(.pg_registry))
132 KEEP (*(SORT(.pg_registry.*)))
133 PROVIDE_HIDDEN (__pg_registry_end = .);
137 PROVIDE_HIDDEN (__pg_resetdata_start = .);
138 KEEP (*(.pg_resetdata))
139 PROVIDE_HIDDEN (__pg_resetdata_end = .);
142 /* Storage for the address for the configuration section so we can grab it out of the hex file */
146 KEEP (*(.custom_defaults_start_address))
148 KEEP (*(.custom_defaults_end_address))
150 __custom_defaults_internal_start = .;
152 } >FLASH_CUSTOM_DEFAULTS
154 PROVIDE_HIDDEN (__custom_defaults_start = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) : __custom_defaults_internal_start);
155 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));
157 /* used by the startup to initialize data */
158 _sidata = LOADADDR(.data);
160 /* Initialized data sections goes into RAM, load LMA copy after code */
164 _sdata = .; /* create a global symbol at data start */
165 *(.data) /* .data sections */
166 *(.data*) /* .data* sections */
169 _edata = .; /* define a global symbol at data end */
170 } >RAM AT> MOVABLE_FLASH
172 /* Uninitialized data section */
176 /* This is used by the startup in order to initialize the .bss secion */
177 _sbss = .; /* define a global symbol at bss start */
178 __bss_start__ = _sbss;
180 *(SORT_BY_ALIGNMENT(.bss*))
184 _ebss = .; /* define a global symbol at bss end */
188 /* used during startup to initialized fastram_data */
189 _sfastram_idata = LOADADDR(.fastram_data);
191 /* Initialized FAST_DATA section for unsuspecting developers */
192 /* init in startup/system_at32f43x.c */
196 _sfastram_data = .; /* create a global symbol at data start */
197 *(.fastram_data) /* .data sections */
198 *(.fastram_data*) /* .data* sections */
201 _efastram_data = .; /* define a global symbol at data end */
202 } >FASTRAM AT> FLASH1
204 /* define FAST_DATA_ZERO_INIT part Initialized in startup_at23f435_437_.S */
206 .fastram_bss (NOLOAD) :
209 __fastram_bss_start__ = _sfastram_bss;
211 *(SORT_BY_ALIGNMENT(.fastram_bss*))
215 __fastram_bss_end__ = _efastram_bss;
218 .persistent_data (NOLOAD) :
220 __persistent_data_start__ = .;
223 __persistent_data_end__ = .;
228 __dmaram_start__ = .;
234 /* User_heap_stack section, used to check that there is enough RAM left */
235 _heap_stack_end = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size;
236 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
237 . = _heap_stack_begin;
242 PROVIDE ( _end = . );
243 . = . + _Min_Heap_Size;
244 . = . + _Min_Stack_Size;
248 /* MEMORY_bank1 section, code must be located here explicitly */
249 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
252 *(.mb1text) /* .mb1text sections (code) */
253 *(.mb1text*) /* .mb1text* sections (code) */
254 *(.mb1rodata) /* read-only data (constants) */
258 /* Remove information from the standard libraries */
266 .ARM.attributes 0 : { *(.ARM.attributes) }