- Clean Reinstallation of Support Package
- Follow the steps for reinstalling a support package
- Create a new local directory to store downloaded firmware packages (for example, this could be 'C:/Users/MyUser/STM32Cube/MyRepo/')
- Open STM32CubeMX and then proceed with the hardware setup popup from MATLAB
- Select the new local folder ( 'C:/Users/MyUser/STM32Cube/MyRepo/' or whatever you choose as the name) to host downloaded firmware packages
- Retry a second time in hardware setup to install firmware if the build issue recurs
- Path and Preferences Check
- Run the following commands in the MATLAB Command Line:
- rehash path getpref('MW_STM32')
- Check if the preference variable "STM32CubeFW" outputs the correct firmware path. Make sure this matches the one under "Help -> Updater Settings" in STM32CubeMX. If not, download the complete firmware to the new location again
- Run the following commands in the MATLAB Command Line:
- Clear Cache and Refresh Customizations
- Before building, run these commands in the MATLAB command window:
- clear all; clear classes; rehash path; rehash toolbox; rehash pathreset; rehash toolboxreset; rehash toolboxcache; RTW.TargetRegistry.reset; sl_refresh_customizations;
- Check under Simulink Preferences in the MATLAB Toolstrip and under General Preferences to make sure the "Code generation folder" is blank for default behavior
- Before building, run these commands in the MATLAB command window:
- Path Requirements
- Ensure there are no spaces in the path, in your case "My Documents" has a space which can cause issues with locating certain paths
- The firmware path should be the new one you created, specifically when running the setup screen after clean installation
- New Model and Firmware Path
- Try with a new model and new .ioc file
- In STM32CubeMX, check if the firmware location is pointing the path to the newly created one and that the version showing is 1.16.2
Why do I see missing header files when I try to build my model for STM32 Boards using Embedded Coder?
5 views (last 30 days)
Show older comments
MathWorks Support Team
on 31 Dec 2020
Edited: MathWorks Support Team
on 30 Jul 2025
I am trying to generate code for a very simple model with using Embedded Coder R2023a with the Embedded Coder Support Package for STMicroelectronics STM32 Processors package. I made sure all the blocks I am using are from this support package, so there should be no compatibility issues. However, I keep seeing the following error when building:
C:/Users/MyUser/Documents/My Documents/STM32Project/Core/Inc/stm32f7xx_hal_def.h:29:10: fatal error: stm32f7xx.h: No such file or directory
29 | #include "stm32f7xx.h"
What I have checked and tried so far:
- I am using compatible versions of STM32CubeMX 6.4.0 and v1.16.2 for the STM32F7 Firmware package downloaded through the hardware support package setup popup in MATLAB.
- In model settings I set “F7xx Based” in “Configuration Parameters -> Hardware Implementation”
- I cleared all my cache, "slprj", and other build artifacts before building
- I created a new .ioc file from the Model Settings
- After successfully creating this .ioc file, I checked the firmware path in STM32CubeMX under "Project Manager -> MCU and Firmware Package" is set to "STM32Cube FW_F7_V1.16.2"
- I ran the following command and manually checked that the firmware is installed correctly:
setpref('MW_STM32','STM32CubeFW','C:/Users/MyUser/STM32Cube/Repository/')
Then when I generate code, I am able to see the missing header file in a Drivers folder in the same directory as the model. However, I still get the error when building.
Accepted Answer
MathWorks Support Team
on 30 Jul 2025
Edited: MathWorks Support Team
on 30 Jul 2025
This issue is likely related to your environment or installation. As a workaround, please try the following steps:
Then try to build and generate code again using Embedded Coder.
If these initial steps do not resolve your build issues, please try to reinstall MATLAB and go through the hardware setup page again to install the necessary firmware. Follow the steps listed above and try to build again.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!