[ros-users] [Discourse.ros.org] [Next Generation ROS] How to cross-compile ROS2 for arm64 architecture

Adam Jiang ros.discourse at gmail.com
Sat Jan 20 10:42:35 UTC 2018



Thank you, @esteve and @pokitoz. I got cross-compilation done for Jetson TX2.

Here is a brief for who is interesting on this.

- toolchain: Linaro gcc toolchain 7.2 https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz

- rootfs: mount Jetson TX2 rootfs with 'sshfs' <code>sudo sshfs -o idmap=user,follow_symlinks,ro,allow_other root@<ip_address>:/ ~/rootfs</code>

- environment variables: <code>export SYSROOT=${HOME}/rootfs</code>; export CROSS_COMPILE=aarch64-linux-gnu-</code>

- CMake toolchain file

<pre>
    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_VERSION 1)
    set(CMAKE_SYSTEM_PROCESSOR aarch64)
    set(CMAKE_SYSROOT $ENV{SYSROOT})
    # specify the cross compiler
    set(CMAKE_C_COMPILER $ENV{CROSS_COMPILE}gcc)
    set(CMAKE_CXX_COMPILER $ENV{CROSS_COMPILE}g++)
    # where is the target environment
    set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/install)
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

    # This assumes that pthread will be available on the target system
    # (this emulates that the return of the TRY_RUN is a return code "0"
    set(THREADS_PTHREAD_ARG "0"
      CACHE STRING "Result from TRY_RUN" FORCE)
</pre>

- Apt 'sources.list'

<pre>
    deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted
    #deb-src [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted
    deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted
    #deb-src [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted
    deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
    #deb-src [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
</pre>

- Install 'libpython3-dev:arm64'

- Ignore 'rviz' and 'opencv' related packages
<pre>
    src/ament/ament_tools/scripts/ament.py build \
        --force-cmake-configure \
        --skip-packages resource_retriever \
                        rviz_assimp_vendor \
                        rviz_ogre_vendor \
                        rviz_yaml_cpp_vendor \
                        rviz_rendering \
                        rviz_rendering_tests \
                        rviz_common \
                        rviz2 \
                        rviz_default_plugins \
        --cmake-args \
            -DCMAKE_TOOLCHAIN_FILE=`pwd`/aarch64_toolchainfile.cmake \
            -DTHIRDPARTY=ON \
            -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
            -DPYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc() + ';' + '/usr/include')") \
            -DPYTHON_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")/aarch64-linux-gnu/libpython3.5m.so --
</pre>





---
[Visit Topic](https://discourse.ros.org/t/how-to-cross-compile-ros2-for-arm64-architecture/3702/15) or reply to this email to respond.




More information about the ros-users mailing list