Main Content

Build Out of the Box Linux Executable from AUTOSAR Adaptive Model

R2026b

As part of generating code for an AUTOSAR adaptive model, you can generate a CMakeLists.txt file for building a Linux® standalone executable. Then, on a Linux system, you can build the executable and run the resulting executable on Linux as a standalone application.

For models using the service interface modeling pattern, configure deployment properties (such as service instance IDs, domain IDs, and logging options) through the Property Inspector in the AUTOSAR architecture model before building. When you build, the software automatically generates the ServiceInstanceManifest.json and ExecutionManifest.json files alongside the C++ code and ARXML files.

If the applications have matching DDS deployment artifacts, they can communicate with each other. Building the executable files from CMakeLists.txt requires running CMake software on a Linux system.

Note

Executable generation from an AUTOSAR adaptive model is supported only on the Linux platform.

To build a Linux standalone executable:

  1. Open a component model that you have configured for the AUTOSAR adaptive target (autosar_adaptive.tlc). The component model must be referenced from an AUTOSAR architecture model where you have configured the platform (Adaptive Platform), network binding (DDS or SOME/IP), and deployment properties.

  2. In the Configuration Parameters dialog box, select Code Generation > Build process > Toolchain settings. Set Toolchain to AUTOSAR Adaptive Linux Executable. The toolchain selection adds ARA functional cluster libraries provided by MathWorks®.

    Note

    The AUTOSAR Adaptive Linux Executable toolchain is supported only if the Embedded Coder® Support Package for Service-Oriented Applications on Linux is installed. For more information, see Install Embedded Coder Support Package for Service-Oriented Applications on Linux (Embedded Coder).

  3. Build the model. The build generates C++ code, ARXML files, a CMakeLists.txt file, and manifest JSON files (ServiceInstanceManifest.json and ExecutionManifest.json).

  4. In the model build folder, open CMakeLists.txt and verify that it is configured for executable generation. For example, make sure that:

    1. The CMakeLists.txt file contains add_executable(modelName …).

    2. The specifications for target_include_directories, target_link_libraries, and link_directories include the values specified in Toolchain settings.

  5. Verify the DDS deployment artifacts from the generated ServiceInstanceManifest.arxml file, including DDS Topic Name, DDS Domain ID, event deployments, and DDS QoS configuration (USER_DATA and Partition QoS). These values are derived from the deployment specification configured in the architecture model Property Inspector.

  6. Get the support package root directory path using the below command in MATLAB:

    path = matlabshared.supportpkg.getSupportPackageRoot
    Copy the path to use it in the next step.

  7. On a Linux system, outside MATLAB®, go to the model build folder. To build the executable file, enter these commands:

    cmake -DSPKG_ROOT=<path from step 6> CMakeLists.txt;
    make all;

    Or, if MATLAB is running on Linux, in the Command Window, run the command codebuild(<pathToExeFolder>), where the argument is the path to the exe folder in the build directory. For example:

    codebuild('pathToExeFolder');
    Internally, the codebuild command also runs the cmake and make commands.

The make command generates an executable file for the adaptive model one level above the model build folder. You can run the executable on Linux as a standalone application. Before running the executable, verify that the generated manifest JSON files (ServiceInstanceManifest.json and ExecutionManifest.json) are present in the directory from which you run the executable. These files configure runtime behavior such as DDS communication and logging.

For AUTOSAR-compliant DDS communication, adaptive applications must have matching TOPIC-NAME, DOMAIN-ID, compatible USER_DATA QoS (service identity and version), and matching Partition QoS strings. For communication with raw DDS applications that do not use AUTOSAR QoS policies, set UseDDS_QosConfiguration to false in the deployment specification, which falls back to topic-name and domain-ID matching only.

See Also

Topics