[学习资料]

一个KEIL例程移植笔记

[复制链接]
452|3
手机看帖
扫描二维码
随时随地手机跟帖
丙丁先生|  楼主 | 2024-6-24 21:30 | 显示全部楼层 |阅读模式
Keil的例程移植是个重点
以上海灵动的FTHR-G0001为例
首先要有手册、例程
d82d10de-e278-465f-8282-9f98dabfa4be.zip
打开例程后发现总是少文件,还有因为路径问题报错
先看一下最终排除错误后的结果:
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps1.jpg
为力求真实,我从头开始截图说明:
打开Keil压缩包,把其中的文件夹 点右键 复制到 另一个位置,
从另一个位置的文件夹里打开KEIL文件,
以上说的是,不要再压缩文件中打开KEIL例程,会加载路径错误。
点开:
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps2.jpg
点开
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps3.jpg
点开,默认读者知晓KEIL安装,并装好keil v5
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps4.jpg
编译:
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps5.jpg
编译版本报错:
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps6.jpg
解决方式:
更换V6.2.1
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps7.jpg
重新编译:33个错误
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps8.jpg
用讯飞星火查询报错原因:
Build started: Project: USART_Interrupt
*** Using Compiler 'V6.21', folder: 'D:\Keil_v5\ARM\ARMCLANG\Bin'
Build target 'USART_Interrupt'
compiling main.c...
../main.c(33): warning: In file included from...
../platform.h:38:10: fatal error: 'hal_conf.h' file not found
   38 | #include "hal_conf.h"
      |          ^~~~~~~~~~~~
1 error generated.
compiling mm32g0001_it.c...
../mm32g0001_it.c(33): warning: In file included from...
../platform.h:38:10: fatal error: 'hal_conf.h' file not found
   38 | #include "hal_conf.h"
      |          ^~~~~~~~~~~~
1 error generated.
compiling usart_interrupt.c...
../usart_interrupt.c(34): warning: In file included from...
../platform.h:38:10: fatal error: 'hal_conf.h' file not found
   38 | #include "hal_conf.h"
      |          ^~~~~~~~~~~~
1 error generated.
compiling platform.c...
../platform.c(34): warning: In file included from...
../platform.h:38:10: fatal error: 'hal_conf.h' file not found
   38 | #include "hal_conf.h"
      |          ^~~~~~~~~~~~
1 error generated.
compiling hal_adc.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_adc.c'
ArmClang: error: no input files
compiling hal_crc.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_crc.c'
ArmClang: error: no input files
compiling hal_dbg.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_dbg.c'
ArmClang: error: no input files
compiling hal_exti.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_exti.c'
ArmClang: error: no input files
compiling hal_flash.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_flash.c'
ArmClang: error: no input files
compiling hal_gpio.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_gpio.c'
ArmClang: error: no input files
compiling hal_i2c.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_i2c.c'
ArmClang: error: no input files
compiling hal_iwdg.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_iwdg.c'
ArmClang: error: no input files
compiling hal_misc.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_misc.c'
ArmClang: error: no input files
compiling hal_pwr.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_pwr.c'
ArmClang: error: no input files
compiling hal_rcc.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_rcc.c'
ArmClang: error: no input files
compiling hal_spi.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_spi.c'
ArmClang: error: no input files
compiling hal_tim.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_tim.c'
ArmClang: error: no input files
compiling hal_uid.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_uid.c'
ArmClang: error: no input files
compiling hal_usart.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/HAL_Lib/src/hal_usart.c'
ArmClang: error: no input files
compiling system_mm32g0001.c...
ArmClang: error: no such file or directory: '../../../../../Device/MM32G0001/Source/system_mm32g0001.c'
ArmClang: error: no input files
assembling startup_mm32g0001_keil.s...
startup_mm32g0001_keil.s: error: A1023E: File "..\..\..\..\..\Device\MM32G0001\Source\KEIL_StartAsm\startup_mm32g0001_keil.s" could not be opened: No such file or directory
".\Objects\USART_Interrupt.axf" - 33 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:19
注释:
从编译错误信息来看,主要问题有以下几点:
1. 找不到头文件 "hal_conf.h"。请确保该头文件存在于正确的路径下,并在项目中正确引用。
2. 找不到源文件 "../../../../../Device/MM32G0001/HAL_Lib/src/hal_adc.c" 等。请确保这些源文件存在于正确的路径下,并在项目中正确引用。
3. 找不到汇编文件 "startup_mm32g0001_keil.s"。请确保该文件存在于正确的路径下,并在项目中正确引用。
请检查项目设置和文件路径,确保所有文件都存在于正确的位置,并在项目中正确引用。
从这个例程中移植 hal_conf.h :
41d52245-d97f-4fd6-820a-49cbe5a16954.zip
注意解压缩成文件夹再用,注意路径:
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps9.jpg​移植过程:
复制
file:///C:/Users/Administrator/AppData/Local/Temp/ksohtml2760/wps10.png​

使用特权

评论回复
丙丁先生|  楼主 | 2024-6-24 21:35 | 显示全部楼层
,总结:无外乎,复制、粘贴、引用、路径、编译、烧录和逐步反复重复直至解决BUG.技巧是讯飞星火的注释程序帮助理解英文!

使用特权

评论回复
wahahaheihei| | 2024-6-25 16:46 | 显示全部楼层
发的什么垃圾内容。。。

使用特权

评论回复
lemonhub| | 2024-7-14 11:22 | 显示全部楼层
wahahaheihei 发表于 2024-6-25 16:46
发的什么垃圾内容。。。

说的好

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

244

主题

716

帖子

1

粉丝