标题: ARM Cortex-M4启动流程分析 [打印本页] 作者: 石小疯 时间: 2022-8-9 22:58 标题: ARM Cortex-M4启动流程分析 概要
After power-on sequence or a system reset, the ARM® Cortex™-M4 processor fetches the top-of-stack value from address 0x0000 0000 and the base address of boot code from 0x0000 0004 in sequence. Then, it starts executing code from the base address of boot code.
Due to the selected boot source, either the main flash memory (original memory space beginning at 0x0800 0000) or the system memory (original memory space beginning at 0x1FFF F000) is aliased in the boot memory space which begins at the address 0x0000 0000.
When the on-chip SRAM, whose memory space is beginning at 0x2000 0000, is selected as the boot source, in the application initialization code, you have to relocate the vector table in SRAM using the NVIC exception table and offset register.
从以上摘取的文本可以看出,Cortex-M4内核在上电由硬件初始化后,将把0x0000 0000地址处的值设置为Stack Pointer (SP),然后跳转到0x0000 0004存储的地址,进而开始执行代码。(这一点和ARM9不一样,ARM9是直接执行0x0000 0000地址处的代码,因此第一条通常是跳转指令。)
以上启动步骤翻译成汇编代码如下: