Merge pull request #10445 from mikeller/revert-10388_in_maintenance_branch
[betaflight.git] / src / link / stm32_flash_f7_split.ld
blob1cbdd5bf35973233a7f697d31fea775c37cdfcf7
1 /*
2 *****************************************************************************
3 **
4 **  File        : stm32_flash_f7_split.ld
5 **
6 **  Abstract    : Common linker script for STM32 devices.
7 **
8 *****************************************************************************
9 */
11 /* Entry Point */
12 ENTRY(Reset_Handler)
14 /* Highest address of the user mode stack */
15 _estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM);    /* end of RAM */
17 /* Base address where the config is stored. */
18 __config_start = ORIGIN(FLASH_CONFIG);
19 __config_end = ORIGIN(FLASH_CONFIG) + LENGTH(FLASH_CONFIG);
21 /* Generate a link error if heap and stack don't fit into RAM */
22 _Min_Heap_Size = 0;      /* required amount of heap  */
23 _Min_Stack_Size = 0x800; /* required amount of stack */
25 /* Define output sections */
26 SECTIONS
28   /* The startup code goes first into FLASH */
29   .isr_vector :
30   {
31     . = ALIGN(512);
32     PROVIDE (isr_vector_table_base = .);
33     KEEP(*(.isr_vector)) /* Startup code */
34     . = ALIGN(4);
35   } >FLASH AT >AXIM_FLASH
37   /* The program code and other data goes into FLASH */
38   .text :
39   {
40     . = ALIGN(4);
41     *(.text)           /* .text sections (code) */
42     *(.text*)          /* .text* sections (code) */
43     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
44     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
45     *(.glue_7)         /* glue arm to thumb code */
46     *(.glue_7t)        /* glue thumb to arm code */
47     *(.eh_frame)
49     KEEP (*(.init))
50     KEEP (*(.fini))
52     . = ALIGN(4);
53     _etext = .;        /* define a global symbols at end of code */
54   } >FLASH1 AT >AXIM_FLASH1
56   /* Critical program code goes into ITCM RAM */
57   /* Copy specific fast-executing code to ITCM RAM */ 
58   tcm_code = LOADADDR(.tcm_code); 
59   .tcm_code :
60   {
61     . = ALIGN(4);
62     tcm_code_start = .; 
63     *(.tcm_code)
64     *(.tcm_code*)
65     . = ALIGN(4);
66     tcm_code_end = .; 
67   } >ITCM_RAM AT >AXIM_FLASH1
69   .ARM.extab   : 
70   { 
71     *(.ARM.extab* .gnu.linkonce.armextab.*) 
72   } >FLASH
73   
74   .ARM : 
75   {
76     __exidx_start = .;
77     *(.ARM.exidx*) __exidx_end = .;
78   } >FLASH AT >AXIM_FLASH
80   .pg_registry :
81   {
82     PROVIDE_HIDDEN (__pg_registry_start = .);
83     KEEP (*(.pg_registry))
84     KEEP (*(SORT(.pg_registry.*)))
85     PROVIDE_HIDDEN (__pg_registry_end = .);
86   } >FLASH AT >AXIM_FLASH
87   
88   .pg_resetdata :
89   {
90     PROVIDE_HIDDEN (__pg_resetdata_start = .);
91     KEEP (*(.pg_resetdata))
92     PROVIDE_HIDDEN (__pg_resetdata_end = .);
93   } >FLASH AT >AXIM_FLASH
95   /* Storage for the address for the configuration section so we can grab it out of the hex file */
96   .custom_defaults :
97   {
98     . = ALIGN(4);
99     KEEP (*(.custom_defaults_start_address))
100     . = ALIGN(4);
101     KEEP (*(.custom_defaults_end_address))
102     . = ALIGN(4);
103     __custom_defaults_internal_start = .;
104     *(.custom_defaults);
105   } >FLASH_CUSTOM_DEFAULTS
107   PROVIDE_HIDDEN (__custom_defaults_start = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) : __custom_defaults_internal_start);
108   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));
110   /* used by the startup to initialize data */
111   _sidata = LOADADDR(.data);
113   /* Initialized data sections goes into RAM, load LMA copy after code */
114   .data :
115   {
116     . = ALIGN(4);
117     _sdata = .;        /* create a global symbol at data start */
118     *(.data)           /* .data sections */
119     *(.data*)          /* .data* sections */
121     . = ALIGN(4);
122     _edata = .;        /* define a global symbol at data end */
123   } >RAM AT >AXIM_FLASH
125   /* Uninitialized data section */
126   . = ALIGN(4);
127   .bss (NOLOAD) :
128   {
129     /* This is used by the startup in order to initialize the .bss secion */
130     _sbss = .;         /* define a global symbol at bss start */
131     __bss_start__ = _sbss;
132     *(.bss)
133     *(SORT_BY_ALIGNMENT(.bss*))
134     *(COMMON)
136     . = ALIGN(4);
137     _ebss = .;         /* define a global symbol at bss end */
138     __bss_end__ = _ebss;
139   } >RAM
141   /* Uninitialized data section */
142   . = ALIGN(4);
143   .sram2 (NOLOAD) :
144   {
145     /* This is used by the startup in order to initialize the .sram2 secion */
146     _ssram2 = .;         /* define a global symbol at sram2 start */
147     __sram2_start__ = _ssram2;
148     *(.sram2)
149     *(SORT_BY_ALIGNMENT(.sram2*))
151     . = ALIGN(4);
152     _esram2 = .;         /* define a global symbol at sram2 end */
153     __sram2_end__ = _esram2;
154   } >SRAM2
156   /* used during startup to initialized fastram_data */
157   _sfastram_idata = LOADADDR(.fastram_data);
159   /* Initialized FAST_RAM section for unsuspecting developers */
160   .fastram_data :
161   {
162     . = ALIGN(4);
163     _sfastram_data = .;        /* create a global symbol at data start */
164     *(.fastram_data)           /* .data sections */
165     *(.fastram_data*)          /* .data* sections */
167     . = ALIGN(4);
168     _efastram_data = .;        /* define a global symbol at data end */
169   } >FASTRAM AT >AXIM_FLASH
171   . = ALIGN(4);
172   .fastram_bss (NOLOAD) :
173   {
174     _sfastram_bss = .;
175     __fastram_bss_start__ = _sfastram_bss;
176     *(.fastram_bss)
177     *(SORT_BY_ALIGNMENT(.fastram_bss*))
179     . = ALIGN(4);
180     _efastram_bss = .;
181     __fastram_bss_end__ = _efastram_bss;
182   } >FASTRAM
184   /* User_heap_stack section, used to check that there is enough RAM left */
185   _heap_stack_end = ORIGIN(STACKRAM)+LENGTH(STACKRAM) - 8; /* 8 bytes to allow for alignment */
186   _heap_stack_begin = _heap_stack_end - _Min_Stack_Size  - _Min_Heap_Size;
187   . = _heap_stack_begin;
188   ._user_heap_stack :
189   {
190     . = ALIGN(4);
191     PROVIDE ( end = . );
192     PROVIDE ( _end = . );
193     . = . + _Min_Heap_Size;
194     . = . + _Min_Stack_Size;
195     . = ALIGN(4);
196   } >STACKRAM = 0xa5
198   /* MEMORY_bank1 section, code must be located here explicitly            */
199   /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
200   .memory_b1_text :
201   {
202     *(.mb1text)        /* .mb1text sections (code) */
203     *(.mb1text*)       /* .mb1text* sections (code)  */
204     *(.mb1rodata)      /* read-only data (constants) */
205     *(.mb1rodata*)
206   } >MEMORY_B1
208   /* Remove information from the standard libraries */
209   /DISCARD/ :
210   {
211     libc.a ( * )
212     libm.a ( * )
213     libgcc.a ( * )
214   }
216   .ARM.attributes 0 : { *(.ARM.attributes) }