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.
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?
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.
Edit: 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.
What I have done:
- 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. - Create a file named
main.c
, and copy the content of the basic example to it. - Add
#define STM32F10X_MD
on the very first line to specify the chip. - Fix typos: replace the
:
on line 31 to;
, and replace line 33 totimer1_init (42);
. - 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
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
how to install the library for use on the command line with Makefile
- you don't "install", you compile from sources and add include paths to your compiler, there is no installation. – KamilCuk-I
to the path of CMSIS-Core and the corresponding STM32 DFP, whereas developing for generic Arm Processors only calls for-I
to the former? The examples unfortunately doesn't specify the compiler options to build it. – nalzokcmake
for easier scripting and managing. The examples show how to use the library, not how to compile with it. With recent STM32CubeMX you can generate makefiles, if you want. – KamilCukrelationship between CMSIS and Keli?
- CMSIS is a library designed by ARM (the company "Arm Holdings"). Keil is a company that was acquired by ARM in 2005 and still exists and still offers producets. One is a library, the other is a company. Keil MDK, a product made by the company Keil, uses CMSIS as a library. – KamilCuk