STM32启动过程详解
扫描二维码
随时随地手机看文章
一、STM32启动文件详细解析
STM32启动文件详细解析(V3.5.0) 以:startup_stm32f10x_hd.s为例
;********************(C)COPYRIGHT2011STMicroelectronics********************
;*FileName:startup_stm32f10x_hd.s
;*Author:MCDApplicationTeam
;*Version:V3.5.0
;*Date:11-March-2011
;*Description:STM32F10xHighDensityDevicesvectortableforMDK-ARM
;*toolchain.
;*Thismoduleperforms:
;*-SettheinitialSP
;*-SettheinitialPC==Reset_Handler
;*-SetthevectortableentrieswiththeexceptionsISRaddress
;*-Configuretheclocksystemandalsoconfiguretheexternal
;*SRAMmountedonSTM3210E-EVALboardtobeusedasdata
;*memory(optional,tobeenabledbyuser)
;*-Branchesto__mainintheClibrary(whicheventually
;*callsmain()).
;*AfterResettheCortexM3processorisinThreadmode,
;*priorityisPrivileged,andtheStackissettoMain.
;*<<
;*******************************************************************************
;THEPRESENTFIRMWAREWHICHISFORGUIDANCEONLYAIMSATPROVIDINGCUSTOMERS
;WITHCODINGINFORMATIONREGARDINGTHEIRPRODUCTSINORDERFORTHEMTOSAVETIME.
;ASARESULT,STMICROELECTRONICSSHALLNOTBEHELDLIABLEFORANYDIRECT,
;INDIRECTORCONSEQUENTIALDAMAGESWITHRESPECTTOANYCLAIMSARISINGFROMTHE
;CONTENTOFSUCHFIRMWAREAND/ORTHEUSEMADEBYCUSTOMERSOFTHECODING
;INFORMATIONCONTAINEDHEREININCONNECTIONWITHTHEIRPRODUCTS.
;*******************************************************************************
;Amountofmemory(inbytes)allocatedforStack
;Tailorthisvaluetoyourapplicationneeds
;
;
;
Stack_SizeEQU0x00000400;EQU伪指令,作用是左边的符号名代表右边的表达式
AREASTACK,NOINIT,READWRITE,ALIGN=3;定义栈段:名称为STACK,未初始化,可读写,ELF的栈段按2^3=8对齐
Stack_MemSPACEStack_Size;分配一片连续的存储区域并初始化为0,栈空间:0x400个字节
__initial_sp;栈空间顶地址
;
;
;
Heap_SizeEQU0x00000200
AREAHEAP,NOINIT,READWRITE,ALIGN=3
__heap_base;堆空间起始地址
Heap_MemSPACEHeap_Size;堆空间:0x200个字节
__heap_limit;堆空间结束地址
PRESERVE8;PRESERVE8指令指定当前文件保持堆栈八字节对齐
THUMB;告诉汇编器下面是32位的Thumb指令,如果需要汇编器将插入位以保证对齐
;VectorTableMappedtoAddress0atReset;中断向量表定义
;实际上是在CODE区(假设STM32从FLASH启动,则此中断向量表起始地址即为0x8000000)
AREARESET,DATA,READONLY;定义一块数据段,只可读
EXPORT__Vectors;EXPORT:在程序中声明一个全局的标号__Vectors,该标号可在其他的文件中引用