我正在使用 STM32F103C8T6 并想使用 CMSIS,这本质上只是寄存器定义,没有代码,让我的生活更轻松,同时仍保持在较低水平。问题是我不知道如何安装该库以便在命令行上使用 Makefile 使用。所有文档似乎都与特定于供应商的 IDE(例如 STM32CubeIDE)绑定。
我想要做的第一件事就是下载 CMSIS 库,我在GitHub。然而解压后ARM.CMSIS.5.6.0.pack
我发现没有名为stm32f10x.h
。我又花了一些时间发现CMSIS 包对于我正在使用的特定 MCU,但它不包含core_cm3.h
,然而它呈现在ARM.CMSIS.5.6.0.pack
. The document说我需要将两者都包含到我的项目中,那么我是否需要将从不同地方下载的文件复制到我的项目中,或者什么?
作为一个额外的问题:CMSIS 和 Keli 之间的关系是什么?设备特定的 CMSIS 包可从以下地址下载www.keil.com
,但我现在不想使用 Keil MDK,因为它似乎是一个商业产品,并且 GNU Arm 工具链为我提供了很好的服务。
Edit:我应该从一开始就更具体,但现在让我们关注如何构建基本 CMSIS 示例作为一个最小的、完整的、可验证的例子。
我做了什么:
- 下载并解压 CMSIS-Core 和 CMSIS-DFP 以
/Users/nalzok/Developer/CMSIS/ARM.CMSIS.5.6.0/
and /Users/nalzok/Developer/CMSIS/Packs/Keil.STM32F1xx_DFP.2.3.0/
, 分别。
- 创建一个名为
main.c
,并复制内容基本示例 to it.
- Add
#define STM32F10X_MD
在第一行指定芯片。
- 修正错别字:替换
:
31号线到;
,并将第 33 行替换为timer1_init (42);
.
- 构建并出现错误
/tmp $ arm-none-eabi-gcc -I/Users/nalzok/Developer/CMSIS/ARM.CMSIS.5.6.0/CMSIS/Include/ -I/Users/nalzok/Developer/CMSIS/Packs/Keil.STM32F1xx_DFP.2.3.0/Device/Include/ main.c
main.c: In function 'main':
main.c:42:5: warning: implicit declaration of function 'Get_InputValues' [-Wimplicit-function-declaration]
42 | Get_InputValues (); // Read Values
| ^~~~~~~~~~~~~~~
main.c:44:5: warning: implicit declaration of function 'Calculation_Response' [-Wimplicit-function-declaration]
44 | Calculation_Response (); // Calculate Results
| ^~~~~~~~~~~~~~~~~~~~
main.c:45:5: warning: implicit declaration of function 'Output_Response' [-Wimplicit-function-declaration]
45 | Output_Response (); // Output Results
| ^~~~~~~~~~~~~~~
/var/folders/m4/7my6q_kj6pxgzb1b7pxyhp0h0000gn/T//cc1ZVBaH.s: Assembler messages:
/var/folders/m4/7my6q_kj6pxgzb1b7pxyhp0h0000gn/T//cc1ZVBaH.s:197: Error: selected processor does not support `wfe' in ARM mode
/var/folders/m4/7my6q_kj6pxgzb1b7pxyhp0h0000gn/T//cc1ZVBaH.s:310: Error: selected processor does not support `cpsid i' in ARM mode
/var/folders/m4/7my6q_kj6pxgzb1b7pxyhp0h0000gn/T//cc1ZVBaH.s:318: Error: selected processor does not support `cpsie i' in ARM mode
根据下面 @KamilCuk 的评论,我添加了更多选项并注释掉了函数Get_InputValues
, Calculation_Response
, and Output_Response
,但现在我遇到了一些不同的错误。
/tmp $ arm-none-eabi-gcc -I/Users/nalzok/Developer/CMSIS/ARM.CMSIS.5.6.0/CMSIS/Include/ -I/Users/nalzok/Developer/CMSIS/Packs/Keil.STM32F1xx_DFP.2.3.0/Device/Include/ -D STM32F1 -D STM32F103x6 -mthumb -mcpu=cortex-m3 main.c
/Users/nalzok/opt/xPacks/arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /Users/nalzok/opt/xPacks/arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x16): undefined reference to `_exit'
/Users/nalzok/opt/xPacks/arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /var/folders/m4/7my6q_kj6pxgzb1b7pxyhp0h0000gn/T//ccqfC5LA.o: in function `Device_Initialization':
main.c:(.text+0x164): undefined reference to `SystemCoreClock'
collect2: error: ld returned 1 exit status