2394919_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2394919_en-US

2394919_en-US

S32 Design Studio - Export and Debug

2

Introduction


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.



3

Open the generated project in S32 Design Studio


MBDT generates code from Simulink models and exports it as an S32 Design Studio-compatible project. After a successful model build, the generated _Config 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.

Open the project from Simulink

To open the project from Simulink, open the model Hardware Settings from the Hardware tab or press Ctrl + E. Then go to Hardware ImplementationHardware board settingsTarget hardware resourcesS32 Design Studio Project and select Open.

ModelSettings.png

Figure 1. S32 Design Studio project settings in Simulink

A dialog appears and prompts you to select the S32 Design Studio installation path.

CristinaGrosu_0-1784029205090.png

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.

CristinaGrosu_1-1784029276242.png

Figure 3. S32 Design Studio path changing

The generated project opens in S32 Design Studio and is ready to build, configure, or debug.

CristinaGrosu_2-1784029297722.png

Figure 4. Generated project opened in S32 Design Studio

Open the project inside the IDE

To import the project manually into S32 Design Studio, follow these steps:

  1. Inside the IDE, select FileImportExisting Projects into Workspace.CristinaGrosu_3-1784029322172.png

    Figure 5. Importing an existing project into the workspace

  2. Browse for the _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.CristinaGrosu_4-1784029341994.png

    Figure 6. Directory selection for the generated project



4

Debug the generated application in S32 Design Studio


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.

Note: Ensure that the target hardware board is connected before starting the debug session.
CristinaGrosu_5-1784029377307.png

Figure 7. Starting the debug session

CristinaGrosu_6-1784029402671.png

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:

  • The Breakpoint action sets a breakpoint when you double-click in the left margin of a .c file:
     
    CristinaGrosu_9-1784029512145.png

    Figure 9. Breakpoint set in the generated source file

  • The Step Over (F6) action executes the current line while remaining in the same function:CristinaGrosu_10-1784029574437.png

    Figure 10. Step Over action in the Debug toolbar

  • The Step Into (F5) action enters a called function:CristinaGrosu_11-1784029598699.png

    Figure 11. Step Into action in the Debug toolbar

  • The Step Return (F7) action runs to the end of the current function:CristinaGrosu_12-1784029621660.png

    Figure 12. Step Return action in the Debug toolbar

  • The Resume (F8) action runs until the next breakpoint:CristinaGrosu_13-1784029651085.png

    Figure 13. Resume action in the Debug toolbar

    CristinaGrosu_14-1784029663308.png

    Figure 14. Breakpoint reached after pressing Resume action

  • The Suspend (F9) action pauses execution at the current instruction:CristinaGrosu_15-1784029686055.png

    Figure 15. Suspend action in the Debug toolbar

    CristinaGrosu_16-1784029703191.png

    Figure 16. Function paused after pressing Suspend action

  • The Terminate (Ctrl + F2) action stops the debug session and disconnects from the target:CristinaGrosu_17-1784029727404.png

    Figure 17. Terminate action in the Debug toolbar

  • The Disconnect action leaves the target running while detaching the debugger:CristinaGrosu_18-1784029746404.png

    Figure 18. Disconnect action in the Debug toolbar



5

Debug the code generated from the Simulink model


The code generated by the Simulink model can be found in the _step() 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.

CristinaGrosu_19-1784029773923.png

Figure 19. modelName_step function

In this function, you will also find the generated code for the blocks placed inside the Simulink model.

CristinaGrosu_20-1784029789766.png

Figure 20. Generated step function in the source code

To monitor variable values, hover over a variable to see its current value:

CristinaGrosu_21-1784029811632.png

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.

CristinaGrosu_22-1784029836554.png

Figure 22. Add new expression in Expressions view

CristinaGrosu_23-1784029861694.png

Figure 23. Variable added to Expressions view

Upon running the code, if the value changes, it will be highlighted.

CristinaGrosu_24-1784029881749.png

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.

CristinaGrosu_25-1784029904920.png

Figure 25. Variable name in Simulink model and generated code


6

Conclusion


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.

Tags (1)
No ratings
Version history
Last update:
yesterday
Updated by: