CMSIS code replacement library

9 次查看(过去 30 天)
Alex Bogias
Alex Bogias 2018-2-22
Hi all,
I have a number of Simulink function which encapsulate Matlab functions. I have split these function up in different models and I code generate them one at a time. Lets call the first model ModelA and the second ModelB. Both models require to use the CMSIS ARM library. Also ModelB has dependencies on ModelA.
ModelA seems to code generate fine, but when ModelB tries to code generate it spits out an error:
"C:\Program Files\MATLAB\R2017b\bin\win64\mex.exe" -c COPTIMFLAGS="-O2" -DMATLAB_MEX_FILE -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\ert\mathfunctions" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab" -I"C:\sw_dev\trunk_latest\development\G3\common\include" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\mathfunctions_ert_rtw" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\ert\_sharedutils" -I"C:\Program Files\MATLAB\R2017b\extern\include" -I"C:\Program Files\MATLAB\R2017b\simulink\include" -I"C:\Program Files\MATLAB\R2017b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2017b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src" -I"C:\sw_dev\trunk_latest\Development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src" DFPI_sfun.c
Building with 'MinGW64 Compiler (C)'.
In file included from C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\mathfunctions_ert_rtw/MathFunctions.h:26:0,
from C:\sw_dev\trunk_latest\Development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src\DFPI_sfun.h:30,
from C:\sw_dev\trunk_latest\Development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src\DFPI_sfun.c:4:
C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\ert\_sharedutils/mw_cmsis.h:12:22: fatal error: arm_math.h: No such file or directory
compilation terminated.
If I add an include (in the Simulation Target model Configuration file) pointing to the CMSIS support package where the arm_math.h is located then I get a whole host of errors:
"C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:314:4: "error: #error Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
#error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:387:11: error: unknown type name 'int8_t'
typedef int8_t q7_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:392:11: error: unknown type name 'int16_t'
typedef int16_t q15_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:397:11: error: unknown type name 'int32_t'
typedef int32_t q31_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:402:11: error: unknown type name 'int64_t'
typedef int64_t q63_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:484:10: error: unknown type name '__INLINE'
static __INLINE q31_t clip_q63_to_q31( "
If I set the code replacement library to the GNU C99 externsions I do not get this error. It seems this problem stems from the fact that ModelB depends on ModelA, where ModelA I use as a library of common function. I do this in order to avoid code duplication.
For example ModelA contains the function definitions for sin, cos, modulo, remainder, etc... which other models depend on. Typically the naming convention I use is "ModelA_cos", "ModelA_Sin", etc... and the functions in other models call them by this name. I was hoping this was a good way to avoid code duplication.
If I remove this 'type' of calling convention from ModelB and I simply use Matlabs' own sin, cos, etc... I can code generate fine using CMSIS as the code replacement library, but code is duplicate across models, which is something I would like to avoid.
Any ideas? Couldn't find much info online.
Thanks Alex
  1 个评论
Alex Bogias
Alex Bogias 2018-2-23
编辑:Alex Bogias 2018-2-27
After much trial and tribulation I added my own #include "stdint.h" file. This seemed to help but I am now getting the error below.
My guess is that this has to do with C89 (vs. C99 Standard Math Library) and the "ARM Compatible", type: "ARM Cortex" target I am specifying.
Building with 'MinGW64 Compiler (C)'.
MEX completed successfully.
### Linking ...
"C:\Program Files\MATLAB\R2017b\bin\win64\mex.exe" -silent LDFLAGS="$LDFLAGS " -output DFPI_sfun.mexw64 @DFPI_sfun.mol "C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\cmsis.instrset\CMSIS\Lib\GCC\libarm_cortexM7l_math.a"
C:/ProgramData/MATLAB/SupportPackages/R2017b/3P.instrset/mingw_w64.instrset/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: unknown architecture of input file `C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\cmsis.instrset\CMSIS\Lib\GCC\libarm_cortexM7l_math.a(arm_sin_f32.o)' is incompatible with i386:x86-64 output
C:/ProgramData/MATLAB/SupportPackages/R2017b/3P.instrset/mingw_w64.instrset/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: unknown architecture of input file `C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\cmsis.instrset\CMSIS\Lib\GCC\libarm_cortexM7l_math.a(arm_cos_f32.o)' is incompatible with i386:x86-64 output
C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\cmsis.instrset\CMSIS\Lib\GCC\libarm_cortexM7l_math.a(arm_sin_f32.o): could not read symbols: Invalid operation
collect2.exe: error: ld returned 1 exit status
[DFPI_sfun.mexw64] Error -1
Any help much appreciated.
Thanks

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by