2021-05-19 10:55 AM
Hello all,
I am having severe issues trying to compile and getting to work a blink LED example on Simulink using the STM32-MAT/Target version 5.6.
At first, I was trying the example on the hands on documentation of the STM32-MAT/Target. Which is blinking a LED using Timers 1, 6, and the pushbutton on my Nucleo board (Nucleo-F767ZI). I was using version 1.6.1 of the STM32CubeIDE, version 6.2 of STMCubeMX, MATLAB/Simulink version 2020B and windows 10.
I wasn't able to create a .project file for the IDE until I downloaded Java version 8.45 which correctly linked everything together I assume. However, when it came to building the project, I was getting several errors about undeclared functions and variables that I wasn't able to figure out.
I decided to look deeper into the documentation for the STM32-MAT/Target and looked at the last supported software for it (version 5.6 of CubeMX , 1.3 of CubeIDE, and MATLAB/Simulink 2018B). I rolled back the software to those versions thinking it might solve the issues I was having. It didn't turn out that way as now I am getting errors related to object files not being generated ( .o files).
I also tried this on a separate computer with the same software to see if my PC was the issue. I am successfully building the model but I get this message "Code generation information file does not exist." that I dont get on my PC and the .project file is not being generated at all.
I have really ran out of ideas of things to try and any help or advice would be greatly appreciated. I will reply/edit my post with the error messages that I am getting.
Error Message:
15:47:36 **** Build of configuration Debug for project test ****
make -j16 all
arm-none-eabi-gcc "../test/Src/test.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"test/Src/test.d" -MT"test/Src/test.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "test/Src/test.o"
arm-none-eabi-gcc "../Src/main.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/main.d" -MT"Src/main.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Src/main.o"
arm-none-eabi-gcc "../Src/stm32f7xx_hal_msp.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/stm32f7xx_hal_msp.d" -MT"Src/stm32f7xx_hal_msp.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Src/stm32f7xx_hal_msp.o"
arm-none-eabi-gcc "../Src/stm32f7xx_it.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/stm32f7xx_it.d" -MT"Src/stm32f7xx_it.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Src/stm32f7xx_it.o"
arm-none-eabi-gcc "../Src/syscalls.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/syscalls.d" -MT"Src/syscalls.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Src/syscalls.o"
arm-none-eabi-gcc "../Src/sysmem.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/sysmem.d" -MT"Src/sysmem.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Src/sysmem.o"
arm-none-eabi-gcc "../Src/system_stm32f7xx.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Src/system_stm32f7xx.d" -MT"Src/system_stm32f7xx.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Src/system_stm32f7xx.o"
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
arm-none-eabi-gcc "../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMemUnit_T=uint8_T' -DMEM_UNIT_BYTES -DUSE_HAL_DRIVER -DSTM32F767xx -DARM_MATH_CM7 -DMATLAB_PROJECT -DDEBUG -c -I../Inc -I../Drivers/CMSIS/DSP/Include -I../Drivers/CMSIS/Include -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Core/Include -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../../../Program Files/MATLAB/R2018b/simulink/include -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../test/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.d" -MT"Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.o"
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
make: *** [test/Src/subdir.mk:18: test/Src/test.o] Error 1
make: *** Waiting for unfinished jobs....
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
make: *** [Src/subdir.mk:33: Src/main.o] Error 1
make: *** [Src/subdir.mk:35: Src/stm32f7xx_hal_msp.o] Error 1
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
make: *** [Src/subdir.mk:37: Src/stm32f7xx_it.o] Error 1
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
make: *** [Src/subdir.mk:39: Src/syscalls.o] Error 1
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
make: *** [Src/subdir.mk:41: Src/sysmem.o] Error 1
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
make: *** [Src/subdir.mk:43: Src/system_stm32f7xx.o] Error 1
make: *** [Drivers/STM32F7xx_HAL_Driver/Src/subdir.mk:81: Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.o] Error 1
"make -j16 all" terminated with exit code 2. Build might be incomplete.
15:47:37 Build Failed. 9 errors, 0 warnings. (took 1s.111ms)
Solved! Go to Solution.
2021-05-21 11:35 AM
Well, turns out deleting the Files/MATLAB/R2018b/simulink/include directory from the project includes solved the issue and I was able to compile the code and load it into the Nucleo board. There is also this YouTube video (https://www.youtube.com/watch?v=ZmSPgDmEMTM) that I found and the person doing the tutorial experiences some of the same issues I was seeing.
2021-05-21 02:49 AM
Never played with Matlab. Does it produce an Eclipse CDT project and a makefile?
Look at the lines with errors, for example 10, 12, 15, ...:
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
In general it is good practice to never use space or non-ascii characters in paths. This can lead to issue in all development tools. GCC is not an exception.
In your case I believe that you or Matlab (or some other tool) created / generated a custom makefile. This makefile contains the following:
-I../../../Program Files/MATLAB/R2018b/simulink/include
That cannot work. Path with spaces must use:
-I"../../../Program Files/MATLAB/R2018b/simulink/include"
If you can address this issue you should be able to get a little bit further on the way, then let's see how deep the rabbit hole goes...
2021-05-21 08:46 AM
@HTeno.1 my pain is such STM32-MAT utility is marked as NRND (i.e. Non Recommended for New Design) ... are such IDE & MX recent releases still compliant with ? but if lucky already @mattias norlander is promoting good tips.
2021-05-21 10:14 AM
Matlab doesn't produce the CDT project files, however, i don't know about the make file.
When you set up your Simulink model, you link CubeMX to it and an .ioc file. When you create your .ioc file is when you tell CubeMX what toolchain you want to use. In my case, CubeIDE. The hands on documentation that comes with the STM32-MAT/Target explains this inmore detail in case you want to look at it.
As far as the space in the Files/MATLAB/R2018b/simulink/include directory, im not sure how to rename it within the IDE. I dont see any settings under Properties-> C/C++ Build General -> Paths and Symbols -> Includes that allows me to do something like that although I might try deleting the include folder but I don't think that is going to work.
2021-05-21 10:21 AM
Yeah, I realized this after talking to their support a couple weeks ago.
My first option was to use the "Simulink Coder Support Package Using STMicroelectronics Nucleo Boards". That support package lets me create a Simulink model and upload it to my board directly from Simulink but there aren't any instructions (that I could find) about how to take that code and export it to an IDE.
I really need that functionality to grab the generated code and export it to compile it somehwere else. I tried manually grabbing those files and creating a project in CubeIDE but I just keep getting endless errors about missing Simulink and Matlab header and source files that.
2021-05-21 11:35 AM
Well, turns out deleting the Files/MATLAB/R2018b/simulink/include directory from the project includes solved the issue and I was able to compile the code and load it into the Nucleo board. There is also this YouTube video (https://www.youtube.com/watch?v=ZmSPgDmEMTM) that I found and the person doing the tutorial experiences some of the same issues I was seeing.
2021-05-27 02:11 AM
I have no idea how the "generated output" (c/h-files and makefiles) from Matlab looks like.
Reading your previous comment and the build output from the console I make the conclusion that "the project" created by Matlab/Simulink is not self-contained. When I say that a project is "self-contained" it means that all the files needed for a successful is stored inside ONE top-level project folder.
In Matlab it seems this is not the case since:
arm-none-eabi-gcc: error: Files/MATLAB/R2018b/simulink/include: No such file or directory
Looks like project is including "shared header files" from the Matlab/Simulink install directory. Not so nice when you want to port the project to CubeIDE. It makes the "detective job" more difficult for you.
That said, I think you are doing the right thing: creating a new Empty or CDT project inside CubeIDE.
Then the process is a tedious work to resolve all dependencies. You have to analyze the makefiles to copy across defines and includes and potentially other important compiler/linker settings.
Then you have to try to either copy the needed h-files or link them into the project.
Make iterative builds to see "how deep the rabbit hole" goes. Hopefully you end up with a well-working project.
Feel free to share your results and way of working with the community! :)
Come back when/if you have more specific questions, but you have to drive the general porting work.
2021-05-27 06:58 AM
Thanks Mattias!
I would really like to have this second approach working sometime in the future and in the event that I do, I will definitely share it with the community. I really havent found a well documented tutorial for what I am trying to do so it could help someone in the future.