cancel
Showing results for 
Search instead for 
Did you mean: 

Issues build simulink project with CRL "ARM CMSIS SIN COS" and SW4STM32. Error: unknown type name ‘__IO’

toniospritz
Associate III

Hello, i have a problem to build in PIL mode PMSM_FOC example. The problem is in the use of CRL: "ARM CMSIS SIN CON". After has manually add of the arm_math.h directory (C:\MATLAB\STM32-MAT\STM32\CRL\CMSIS_SIN_COS_CRL\FastMathFunctions) in the include paths (-l) the building process returns the following error code for 100 elements.

Building file: C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Src/arm_cos_f32.c
Invoking: MCU GCC Compiler
C:\MATLAB\STM32-MAT\STM32\STM32demos\MotorControl\FOC\PMSM_FOC_Compute_PIL\SW4STM32\PMSM_FOC_Compute\Debug
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DUSE_HAL_DRIVER -DARM_MATH_CM4 '-DMemUnit_T=uint8_T' '-DMEM_UNIT_BYTES=1' '-DRTIOSTREAM_TX_BUFFER_BYTE_SIZE=128' '-DRTIOSTREAM_RX_BUFFER_BYTE_SIZE=128' '-DCODER_ASSUMPTIONS_ENABLED=1' -DCODE_INSTRUMENTATION_ENABLED -DCA_CHECK_FLOATING_POINT_ENABLED -DCA_CHECK_LONG_LONG_ENABLED -DCA_CHECK_DAZ_ENABLED -DSTM32F429xx -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Inc" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/STM32F4xx_HAL_Driver/Inc" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Device/ST/STM32F4xx/Include" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Include" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Inc" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/slprj/stm32/PMSM_FOC_Compute" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/slprj/stm32/PMSM_FOC_Compute/coderassumptions" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/slprj/stm32/PMSM_FOC_Compute/pil" -I"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/slprj/stm32/_sharedutils" -I"C:/MATLAB/STM32-MAT/STM32/addSrc/inc" -I"C:/MATLAB/STM32-MAT/STM32/pil/stm32SerialRtiostream" -I"C:/Program Files/MATLAB/R2019b/extern/include" -I"C:/Program Files/MATLAB/R2019b/extern/include/coder/connectivity/CodeInstrTgtAppSvc" -I"C:/Program Files/MATLAB/R2019b/extern/include/coder/connectivity/CoderAssumpTgtAppSvc" -I"C:/Program Files/MATLAB/R2019b/extern/include/coder/connectivity/XILTgtAppSvc" -I"C:/Program Files/MATLAB/R2019b/rtw/c/ert" -I"C:/Program Files/MATLAB/R2019b/rtw/c/src" -I"C:/Program Files/MATLAB/R2019b/rtw/c/src/ext_mode/common" -I"C:/Program Files/MATLAB/R2019b/simulink/include" -I"C:/Program Files/MATLAB/R2019b/toolbox/coder/rtiostream/src" -I"C:/Program Files/MATLAB/R2019b/toolbox/coder/rtiostream/src/utils" -I"C:/Program Files/MATLAB/R2019b/toolbox/rtw/targets/pil/c" -I"C:/MATLAB/STM32-MAT/STM32/CRL/CMSIS_SIN_COS_CRL/FastMathFunctions"  -Og -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP -MF"MATLAB/arm_cos_f32.d" -MT"MATLAB/arm_cos_f32.o" -o "MATLAB/arm_cos_f32.o" "C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Src/arm_cos_f32.c"
In file included from C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:141:0,
                 from C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Inc/STM32_Config.h:40,
                 from C:/MATLAB/STM32-MAT/STM32/CRL/CMSIS_SIN_COS_CRL/FastMathFunctions/arm_math.h:256,
                 from C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Src/arm_cos_f32.c:30:
C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h:188:3: error: unknown type name '__IO'
   __IO uint32_t SR;     /*!< ADC status register,                         Address offset: 0x00 */
   ^~~~
C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h:188:17: error: expected ':', ',', ';', '}' or '__attribute__' before 'SR'
   __IO uint32_t SR;     /*!< ADC status register,                         Address offset: 0x00 */

Someone can help me? I've tried to add arm_cm4.h and stm32f429xx.h ditectories and i have the same error.

1 ACCEPTED SOLUTION

Accepted Solutions

>Now the program compiles and the PIL is run with simulink.

It's an example project.

If its proof of concept, then works is good enough.

>I've try to put the include inside the main or in the foc_compute files <snip> but in this cases the issues come back

I've not used "arm_math.h". My guess is the situation of arm_math.h and __CMSIS_GENERIC arise from its expectation the math code would be separated from the hardware. Can you organise your app so your "math" modules that include "arm_math.h" don't include "stm32f429xx.h"?

You might also find some answers at https://community.st.com/s/question/0D50X0000At139a.

View solution in original post

13 REPLIES 13
alister
Lead

>the building process returns the following error code

__IO is defined in Drivers\CMSIS\Include\core_<your-core>.h.

stm32f4xx.h should include stm32f429xx.h, should include core_cm4.h.

Either stm32f429xx.h has been modified or the FW package is broken.

thanks Alister for you answer.

I've check the stmf4xx.h header and is present in the include path (../../../Drivers/CMSIS/Device/ST/STM32F4xx/Include) and the directory is for stm429xx.h that use the defined "__IO".

The core_cm4.h instead is present in 2 directory and the files match. the directories are

(C:\MATLAB\STM32-MAT\STM32\STM32demos\MotorControl\FOC\PMSM_FOC_Compute_PIL\Drivers\CMSIS\Include)

and

(C:\MATLAB\STM32-MAT\STM32\STM32demos\MotorControl\FOC\PMSM_FOC_Compute_PIL\Drivers\CMSIS\Core\Include)

I've add manually ....core\include directory to the paths of the toolchain, but i've del same errors in the build process. (cmsis\include and cmsis\core\include have inside the same files)

thak you for help

toniospritz
Associate III
 

>and the directory is for stm429xx.h that use the defined "__IO".

You're confirming stm429xx.h includes "core_cm4.h"? Yes I know it does.

>I've add manually ....core\include directory to the paths

Your first post's console output shows "C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Include" is already included, your second post says "core_cm4.h" is in that directory, and your first post's compiler output in the console output doesn't indicate "core_cm4.h" wasn't found. Is the attached stm429xx.h the same file as was used in the compile in your first post?

You've attached good stm429xx.h and core_cm4.h files. So the build problem is now resolved?

The following comments are only to assist improving the quality of the software project...

>The core_cm4.h instead is present in 2 directory and the files match

Ideally there'd be only one "Drivers/CMSIS/Include" directory.

I see in your first post's compiler output, all the include directories are absolute. Ideally they'd all be relative your build directory, which is "C:\MATLAB\STM32-MAT\STM32\STM32demos\MotorControl\FOC\PMSM_FOC_Compute_PIL\SW4STM32\PMSM_FOC_Compute\Debug". The advantage of relative paths is, you could version-control it and another developer, or yourself at some later time, could clone the repository anywhere and build it OK.

No, the building process not finish....

I apologize for explaining badly and for my bad english.

I added those directories (cmsis/include and cmsis/core/include) as absolute references for testing only.

This is my include paths list:

../../../Inc
../../../Drivers/STM32F4xx_HAL_Driver/Inc
../../../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
../../../Drivers/CMSIS/Device/ST/STM32F4xx/Include
../../../Drivers/CMSIS/Include
../../../PMSM_FOC_Compute/Inc
../../../..
../../../../slprj/stm32/PMSM_FOC_Compute
../../../../slprj/stm32/PMSM_FOC_Compute/coderassumptions
../../../../slprj/stm32/PMSM_FOC_Compute/pil
../../../../slprj/stm32/_sharedutils
../../../../../../../addSrc/inc
../../../../../../../pil/stm32SerialRtiostream
"../../../../../../../../../../Program Files/MATLAB/R2019b/extern/include"
"../../../../../../../../../../Program Files/MATLAB/R2019b/extern/include/coder/connectivity/CodeInstrTgtAppSvc"
"../../../../../../../../../../Program Files/MATLAB/R2019b/extern/include/coder/connectivity/CoderAssumpTgtAppSvc"
"../../../../../../../../../../Program Files/MATLAB/R2019b/extern/include/coder/connectivity/XILTgtAppSvc"
"../../../../../../../../../../Program Files/MATLAB/R2019b/rtw/c/ert"
"../../../../../../../../../../Program Files/MATLAB/R2019b/rtw/c/src"
"../../../../../../../../../../Program Files/MATLAB/R2019b/rtw/c/src/ext_mode/common"
"../../../../../../../../../../Program Files/MATLAB/R2019b/simulink/include"
"../../../../../../../../../../Program Files/MATLAB/R2019b/toolbox/coder/rtiostream/src"
"../../../../../../../../../../Program Files/MATLAB/R2019b/toolbox/coder/rtiostream/src/utils"
"../../../../../../../../../../Program Files/MATLAB/R2019b/toolbox/rtw/targets/pil/c"
"../../../../../../../CRL/CMSIS_SIN_COS_CRL/FastMathFunctions"

The console put out only absolute addresses :(

in the attach the complete console output

here there is the full sw4stm32 project

>No, the building process not finish....

"C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Src/arm_cos_f32.c"
In file included from C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:141:0,
                 from C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Inc/STM32_Config.h:40,
                 from C:/MATLAB/STM32-MAT/STM32/CRL/CMSIS_SIN_COS_CRL/FastMathFunctions/arm_math.h:256,
                 from C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/PMSM_FOC_Compute/Src/arm_cos_f32.c:30:
C:/MATLAB/STM32-MAT/STM32/STM32demos/MotorControl/FOC/PMSM_FOC_Compute_PIL/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h:188:3: error: unknown type name '__IO'

At line 188 of stm32f429xx.h, the compiler's saying '__IO' is unknown type.

At line 174 of stm32f429xx.h, the compiler's including "core_cm4.h", which at line 222 is defining '__IO', like this:

#define     __IO    volatile             /*!< Defines 'read / write' permissions */

So something is inhibiting "core_cm4.h" from reaching line 222.

Do you have another different "core_cm4.h"?

Or, is something before stm32f429xx.h includes "core_cm4.h" defining __CORE_CM4_H_DEPENDANT?

Or, is something before stm32f429xx.h includes "core_cm4.h" defining __CMSIS_GENERIC?

Hi Alister,

I don't know if I made a mistake that canceled another one or made a correct change.

I thought I'd pass the chip references before the arm_mat.h definitions and added a #include "stm32f429xx.h" inside the header, before line 251.

Now the program compiles and the PIL is run with simulink.

Do you think it is correct?

Thanks for your patience and for the help you are giving me. You are an angel!:baby_angel: