How do I create a Connext DDS application with RTI Code Generator and build it on my ARM-embedded target?

This article describes the procedure to build and run Code Generator (rtiddsgen) examples directly on an embedded target. We will use a Raspberry Pi for this example, but the procedure is similar for other embedded targets. 

In order to build directly on the target, the target must include a native compiler and associated tools and libraries (i.e., Raspbian, Ubuntu, etc.).  Real-time target operating systems, such as VxWorks, do not typically contain the required target native compiler and tools.    

If you prefer to cross-compile, or if your target system does not contain native build tools, you can use the cross-compiling method as described in this article:  HOWTO Run RTI Connext DDS on Raspberry Pi.

To get started with generating and compiling rtiddsgen examples directly on-board, follow the steps below:

  1. Install ARM target package on the host

The purpose of this step is to bundle the target-specific tools so they can be copied and extracted onto the target.

Begin by installing the desired ARM target, e.g., rti_connext_dds-X.Y.Z-<pro>-target-<ARM architecture><compiler version>.rtipkg, on top of a standard i86/x64 RTI Connext DDS host installation (e.g., rti_connext_dds-6.0.1-pro-host-x64linux.run). 

For the Raspberry Pi target example, the following target package was used:

rti_connext_dds-6.0.1-pro-target-armv8Linux4.4gcc5.4.0.rtipkg

  1. Create a deployment tarball  

Use the attached create_rpi_deployment.sh script to copy the required host and target files to the Raspberry Pi target.

The script creates a tarball that contains all the files required to generate and compile Connext DDS applications and run Connext DDS utilities and services (e.g., rtiddsping, rtiroutingservice). 

The create_rpi_deployment.sh script takes two arguments -- NDDSHOME and the target architecture.

For example:

$ ./create_rpi_deployment.sh $NDDSHOME armv8Linux4.4gcc5.4.0RPi libraries found.
     RPi libraries found. 
     Copying RPi files from: /opt/RTI/rti_connext_dds-6.0.1 ... 
     Tar'ing up folder...
     Done.
     $ ls -lag rti*.tar.gz
     -rw-rw-r--. 1 irwin 190262197 Feb 25 12:05 rti_connext_dds-rpi_202002251205.tar.gz    
  1. Copy the resultant deployment tarball onto the target

This step depends on target accessibility (e.g., ftp, nfs).

The remaining steps are performed on the target.

  1. Extract  the contents of the deployment tarball into a convenient location

The deployment tarball consists of a rti_connext_dds-rpi  tree.

For example:

tar xvfz rti_connext_dds-rpi_202002251205.tar.gz

The  rti_connext_dds-rpi tree contains the target-specific tools to build and run Connext DDS applications directly on the target.

  1. Install Java on target if needed and set  the JREHOME environmental variable

The rtiddsgen code generator requires a JRE, so install one if not already installed.

Once installed,  set the JREHOME environmental variable  to your Java JRE installation.

For example:

% which java
  /usr/bin/java
% ls -lag /usr/bin/java
  lrwxrwxrwx 1 root 22 Jul  9  2019 /usr/bin/java -> /etc/alternatives/java
% ls -lag /etc/alternatives/java
  lrwxrwxrwx 1 root 43 Jul  9  2019 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-armhf/bin/java
% export JREHOME=/usr/lib/jvm/java-11-openjdk-armhf/

 

  1. HelloWorld Test

To sanity-check the installation, create and run a basic HelloWorld example.

These steps assume you are familiar with DDS and the RTI Tools. (For a much more detailed description of the tools, and a series of tutorials on Connext DDS, please refer to the following document: RTI Connext DDS Getting Started Guide.)

mkdir ~/HelloWorld

cd  ~/HelloWorld

 

edit HelloWorld.idl

struct HelloMsg {
   long id; //@key
   string<256> msg;
};

 

Configure environmental variables (NDDSHOME, LD_LIBRARY_PATH).

Set NDDSHOME  to the location where the deployment package was extracted. 

Set LD_LIBRARY_PATH to the target-specific library in the extracted deployment package. 

For example:     

export NDDSHOME= ~/rti_connext_dds-rpi

export LD_LIBRARY_PATH=$NDDSHOME/lib/

 

Create an example using rtiddsgen:

$NDDSHOME/bin/rtiddsgen -language C++ -example armv8Linux4.4gcc5.4.0 HelloWorld.idl

 

Build the example:  

make -f makefile_HelloWorld_armv8Linux4.4gcc5.4.0

 

Run the example:

./objs/armv8Linux4.4gcc5.4.0/HelloWorld_publisher

./objs/armv8Linux4.4gcc5.4.0/HelloWorld_subscriber



Notes:

create_rpi_deployment.sh script contents

#!/bin/bash

if [ -z "$1" ]; then
 echo "! Please specify location of RTI Connext installation."
 echo "Syntax => create_rpi_installation <Connext installation> <ARM target architecture>"
 exit 1
fi

if [ -z "$2" ]; then
 echo "! Please specify ARM target architecture. Example: armv6vfph"
 echo "Syntax => create_rpi_installation <Connext installation> <ARM target architecture>"
 exit 1
fi

 installation_loc="$1"
 rpi_arch="$2"

 rpi_folder="rti_connext_dds-rpi"
 pi_lib_dir="$installation_loc/lib/$rpi_arch"

 if [ ! -d "$pi_lib_dir" ]; then
  echo "! RPi libraries ($rpi_arch) not found in RTI Connext installation path."
  echo "! Searched for $pi_lib_dir"
  exit 1
  else
  echo "RPi libraries found."
 fi

 if [ -d "$rpi_folder" ]; then
 read -p "$rpi_folder folder already exists. Delete it? (y/n) " yn
  case $yn in
   [Yy]* ) rm -rf $rpi_folder;;
   [Nn]* ) echo "Exiting"; exit;;
  esac
 fi

 echo "Copying RPi files from: $1 ..."
 mkdir $rpi_folder
 mkdir $rpi_folder/lib
 mkdir $rpi_folder/resource
 mkdir -p $rpi_folder/resource/app/bin
 mkdir -p $rpi_folder/resource/app/lib
 mkdir -p $rpi_folder/resource/app/app_support
 mkdir -p $rpi_folder/resource/xml
 cp -r $installation_loc/rti_versions.xml $rpi_folder/
 cp -r $installation_loc/RTI_License_Agreement.pdf $rpi_folder/
 cp -r $installation_loc/include $rpi_folder/
 cp -r $installation_loc/bin $rpi_folder/
 cp -r $installation_loc/lib/$rpi_arch $rpi_folder/lib/
 cp -r $installation_loc/lib/java $rpi_folder/lib/
 cp -r $installation_loc/resource/scripts $rpi_folder/resource/
 cp -r $installation_loc/resource/idl $rpi_folder/resource/
 cp -r $installation_loc/resource/schema $rpi_folder/resource/
 cp -r $installation_loc/resource/app/lib/$rpi_arch
 $rpi_folder/resource/app/lib/
 cp -r $installation_loc/resource/app/lib/java $rpi_folder/resource/app/lib/
 cp -r $installation_loc/resource/app/bin/$rpi_arch
 $rpi_folder/resource/app/bin/
 cp -r $installation_loc/resource/app/app_support/rtiddsgen
 $rpi_folder/resource/app/app_support
 cp -r $installation_loc/resource/xml $rpi_folder/resource/
 echo "Tar'ing up folder..."
 DATE=$(date +"%Y%m%d%H%M")
 tar -zcf rti_connext_dds-rpi_$DATE.tar.gz rti_connext_dds-rpi
 rm -f -R rti_connext_dds-rpi
 echo "Done."
Platform: