2 ******************************************************************************
4 * @file link_stm32f10x_HD.ld
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009.
6 * @brief PiOS linker for the OpenPilot board
7 * @see The GNU Public License (GPL) Version 3
9 *****************************************************************************/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 /* Memory Spaces Definitions */
30 RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
31 FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
32 FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
33 EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
34 EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
35 EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
36 EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
39 /* higher address of the user mode stack */
42 /* default stack sizes.
44 These are used by the startup in order to allocate stacks for the different modes.
46 Note: FreeRTOS gives each task an own stack
51 PROVIDE ( _Stack_Size = __Stack_Size ) ;
53 __Stack_Init = _estack - __Stack_Size ;
55 /*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
56 PROVIDE ( _Stack_Init = __Stack_Init ) ;
59 There will be a link error if there is not this amount of RAM free at the end.
61 _Minimum_Stack_Size = 0x100 ;
63 /* Check valid alignment for VTOR */
64 ASSERT(ORIGIN(FLASH) == ALIGN(ORIGIN(FLASH), 0x80), "Start of memory region flash not aligned for startup vector table");
68 this sends all unreferenced IRQHandlers to reset
72 PROVIDE ( Undefined_Handler = 0 ) ;
73 PROVIDE ( SWI_Handler = 0 ) ;
74 PROVIDE ( IRQ_Handler = 0 ) ;
75 PROVIDE ( Prefetch_Handler = 0 ) ;
76 PROVIDE ( Abort_Handler = 0 ) ;
77 PROVIDE ( FIQ_Handler = 0 ) ;
79 PROVIDE ( NMI_Handler = 0 ) ;
80 PROVIDE ( HardFault_Handler = 0 ) ;
81 PROVIDE ( MemManage_Handler = 0 ) ;
82 PROVIDE ( BusFault_Handler = 0 ) ;
83 PROVIDE ( UsageFault_Handler = 0 ) ;
84 PROVIDE ( SVC_Handler = 0 ) ;
85 PROVIDE ( DebugMon_Handler = 0 ) ;
86 PROVIDE ( PendSV_Handler = 0 ) ;
87 PROVIDE ( SysTick_Handler = 0 ) ;
89 PROVIDE ( WWDG_IRQHandler = 0 ) ;
90 PROVIDE ( PVD_IRQHandler = 0 ) ;
91 PROVIDE ( TAMPER_IRQHandler = 0 ) ;
92 PROVIDE ( RTC_IRQHandler = 0 ) ;
93 PROVIDE ( FLASH_IRQHandler = 0 ) ;
94 PROVIDE ( RCC_IRQHandler = 0 ) ;
95 PROVIDE ( EXTI0_IRQHandler = 0 ) ;
96 PROVIDE ( EXTI1_IRQHandler = 0 ) ;
97 PROVIDE ( EXTI2_IRQHandler = 0 ) ;
98 PROVIDE ( EXTI3_IRQHandler = 0 ) ;
99 PROVIDE ( EXTI4_IRQHandler = 0 ) ;
100 PROVIDE ( DMAChannel1_IRQHandler = 0 ) ;
101 PROVIDE ( DMAChannel2_IRQHandler = 0 ) ;
102 PROVIDE ( DMAChannel3_IRQHandler = 0 ) ;
103 PROVIDE ( DMAChannel4_IRQHandler = 0 ) ;
104 PROVIDE ( DMAChannel5_IRQHandler = 0 ) ;
105 PROVIDE ( DMAChannel6_IRQHandler = 0 ) ;
106 PROVIDE ( DMAChannel7_IRQHandler = 0 ) ;
107 PROVIDE ( ADC_IRQHandler = 0 ) ;
108 PROVIDE ( USB_HP_CAN1_TX_IRQHandler = 0 ) ;
109 PROVIDE ( USB_LP_CAN1_RX0_IRQHandler = 0 ) ;
110 PROVIDE ( CAN1_RX1_IRQHandler = 0 ) ;
111 PROVIDE ( CAN1_SCE_IRQHandler = 0 ) ;
112 PROVIDE ( EXTI9_5_IRQHandler = 0 ) ;
113 PROVIDE ( TIM1_BRK_IRQHandler = 0 ) ;
114 PROVIDE ( TIM1_UP_IRQHandler = 0 ) ;
115 PROVIDE ( TIM1_TRG_COM_IRQHandler = 0 ) ;
116 PROVIDE ( TIM1_CC_IRQHandler = 0 ) ;
117 PROVIDE ( TIM2_IRQHandler = 0 ) ;
118 PROVIDE ( TIM3_IRQHandler = 0 ) ;
119 PROVIDE ( TIM4_IRQHandler = 0 ) ;
120 PROVIDE ( I2C1_EV_IRQHandler = 0 ) ;
121 PROVIDE ( I2C1_ER_IRQHandler = 0 ) ;
122 PROVIDE ( I2C2_EV_IRQHandler = 0 ) ;
123 PROVIDE ( I2C2_ER_IRQHandler = 0 ) ;
124 PROVIDE ( SPI1_IRQHandler = 0 ) ;
125 PROVIDE ( SPI2_IRQHandler = 0 ) ;
126 PROVIDE ( USART1_IRQHandler = 0 ) ;
127 PROVIDE ( USART2_IRQHandler = 0 ) ;
128 PROVIDE ( USART3_IRQHandler = 0 ) ;
129 PROVIDE ( EXTI15_10_IRQHandler = 0 ) ;
130 PROVIDE ( RTCAlarm_IRQHandler = 0 ) ;
131 PROVIDE ( USBWakeUp_IRQHandler = 0 ) ;
132 PROVIDE ( TIM8_BRK_IRQHandler = 0 ) ;
133 PROVIDE ( TIM8_UP_IRQHandler = 0 ) ;
134 PROVIDE ( TIM8_TRG_COM_IRQHandler = 0 ) ;
135 PROVIDE ( TIM8_CC_IRQHandler = 0 ) ;
136 PROVIDE ( ADC3_IRQHandler = 0 ) ;
137 PROVIDE ( FSMC_IRQHandler = 0 ) ;
138 PROVIDE ( SDIO_IRQHandler = 0 ) ;
139 PROVIDE ( TIM5_IRQHandler = 0 ) ;
140 PROVIDE ( SPI3_IRQHandler = 0 ) ;
141 PROVIDE ( UART4_IRQHandler = 0 ) ;
142 PROVIDE ( UART5_IRQHandler = 0 ) ;
143 PROVIDE ( TIM6_IRQHandler = 0 ) ;
144 PROVIDE ( TIM7_IRQHandler = 0 ) ;
145 PROVIDE ( DMA2_Channel1_IRQHandler = 0 ) ;
146 PROVIDE ( DMA2_Channel2_IRQHandler = 0 ) ;
147 PROVIDE ( DMA2_Channel3_IRQHandler = 0 ) ;
148 PROVIDE ( DMA2_Channel4_5_IRQHandler = 0 ) ;
152 /******************************************************************************/
153 /* Peripheral memory map */
154 /******************************************************************************/
155 /*this allows to compile the ST lib in "non-debug" mode*/
158 /* Peripheral and SRAM base address in the alias region */
159 PERIPH_BB_BASE = 0x42000000;
160 SRAM_BB_BASE = 0x22000000;
162 /* Peripheral and SRAM base address in the bit-band region */
163 SRAM_BASE = 0x20000000;
164 PERIPH_BASE = 0x40000000;
166 /* Flash registers base address */
167 PROVIDE ( FLASH_BASE = 0x40022000);
168 /* Flash Option Bytes base address */
169 PROVIDE ( OB_BASE = 0x1FFFF800);
171 /* Peripheral memory map */
172 APB1PERIPH_BASE = PERIPH_BASE ;
173 APB2PERIPH_BASE = (PERIPH_BASE + 0x10000) ;
174 AHBPERIPH_BASE = (PERIPH_BASE + 0x20000) ;
176 PROVIDE ( TIM2 = (APB1PERIPH_BASE + 0x0000) ) ;
177 PROVIDE ( TIM3 = (APB1PERIPH_BASE + 0x0400) ) ;
178 PROVIDE ( TIM4 = (APB1PERIPH_BASE + 0x0800) ) ;
179 PROVIDE ( RTC = (APB1PERIPH_BASE + 0x2800) ) ;
180 PROVIDE ( WWDG = (APB1PERIPH_BASE + 0x2C00) ) ;
181 PROVIDE ( IWDG = (APB1PERIPH_BASE + 0x3000) ) ;
182 PROVIDE ( SPI2 = (APB1PERIPH_BASE + 0x3800) ) ;
183 PROVIDE ( USART2 = (APB1PERIPH_BASE + 0x4400) ) ;
184 PROVIDE ( USART3 = (APB1PERIPH_BASE + 0x4800) ) ;
185 PROVIDE ( I2C1 = (APB1PERIPH_BASE + 0x5400) ) ;
186 PROVIDE ( I2C2 = (APB1PERIPH_BASE + 0x5800) ) ;
187 PROVIDE ( CAN = (APB1PERIPH_BASE + 0x6400) ) ;
188 PROVIDE ( BKP = (APB1PERIPH_BASE + 0x6C00) ) ;
189 PROVIDE ( PWR = (APB1PERIPH_BASE + 0x7000) ) ;
191 PROVIDE ( AFIO = (APB2PERIPH_BASE + 0x0000) ) ;
192 PROVIDE ( EXTI = (APB2PERIPH_BASE + 0x0400) ) ;
193 PROVIDE ( GPIOA = (APB2PERIPH_BASE + 0x0800) ) ;
194 PROVIDE ( GPIOB = (APB2PERIPH_BASE + 0x0C00) ) ;
195 PROVIDE ( GPIOC = (APB2PERIPH_BASE + 0x1000) ) ;
196 PROVIDE ( GPIOD = (APB2PERIPH_BASE + 0x1400) ) ;
197 PROVIDE ( GPIOE = (APB2PERIPH_BASE + 0x1800) ) ;
198 PROVIDE ( ADC1 = (APB2PERIPH_BASE + 0x2400) ) ;
199 PROVIDE ( ADC2 = (APB2PERIPH_BASE + 0x2800) ) ;
200 PROVIDE ( TIM1 = (APB2PERIPH_BASE + 0x2C00) ) ;
201 PROVIDE ( SPI1 = (APB2PERIPH_BASE + 0x3000) ) ;
202 PROVIDE ( USART1 = (APB2PERIPH_BASE + 0x3800) ) ;
204 PROVIDE ( DMA = (AHBPERIPH_BASE + 0x0000) ) ;
205 PROVIDE ( DMA_Channel1 = (AHBPERIPH_BASE + 0x0008) ) ;
206 PROVIDE ( DMA_Channel2 = (AHBPERIPH_BASE + 0x001C) ) ;
207 PROVIDE ( DMA_Channel3 = (AHBPERIPH_BASE + 0x0030) ) ;
208 PROVIDE ( DMA_Channel4 = (AHBPERIPH_BASE + 0x0044) ) ;
209 PROVIDE ( DMA_Channel5 = (AHBPERIPH_BASE + 0x0058) ) ;
210 PROVIDE ( DMA_Channel6 = (AHBPERIPH_BASE + 0x006C) ) ;
211 PROVIDE ( DMA_Channel7 = (AHBPERIPH_BASE + 0x0080) ) ;
212 PROVIDE ( RCC = (AHBPERIPH_BASE + 0x1000) ) ;
214 /* System Control Space memory map */
215 SCS_BASE = 0xE000E000;
217 PROVIDE ( SysTick = (SCS_BASE + 0x0010) ) ;
218 PROVIDE ( NVIC = (SCS_BASE + 0x0100) ) ;
219 PROVIDE ( SCB = (SCS_BASE + 0x0D00) ) ;
222 /* Sections Definitions */
227 /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
230 KEEP(*(.isr_vector)) /* Startup code */
234 /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */
238 *(.flashtext) /* Startup code */
243 /* the program code is stored in the .text section, which goes to Flash */
248 *(.text) /* remaining code */
249 *(.text.*) /* remaining code */
250 *(.rodata) /* read-only data (constants) */
257 /* This is used by the startup in order to initialize the .data secion */
263 /* This is the initialized data section
264 The program executes knowing that the data is in the RAM
265 but the loader puts the initial values in the FLASH (inidata).
266 It is one task of the startup to copy the initial values from FLASH to RAM. */
267 .data : AT ( _sidata )
270 /* This is used by the startup in order to initialize the .data secion */
276 /* This is used by the startup in order to initialize the .data secion */
282 /* This is the uninitialized data section */
286 /* This is used by the startup in order to initialize the .bss secion */
293 /* This is used by the startup in order to initialize the .bss secion */
297 PROVIDE ( end = _ebss );
298 PROVIDE ( _end = _ebss );
300 /* This is the user stack section
301 This is just to check that there is enough RAM left for the User mode stack
302 It should generate an error if it's full.
309 . = . + _Minimum_Stack_Size ;
317 /* this is the FLASH Bank1 */
318 /* the C or assembly source must explicitly place the code or data there
319 using the "section" attribute */
322 *(.b1text) /* remaining code */
323 *(.b1rodata) /* read-only data (constants) */
327 /* this is the EXTMEM */
328 /* the C or assembly source must explicitly place the code or data there
329 using the "section" attribute */
334 *(.eb0text) /* remaining code */
335 *(.eb0rodata) /* read-only data (constants) */
342 *(.eb1text) /* remaining code */
343 *(.eb1rodata) /* read-only data (constants) */
350 *(.eb2text) /* remaining code */
351 *(.eb2rodata) /* read-only data (constants) */
358 *(.eb3text) /* remaining code */
359 *(.eb3rodata) /* read-only data (constants) */
366 /* after that it's only debugging information. */
368 /* remove the debugging information from the standard libraries */
376 /* Stabs debugging sections. */
377 .stab 0 : { *(.stab) }
378 .stabstr 0 : { *(.stabstr) }
379 .stab.excl 0 : { *(.stab.excl) }
380 .stab.exclstr 0 : { *(.stab.exclstr) }
381 .stab.index 0 : { *(.stab.index) }
382 .stab.indexstr 0 : { *(.stab.indexstr) }
383 .comment 0 : { *(.comment) }
384 /* DWARF debug sections.
385 Symbols in the DWARF debugging sections are relative to the beginning
386 of the section so we begin them at 0. */
388 .debug 0 : { *(.debug) }
389 .line 0 : { *(.line) }
390 /* GNU DWARF 1 extensions */
391 .debug_srcinfo 0 : { *(.debug_srcinfo) }
392 .debug_sfnames 0 : { *(.debug_sfnames) }
393 /* DWARF 1.1 and DWARF 2 */
394 .debug_aranges 0 : { *(.debug_aranges) }
395 .debug_pubnames 0 : { *(.debug_pubnames) }
397 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
398 .debug_abbrev 0 : { *(.debug_abbrev) }
399 .debug_line 0 : { *(.debug_line) }
400 .debug_frame 0 : { *(.debug_frame) }
401 .debug_str 0 : { *(.debug_str) }
402 .debug_loc 0 : { *(.debug_loc) }
403 .debug_macinfo 0 : { *(.debug_macinfo) }
404 /* SGI/MIPS DWARF 2 extensions */
405 .debug_weaknames 0 : { *(.debug_weaknames) }
406 .debug_funcnames 0 : { *(.debug_funcnames) }
407 .debug_typenames 0 : { *(.debug_typenames) }
408 .debug_varnames 0 : { *(.debug_varnames) }