在Keil中使用HAL库时出现.\Objects\test.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32f107xc.o).等问题。
在上一篇中谈到使用stm32f107的HAL库,实践中出现以下问题:
.\Objects\test.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32f107xc.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol __UNALIGNED_UINT32_WRITE (referred from stm32f1xx_ll_usb.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol __UNALIGNED_UINT32_READ (referred from stm32f1xx_ll_usb.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol SystemCoreClock (referred from stm32f1xx_hal.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol AHBPrescTable (referred from stm32f1xx_hal_rcc.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol APBPrescTable (referred from stm32f1xx_hal_rcc.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol __UNALIGNED_UINT32_READ (referred from stm32f1xx_ll_usb.o).
原因
问题是未定义一些东西,即使我去定义
void SystemInit()
{
}
仍然有些问题,后来发现是没有添加头文件stm32f107xc.h.
解决办法
目录:(你在官网上下载的STM32Cube_FW_F1_V1.8.0下的目录)\STM32Cube_FW_F1_V1.8.0\Drivers\CMSIS\Device\ST\STM32F1xx\Include
复制到你的工程文件下\KEIL files\Hal_test\STM32F1xx_HAL_Driver 下
至于下面的两个错误解决办法是c文件中添加定义
.\Objects\test.axf: Error: L6218E: Undefined symbol __UNALIGNED_UINT32_WRITE (referred from stm32f1xx_ll_usb.o).
.\Objects\test.axf: Error: L6218E: Undefined symbol __UNALIGNED_UINT32_READ (referred from stm32f1xx_ll_usb.o).
void __UNALIGNED_UINT32_READ(){}
void __UNALIGNED_UINT32_WRITE(){}

注:如遇到这种问题"Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
解决办法:就在stm32f1xx.h文件下取消你所用的mcu的注释就可以了,我用的是STM32F107VC,所以修改如图

本文解决在Keil中使用STM32 HAL库时出现的未定义符号错误,如SystemInit等。通过添加stm32f107xc.h头文件及定义特定函数,如__UNALIGNED_UINT32_READ和__UNALIGNED_UINT32_WRITE,成功解决编译问题。
2836

被折叠的 条评论
为什么被折叠?



