在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(){}