cross_compile package from cross_compile repo

cross_compile

Package Summary

Tags No category tags.
Version 0.1.1
License Apache 2.0
Build type AMENT_PYTHON
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ros-tooling/cross_compile.git
VCS Type git
VCS Version dashing-devel
Last Updated 2019-10-18
Dev Status DEVELOPED
Released RELEASED

Package Description

A cross compilation tool for ROS 2 packages.

Additional Links

No additional links.

Maintainers

  • AWS RoboMaker

Authors

No additional authors.

ROS2 Cross Compile

A tool for cross compiling ROS2 packages.

Installation

Prerequisites

Ubuntu

The cross compilation toolchain and docker have to be installed. The following instructions have been tested on Ubuntu Xenial (16.04) and Bionic (18.04).

# Install cross compilation toolchain
sudo apt-get update
sudo apt-get install -y build-essential cmake git wget curl lsb-core bash-completion \
    qemu-user-static g++-aarch64-linux-gnu g++-arm-linux-gnueabihf python3-pip htop
sudo python3 -m pip install -U  colcon-common-extensions rosdep vcstool

# Also install docker and make it available to the current user
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo usermod -aG docker $USER
newgrp docker # this reloads the group permissions in the current shell, unnecessary after relogin
docker run hello-world

Installing from source

Latest (unstable development - master branch)

Please follow those instructions if you plan to contribute to this repository.

  • Install all software dependencies required for ROS 2 development by following the ROS 2 documentation
  • Checkout the source code and compile it as follows
mkdir -p ~/ros2_cross_compile_ws/src
cd ros2_cross_compile_ws

# Use vcs to clone all required repositories
curl https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos | vcs import src/
curl https://raw.githubusercontent.com/ros-tooling/cross_compile/master/cross_compile.repos | vcs import src/

# Install all required system dependencies
# Some packages may fail to install, this is expected on an unstable branch,
# and is generally OK.
rosdep update
rosdep install -r --rosdistro=eloquent --ignore-packages-from-source --from-paths src/

# Use colcon to compile cross_compile code and all its dependencies
colcon build --packages-up-to cross_compile

# If you use bash or zsh, source .bash or .zsh, instead of .sh
source install/local_setup.sh

Usage

We need to setup a sysroot directory for the docker artifacts. Docker can only copy from a specific context so all these assets need to be copied relative to the Dockerfile path.

1. Copy the QEMU Binaries

mkdir sysroot
cd sysroot
# Create a directory to store qemu assets
mkdir qemu-user-static
cp /usr/bin/qemu-* qemu-user-static

2. Copy the ROS2 packages

If you want to cross compile specific local packages:

# Create a directory to store source packages
mkdir -p ros2_ws/src
cp -r <full_path_to_your_ros_ws>/src ros2_ws/src

If you want to cross compile the latest ROS2 release instead of your workspace:

mkdir -p ros2_ws/src
# Get ROS2 sources
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
vcs import ros2_ws/src < ros2.repos

3. Run the cross compilation script

In the end your sysroot directory should look like this:

sysroot/
 +-- qemu-user-static/
 |   +-- qemu-*-static
 +-- ros2_ws/
     +-- src/
          |-- (ros2 packages)
          +-- ...

Then run the tool:

ros2 run cross_compile cross_compile --arch aarch64 --os ubuntu --sysroot-path /directory/with/sysroot

Sample Docker images

You can use the Official Dockerhub ROS Repo to find base images.

You can also use OSRF's Dockerhub Repo to obtain images as well.

License

This library is licensed under the Apache 2.0 License.

Troubleshooting

Lib Poco Issue

From the ROS2 Cross compilation docs:

The Poco pre-built has a known issue where it is searching for libz and libpcre on the host system instead of SYSROOT. As a workaround for the moment, please link both libraries into the the host’s file-system.

mkdir -p /usr/lib/$TARGET_TRIPLE
ln -s `pwd`/sysroot_docker/lib/$TARGET_TRIPLE/libz.so.1 /usr/lib/$TARGET_TRIPLE/libz.so
ln -s `pwd`/sysroot_docker/lib/$TARGET_TRIPLE/libpcre.so.3 /usr/lib/$TARGET_TRIPLE/libpcre.so

CHANGELOG

Changelog for package cross_compile

0.1.1 (2019-10-18)

  • Remove non-portable use of USER environment variable (#25)
  • Add travis configuration to build master and PRs (#23)
  • Contributors: Emerson Knapp, Prajakta Gokhale

0.1.0 (2019-10-17)

  • Fix flake8 issues (#24)
  • Add new cross-compile tool implememntation (#22)
  • Contributors: Prajakta Gokhale, Thomas Moulard

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Package Dependencies

System Dependencies

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cross_compile at answers.ros.org