Allow change of debug flags without forcing complete rebuild (#13708)
[betaflight.git] / src / link / stm32_flash_h743_2m.ld
blob9a283377a391f29e6da86221ec54612b01106d93
1 /*
2 *****************************************************************************
3 **
4 **  File        : stm32_flash_h7x3_2m.ld
5 **
6 **  Abstract    : Linker script for STM32H743xI Device with
7 **                512K AXI-RAM mapped onto AXI bus on D1 domain
8 **                128K SRAM1 mapped on D2 domain
9 **                128K SRAM2 mapped on D2 domain
10 **                 32K SRAM3 mapped on D2 domain
11 **                 64K SRAM4 mapped on D3 domain
12 **                 64K ITCM
13 **                128K DTCM
15 *****************************************************************************
18 /* Entry Point */
19 ENTRY(Reset_Handler)
22 0x00000000 to 0x0000FFFF   64K ITCM
23 0x20000000 to 0x2001FFFF  128K DTCM
24 0x24000000 to 0x2407FFFF  512K AXI SRAM, D1 domain, main RAM
25 0x30000000 to 0x3001FFFF  128K SRAM1, D2 domain
26 0x30020000 to 0x3003FFFF  128K SRAM2, D2 domain
27 0x30040000 to 0x30047FFF   32K SRAM3, D2 domain, unused
28 0x38000000 to 0x3800FFFF   64K SRAM4, D3 domain, unused
29 0x38800000 to 0x38800FFF    4K BACKUP SRAM, Backup domain, unused
31 0x08000000 to 0x081FFFFF 2048K full flash,
32 0x08000000 to 0x0801FFFF  128K isr vector, startup code,
33 0x08020000 to 0x0803FFFF  128K config,                  // FLASH_Sector_1
34 0x08040000 to 0x081FFFFF 1792K firmware,
37 /* Specify the memory areas */
38 MEMORY
40     FLASH (rx)        : ORIGIN = 0x08000000, LENGTH = 128K
41     FLASH_CONFIG (r)  : ORIGIN = 0x08020000, LENGTH = 128K
42     FLASH1 (rx)       : ORIGIN = 0x08040000, LENGTH = 1792K
44     ITCM_RAM (rwx)    : ORIGIN = 0x00000000, LENGTH = 64K
45     DTCM_RAM (rwx)    : ORIGIN = 0x20000000, LENGTH = 128K
46     RAM (rwx)         : ORIGIN = 0x24000000, LENGTH = 512K
48     D2_RAM (rwx)      : ORIGIN = 0x30000000, LENGTH = 256K /* SRAM1 + SRAM2 */
50     MEMORY_B1 (rx)    : ORIGIN = 0x60000000, LENGTH = 0K
53 REGION_ALIAS("STACKRAM", DTCM_RAM)
54 REGION_ALIAS("FASTRAM", DTCM_RAM)
56 /* Entry Point */
57 ENTRY(Reset_Handler)
59 /* Highest address of the user mode stack */
60 _estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - 8; /* Reserve 2 x 4bytes for info across reset */
62 /* Base address where the config is stored. */
63 __config_start = ORIGIN(FLASH_CONFIG);
64 __config_end = ORIGIN(FLASH_CONFIG) + LENGTH(FLASH_CONFIG);
66 /* Generate a link error if heap and stack don't fit into RAM */
67 _Min_Heap_Size = 0;      /* required amount of heap  */
68 _Min_Stack_Size = 0x800; /* required amount of stack */
70 /* Define output sections */
71 SECTIONS
73   /* The startup code goes first into FLASH */
74   .isr_vector :
75   {
76     . = ALIGN(512);
77     PROVIDE (isr_vector_table_base = .);
78     KEEP(*(.isr_vector)) /* Startup code */
79     . = ALIGN(4);
80   } >FLASH
82   /* The program code and other data goes into FLASH */
83   .text :
84   {
85     . = ALIGN(4);
86     *(.text)           /* .text sections (code) */
87     *(.text*)          /* .text* sections (code) */
88     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
89     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
90     *(.glue_7)         /* glue arm to thumb code */
91     *(.glue_7t)        /* glue thumb to arm code */
92     *(.eh_frame)
94     KEEP (*(.init))
95     KEEP (*(.fini))
97     . = ALIGN(4);
98     _etext = .;        /* define a global symbols at end of code */
99   } >FLASH1
101   /* Critical program code goes into ITCM RAM */
102   /* Copy specific fast-executing code to ITCM RAM */
103   tcm_code = LOADADDR(.tcm_code);
104   .tcm_code :
105   {
106     . = ALIGN(4);
107     tcm_code_start = .;
108     *(.tcm_code)
109     *(.tcm_code*)
110     . = ALIGN(4);
111     tcm_code_end = .;
112   } >ITCM_RAM AT >FLASH1
114   .ARM.extab   :
115   {
116     *(.ARM.extab* .gnu.linkonce.armextab.*)
117   } >FLASH1
119   .ARM :
120   {
121     __exidx_start = .;
122     *(.ARM.exidx*) __exidx_end = .;
123   } >FLASH1
125   .pg_registry :
126   {
127     PROVIDE_HIDDEN (__pg_registry_start = .);
128     KEEP (*(.pg_registry))
129     KEEP (*(SORT(.pg_registry.*)))
130     PROVIDE_HIDDEN (__pg_registry_end = .);
131   } >FLASH1
133   .pg_resetdata :
134   {
135     PROVIDE_HIDDEN (__pg_resetdata_start = .);
136     KEEP (*(.pg_resetdata))
137     PROVIDE_HIDDEN (__pg_resetdata_end = .);
138   } >FLASH1
140   /* used by the startup to initialize data */
141   _sidata = LOADADDR(.data);
143   /* Initialized data sections goes into RAM, load LMA copy after code */
144   .data :
145   {
146     . = ALIGN(4);
147     _sdata = .;        /* create a global symbol at data start */
148     *(.data)           /* .data sections */
149     *(.data*)          /* .data* sections */
151     . = ALIGN(4);
152     _edata = .;        /* define a global symbol at data end */
153   } >RAM AT >FLASH1
155   /* Uninitialized data section */
156   . = ALIGN(4);
157   .bss (NOLOAD) :
158   {
159     /* This is used by the startup in order to initialize the .bss secion */
160     _sbss = .;         /* define a global symbol at bss start */
161     __bss_start__ = _sbss;
162     *(.bss)
163     *(SORT_BY_ALIGNMENT(.bss*))
164     *(COMMON)
166     . = ALIGN(4);
167     _ebss = .;         /* define a global symbol at bss end */
168     __bss_end__ = _ebss;
169   } >RAM
171   /* Uninitialized data section */
172   . = ALIGN(4);
173   .sram2 (NOLOAD) :
174   {
175     /* This is used by the startup in order to initialize the .sram2 secion */
176     _ssram2 = .;         /* define a global symbol at sram2 start */
177     __sram2_start__ = _ssram2;
178     *(.sram2)
179     *(SORT_BY_ALIGNMENT(.sram2*))
181     . = ALIGN(4);
182     _esram2 = .;         /* define a global symbol at sram2 end */
183     __sram2_end__ = _esram2;
184   } >RAM
186   /* used during startup to initialized fastram_data */
187   _sfastram_idata = LOADADDR(.fastram_data);
189   /* Initialized FAST_DATA section for unsuspecting developers */
190   .fastram_data :
191   {
192     . = ALIGN(4);
193     _sfastram_data = .;        /* create a global symbol at data start */
194     *(.fastram_data)           /* .data sections */
195     *(.fastram_data*)          /* .data* sections */
197     . = ALIGN(4);
198     _efastram_data = .;        /* define a global symbol at data end */
199   } >FASTRAM AT >FLASH1
201   . = ALIGN(4);
202   .fastram_bss (NOLOAD) :
203   {
204     _sfastram_bss = .;
205     __fastram_bss_start__ = _sfastram_bss;
206     *(.fastram_bss)
207     *(SORT_BY_ALIGNMENT(.fastram_bss*))
209     . = ALIGN(4);
210     _efastram_bss = .;
211     __fastram_bss_end__ = _efastram_bss;
212   } >FASTRAM
214   /* used during startup to initialized dmaram_data */
215   _sdmaram_idata = LOADADDR(.dmaram_data);
217   . = ALIGN(32);
218   .dmaram_data :
219   {
220     PROVIDE(dmaram_start = .);
221     _sdmaram = .;
222     _dmaram_start__ = _sdmaram;
223     _sdmaram_data = .;        /* create a global symbol at data start */
224     *(.dmaram_data)           /* .data sections */
225     *(.dmaram_data*)          /* .data* sections */
226     . = ALIGN(32);
227     _edmaram_data = .;        /* define a global symbol at data end */
228   } >RAM AT >FLASH1
230   . = ALIGN(32);
231   .dmaram_bss (NOLOAD) :
232   {
233     _sdmaram_bss = .;
234     __dmaram_bss_start__ = _sdmaram_bss;
235     *(.dmaram_bss)
236     *(SORT_BY_ALIGNMENT(.dmaram_bss*))
237     . = ALIGN(32);
238     _edmaram_bss = .;
239     __dmaram_bss_end__ = _edmaram_bss;
240   } >RAM
242   . = ALIGN(32);
243   .DMA_RAM (NOLOAD) :
244   {
245     KEEP(*(.DMA_RAM))
246     PROVIDE(dmaram_end = .);
247     _edmaram = .;
248     _dmaram_end__ = _edmaram;
249   } >RAM
251   .DMA_RW_D2 (NOLOAD) :
252   {
253     . = ALIGN(32);
254     PROVIDE(dmarw_start = .);
255     _sdmarw = .;
256     _dmarw_start__ = _sdmarw;
257     KEEP(*(.DMA_RW))
258     PROVIDE(dmarw_end = .);
259     _edmarw = .;
260     _dmarw_end__ = _edmarw;
261   } >D2_RAM
263   .DMA_RW_AXI (NOLOAD) :
264   {
265     . = ALIGN(32);
266     PROVIDE(dmarwaxi_start = .);
267     _sdmarwaxi = .;
268     _dmarwaxi_start__ = _sdmarwaxi;
269     KEEP(*(.DMA_RW_AXI))
270     PROVIDE(dmarwaxi_end = .);
271     _edmarwaxi = .;
272     _dmarwaxi_end__ = _edmarwaxi;
273   } >RAM
275   .persistent_data (NOLOAD) :
276   {
277     __persistent_data_start__ = .;
278     *(.persistent_data)
279     . = ALIGN(4);
280     __persistent_data_end__ = .;
281   } >RAM
284   /* User_heap_stack section, used to check that there is enough RAM left */
285   _heap_stack_end = ORIGIN(STACKRAM)+LENGTH(STACKRAM) - 8; /* 8 bytes to allow for alignment */
286   _heap_stack_begin = _heap_stack_end - _Min_Stack_Size  - _Min_Heap_Size;
287   . = _heap_stack_begin;
288   ._user_heap_stack :
289   {
290     . = ALIGN(4);
291     PROVIDE ( end = . );
292     PROVIDE ( _end = . );
293     . = . + _Min_Heap_Size;
294     . = . + _Min_Stack_Size;
295     . = ALIGN(4);
296   } >STACKRAM = 0xa5
298   /* MEMORY_bank1 section, code must be located here explicitly            */
299   /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
300   .memory_b1_text :
301   {
302     *(.mb1text)        /* .mb1text sections (code) */
303     *(.mb1text*)       /* .mb1text* sections (code)  */
304     *(.mb1rodata)      /* read-only data (constants) */
305     *(.mb1rodata*)
306   } >MEMORY_B1
308   /* Remove information from the standard libraries */
309   /DISCARD/ :
310   {
311     libc.a ( * )
312     libm.a ( * )
313     libgcc.a ( * )
314   }
316   .ARM.attributes 0 : { *(.ARM.attributes) }