diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ae6124d..33fe08b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,8 @@ Changelog for package acceleration_firmware_kr260 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1.0.0 (2022-06-27) +v1.0.0 (2022-06-28) ------------------- +* Adjustments for enhancing sysroot with ROS 2 * Create kr260 ROS mixins, leverage Ubuntu 22.04 sysroot +* Initial commit diff --git a/CMakeLists.txt b/CMakeLists.txt index c754593..f38f31c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,15 @@ if (NOT EXISTS ${FIRMWARE_DIR}) DESTINATION ${FIRMWARE_DIR} ) + + # Deploy also patches for firmware and related scripts + # + install( + DIRECTORY + patches/ + DESTINATION + ${FIRMWARE_DIR}/patches + ) endif() # NOT EXISTS ${FIRMWARE_DIR} # NOTE: @@ -76,8 +85,8 @@ install( ${CMAKE_BINARY_DIR} ) install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/generate_mixin.cmake") +install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/ros2_cross.cmake") install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/colcon_ignore.cmake") - # kept so that other packages can depend on it ament_package() diff --git a/cmake/ros2_cross.cmake b/cmake/ros2_cross.cmake new file mode 100644 index 0000000..91ec6fb --- /dev/null +++ b/cmake/ros2_cross.cmake @@ -0,0 +1,18 @@ +# Copyright (c) 2022, Acceleration Robotics +# Author: VĂ­ctor Mayoral Vilches +# +# Install ROS 2 and related dependencies inside of the sysroot +# for simplified cross-compilation flows + +message(STATUS "Preparing sysroot for ROS 2 cross-compilation") +set(CUSTOMIZESHSCRIPT ${FIRMWARE_DIR}/sysroots/bin/customize.sh) +set(PATCH ${FIRMWARE_DIR}/patches/customize.patch) +set(SYSROOTPATH ${FIRMWARE_DIR}/sysroots/aarch64-xilinx-linux) + +# apply patch +run("${TESTFIRMWARE} patch ${CUSTOMIZESHSCRIPT} ${PATCH}") + +# install ROS 2, LTTng and net-tools inside of the sysroot +run("${TESTFIRMWARE} sudo ${CUSTOMIZESHSCRIPT} ${SYSROOTPATH} jammy http://packages.ros.org/ros2/ubuntu '' net-tools > /dev/null") + +message(STATUS "Sysroot cooked for cross-compilation.") diff --git a/cmake/sysroot.cmake b/cmake/sysroot.cmake index d3f6c52..b8bf6cd 100644 --- a/cmake/sysroot.cmake +++ b/cmake/sysroot.cmake @@ -5,8 +5,9 @@ message(STATUS "Deploying sysroot") set(TARGET_SYSROOT_DIR ${FIRMWARE_DIR}/sysroots/aarch64-xilinx-linux) +set(SYSROOTNAME "iot-limerick-kria-classic-desktop-2204-x06-20220614-78-sysroot.tar.xz") # extract sysroot and scripts -run("${TESTFIRMWARE} tar -xf ${FIRMWARE_DIR}/iot-limerick-kria-classic-desktop-2204-x04-20220517-68-sysroot.tar.xz -C ${FIRMWARE_DIR}") +run("${TESTFIRMWARE} tar -xf ${FIRMWARE_DIR}/${SYSROOTNAME} -C ${FIRMWARE_DIR}") message(STATUS "Ubuntu sysroot deployed.") diff --git a/patches/customize.patch b/patches/customize.patch new file mode 100644 index 0000000..a5e394e --- /dev/null +++ b/patches/customize.patch @@ -0,0 +1,62 @@ +--- customize.sh.orig 2022-06-28 10:08:17.044428956 +0200 ++++ customize.sh 2022-06-28 10:12:18.120721347 +0200 +@@ -46,6 +46,49 @@ + LC_ALL=C sort -r) + } + ++# Installs ROS 2 Humble ++install_ros2_humble() ++# $1: suite ++{ ++ local sources="deb [arch=arm64 signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $1 main" ++ local setup_pkgs=( ++ software-properties-common ++ curl ++ gnupg ++ lsb-release ++ ) ++ local key_hash=C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 ++ local pkgs=( ++ ros-humble-desktop ros-humble-image-common ++ ) ++ ++ # get key from Open Robotics ++ local opts='--no-install-recommends -y' ++ chroot . apt update ++ chroot . sh -c "DEBIAN_FRONTEND=noninteractive apt install $opts ${setup_pkgs[*]}" ++ chroot . sh -c "curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg" ++ ++ printf "%s\n" "$sources" >> etc/apt/sources.list.d/devel.list ++ chroot . apt update ++ chroot . sh -c "DEBIAN_FRONTEND=noninteractive apt install $opts ${pkgs[*]}" ++ rm etc/apt/sources.list.d/devel.list ++ chroot . apt update ++} ++ ++# Install the Linux Tracing Toolkit next generation (LTTng) ++install_lttng() ++{ ++ local pkgs=( ++ liblttng-ust-dev ++ python3-lttng ++ lttng-tools ++ ) ++ local opts='--no-install-recommends -y' ++ pkgs+=("$@") ++ chroot . apt update ++ chroot . sh -c "DEBIAN_FRONTEND=noninteractive apt install $opts ${pkgs[*]}" ++} ++ + # Installs a list of packages. + # $1..$#: Additional packages can be specified as arguments + install_packages() +@@ -219,6 +262,9 @@ + prepare_chroot + # TODO there is no gstreamer jammy release yet + #install_xilinx_gstreamer "$suite" ++install_ros2_humble "$suite" ++install_lttng ++ + if [ "$ppa_src" == "public" ]; then + install_packages "$@" "${pkgs_in_private_archive[@]}" + else diff --git a/scripts/kr260.mixin.template b/scripts/kr260.mixin.template index b4e9309..6d25418 100644 --- a/scripts/kr260.mixin.template +++ b/scripts/kr260.mixin.template @@ -4,7 +4,7 @@ build: - "-DCMAKE_SYSTEM_NAME=Linux" - "-DCMAKE_SYSTEM_VERSION=1" - "-DCMAKE_SYSTEM_PROCESSOR=aarch64" - - "-CMAKE_LIBRARY_ARCHITECTURE=aarch64-linux-gnu" + - "-DCMAKE_LIBRARY_ARCHITECTURE=aarch64-linux-gnu" - "-DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc" - "-DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++" - "-DCMAKE_SYSROOT=ARG1_FIRMWARE_DIR/sysroots/aarch64-xilinx-linux"