最近在学校学习LPC1114嵌入式课程,为了助力开源事业,重新编写了LPC1114 gcc 启动文件和链接脚本。
GCC 启动文件 lpc1114_startup.s
.cpu cortex-m0
.fpu softvfp
.syntax unified
.thumb
.global g_pfnVectors
.global Default_Handler
/* start address of the static initialization data */
.word _sidata
/* start address of the data section */
.word _sdata
/* end address of the data section */
.word _edata
/* start address of the bss section */
.word _sbss
/* end address of the bss section */
.word _ebss
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
ldr r0, = _estack
mov sp,r0 /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
ldr r0,= _sdata
ldr r1,= _edata
ldr r2,= _sidata
movs r3,#0x00
b LoopCopyDataInit
CopyDataInit:
ldr r4,[ r2, r3 ]
str r4,[ r0, r3 ]
adds r3,r3,#4
LoopCopyDataInit:
adds r4,r0,r3
cmp r4, r1
bcc CopyDataInit
ldr r2,= _sbss
ldr r4,= _ebss
movs r3,#0
b LoopFillZerobss
FillZerobss:
str r3,[r2]
adds r2,r2,#4
LoopFillZerobss:
cmp r2,r4
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
bl __libc_init_array
/* Call the application's entry point.*/
bl main
LoopForever:
b LoopForever
.size Reset_Handler, .-Reset_Handler
.section .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
b Infinite_Loop
.size Default_Handler, .-Default_Handler
.section .isr_vector,"a",%progbits
.type g_pfnVectors, %object
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors:
.word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word SVC_Handler
.word 0
.word 0
.word PendSV_Handler
.word SysTick_Handler
.word WAKEUP_IRQHandler @16+0
.word WAKEUP_IRQHandler @16+1
.word WAKEUP_IRQHandler @16+2
.word WAKEUP_IRQHandler @16+3
.word WAKEUP_IRQHandler @16+4
.word WAKEUP_IRQHandler @16+5
.word WAKEUP_IRQHandler @16+6
.word WAKEUP_IRQHandler @16+7
.word WAKEUP_IRQHandler @16+8
.word WAKEUP_IRQHandler @16+9
.word WAKEUP_IRQHandler @16+10
.word WAKEUP_IRQHandler @16+11
.word WAKEUP_IRQHandler @16+12
.word WAKEUP_IRQHandler @16+13
.word CAN_IRQHandler @ 16+13: CAN
.word SSP1_IRQHandler @; 16+14: SSP1
.word I2C_IRQHandler @; 16+15: I2C
.word TIMER16_0_IRQHandler @; 16+16: 16-bit Counter-Timer 0
.word TIMER16_1_IRQHandler @; 16+17: 16-bit Counter-Timer 1
.word TIMER32_0_IRQHandler @; 16+18: 32-bit Counter-Timer 0
.word TIMER32_1_IRQHandler @; 16+19: 32-bit Counter-Timer 1
.word SSP0_IRQHandler @; 16+20: SSP0
.word UART_IRQHandler @; 16+21: UART
.word USB_IRQHandler @; 16+22: USB IRQ
.word USB_FIQHandler @; 16+24: USB FIQ
.word ADC_IRQHandler @; 16+24: A/D Converter
.word WDT_IRQHandler @; 16+25: Watchdog Timer
.word BOD_IRQHandler @; 16+26: Brown Out Detect
.word FMC_IRQHandler @; 16+27: IP2111 Flash Memory Controller
.word PIOINT3_IRQHandler @; 16+28: PIO INT3
.word PIOINT2_IRQHandler @; 16+29: PIO INT2
.word PIOINT1_IRQHandler @; 16+30: PIO INT1
.word PIOINT0_IRQHandler @; 16+31: PIO INT0
.weak NMI_Handler
.thumb_set NMI_Handler,Default_Handler
.weak HardFault_Handler
.thumb_set HardFault_Handler,Default_Handler
.weak SVC_Handler
.thumb_set SVC_Handler,Default_Handler
.weak PendSV_Handler
.thumb_set PendSV_Handler,Default_Handler
.weak SysTick_Handler
.thumb_set SysTick_Handler,Default_Handler
.weak WAKEUP_IRQHandler
.thumb_set WAKEUP_IRQHandler,Default_Handler
.weak CAN_IRQHandler
.thumb_set CAN_IRQHandler,Default_Handler
.weak SSP1_IRQHandler
.thumb_set SSP1_IRQHandler,Default_Handler
.weak I2C_IRQHandler
.thumb_set I2C_IRQHandler,Default_Handler
.weak TIMER16_0_IRQHandler
.thumb_set TIMER16_0_IRQHandler,Default_Handler
.weak TIMER16_1_IRQHandler
.thumb_set TIMER16_1_IRQHandler,Default_Handler
.weak TIMER32_0_IRQHandler
.thumb_set TIMER32_0_IRQHandler,Default_Handler
.weak TIMER32_1_IRQHandler
.thumb_set TIMER32_1_IRQHandler,Default_Handler
.weak SSP0_IRQHandler
.thumb_set SSP0_IRQHandler,Default_Handler
.weak UART_IRQHandler
.thumb_set UART_IRQHandler,Default_Handler
.weak USB_IRQHandler
.thumb_set USB_IRQHandler,Default_Handler
.weak USB_FIQHandler
.thumb_set USB_FIQHandler,Default_Handler
.weak ADC_IRQHandler
.thumb_set ADC_IRQHandler,Default_Handler
.weak WDT_IRQHandler
.thumb_set WDT_IRQHandler,Default_Handler
.weak BOD_IRQHandler
.thumb_set BOD_IRQHandler,Default_Handler
.weak FMC_IRQHandler
.thumb_set FMC_IRQHandler,Default_Handler
.weak PIOINT3_IRQHandler
.thumb_set PIOINT3_IRQHandler ,Default_Handler
.weak PIOINT2_IRQHandler
.thumb_set PIOINT2_IRQHandler ,Default_Handler
.weak PIOINT1_IRQHandler
.thumb_set PIOINT1_IRQHandler ,Default_Handler
.weak PIOINT0_IRQHandler
.thumb_set PIOINT0_IRQHandler ,Default_Handler
匹配的链接文件 lpc1114.ld
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x000; /* required amount of heap */
_Min_Stack_Size = 0x100; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K */
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x8000 /* 32K */
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
/* Startup code */
/* .isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector))
. = ALIGN(4);
} >FLASH */
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
_stext = .;
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text.*) /* .text* sections (code) */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.gnu.linkonce.t*)
/* *(.eh_frame) */
/* KEEP (*(.init))
KEEP (*(.fini))
*/
/* section information for finsh shell */
/* . = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .; */
/* section information for initial. */
/* . = ALIGN(4);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
. = ALIGN(4); */
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
/* .rodata :
{
. = ALIGN(4);
*(.rodata)
*(.rodata*)
. = ALIGN(4);
} >FLASH */
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
/* This is used by the startup in order to initialize the .data secion */
_sidata = .;
} > FLASH
__exidx_end = .;
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.gnu.linkonce.d*)
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT >FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
但是这套代码好像只可以选择【默认优化级别 -O0】运行,可以编译通过,可以运行多任务系统,
还请大家指教。