Skip to content

Commit

Permalink
Adjustments for enhancing sysroot with ROS 2
Browse files Browse the repository at this point in the history
Signed-off-by: Víctor Mayoral Vilches <[email protected]>
  • Loading branch information
vmayoral committed Jun 28, 2022
1 parent 7cfc372 commit bfa6c06
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
18 changes: 18 additions & 0 deletions cmake/ros2_cross.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2022, Acceleration Robotics
# Author: Víctor Mayoral Vilches <[email protected]>
#
# 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.")
3 changes: 2 additions & 1 deletion cmake/sysroot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
62 changes: 62 additions & 0 deletions patches/customize.patch
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion scripts/kr260.mixin.template
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit bfa6c06

Please sign in to comment.