编译CMSIS数学函数时Makefile无法生成ARM汇编目标文件求助
问题:CMSIS汇编文件arm_bitreversal2.s编译失败,Makefile无对应规则
尝试编译CMSIS的RealFFT相关函数时,遇到以下报错:
make: *** No rule to make target 'build/arm_bitreversal2.o', needed by 'build/MyProject.elf'. Stop.
当前使用的Makefile内容如下:
# Project Name TARGET = MyProject # Sources CPP_SOURCES = MyProject.cpp # Library Locations LIBDAISY_DIR = ../DaisyExamples/libDaisy DAISYSP_DIR = ../DaisyExamples/DaisySP ASM_SOURCES = \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal2.s C_SOURCES = \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_rfft_fast_f32.c \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_rfft_fast_init_f32.c \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/CommonTables/arm_common_tables.c \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/CommonTables/arm_const_structs.c \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_f32.c \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.c \ $(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_cfft_radix8_f32.c C_INCLUDES += \ -I$(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Include # Core location, and generic makefile. SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core include $(SYSTEM_FILES_DIR)/Makefile
解决方法
1. 检查通用Makefile对汇编文件的支持
打开$(LIBDAISY_DIR)/core/Makefile,确认:
- 是否存在对
ASM_SOURCES变量的处理逻辑,比如是否将其加入总源文件列表 - 是否定义了
.s.o的编译规则(即把汇编文件编译为目标文件的规则)
如果通用Makefile未处理汇编文件,需要在自己的Makefile中手动添加相关规则。
2. 手动添加汇编文件编译规则
在include $(SYSTEM_FILES_DIR)/Makefile之前,添加以下规则:
# 编译ARM汇编文件 build/%.o: %.s $(AS) $(ASFLAGS) -c $< -o $@
确保AS(ARM汇编器,通常为arm-none-eabi-as)和ASFLAGS(汇编器参数,需包含目标架构,比如-mthumb -mcpu=cortex-m7)在通用Makefile中已正确定义。
3. 验证汇编文件路径正确性
确认$(LIBDAISY_DIR)/Drivers/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal2.s文件真实存在,路径拼写无误(Linux/macOS环境下路径大小写敏感)。
4. 确认汇编文件架构兼容性
arm_bitreversal2.s是针对ARMv7-M架构(Cortex-M3/M4/M7)的汇编代码,Daisy平台使用Cortex-M7,需确保ASFLAGS中包含正确的架构参数,比如:
ASFLAGS += -mthumb -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard
内容的提问来源于stack exchange,提问作者Phil
相关产品推荐
相关产品推荐

