Why do I get the error "fatal error: core_cm4.h: No such file or directory" when using the STM32F4 Discovery board or ARM Cortex M?
79 views (last 30 days)
Why do I get the following error when trying to build the stm32f4discovery_gettingstarted example?
In file included from <command-line>:0:0:
C:/MATLAB/SupportPackages/R2015b/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include/stm32f4xx.h:245:81: fatal error: core_cm4.h: No such file or directory
#include "core_cm4.h" /* Cortex-M4 processor and core peripherals */
gmake: * [stm32f4discovery_gettingstarted.o] Error 1
Make sure the following are true:
(1) The version of CMSIS is correct (4.3.0)
(2) The folder for CMSIS contains all of the following contents: the folder CMSIS, the folder Device, and the file ARM.CMSIS.pdsc
(3) The folder for CMSIS is specified correctly in the targetupdater
More Answers (2)
murat on 16 Jan 2018
Edited: MathWorks Support Team on 19 May 2021
Hello, you need download cmsis packages from ARM github page and must be copy to "C:\ProgramData\MATLAB\SupportPackages\R2017a\3P.instrset\cmsis.instrset" folder. If that "cmsis.instrset" folder is not exist in 3P.instrset folder, create it and paste cmsis package after unzip. Your cmsis.instrset folder will looks like that https://prnt.sc/i1ce3x . After you can compile your program without errors.
download links:  https://github.com/ARM-software/CMSIS/tree/v4.4.0
Kirill Kirichenko on 26 Feb 2018
I have the same problem with 2017b. And I noticed that the generated mk file does not contain fill path to the CMSIS headers root, it contains -I/CMSIS/Include rather than having a full path like -Ic:/path/to/CMSIS/Include. The missing header file is under CMSIS/Include and the project doesn't compile.
Okay I can go to stm32f4discovery_gettingstarted_ert_rtw and edit stm32f4discovery_gettingstarted.mk file which also contains wrong path to /CMSIS/Lib/GCC/libarm_cortexM4lf_math.a and /CMSIS/RTOS/RTX/LIB/GCC/libRTX_CM4.a (paths aren't full too) and fix it all and then the project compiles. But next time I rebuild the project in Simulink it rewrites the makefile and the problem comes back. I did what murat said and it didn't help. It looks like I haven't done some CMSIS configuration step. Or the Simulink solution is wrong.
Signal Processing DSP System Toolbox Code Generation Code Generation for ARM Cortex-M and ARM Cortex-A Processors