在Keil中使用HAL库时出现.\Objects\test.axf: Error: L6218E: Undefined symbol SystemInit (referred from start)等

在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中使用HAL库时出现.\Objects\test.axf: Error: L6218E: Undefined symbol SystemInit (referred from start)等_第1张图片

这是我测试好的f107工程直接用link

你可能感兴趣的:(STM32学习笔记,STM32F107,STM32F1XX_HAL,Error:,L6218E:,Undefined,symbol,Sys)