Ubuntu下使用GCC编译STM32工程
最近在Ubuntu上使用GCC编译工具编译STM32的工程以下是一些遇到的问题以及解决的方法,该贴为常更新贴,后期遇到新的问题在添加进本帖。
GCC 编译器版本:gcc-arm-none-eabi-9-2019-q4
Ubuntu系统版本: Ubuntu 16.04 LTS
硬件平台: STM32F303CCT6
ERROR Ⅰ: error: expected ‘(’ before ‘void’ __ASM void xxx
关于汇编的使用在使用GCC进行编译的时候会出现这种错误,但是在使用Keil5进行编译时却是正常的,就比如下面这段代码:
__ASM void MSR_MSP(u32 addr) { MSR MSP, r0
BX r14 }
修改方法如下,使用__ASM volatile()将汇编语句包裹起来:
void MSR_MSP(u32 addr) { __ASM volatile("MSR MSP, r0"); __ASM volatile("BX r14"); }
ERROR Ⅱ: selected processor does not support `xxxxx’ in Thumb mode
修改Makfile,添加支持软/硬件浮点参数(需结合具体使用的硬件平台,本工程基于STM32F303CCT6具有浮点运算单元FPU)
# fpu FPU = -mfpu=fpv4-sp-d16 # float-abi FLOAT-ABI = -mfloat-abi=hard
ERROR Ⅲ:error: unknown type name ‘uintx_t’; did you mean ‘wint_t’?
解决方法:
添加以下头文件
#include <stdint.h>
ERROR Ⅳ:交叉编译arm-none-eabi-gcc编译汇编文件(startup_stm32f10x_hd.S)出错
make[1]: Entering directory /home/demo/testPrij/stm32lib/CMSIS/DeviceSupport' arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m3 -mthumb-interwork -I. -x assembler-with-cpp -Wa,-adhlns=startup_stm32f10x_hd.lst,-ggdb startup_stm32f10x_hd.S -o startup_stm32f10x_hd.o startup_stm32f10x_hd.S: Assembler messages: startup_stm32f10x_hd.S:1: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:2: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:3: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:4: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:5: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:6: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:7: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:8: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:9: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:10: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:11: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:12: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:13: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:14: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:15: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:16: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:17: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:18: Error: junk at end of line, first unrecognized character is *' startup_stm32f10x_hd.S:19: Error: junk at end of line, first unrecognized character is
’
startup_stm32f10x_hd.S:20: Error: junk at end of line, first unrecognized character is `*’
修改方法:
将后缀.s改为.S
后期遇到其他的问题会更新…
本文地址:https://blog.csdn.net/qq_33475105/article/details/107888902