MDK-ARM编译器V6和V5

来源:互联网 发布:插件 人物关系图 js 编辑:程序博客网 时间:2024/05/16 03:43

    最新版本的arm 开发工具MDK5.23带有v6.6 和 V5.06 update4的ARM Compiler,官方资料表明,V5版本的编译器已经停止开发,以后只进行维护,ARM推荐大家都使用后续V6版本的编译器,而且根网友的对比测试结果,V5和V6编译器编译速度差异巨大,于是就尝试使用新的编译器进行编译,也直观发现新版本编译器编译速度很快。

选择新版本编译器的操作在target目录下:

还需要同时修改c/c++目录下语言选项(和选择编译器的操作有先后顺序):

然后编译发现如下尴尬的错误和警告:

../CMSIS/CM3/core_cm3.c(445): error: non-ASM statement in naked function is not supported
  uint32_t result=0;
  ^
../CMSIS/CM3/core_cm3.c(442): note: attribute is here
uint32_t __get_PSP(void) __attribute__( ( naked ) );
                                          ^
../CMSIS/CM3/core_cm3.c(465): error: parameter references not allowed in naked functions
                  "BX  lr     \n\t" : : "r" (topOfProcStack) );
                                             ^
../CMSIS/CM3/core_cm3.c(461): note: attribute is here
void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) );
                                                         ^
../CMSIS/CM3/core_cm3.c(479): error: non-ASM statement in naked function is not supported
  uint32_t result=0;
  ^
../CMSIS/CM3/core_cm3.c(476): note: attribute is here
uint32_t __get_MSP(void) __attribute__( ( naked ) );
                                          ^
../CMSIS/CM3/core_cm3.c(499): error: parameter references not allowed in naked functions
                  "BX  lr     \n\t" : : "r" (topOfMainStack) );
                                             ^
../CMSIS/CM3/core_cm3.c(495): note: attribute is here

.......

其中必有的错误  \Obj\Project.axf" - 4 Error(s) 

    错误都来自STM32工程的core_cm3.c文件的汇编嵌入语句中。错误内容是非汇编语句在 naked function不被支持,具体的解释是一个被声明为naked 特性的函数不可以通过任何方式使用局部变量,而在上述__get_MSP(void)/_set_PSP(uint32_t topOfProcStack)/_set_MSP(uint32_t topOfMainStack)等naked 函数中却声明一个局部变量并在代码中进行了赋值操作。

    但由于core_cm3.c文件是官方库文件,不可编辑,所以修改这个问题比较麻烦,目前也没有什么好的办法,还期望有解决这个问题的大神能伸出援手。