This article explains how to take a project generated with the Model-Based Design Toolbox (MBDT) in Simulink and open, build, and debug it in S32 Design Studio. It focuses on the transition from model execution in Simulink to target-level debugging and validation on S32 hardware.
MBDT generates code from Simulink models and exports it as an S32 Design Studio-compatible project. After a successful model build, the generated folder contains the files required by the IDE. The project can then be opened directly from Simulink or imported into S32 Design Studio for further configuration, building, and debugging on S32 hardware.
Before opening or debugging the project in S32 Design Studio, build the Simulink model. The build process generates the code and project structure required for IDE integration.
You can open the generated project either directly from Simulink or manually from within S32 Design Studio. Use the Simulink option when you want to launch the generated project immediately after configuration. Use the IDE import option when you want to manage the project manually from an S32 Design Studio workspace.
To open the project from Simulink, open the model Hardware Settings from the Hardware tab or press Ctrl + E. Then go to Hardware Implementation → Hardware board settings → Target hardware resources → S32 Design Studio Project and select Open.
Figure 1. S32 Design Studio project settings in Simulink
A dialog appears and prompts you to select the S32 Design Studio installation path.
Figure 2. S32 Design Studio installation path selection
To select the S32 Design Studio installation path later, or to change it during toolbox usage, click Browse in the S32 Design Studio location field under the Tools Paths group.
Figure 3. S32 Design Studio path changing
The generated project opens in S32 Design Studio and is ready to build, configure, or debug.
Figure 4. Generated project opened in S32 Design Studio
To import the project manually into S32 Design Studio, follow these steps:
Figure 5. Importing an existing project into the workspace
_Config folder in Select root directory. Before clicking Finish, make sure that Copy projects into workspace is disabled. If the project is copied into the S32 Design Studio workspace, the build process will fail.Figure 6. Directory selection for the generated project
To build and debug the project in S32 Design Studio, select the project and click Debug. S32 Design Studio builds the project and automatically switches to the Debug perspective.
Figure 7. Starting the debug session
Figure 8. Debug perspective in S32 Design Studio
After the debugger launches and the application is loaded on the target, you can use the following actions to control program execution and inspect the generated code:
.c file:
Figure 9. Breakpoint set in the generated source file
Figure 10. Step Over action in the Debug toolbar
Figure 11. Step Into action in the Debug toolbar
Figure 12. Step Return action in the Debug toolbar
Figure 13. Resume action in the Debug toolbar
Figure 14. Breakpoint reached after pressing Resume action
Figure 15. Suspend action in the Debug toolbar
Figure 16. Function paused after pressing Suspend action
Figure 17. Terminate action in the Debug toolbar
Figure 18. Disconnect action in the Debug toolbar
The code generated by the Simulink model can be found in the function.
To enter this function, set a breakpoint before the function call, run the application until the breakpoint is reached, and then select Step Into. Alternatively, Ctrl + Click the function name to open the function and place a breakpoint inside it.
Figure 19. modelName_step function
In this function, you will also find the generated code for the blocks placed inside the Simulink model.
Figure 20. Generated step function in the source code
To monitor variable values, hover over a variable to see its current value:
Figure 21. Variable value displayed on hover
Alternatively, add the variable to the Expressions view by selecting Add new expression, entering the variable name, and pressing Enter.
Figure 22. Add new expression in Expressions view
Figure 23. Variable added to Expressions view
Upon running the code, if the value changes, it will be highlighted.
Figure 24. Variable value highlighted during debug
The names of the variables in the generated code are the same as the names they have in the Simulink model, making it easier to debug the generated code.
Figure 25. Variable name in Simulink model and generated code
After identifying the generated function and monitoring key variables, you can validate how the Simulink model behavior maps to the generated application running on the target hardware.
For more tutorials on installing, activating, and using S32 Design Studio, see the S32 Design Studio tutorials on the community page: S32 Design Studio Knowledge Base.