I have a bare metal STM32 C project working on a NUCLEO-F446RE. To learn about MCUs, I did not use any code generators or IDEs, but created a simple Makefile, linker script, start up C code, and #defines for the memory registers (using things like this and this as references.

I'd like to include the CMSIS files for STM32 Cortex M F446RE, so that I don't have to manually define the register locations. However, all the instructions I can find on how to do this state "Download Keil or STM32Cube and use the GUI".

Since CMSIS is a standard, I expect it possible to avoid having to use a GUI generator. I've already downloaded all the STM32 files, and I'd simply like to use them in my project. However, navigating them, to know which ones to include, is proving tough.

I'd expect to be able to do something like:

  1. Add one or more #defines (e.g. specifying the MCU)to the command line args given to gcc in my Makefile
  2. Add one or more source files (.c or .s) to the sources given to gcc in my Makefile
  3. Add one or more #includes in my actual code.

Is this documented anywhere? How can I determine what to #define/compile/#include to use CMSIS?

I'd expect perhaps a few other potential steps:

  1. Take out some of my linker script and initialization code
  2. and instead implement some of the symbols defined in the CMSIS (for startup and interrupt routines).

I'm happy to do this, but would like to do this knowingly, without using a GUI IDE which generates all sorts of code for me. How can I do this? Is there a simple example available? Or reference doc? This https://www.keil.com/pack/doc/CMSIS/Core/html/using_pg.html provides a high level overview, but not enough to know which specific files and #defines are needed for e.g. STM32F446RE.


I see the original question title "Can I use CMSIS without a GUI or IDE" may be misleading. I know that in principle this is possible - the GUI doesn't have any magic powers, it simply sets up the relevant files. I've corrected the question to be more clear: How do I do this? How do I find:

  1. Which files I need to copy into my project
  2. Which defines I need to make
  3. What else is, if anything, is needed to use CMSIS
  • \$\begingroup\$ For the STM32 CMSIS code, all you typically have to do is #define the specific MCU you're using it on and then #include the "master" header file for that MCU family. So for your F446RE, you'd #define STM32F446xx and #include "stm32f4xx.h". \$\endgroup\$
    – brhans
    Commented Sep 4, 2023 at 14:23

1 Answer 1


Well yes of course you can.
Code is here: https://github.com/ARM-software/CMSIS_5
Also available with driver pack from ST: https://github.com/STMicroelectronics/STM32CubeF4

  1. The compiler doesn't know about CMSIS, it only knows about target architecture, you've already solved that problem. You may need to add some defines in the proprocessor to compile the right parts of cmsis. But most of the selection is file based (2). However, ST's HAL can take care of most of these defines.

  2. Yeah, stm32f446xx.h probably already takes care about that. L#169

  3. I don't your linker script will become easier... there is a reason people use and IDE! But startup yes, especially clock tree stuff.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.