简介
我们在编译keil工程的时候总是遇到很多问题,我把一些常见的问题和解决方案汇总下来,仅供大家参考。
问题汇总
问题1
问题描述
选择arm v6版本编译器,编译keil5工程,报错;core_cm3.c出现4处报错,具体内容如下:
Build started: Project: stm32f10x_Project_Template
*** Using Compiler ‘V6.14’, folder: ‘E:\Keil\ARM\ARMCLANG\Bin’
Build target ‘Template’
CMSIS/core_cm3.c(445): error: non-ASM statement in naked function is not supported
uint32_t result=0;
^
CMSIS/core_cm3.c(442): note: attribute is here
uint32_t __get_PSP(void) attribute( ( naked ) );
^
CMSIS/core_cm3.c(465): error: parameter references not allowed in naked functions
“BX lr \n\t” : : “r” (topOfProcStack) );
^
CMSIS/core_cm3.c(461): note: attribute is here
void __set_PSP(uint32_t topOfProcStack) attribute( ( naked ) );
^
CMSIS/core_cm3.c(479): error: non-ASM statement in naked function is not supported
uint32_t result=0;
^
CMSIS/core_cm3.c(476): note: attribute is here
uint32_t __get_MSP(void) attribute( ( naked ) );
^
CMSIS/core_cm3.c(499): error: parameter references not allowed in naked functions
“BX lr \n\t” : : “r” (topOfMainStack) );
^
CMSIS/core_cm3.c(495): note: attribute is here
void __set_MSP(uint32_t topOfMainStack) attribute( ( naked ) );
^
4 errors generated.
compiling core_cm3.c…
“.\Objects\stm32f10x_Project_Template.axf” - 4 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:00
问题分析
因为core_cm3.c和core_cm3.h文件太老导致的,这个文件还是2009年的版本,ST已经停止维护。
解决方案
有两个方案。
方案1:
下载STM32cube_FW软件包,Drivers\CMSIS\Include目录下拷贝cmsis_armcc.h、core_cm3.h、cmsis_armclang.h这几个文件覆盖掉老的core_cm3.h文件,然后停用core_cm3.c,改用CMSIS标准接口(如下图所示);
需要注意的是,CMSIS标准接口屏蔽了实现细节。
方案2:
降低编译器的版本,如下图:
问题2
问题描述
进行软件仿真,程序无法运行,卡在芯片系统初始化流程,如下图:
问题分析
软件仿真时,加载仿真所需的动态库失败。
解决方案
修改动态库,如下图所示:
指定动态库为DARMSTM.DLL,参数设置为你使用的芯片型号。
问题3
问题描述
移植了freertos内核,编译时报错,报错信息如下:
../freertos_code/include\FreeRTOS.h(65): warning: In file included from...
../freertos_code/include/portable.h(53): warning: In file included from...
../freertos_code/portable/RVDS/ARM_CM3\portmacro.h(176): error: unknown type name '__forceinline'
static portFORCE_INLINE void vPortSetBASEPRI( uint32_t ulBASEPRI )
^
../freertos_code/portable/RVDS/ARM_CM3\portmacro.h(171): note: expanded from macro 'portFORCE_INLINE'
^
../freertos_code/portable/RVDS/ARM_CM3\portmacro.h(179): error: expected 'volatile', 'inline', 'goto', or '('
{
^
../freertos_code/portable/RVDS/ARM_CM3\portmacro.h(189): error: unknown type name '__forceinline'
static portFORCE_INLINE void vPortRaiseBASEPRI( void )
^
../freertos_code/portable/RVDS/ARM_CM3\portmacro.h(171): note: expanded from macro 'portFORCE_INLINE'
^
../freertos_code/portable/RVDS/ARM_CM3\portmacro.h(194): error: expected 'volatile', 'inline', 'goto', or '('
{
问题分析
内联汇编语法不对造成错误。
解决方案
方案1:
按照如下格式修改内联汇编:
__asm volatile (
" ldr r3, pxCurrentTCBConst2 \n"
" ldr r1, [r3] \n"
" ldr r0, [r1] \n"
" ldmia r0!, {r4-r11} \n"
" msr psp, r0 \n"
" isb \n"
" mov r0, #0 \n"
" msr basepri, r0 \n"
" orr r14, #0xd \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
);
方案2:
把freertos源文件中的RVDS文件夹里的ARM_CM3文件夹替换为GCC里的ARM_CM3文件夹。
总结
本篇文章汇总记录了使用stm32工程常见的问题和解决方案,后续有时间会继续更新。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)