.. include:: vars.rst .. _section-porting: ******* Porting ******* To build |TSS| for a new platform or architecture, create or update files in the CMake resource directory (``/resource/cmake``). The CMake resource directory contains ``Toolchains`` and ``Modules`` directories. ``Toolchains`` contains `CMake toolchain `_ files. ``Modules`` contains RTI-specific CMake scripts, including additional platform- and toolchain-specific files. Build |TSS_HEADING| for a New CMake Platform ============================================ To port |TSS| to a new CMake platform, a corresponding platform file may be required in the ``Toolchains`` directory (``/resource/cmake/Toolchains/Platform``). While a host platform likely will not need one, a cross-compiled platform likely will. Follow the `CMake toolchain `_ documentation to create a new platform file. Alternately, contact `RTI Support `_ and ask about the availability of new CMake platforms or toolchains. To set RTI-specific compiler options, each platform must have a CMake platform file in the ``Modules`` directory (``/resource/cmake/Modules/ProjectOptions/Platform``). These compiler options depend on the platform defined by the **CMAKE_SYSTEM_NAME** variable in a corresponding toolchain file (or guessed by CMake). RTI includes these platform and toolchain files in the ```` top-level CMakeList file, based on the :ref:`RTI TSS architecture name `. These files may enable or disable |TSS| features and products depending on CMake variables defined by you or the toolchain file. Cross-Compilation ----------------- A cross-compiled CMake platform must have another platform file in ``/resource/cmake/Modules/Platform`` to set the target platform. You must create a file named ``.cmake`` for this purpose; other configuration files are optional. General rules for the cross-compiled platform file are as follows: * The file must start with the name of the platform to support, as defined by the **CMAKE_SYSTEM_NAME** variable. * These files must **not** contain any RTI-specific options; those options need to be defined in the ``ProjectOptions`` folder (``/resource/cmake/Modules/ProjectOptions``). * Hard-coded paths are not allowed; use relative paths to CMake variables or environment variables. Build |TSS_HEADING| for a New CMake Architecture ================================================ While the ``Platform`` directories contain CMake files with shared settings between the toolchains of a platform family, the ``Architecture`` directory (``/resource/cmake/Toolchains/Architecture``) contains the toolchain file for a specific architecture. To port |TSS| to a new CMake architecture, create a new toolchain file in this directory. A basic toolchain file, for example, could include just the following: :: # Toolchain file for Linux x64 with GCC 4.8.2 include("${CMAKE_CURRENT_LIST_DIR}/../Common.cmake") platform_setup() set(PLATFORM_C_COMPILER_EXPECTED_VERSION 4.8.2) set(PLATFORM_CXX_COMPILER_EXPECTED_VERSION 4.8.2) set(CMAKE_C_FLAGS "-m64 ${COMPILER_WARNING_FLAGS_C}") set(CMAKE_CXX_FLAGS "${COMPILER_WARNING_FLAGS_CXX}") set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc ${CMAKE_EXE_LINKER_FLAGS}") set(SYSLIBS_ARCH "-ldl -lnsl -lm -lpthread -lrt") Variable Definitions -------------------- General ^^^^^^^ The following variables can be used with any CMake architecture: * **CMAKE__COMPILER**: Full path for the compiler. * **CMAKE_AR**: Full path for the archiving tool for static libraries. * **CMAKE_RANLIB**: Full path for the randomizing tool for static libraries. * **CMAKE_LINKER**: Full path for the linker. Note that for most platforms, CMake uses the compiler for linking. This can be changed in the platform files, overriding the linking rules. * **CMAKE__FLAGS_INIT**: Flags for the compiler. * **CMAKE_SHARED_LINKER_FLAGS_INIT**: Flags for the linker. * **COMPILER_WARNING_FLAGS_C**: Flags to enable warnings in the C compiler. * **COMPILER_WARNING_FLAGS_CXX**: Flags to enable warnings in the C++ compiler. * **WARNING_AS_ERROR_FLAG**: Flags to enable treat warnings as errors. Typically, it's enough to specify the compilers in your toolchain file. CMake internally searches for the tools *ar* and *ranlib*, as well as the *linker*, from the directory containing the compiler. Cross-compiling ^^^^^^^^^^^^^^^ The following CMake variables can be used when cross-compiling: * **CMAKE_SYSTEM_NAME**: Target platform name, usually output from ``uname -s``. Used by CMake to load the platform configuration files under *Platform/$*. Setting this variable means cross-compiling and CMake sets the **CMAKE_CROSSCOMPILING** variable. * **CMAKE_SYSTEM_VERSION**: Target platform version, usually output from ``uname -r``. Not used by CMake. * **CMAKE_SYSTEM_PROCESSOR**: Target CPU name, usually output from ``uname -p``. Used to load options for the compiler. * **CMAKE_SYSROOT**: Path to pass to the compiler in the **--sysroot** flag. Port |TSS_HEADING| to VxWorks® 653 Systems ========================================== Build |TSS_HEADING| ------------------- This section explains how to build a |TSS| library for a VxWorks 653 3.0.1.1 target platform using CMake. #. Make sure `CMake `_ is in the **PATH** environment variable. #. Set the following environment variables: .. code-block:: none RTIMEARCH=ppce6500Vx653-3.0.1.1gcc4.3.3 RTIMEHOME= RTITSSARCH=ppce6500Vx653-3.0.1.1gcc4.3.3 RTITSSHOME= #. Set the environment for VxWorks 653 3.0.1.1: .. code-block:: none /wrenv.sh -p vxworks653-3.0.1 #. Change directory to ````. #. Create a build directory and change to it. For example: .. code-block:: none mkdir ${RTITSSHOME}/build cd ${RTITSSHOME}/build #. Execute the following command to configure CMake and generate the Makefile: .. code-block:: none cmake -DRTI_CONNEXT_TYPE=micro -DRTI_TSS_ENABLE_FACE_COMPLIANCE=SafetyBase -DCMAKE_BUILD_TYPE= .. #. Execute the following command to build the libraries: .. code-block:: none cmake --build . #. The |TSS| libraries will be available at the following location: .. code-block:: none ${RTITSSHOME}/lib/${RTITSSARCH}/micro Create and Set Up an Application Project ---------------------------------------- This section steps you through the process of creating |TSS| VxWorks 653 application projects on Wind River® Workbench. #. Make sure the |CONNEXT_MICRO| libraries are built. #. Open Wind River Workbench. #. Create a new Module Integration Project: * Go to **File > New > Wind River Workbench Project**. * Select the target operating system, “VxWorks 653 3.0.1.1." * Select "Module Integration Project." * Enter a project name. * Select the board support package, “fsl_t2080_qds." * *Recommended:* Add partitions here by clicking **Add** and selecting **Independent Cert OS**." The application configuration and operating system projects are created automatically, and steps 2 - 5 can be omitted. * Click **Finish**. #. Create a new Partition Application Project: * Go to **File > New > Wind River Workbench Project**. * Select the target operating system, **VxWorks 653 3.0.1.1**. * Select **Partition Application**. * Enter an application name; for example, “part1_app." * Click **Finish**. * Drag the new application project into the Module Integration Project. #. Create a new Partition Configuration Project: * Same as the previous step, but select **Partition Configuration** and, for example, “part1_cfg” as an application name. #. Create a new Partition Operating System Project: * Go to **File > New > Wind River Workbench Project**. * Select the target operating system, **VxWorks 653 3.0.1.1**. * Select **Partition Operating System**. * Enter a name; for example, “part1_pos." * Select **Based on**: “a board support package." * Select **BSP**: "fsl_t2080_qds." * Select **Independent Cert OS**." * Click **Finish**. * Drag the new POS project into the Module Integration Project. * Right-click the application project, select **Properties > Project References**, check the box of the new POS project, then click **OK**. #. Repeat steps 4 - 6 for all applications as needed. Create Partitions, Ports, and Channels -------------------------------------- #. Add partitions. (If all partitions were created during the creation of the Module Integration Project, this step can be omitted.) * Open **Module Configuration**, click the **Partitions** tab and select **Add > Partition**. * Select a partition name. * In **Payloads**, add the application, configuration, and operating system projects created above. This can be done directly when creating the partition or in the module configuration, as shown below: .. image:: images/image2.png :width: 500 * Repeat for as many partitions as needed. #. Create ports. * In the **Partitions** tab, click on **Ports** for one of the new partitions. * Click the **+** button to add ports. .. image:: images/image3.* :width: 500 Queueing ports are used for inter- or intra-partition communication. Serial ports are used to log output to the AMIO console. For the partition that is used for communication, two intra send and receive serial ports are needed, as well as one send and receive serial port for channels to the other partitions. The following example shows two partitions: .. image:: images/image4.png :width: 500 * Go to the **Module** tab and set the **Memory** configuration for the ports: .. image:: images/image5.png :width: 500 #. Create channels. * In the **Module** tab, click **Channels**, select **Add**, then select the source and destination partition and ports: .. image:: images/image6.* :width: 500 * Create channels between the serial ports used to view output with the AMIO console. #. Configure the kernel. * Open the Kernel configuration of the POS project. * Right-click **Certified Network Components**, then select **Include > Next > Finish**. .. image:: images/image7.* :width: 500 * For one of the partitions, set **AMIO_SERVER_POLL_FREQUENCY** to a non-zero value, and add the serial device in **Module Configuration > Partitions > Devices**. In the following example, the value is "10" and the serial device is "uart0": .. image:: images/image8.png :width: 500 * In the **Module Configuration**, set **Periodic processing start** to **true**. .. image:: images/image9.png :width: 500 .. note:: We recommended testing the configuration at this point (before adding any application code and dependencies). To do so, add a print command in the function **_653AppEntry** (653Application.c) and check the output on the AMIO console. Add Dependencies and Defines ---------------------------- #. Add Include Paths to **Build Properties**: * Right-click the **Connext_TSS** project and select **Properties > Build Properties > Paths**. * Add ``-I/include``, then click **OK**. .. image:: images/properties-paths.png :width: 600 * Repeat the previous two steps for the following paths: * ``-I/include/micro`` * ``-I/include/micro/FACE`` * ``-I/include/rti_me`` #. Add Defines to **Build Properties**: * Right-click the **Connext_TSS** project and select **Properties > Build Properties > Defines**. * Add ``-DRTI_ARINC653=1``, then click **OK**. .. image:: images/properties-defines.png :width: 600 * Repeat the previous two steps for the following Defines: * ``-DRTI_VXWORKS`` * ``-DRTI_VX653=3011`` * ``-DRTI_ENDIAN_BIG`` * ``-DRTI_DPSE`` * ``-DRTI_APP_ENABLE_UDP=1`` * ``-DRTIME_TARGET_NAME='"ARINC653"'`` * ``-DRTI_CERT`` * ``-DOSAPI_INCLUDE_ARINC653=1`` * ``-DENABLE_FACE_COMPLIANCE=FACE_COMPLIANCE_LEVEL_SAFETY_BASE`` * ``-DLOG_FILE_TYPE=LOG_FILE_STDOUT`` * ``-DRTI_CONNEXT_MICRO`` * ``-DRTI_STATIC_BUILD`` #. Add Micro library to **Build Properties**: * Right-click the **Connext_TSS** project, then select **Properties > Build Properties > Libraries**. * Select **Add fully qualified library file**, input the path to the |CONNEXT_MICRO| library (``/lib/ppce6500Vx653-3.0.1.1gcc4.3.3/librti_mez[d].a``), then click **OK**. .. image:: images/properties-libraries.png :width: 600 * Repeat the previous step for the |TSS| library (``/lib/ppce6500Vx653-3.0.1.1gcc4.3.3/micro/librti_tsscppz[d].a``).