解决Keil5.38编译STM32时出现四个错误的方法
以上为错误截图,一下为错误信息
Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported
uint32_t result=0;
^
Start/core_cm3.c(442): note: attribute is here
uint32_t __get_PSP(void) __attribute__( ( naked ) );
^
Start/core_cm3.c(465): error: parameter references not allowed in naked functions
"BX lr \n\t" : : "r" (topOfProcStack) );
^
Start/core_cm3.c(461): note: attribute is here
void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) );
^
Start/core_cm3.c(479): error: non-ASM statement in naked function is not supported
uint32_t result=0;
^
Start/core_cm3.c(476): note: attribute is here
uint32_t __get_MSP(void) __attribute__( ( naked ) );
^
Start/core_cm3.c(499): error: parameter references not allowed in naked functions
"BX lr \n\t" : : "r" (topOfMainStack) );
^
Start/core_cm3.c(495): note: attribute is here
void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) );
^
4 errors generated.
compiling core_cm3.c…
compiling system_stm32f10x.c…
compiling stm32f10x_tim.c…
".\Objects\stm32.axf" – 4 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:02
解决方法:是因为keil5.38使用了6的编译器,网上大多数都是切换到5编译器,我的办法是将core_cm3.h、core_cm3.c文件替换成新的core_cm3.h文件,将core_cm3.c删除。同时在当前目录下添加一下文件。
以下为报错前的start目录
替换后的start目录为:
替换以后可以看到,编译已经成功了
我将以上四个文件打包到百度网盘,需要的自取:
链接: https://pan.baidu.com/s/1jTSXPVFOwuZB5noyv31T0A?pwd=kq7r 提取码: kq7r 复制这段内容后打开百度网盘手机App,操作更方便哦