cross_compile package from cross_compile repo

cross_compile

Package Summary

Tags No category tags.
Version 0.2.0
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 eloquent
Last Updated 2020-01-02
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Package Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A cross compilation tool for ROS 2 packages.

Additional Links

No additional links.

Maintainers

  • ROS Tooling Working Group

Authors

No additional authors.

ROS2 Cross Compile

License Documentation Status

A tool to automate ROS2 packages compilation to non-native architectures.

:construction: cross_compile relies on running emulated builds using QEmu, #69 tracks progress toward enabling cross-compilation.

Installation

Prerequisites

This tool requires:

  • Docker
  • Python 3.5, or newer.
  • QEmu

Installing system dependencies on Ubuntu

On Ubuntu Bionic (18.04), run the following commands to install system dependencies:

# Install requirements for Docker and qemu-user-static
sudo apt update && sudo apt install -y curl qemu-user-static

# Full instructions on installing Docker may be found here:
# https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-engine---community
curl -fsSL https://get.docker.com | sudo sh -

# Allow the current user to invoke Docker CLI.
sudo usermod -aG docker $USER

# Reload the group permissions in the current shell. Otherwise logout and login again to apply permissions
newgrp docker

# Verify current user can run Docker
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 ~/ros_cross_compile_ws/src
cd ros_cross_compile_ws

# Use vcs to clone all required repositories
curl -fsSL https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos | vcs import src/
curl -fsSL 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.
sudo rosdep init
rosdep update
rosdep install -r -y --rosdistro=eloquent --ignore-packages-from-source --from-paths src/

# Use colcon to compile cross_compile code and all its dependencies
# ros2run is required to run the cross_compile script, but may be installed elsewhere on the host.
colcon build --packages-up-to cross_compile ros2run

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

Usage

This script requires a sysroot directory containing the ROS 2 workspace, and the toolchain.

The following instructions explain how to create a sysroot directory.

Create the directory structure

mkdir -p sysroot/qemu-user-static
mkdir -p sysroot/ros_ws/src

Copy the QEMU Binaries

cp /usr/bin/qemu-*-static sysroot/qemu-user-static/

3. Prepare ros_ws

Use ROS or ROS 2 source installation guide to get the ROS repositories needed to cross compile.

Once you have the desired sources, copy them in the sysroot to use with the tool.

# Copy ros sources into the sysroot directory
cp -r <full_path_to_your_ros_ws>/src sysroot/ros_ws/src

Run the cross compilation script

In the end your sysroot directory should look like this:

sysroot/
 +-- qemu-user-static/
 |   +-- qemu-*-static
 +-- ros_ws/
     +-- src/
          |-- (ros packages)
          +-- ...

Then run the tool:

ros2 run cross_compile cross_compile --sysroot-path /absolute/path/to/sysroot \
                                     --arch aarch64 \
                                     --os ubuntu

Custom Setup Script

Your ROS application may have build needs that aren't covered by rosdep install. If this is the case (for example you need to add extra apt repos), we provide the option --custom-setup-script to execute arbitrary code in the sysroot container.

The path provided may be absolute, or relative to the current directory.

Keep in mind * It is up to the user to determine whether the script is compatible with chosen base platform * Make sure to specify non-interactive versions of commands, e.g. apt-get install -y, or the script may hang waiting for input * You cannot make any assumptions about the state of the apt cache, so run apt-get update before installing packages * You will be running as root user in the container, so you don't need sudo

Below is an example script for an application that installs some custom Raspberry Pi libraries.

apt-get update
apt-get install -y software-properties-common

# Install Raspberry Pi library that we have not provided a rosdep rule for
add-apt-repository ppa:rpi-distro/ppa
apt-get install -y pigpio

License

This library is licensed under the Apache 2.0 License.

Build status

ROS 2 Release Branch Name Development Source Debian Package X86-64 Debian Package ARM64 Debian Package ARMHF Debian package
Latest master Test Pipeline Status N/A N/A N/A N/A
Dashing dashing-devel Build Status Build Status Build Status N/A N/A
CHANGELOG
No CHANGELOG found.

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

No version for distro dashing. Known supported distros are highlighted in the buttons above.
No version for distro melodic. Known supported distros are highlighted in the buttons above.
No version for distro kinetic. Known supported distros are highlighted in the buttons above.
No version for distro ardent. Known supported distros are highlighted in the buttons above.
No version for distro bouncy. Known supported distros are highlighted in the buttons above.
No version for distro crystal. Known supported distros are highlighted in the buttons above.
No version for distro lunar. Known supported distros are highlighted in the buttons above.
No version for distro jade. Known supported distros are highlighted in the buttons above.
No version for distro indigo. Known supported distros are highlighted in the buttons above.
No version for distro hydro. Known supported distros are highlighted in the buttons above.