MATLAB: Do I get build errors about missing headers (arm_math.h) when using CMSIS Code Replacement Library for ARM Cortex

arm_math.hcmsiscrlEmbedded Codermw_cmsis.h

I am trying to use CMSIS Code Replacement Library (CRL) targeting ARM Cortex-M in R2019a.
My model contains cosine and sine blocks. After code generation, the Code Replacement Report confirms that crl_table_cmsis.mat library was used:
arm_cos_f32…………….<Root>/Sin1
arm_sin_f32…………….<Root>/Sin
The corresponding implementation header is mw_cmsis.h, which again includes arm_math.h from CMSIS library.
During build, I see below below error using Visual Studio 2017:
….\harness_embedded_light_ert_rtw\mw_cmsis.h(12): fatal error C1083: Cannot open include file: 'arm_math.h': No such file or directory

Best Answer

There are two things to note about builds using CMSIS code replacement libraries (CRL):
1) CMSIS libraries only work with GNU toolchains, not with Visual Studio compilers. Ensure that the selected toolchain is "GNU Tools for ARM Embedded Processors" in the "Code Generation" area of your model's Configuration Parameters.
2) The root cause for the error message is that no Hardware Board was selected in the model. CMSIS CRL will work when you select any of the Hardware boards that we ship as part of ARM Cortex Support Packages.
CMSIS needs this information, for example which ARM architecture (M0, M3, ...M7) is used. The correct CMSIS library will be selected based on the selected architecture. This information is coming from the Hardware Board parameter. Set this parameter accordingly in the "Hardware Implementation" area of your model's Configuration Parameters.
If you are not using any of the hardware boards that we support as part of our support packages, you can follow the Target Creation workflow to create a target for your hardware as explained here: https://www.mathworks.com/help/supportpkg/armcortexm/target-sdk.html
In this way, you can create a target and add the necessary information such as architecture, library name etc.