迁移华为的liteOS到STM32F4的开发板上,按照官方的步骤修改makefile后报错:
代码语言:javascript复制arm-none-eabi-gcc.exe: warning: '-x assembler-with-cpp' after last input file has no effect
arm-none-eabi-gcc.exe: fatal error: no input files
compilation terminated.
解决过程
根据Makefile的报错地点可以看出是在对.S文件的编译过程中找不到文件所致,将结果打印出来:
代码语言:javascript复制arm-none-eabi-gcc -x assembler-with-cpp -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -DUSE_STDPERIPH_DRIVER -DSTM32F407xx -DSTM32F40_41xxx -I./Inc -IProjectDrivers/Inc -IProjectDrivers/Inc/Inc -IProjectDrivers/Inc/CORE -IDrivers/CMSIS/include -I./Src/SYSTEM -I./Src/MALLOC -I./ProjectDrivers/HARDWARE -IThirdParties/LWIP -I./ThirdParties/LWIP -I./ThirdParties/LWIP/arch -I./ThirdParties/LWIP/lwip_app -I./ThirdParties/LWIP/lwip_app/lwip_comm -I./ThirdParties/LWIP/lwip_app/tcp_server_demo -I./ThirdParties/LWIP/lwip_app/udp_demo -I./ThirdParties/LWIP/lwip-1.4.1 -I./ThirdParties/LWIP/lwip-1.4.1/src -I./ThirdParties/LWIP/lwip-1.4.1/src/api -I./ThirdParties/LWIP/lwip-1.4.1/src/core -I./ThirdParties/LWIP/lwip-1.4.1/src/core/ipv4 -I./ThirdParties/LWIP/lwip-1.4.1/src/include -I./ThirdParties/LWIP/lwip-1.4.1/src/include/ipv4 -I./ThirdParties/LWIP/lwip-1.4.1/src/include/ipv4/lwip -I./ThirdParties/LWIP/lwip-1.4.1/src/include/lwip -I./ThirdParties/LWIP/lwip-1.4.1/src/include/netif -I./ThirdParties/LWIP/lwip-1.4.1/src/netif -I./utils/datastructure -I./utils/tools -I ./Middlewares/LiteOS/arch/arm/arm-m/include -I ./Middlewares/LiteOS/arch/arm/common/cmsis -I./OS_CONFIG -I ./Middlewares/LiteOS/kernel/base/include -I ./Middlewares/LiteOS/kernel/extended/include -I ./Middlewares/LiteOS/kernel/include -O1 -Wall -Wno-pointer-sign -Wno-missing-braces -Wno-format -Wno-address -Wno-unused-but-set-variable -s -fdata-sections -ffunction-sections -g -gdwarf-2 --specs=nano.specs --specs=nosys.specs -MMD -MP -MF"Output/obj/los_dispatch_gcc.d"./Middlewares/LiteOS/arch/arm/arm-m/cortex-m4/gcc/los_dispatch_gcc.S -o Output/obj/los_dispatch_gcc.o
注意这里-MF"Output/obj/los_dispatch_gcc.d"./Middlewares/LiteOS/arch/arm/arm-m/cortex-m4/gcc/los_dispatch_gcc.S
,".d"后面紧跟着./Middlewares,这说明本该分开的两个参数被合并到一起了,查看Makefile:
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
@echo $(notdir $(<:.s=.o))
$(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS)$< -o $@
@echo $(notdir $(<:.s=.o))
第二个CFLAGS后面少了个空格,修改后如下:
代码语言:javascript复制$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
@echo $(notdir $(<:.s=.o))
$(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
@echo $(notdir $(<:.s=.o))
重新编译:
代码语言:javascript复制$ make
main.o
linking...
arm-none-eabi-size Output/obj/out.elf
text data bss dec hex filename
31876 308 3456 35640 8b38 Output/obj/out.elf
# rm -fR Output/obj/Output/obj
# mkdir Output/obj/Output/obj
arm-none-eabi-objcopy -O ihex Output/obj/out.elf Output/obj/out.hex
arm-none-eabi-objcopy -O binary -S Output/obj/out.elf Output/obj/out.bin
cp Output/obj/*.bin Output/bin/
cp Output/obj/*.elf Output/bin/
cp Output/obj/*.hex Output/bin/
cp Output/obj/*.map Output/bin/