Error when building model in simulink "Error(s) encountered while building model"

59 views (last 30 days)
I'm using R2024a and Embedded Encoder Support Package for Infineon AURIX TC3x Microcontrollers inside the add on.
In Matlab Simulink when I build for the first time, the code can be successfully generated; but when I build for the second time, the code cannot be successfully generated. I need to delete the originally generated code file to build successfully.
Any help would be appreciated

Answers (1)

R
R on 19 Jun 2024
The issue you're encountering seems to be related to the code generation process not properly overwriting or managing previously generated files. This can be due to a variety of reasons, including but not limited to, file permissions, Simulink configuration settings, or issues within specific setup.
As a workaround, before building your project for the second time, use a pre-build callback to automate this. In Simulink, you can configure a pre-build callback as follows:
  1. In the Simulink® Toolstrip, on the Modeling tab, in the Design gallery, click Property Inspector.
  2. With no selection at the top level of your model or referenced model, on the Properties tab, in the Callbacks section, select the callback - InitFcn and update the model before each build.
  3. Here’s the callback code you can use:
try
rmdir('RollAxisAutopilot_ert_rtw', 's');
rmdir('slprj', 's');
catch Me
disp(Me.message);
end
where RollAxisAutopilot was the model name I used- you can replace it with yours.
You can use a function to clean the build folder, albeit you'd have to run it manually every time unless it's integrated into the model’s callbacks for automatic execution.

Community Treasure Hunt

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

Start Hunting!