在没有IDE的情况下如何使用CMSIS? [英] How do you use CMSIS without an IDE?

查看:134
本文介绍了在没有IDE的情况下如何使用CMSIS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用STM32F103C8T6,并且想使用CMSIS,这实际上只是寄存器定义,没有代码,让我的生活更轻松,同时仍然保持低水平.问题是我不知道如何安装该库以在命令行上与Makefile一起使用.所有文档似乎都绑定了特定于供应商的IDE,例如STM32CubeIDE.

I am working with STM32F103C8T6 and would like to use CMSIS, which is essentially just register definitions and no code, to make my life easier while still staying at a low level. The problem is that I have no idea how to install the library for use on the command line with Makefile. All documentation seems to be bound with a vendor-specific IDE like STM32CubeIDE.

我想要做的第一件事就是下载CMSIS库,该库是在 GitHub上找到的.但是,解压缩 ARM.CMSIS.5.6.0.pack 后,我没有找到名为 stm32f10x.h 的文件.我花了一些时间,发现一个CMSIS包适用于我正在使用的特定MCU,但其中不包含 core_cm3.h ,但是该代码显示在 ARM.CMSIS.5.6.0.pack 中.文档说,我需要将两者都包括在内项目,那么我需要将从其他位置下载的文件复制到我的项目中吗?

I suppose the first thing to do is to download the CMSIS library, which I found on GitHub. However, after unzipping ARM.CMSIS.5.6.0.pack I found no files named stm32f10x.h. I spend some more time and found a CMSIS pack for the specific MCU I'm using, but it doesn't contain core_cm3.h, which however presents in ARM.CMSIS.5.6.0.pack. The document says I need to include both to my project, so do I need to copy the files downloaded from different places to my project, or what?

一个额外的问题:CMSIS和Keli之间是什么关系?特定于设备的CMSIS包是从 www.keil.com 下载的,但是我现在不想使用Keil MDK,因为它似乎是一种商业产品,并且GNU Arm工具链是很好地为我服务.

As a bonus question: what is the relationship between CMSIS and Keli? The device-specific CMSIS pack is downloaded from www.keil.com, but I don't want to use Keil MDK for now, as it appears to be a commercial product, and the GNU Arm toolchain is serving me pretty well.

编辑:从一开始我就应该更具体一些,但现在让我们集中讨论如何构建

I should have been more specific from the beginning, but now let's focus on how to build the Basic CMSIS Example as a minimal, complete and verifiable example.

我做了什么:

  1. 将CMSIS-Core和CMSIS-DFP下载并解压缩到/Users/nalzok/Developer/CMSIS/ARM.CMSIS.5.6.0//Users/nalzok/Developer/CMSIS/Packs/Keil.STM32F1xx_DFP.2.3.0/.
  2. 创建一个名为 main.c 的文件,然后复制
  1. Download and unzip CMSIS-Core and CMSIS-DFP to /Users/nalzok/Developer/CMSIS/ARM.CMSIS.5.6.0/ and /Users/nalzok/Developer/CMSIS/Packs/Keil.STM32F1xx_DFP.2.3.0/, respectively.
  2. Create a file named main.c, and copy the content of the basic example to it.
  3. Add #define STM32F10X_MD on the very first line to specify the chip.
  4. Fix typos: replace the : on line 31 to ;, and replace line 33 to timer1_init (42);.
  5. Build and get an error


/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 Output_Response ,但是现在我有一些不同的错误.

As per @KamilCuk's comment below, I added more options and commented out the functions Get_InputValues, Calculation_Response, and Output_Response, but now I am having some different errors.

/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

推荐答案

有关最新的设备标头,建议从ST网站下载 STM32CubeF1 程序包.除其他外(中间件,HAL等),此软件包在/Drivers/CMSIS/Device 文件夹中包含必需的设备头.您需要为 stm32f1xx.h 标头定义的 STM32F103xB 符号才能正常工作.

For the latest device headers, I suggest downloading STM32CubeF1 package from the ST website. Among other things (Middlewares, HAL etc.), this package contains the required device headers in /Drivers/CMSIS/Device folder. You need STM32F103xB symbol defined for stm32f1xx.h header to work correctly.

当然, STM32CubeF1 软件包还包含CMSIS库,但是它们通常有些过时了.我更喜欢从您提到的github存储库中以.pack文件的形式下载它们.您至少需要/CMSIS/Core 中的标头.如果需要,可以添加CMSIS的其他部分.其中一些(例如DSP)可能还需要您添加/Lib 文件夹中提供的静态库.

Of course, STM32CubeF1 package also contains CMSIS libraries but they are generally a little bit outdated. I prefer to download them as .pack files from the github repo you mentioned. You need the headers in /CMSIS/Core at least. You may add additional parts of the CMSIS if you wish. Some of them (like DSP) may also need you to add static libraries provided in /Lib folders.

请注意,如果您从github克隆CMSIS存储库而不是下载.pack文件,则最终将获得静态库的占位符版本,因为该项目使用 git LFS .您不能直接使用这些静态库文件(.a文件),因为它们只是某种指针.我不熟悉 git LFS ,但是我想您需要一些git命令(也许是结帐)来告诉您的PC下载实际的.a文件.

Please be aware that if you clone the CMSIS repo from github instead of downloading the .pack file, you end up with placeholder versions of the static libraries, as the project uses git LFS. You can't use these static library files (.a files) directly as they are just some kind of pointers. I'm not familiar with git LFS, but I guess you need some git commands (maybe checkout) to tell your PC to download the actual .a files.

还请注意,有时CMSIS文件夹结构会因版本而异.您在 STM32CubeF1 中获得的文件夹结构可能与您从官方CMSIS存储库中下载的文件夹结构不同.

Also note that sometimes CMSIS folder structure changes from version to version. The folder structure you get in STM32CubeF1 may be different from the one you download from the official CMSIS repo.

我忘了提及:除了CMSIS和ST设备标头,您还需要以下文件:

I forgot to mention: Other than CMSIS and ST device headers, you also need the following files:

  • system_stm32f1xx.c( STM32CubeF1 /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates 文件夹)
  • startup_stm32f103xb.s( STM32CubeF1 /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc 文件夹)
  • STM32CubeF1 程序包/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker 文件夹中的链接描述文件.奇怪的是,没有STM32F103x8,因此您可能需要选择STM32F103xB并对其进行修改.我使用IDE生成的一个.
  • system_stm32f1xx.c (STM32CubeF1 package /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates folder)
  • startup_stm32f103xb.s (STM32CubeF1 package /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc folder)
  • A linker script from STM32CubeF1 package /Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker folder. Strangely, there is none for STM32F103x8, so you probably need to pick STM32F103xB and modify it. I use an IDE generated one.

更新:

在这里,您可以找到在STM32CubeIDE中创建的最小项目.我创建了一个空的C项目.IDE提供了一个链接描述文件和一个启动文件(.s),但我删除了它们并使用了 STM32CubeF1 包中包含的文件.我还从/Drivers/Device/ST/STM32F1xx/Include目录中删除了不相关的头文件.但是我没有碰过/Drivers/CMSIS/Core/Include中的文件,尽管那里有许多不相关的文件,因为很难确定哪些文件是不需要的.

Here you can find a minimal project created in STM32CubeIDE. I created an empty C project. The IDE provides a linker script and a startup file (.s) but I deleted them and used the ones included in the STM32CubeF1 package. I also deleted unrelated header files from the /Drivers/Device/ST/STM32F1xx/Include directory. But I didn't touched the ones in the /Drivers/CMSIS/Core/Include although there are lots of unrelated files there, as it's harder to determine which ones are needed and which ones are not.

我知道您正在寻找没有IDE的解决方案,但是我认为这个示例项目至少可以为您提供有关所需文件和项目结构的一些线索.

I know that you look for a solution without an IDE, but I think this example project can at least give you some clues about the required files and the project structure.

注意:示例项目名称为 blinky.cube ,但是项目中没有Cube.我使用这种命名约定只是为了指定我使用的IDE,在这种情况下为STM32CubeIDE.

Note: The example project name is blinky.cube but there is no Cube in the project. I use this naming convention just to specify the IDE I use, which is STM32CubeIDE in this case.

这篇关于在没有IDE的情况下如何使用CMSIS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆