Main Content

Generate AUTOSAR C Code and XML Descriptions

Generate AUTOSAR-compliant C code and export AUTOSAR XML (ARXML) descriptions from AUTOSAR component model.

If you have Simulink Coder and Embedded Coder software, you can build AUTOSAR component models. Building a classic component model generates algorithmic C code and exports ARXML descriptions that comply with AUTOSAR Classic Platform specifications. Use the generated C code and ARXML descriptions for testing in Simulink or integration into an AUTOSAR run-time environment.

Prepare AUTOSAR Component Model for Code Generation

Open a component model from which you want to generate AUTOSAR C code and ARXML descriptions. This example uses AUTOSAR example model autosar_swc.


Optionally, to refine model configuration settings for code generation, you can use the Embedded Coder Quick Start (recommended). This example uses the Embedded Coder Quick Start. From the Apps tab, open the AUTOSAR Component Designer app. On the AUTOSAR tab, click Quick Start.

Work through the quick-start procedure. In the Output window, select output option C code compliant with AUTOSAR.

The quick-start software takes the following steps to configure an AUTOSAR software component model:

  1. Configures code generation settings for the model. If the AUTOSAR target is not selected, the software sets model configuration parameter System target file to autosar.tlc and Generate XML file for schema version to a default value.

  2. If no AUTOSAR mapping exists, the software creates a mapped AUTOSAR software component for the model.

  3. Performs a model build.

In the last window, when you click Finish, your model opens in the AUTOSAR code perspective.

Inspect XML Options in AUTOSAR Dictionary

Before generating code, open the AUTOSAR Dictionary and examine the settings of AUTOSAR XML export parameters. On the AUTOSAR tab, select Code Interface > AUTOSAR Dictionary. In the AUTOSAR Dictionary, select XML Options.

The XML options view in the AUTOSAR Dictionary displays XML export parameters and their values. You can configure:

  • XML file packaging for AUTOSAR elements created in Simulink

  • AUTOSAR package paths

  • Aspects of exported AUTOSAR XML content

This example sets Exported XML file packaging to Modular, so that ARXML is exported into modular files, including modelname_component.arxml, modelname_datatype.arxml, and modelname_interface.arxml.

Generate AUTOSAR C Code and XML Descriptions

To generate AUTOSAR C code and XML software descriptions that comply with Classic Platform specifications, build the model. In the model window, press Ctrl+B. The build process generates C code and ARXML descriptions to the model build folder, autosar_swc_autosar_rtw. Data types and related elements that are not used in the model are removed from the exported ARXML files. When the build completes, a code generation report opens.

Related Links