Build Out of the Box Linux Executable from AUTOSAR Adaptive Model
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.
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:
Open a component model that you have configured for the AUTOSAR adaptive target (
autosar_adaptive.tlc).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 Executabletoolchain is supported only if the Embedded Coder® Support Package for Linux Applications is installed. For more information, see Support Package Installation (Embedded Coder).Build the model. The build generates C++ code, ARXML files, and a
CMakeLists.txtfile.In the model build folder, open
CMakeLists.txtand verify that it is configured for executable generation. For example, make sure that:The
CMakeLists.txtfile containsadd_executable(modelName …).The specifications for
target_include_directories,target_link_libraries, andlink_directoriesinclude the values specified in Toolchain settings.
Verify the
DDSdeployment artifactsDDS Topic NameandDDS Domain IDfrom the generatedServiceInstanceManifest.arxmlfile.Clear and re-create the mapping for the model with existing mappings (models created by using a MATLAB® version prior to 22a), to have
DDSbinding as default. Otherwise, the model continues using user-defined bindings. To re-create the mapping, use this command:autosar.api.create(<modelName>,'default');Get the support package root directory path using the below command in MATLAB:
Copy the path to use it in the next step.path = matlabshared.supportpkg.getSupportPackageRoot
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(<pathToBuildFolder>). For example:Internally, thecodebuild('<modelName>_autosar_adaptive'>;codebuildcommand also runs thecmakeandmakecommands.
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.
Adaptive applications having event deployment artifacts with the same
TOPIC-NAME and DOMAIN-ID can communicate with each
other.