Merge pull request #11275 from P-I-Engineer/VTX-power-OSD
[betaflight.git] / src / link / stm32_ram_h743.ld
blobebdabe7c6f42d858e428b8a61935c8e34a00e04d
1 /*
2 *****************************************************************************
3 **
4 **  File        : stm32_ram_h743.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     ITCM_RAM (rwx)    : ORIGIN = 0x00000000, LENGTH = 64K
41     DTCM_RAM (rwx)    : ORIGIN = 0x20000000, LENGTH = 128K
42     RAM (rwx)         : ORIGIN = 0x24000000, LENGTH = 512K
44     D2_RAM (rwx)      : ORIGIN = 0x30000000, LENGTH = 256K /* SRAM1 + SRAM2 */
46     MEMORY_B1 (rx)    : ORIGIN = 0x60000000, LENGTH = 0K
49 REGION_ALIAS("STACKRAM", DTCM_RAM)
50 REGION_ALIAS("FASTRAM", DTCM_RAM)
52 /* INCLUDE "stm32_flash_f7_split.ld" */
54 *****************************************************************************
56 **  File        : stm32_flash_f7_split.ld
58 **  Abstract    : Common linker script for STM32 devices.
60 *****************************************************************************
63 /* Entry Point */
64 ENTRY(Reset_Handler)
66 /* Highest address of the user mode stack */
67 _estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - 8; /* Reserve 2 x 4bytes for info across reset */
69 /* Generate a link error if heap and stack don't fit into RAM */
70 _Min_Heap_Size = 0;      /* required amount of heap  */
71 _Min_Stack_Size = 0x800; /* required amount of stack */
73 /* Define output sections */
74 SECTIONS
76   /* The startup code goes first into FLASH */
77   .isr_vector :
78   {
79     . = ALIGN(512);
80     PROVIDE (isr_vector_table_base = .);
81     KEEP(*(.isr_vector)) /* Startup code */
82     . = ALIGN(4);
83   } >RAM
85   /* The program code and other data goes into FLASH */
86   .text :
87   {
88     . = ALIGN(4);
89     *(.text)           /* .text sections (code) */
90     *(.text*)          /* .text* sections (code) */
91     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
92     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
93     *(.glue_7)         /* glue arm to thumb code */
94     *(.glue_7t)        /* glue thumb to arm code */
95     *(.eh_frame)
97     KEEP (*(.init))
98     KEEP (*(.fini))
100     . = ALIGN(4);
101     _etext = .;        /* define a global symbols at end of code */
102   } >RAM
104   /* Critical program code goes into ITCM RAM */
105   /* Copy specific fast-executing code to ITCM RAM */ 
106   tcm_code = LOADADDR(.tcm_code); 
107   .tcm_code :
108   {
109     . = ALIGN(4);
110     tcm_code_start = .; 
111     *(.tcm_code)
112     *(.tcm_code*)
113     . = ALIGN(4);
114     tcm_code_end = .; 
115   } >ITCM_RAM
117   .ARM.extab   : 
118   { 
119     *(.ARM.extab* .gnu.linkonce.armextab.*) 
120   } >RAM
121   
122   .ARM : 
123   {
124     __exidx_start = .;
125     *(.ARM.exidx*) __exidx_end = .;
126   } >RAM
128   .pg_registry :
129   {
130     PROVIDE_HIDDEN (__pg_registry_start = .);
131     KEEP (*(.pg_registry))
132     KEEP (*(SORT(.pg_registry.*)))
133     PROVIDE_HIDDEN (__pg_registry_end = .);
134   } >RAM
135   
136   .pg_resetdata :
137   {
138     PROVIDE_HIDDEN (__pg_resetdata_start = .);
139     KEEP (*(.pg_resetdata))
140     PROVIDE_HIDDEN (__pg_resetdata_end = .);
141   } >RAM
143   /* used by the startup to initialize data */
144   _sidata = LOADADDR(.data);
146   /* Initialized data sections goes into RAM, load LMA copy after code */
147   .data :
148   {
149     . = ALIGN(4);
150     _sdata = .;        /* create a global symbol at data start */
151     *(.data)           /* .data sections */
152     *(.data*)          /* .data* sections */
154     . = ALIGN(4);
155     _edata = .;        /* define a global symbol at data end */
156   } >DTCM_RAM
158   /* Uninitialized data section */
159   . = ALIGN(4);
160   .bss (NOLOAD) :
161   {
162     /* This is used by the startup in order to initialize the .bss secion */
163     _sbss = .;         /* define a global symbol at bss start */
164     __bss_start__ = _sbss;
165     *(.bss)
166     *(SORT_BY_ALIGNMENT(.bss*))
167     *(COMMON)
169     . = ALIGN(4);
170     _ebss = .;         /* define a global symbol at bss end */
171     __bss_end__ = _ebss;
172   } >DTCM_RAM
174   /* Uninitialized data section */
175   . = ALIGN(4);
176   .sram2 (NOLOAD) :
177   {
178     /* This is used by the startup in order to initialize the .sram2 secion */
179     _ssram2 = .;         /* define a global symbol at sram2 start */
180     __sram2_start__ = _ssram2;
181     *(.sram2)
182     *(SORT_BY_ALIGNMENT(.sram2*))
184     . = ALIGN(4);
185     _esram2 = .;         /* define a global symbol at sram2 end */
186     __sram2_end__ = _esram2;
187   } >DTCM_RAM
189   /* used during startup to initialized fastram_data */
190   _sfastram_idata = LOADADDR(.fastram_data);
192   /* Initialized FAST_DATA section for unsuspecting developers */
193   .fastram_data :
194   {
195     . = ALIGN(4);
196     _sfastram_data = .;        /* create a global symbol at data start */
197     *(.fastram_data)           /* .data sections */
198     *(.fastram_data*)          /* .data* sections */
200     . = ALIGN(4);
201     _efastram_data = .;        /* define a global symbol at data end */
202   } >FASTRAM
204   . = ALIGN(4);
205   .fastram_bss (NOLOAD) :
206   {
207     _sfastram_bss = .;
208     __fastram_bss_start__ = _sfastram_bss;
209     *(.fastram_bss)
210     *(SORT_BY_ALIGNMENT(.fastram_bss*))
212     . = ALIGN(4);
213     _efastram_bss = .;
214     __fastram_bss_end__ = _efastram_bss;
215   } >FASTRAM
217   /* used during startup to initialized dmaram_data */
218   _sdmaram_idata = LOADADDR(.dmaram_data);
220   . = ALIGN(32);
221   .dmaram_data :
222   {
223     PROVIDE(dmaram_start = .);
224     _sdmaram = .;
225     _dmaram_start__ = _sdmaram;
226     _sdmaram_data = .;        /* create a global symbol at data start */
227     *(.dmaram_data)           /* .data sections */
228     *(.dmaram_data*)          /* .data* sections */
229     . = ALIGN(32);
230     _edmaram_data = .;        /* define a global symbol at data end */
231   } >RAM
233   . = ALIGN(32);
234   .dmaram_bss (NOLOAD) :
235   {
236     _sdmaram_bss = .;
237     __dmaram_bss_start__ = _sdmaram_bss;
238     *(.dmaram_bss)
239     *(SORT_BY_ALIGNMENT(.dmaram_bss*))
240     . = ALIGN(32);
241     _edmaram_bss = .;
242     __dmaram_bss_end__ = _edmaram_bss;
243   } >RAM
245   . = ALIGN(32);
246   .DMA_RAM (NOLOAD) :
247   {
248     KEEP(*(.DMA_RAM))
249     PROVIDE(dmaram_end = .);
250     _edmaram = .;
251     _dmaram_end__ = _edmaram;
252   } >RAM
254   .DMA_RW_D2 (NOLOAD) :
255   {
256     . = ALIGN(32);
257     PROVIDE(dmarw_start = .);
258     _sdmarw = .;
259     _dmarw_start__ = _sdmarw;
260     KEEP(*(.DMA_RW))
261     PROVIDE(dmarw_end = .);
262     _edmarw = .;
263     _dmarw_end__ = _edmarw;
264   } >D2_RAM
266   .DMA_RW_AXI (NOLOAD) :
267   {
268     . = ALIGN(32);
269     PROVIDE(dmarwaxi_start = .);
270     _sdmarwaxi = .;
271     _dmarwaxi_start__ = _sdmarwaxi;
272     KEEP(*(.DMA_RW_AXI))
273     PROVIDE(dmarwaxi_end = .);
274     _edmarwaxi = .;
275     _dmarwaxi_end__ = _edmarwaxi;
276   } >RAM
278   .persistent_data (NOLOAD) :
279   {
280     __persistent_data_start__ = .;
281     *(.persistent_data)
282     . = ALIGN(4);
283     __persistent_data_end__ = .;
284   } >RAM
287   /* User_heap_stack section, used to check that there is enough RAM left */
288   _heap_stack_end = ORIGIN(STACKRAM)+LENGTH(STACKRAM) - 8; /* 8 bytes to allow for alignment */
289   _heap_stack_begin = _heap_stack_end - _Min_Stack_Size  - _Min_Heap_Size;
290   . = _heap_stack_begin;
291   ._user_heap_stack :
292   {
293     . = ALIGN(4);
294     PROVIDE ( end = . );
295     PROVIDE ( _end = . );
296     . = . + _Min_Heap_Size;
297     . = . + _Min_Stack_Size;
298     . = ALIGN(4);
299   } >STACKRAM = 0xa5
301   /* MEMORY_bank1 section, code must be located here explicitly            */
302   /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
303   .memory_b1_text :
304   {
305     *(.mb1text)        /* .mb1text sections (code) */
306     *(.mb1text*)       /* .mb1text* sections (code)  */
307     *(.mb1rodata)      /* read-only data (constants) */
308     *(.mb1rodata*)
309   } >MEMORY_B1
311   /* Remove information from the standard libraries */
312   /DISCARD/ :
313   {
314     libc.a ( * )
315     libm.a ( * )
316     libgcc.a ( * )
317   }
319   .ARM.attributes 0 : { *(.ARM.attributes) }