e2zone 发表于 2013-6-16 14:24 
我觉得他们说的那个库不是固件库。
因为那篇**中说,启动文件中的__main不是指c文件中的main函数。而是 ...
对于STM32来说,从__main到main的过程对于iar和rvct(mdk所用的编译器)来说都是封装在.a库文件里面的,只有gcc是“裸”的,代码如下。
bss段就是rvct的ZI段,text就是RW段位于flash部分,data段就是RW位于ram的部分。
int fu_ck_mojinming; //这就是ZI段数据
int fu_ck_mojinming=1; //这就是RW段数据,fu_ck_mojinming的初值位于flash的text段,上电后要搬到ram的data段才能执行,撸主明白了么?
- /***************************************************************************/
- /* ResetHandler */
- /* */
- /* This function is used for the C runtime initialisation, */
- /* for handling the .data and .bss segments. */
- /***************************************************************************/
- void ResetHandler (void)
- {
- uint32_t *pSrc;
- uint32_t *pDest;
-
- /*
- * Call the SystemInit code from CMSIS interface if available.
- * SystemInit is a week function which can be override
- * by an external function.
- */
- SystemInit();
-
- /*
- * Set the "Vector Table Offset Register". From the ARM
- * documentation, we got the following information:
- *
- * Use the Vector Table Offset Register to determine:
- * - if the vector table is in RAM or code memory
- * - the vector table offset.
- */
- *((uint32_t*)0xE000ED08) = (uint32_t)&_stext;
-
- /*
- * Copy the initialized data of the ".data" segment
- * from the flash to the are in the ram.
- */
- pSrc = &_etext;
- pDest = &_sdata;
- while(pDest < &_edata)
- {
- *pDest++ = *pSrc++;
- }
-
- /*
- * Clear the ".bss" segment.
- */
- pDest = &_sbss;
- while(pDest < &_ebss)
- {
- *pDest++ = 0;
- }
-
- /*
- * And now the main function can be called.
- * Scotty, energie...
- */
- main();
-
- /*
- * In case there are problems with the
- * "warp drive", stop here.
- */
- while(1) {};
- } /* ResetHandler */
|