LZ最近在用KL02,移植了官网提供的例程。但在启动代码分析时,遇到了难题。
首先下图在野火的说明文档上看到的启动过程分析:
以下结合我的代码具体说明:
这里产生了第一个疑问:VECTOR_000指向的堆栈指针__BOOT_STACK_ADDRESS是在哪里定义的?
接下来的图是在crt0.s文件中__startup对应的汇编代码:
在编译时产生了很多莫名其妙的错误。。难道是我的编译器设置不支持汇编?求大神指教。
我看到有的例程里面并没有加入crt0.s文件,不加入这个文件的话可以启动吗?
之后即使进入第三步start.c文件执行start函数,该函数没问题。
void start(void)
{
/* Disable the watchdog timer */
SIM_COPC = 0x00;
/* Copy any vector or data sections that need to be in RAM */
#ifndef CMSIS // If conforming to CMSIS, we do not need to perform this code
#ifndef BOOTLOADER
/* Copy any vector or data sections that need to be in RAM */
common_startup();
#endif
#endif
/* Perform processor initialization */
sysinit();
#ifndef BOOTLOADER
printf(" \r\n");
/* Determine the last cause(s) of reset */
outSRS();
/* Determine specific Kinetis device and revision */
cpu_identify();
#endif
/* in KEIL, should not call main, but in starup_MKL05Z4.s Reset_Handler */
#ifndef KEIL
/* Jump to main process */
main();
/* No actions to perform after this so wait forever */
while(1);
#endif
}
不知道以上的启动过程是否正确,请大神赐教。