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?
98 次查看（过去 30 天）
MathWorks Support Team ，2016-5-26
编辑： MathWorks Support Team ，2021-5-19
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
MathWorks Support Team 2016-5-26
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
编辑：MathWorks Support Team 2021-5-19
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 2018-2-26
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
Find more on Code Generation for ARM Cortex-M and ARM Cortex-A Processors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!