Skip to content

Commit

Permalink
Move to Ubuntu 22.04 as base image, adapt CMake macros
Browse files Browse the repository at this point in the history
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
  • Loading branch information
vmayoral committed Oct 4, 2022
1 parent c211f80 commit 00d4966
Show file tree
Hide file tree
Showing 20 changed files with 532 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode
firmware/*sysroot.tar.xz
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package acceleration_firmware_kv260
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1.1.0 (2022-10-04)
-------------------
* Move to Ubuntu 22.04 as base image, adapt CMake macros

1.0.0 (2022-06-27)
-------------------
* Update artifacts in alignment with Vitis 2022.1 changes
Expand Down
92 changes: 92 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# ____ ____
# / /\/ /
# /___/ \ / Copyright (c) 2021, Xilinx®.
# \ \ \/ Author: Víctor Mayoral Vilches <victorma@xilinx.com>
# \ \
# / /
# /___/ /\
# \ \ / \
# \___\/\___\
#
cmake_minimum_required(VERSION 3.5)
project(acceleration_firmware_kv260)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
include(cmake/firmware_setup.cmake) # define only once, here

# # deploy firmware into "firmware" directory, file by file
# # locate all firmware files, recursively
# file(GLOB_RECURSE firmware_FILES
# "firmware/*"
# LIST_DIRECTORIES
# true
# )
# # NOTE that "${CMAKE_INSTALL_PREFIX}/../firmware" will be at the same
# # level as "install", "build" or "log" if "--merge-install" option is used.
# # Otherwise, it'll reside within "install"
# install(
# FILES
# ${firmware_FILES}
# DESTINATION
# ${CMAKE_INSTALL_PREFIX}/../firmware
# )


if (NOT EXISTS ${FIRMWARE_DIR})
# Deploy firmware directory into "firmware" directory, file by file
#
# NOTE that "${CMAKE_INSTALL_PREFIX}/../firmware" will be at the same
# level as "install", "build" or "log" if "--merge-install" option is used.
# Otherwise, it'll reside within "install"
install(
DIRECTORY
firmware/
DESTINATION
${FIRMWARE_DIR}
)

# Deploy also patches for firmware and related scripts
#
install(
DIRECTORY
patches/
DESTINATION
${FIRMWARE_DIR}/patches
)
endif() # NOT EXISTS ${FIRMWARE_DIR}

# NOTE:
# The following scripts avoid the use of CMake EXISTS
# due to undefined behavior. Refer to the development
# notes for more details https://gitlab.com/xilinxrobotics/docs/-/issues/9#note_505935065
# For more details, refer to the xilinx_vitis package.

# To execute logic after the install() CMake command, embed
# follow-up actions into CMake scripts which get added to the
# "cmake_install.cmake" script in order
# See https://stackoverflow.com/a/10000327
install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/firmware_setup.cmake")
install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/sysroot.cmake")
# Generate toolchain, first install template, then execute
install(
FILES
"${CMAKE_SOURCE_DIR}/scripts/kv260.mixin.template"
"${CMAKE_SOURCE_DIR}/scripts/index.yaml.template"
DESTINATION
${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()
94 changes: 57 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,72 @@
# acceleration_firmware_kv260

| Board | Picture | Description |
| Board | Picture | Description |
|------------|-------|-------------|
| [Kria KV260 Vision AI Starter Kit](https://www.xilinx.com/products/som/kria/kv260-vision-starter-kit.html) | ![](https://www.xilinx.com/content/dam/xilinx/imgs/products/som/som-kv260-4.png) | The Kria™ KV260 starter kit is a development platform for the K26, the first adaptive Single Board Computer. KV260 offers a compact production-grade board for edge vision and robotics applications. |


This repository provides AMD/Xilinx's firmware artifacts for the KV260 board meant to accelerate ROS 2 robotic applications.
This repository provides AMD/Xilinx's firmware artifacts for the KV260 board using Ubuntu 22.04 meant to accelerate ROS 2 robotic applications.

<ins>**NOTE**</ins>: *This repository is has various **GB** of data. Due to GitHub size restrictions, the whole source code is available under [releases](https://github.com/ros-acceleration/acceleration_firmware_kv260/releases)*. *Refer to each corresponding's release `firmware/ARTIFACTS.md` file for a description of all the artifacts included*.
<ins>**NOTE on Ubuntu 22.04 integration**</ins>: *Ubuntu 22.04 sysroot is provided by Canonical and AMD at their own terms as available at https://ubuntu.com/download/amd-xilinx. Refer to this resource for more information. This repository leverages the resulting artifacts "as they are" and enables ROS 2 build flows while integrating hardware acceleration through Vitis and Vivado tools.*.

## Use this ROS 2 package

### Fetch from sources
To fetch it from sources, proceed as follows to include the Ubuntu 22.04 resources:

```bash
git clone https://github.com/ros-acceleration/acceleration_firmware_kv260
wget https://people.canonical.com/~platform/images/xilinx/kria-ubuntu-22.04/iot-limerick-kria-classic-desktop-2204-x06-20220614-78-sysroot.tar.xz -P acceleration_firmware_kv260/firmware/ # will take a few seconds
```

### Fetch using VCS
When leveraging `vcs`, just use one of the official release links, which should include the Ubuntu 22.04 resources. E.g. include the following in your `.repos` file:

```bash
repositories:
firmware/acceleration_firmware_kv260:
type: zip
url: https://github.com/ros-acceleration/acceleration_firmware_kv260/releases/download/v1.1.0/acceleration_firmware_kv260.zip
```

## Hardware Acceleration capabilities

According to [REP-2008's proposal](https://github.com/ros-infrastructure/rep/pull/324).

| Capability | KRS `alpha`[^1] | KRS `beta`[^2] | KRS `1.0`[^3] (*Yocto/PetaLinux*) |
|------------|-------------|------------|-------------|
| **`1.` Kernel Levels** | | | |
| [`1.i` level I kernels](https://ros.org/reps/rep-2008.html#i) ||||
| [`1.ii` level II kernels](https://ros.org/reps/rep-2008.html#ii) | :warning: (see [this](https://github.com/Lien182/ReconROS)) | ✓ ([`acceleration_examples` (graph acceleration)](https://github.com/ros-acceleration/acceleration_examples/tree/main/graphs/perception/perception_2nodes), [`ReconROS`](https://github.com/Lien182/ReconROS)) | ✓ ([`acceleration_examples` (graph acceleration)](https://github.com/ros-acceleration/acceleration_examples/tree/main/graphs), [`ReconROS`](https://github.com/Lien182/ReconROS)) |
| [`1.iii` level III kernels](https://ros.org/reps/rep-2008.html#iii) | | | |
| **`2.` Build System** | | | |
| [`2.i` ament extensions](https://ros.org/reps/rep-2008.html#id13) ||||
| [`2.ii` `ament_acceleration` support](https://ros.org/reps/rep-2008.html#id14) | |||
| **`3`. Build Tools** | | | |
| [`3.i` hardware emulation (`hw_emu`) ](https://ros.org/reps/rep-2008.html#id15) | | | |
| [`3.ii` hardware emulation (`sw_emu`)](https://ros.org/reps/rep-2008.html#id16) | :warning: | | |
| [`3.iii` image tooling](https://ros.org/reps/rep-2008.html#id17) ||| |
| [`3.iv` Linux kernel ](https://ros.org/reps/rep-2008.html#iv) ||||
| [`3.iv.a` modern Linux kernel](https://ros.org/reps/rep-2008.html#iv-a) ||||
| [`3.iv.b` LTS Linux kernel](https://ros.org/reps/rep-2008.html#iv-b) | |||
| [`3.v` hypervisor ](https://ros.org/reps/rep-2008.html#v) || | |
| [`3.v.a` no control domain VMs](https://ros.org/reps/rep-2008.html#v-a) || | |
| [`3.v.b` guest VMs in disk](https://ros.org/reps/rep-2008.html#v-b) || | |
| [`3.v.c` control domain in disk](https://ros.org/reps/rep-2008.html#v-c) || | |
| [`3.v.d` no control domain VMs in disk](https://ros.org/reps/rep-2008.html#v-d) | | | |
| [`3.vi` network booting ](https://ros.org/reps/rep-2008.html#vi) | | | |
| [`3.vi.a` boot artifacts ](https://ros.org/reps/rep-2008.html#vi-a) | | | |
| [`3.vi.b` rootfs ](https://ros.org/reps/rep-2008.html#vi-b) | | | |
| [`3.vi.c` multi-network boot](https://ros.org/reps/rep-2008.html#vi-c) | | | |
| [`3.vi.d` secure network booting](https://ros.org/reps/rep-2008.html#vi-d) | | | |
| [`3.vi.e` save in disk network boot](https://ros.org/reps/rep-2008.html#vi-e) | | | |
| **`4.` Benchmarking** | | | |
| [`4.i` kernel benchmarking](https://ros.org/reps/rep-2008.html#id18) ||||
| [`4.ii` ROS 2 acceleration benchmarking](https://ros.org/reps/rep-2008.html#id19) | |||
| **`5.` Documentation** | | | |
| [`5.i` in-code documentation](https://ros.org/reps/rep-2008.html#id20) ||||
| **`6.` Testing and CI** | | | |
| [`6.i` `acceleration_examples` ](https://ros.org/reps/rep-2008.html#id21) ||||
| Capability | KRS `alpha`[^1] | KRS `beta`[^2] | KRS `1.0`[^3] (*Ubuntu 22.04*) | KRS `1.1`[^3] (*Ubuntu 22.04*) |
|------------|-------------|------------|-------------|-------------|
| **`1.` Kernel Levels** | | | | |
| [`1.i` level I kernels](https://ros.org/reps/rep-2008.html#i) |||||
| [`1.ii` level II kernels](https://ros.org/reps/rep-2008.html#ii) | :warning: (see [this](https://github.com/Lien182/ReconROS)) | ✓ ([`acceleration_examples` (graph acceleration)](https://github.com/ros-acceleration/acceleration_examples/tree/main/graphs/perception/perception_2nodes), [`ReconROS`](https://github.com/Lien182/ReconROS)) | ✓ ([`acceleration_examples` (graph acceleration)](https://github.com/ros-acceleration/acceleration_examples/tree/main/graphs), [`ReconROS`](https://github.com/Lien182/ReconROS)) | ✓ ([`acceleration_examples` (graph acceleration)](https://github.com/ros-acceleration/acceleration_examples/tree/main/graphs), [`ReconROS`](https://github.com/Lien182/ReconROS)) |
| [`1.iii` level III kernels](https://ros.org/reps/rep-2008.html#iii) | | | | |
| **`2.` Build System** | | | | |
| [`2.i` ament extensions](https://ros.org/reps/rep-2008.html#id13) |||||
| [`2.ii` `ament_acceleration` support](https://ros.org/reps/rep-2008.html#id14) | ||||
| **`3`. Build Tools** | | | | |
| [`3.i` hardware emulation (`hw_emu`) ](https://ros.org/reps/rep-2008.html#id15) | | | | |
| [`3.ii` hardware emulation (`sw_emu`)](https://ros.org/reps/rep-2008.html#id16) | :warning: | | | |
| [`3.iii` image tooling](https://ros.org/reps/rep-2008.html#id17) ||| | |
| [`3.iv` Linux kernel ](https://ros.org/reps/rep-2008.html#iv) |||||
| [`3.iv.a` modern Linux kernel](https://ros.org/reps/rep-2008.html#iv-a) |||||
| [`3.iv.b` LTS Linux kernel](https://ros.org/reps/rep-2008.html#iv-b) | ||||
| [`3.v` hypervisor ](https://ros.org/reps/rep-2008.html#v) || | | |
| [`3.v.a` no control domain VMs](https://ros.org/reps/rep-2008.html#v-a) || | | |
| [`3.v.b` guest VMs in disk](https://ros.org/reps/rep-2008.html#v-b) || | | |
| [`3.v.c` control domain in disk](https://ros.org/reps/rep-2008.html#v-c) || | | |
| [`3.v.d` no control domain VMs in disk](https://ros.org/reps/rep-2008.html#v-d) | | | | |
| [`3.vi` network booting ](https://ros.org/reps/rep-2008.html#vi) | | | | |
| [`3.vi.a` boot artifacts ](https://ros.org/reps/rep-2008.html#vi-a) | | | | |
| [`3.vi.b` rootfs ](https://ros.org/reps/rep-2008.html#vi-b) | | | | |
| [`3.vi.c` multi-network boot](https://ros.org/reps/rep-2008.html#vi-c) | | | | |
| [`3.vi.d` secure network booting](https://ros.org/reps/rep-2008.html#vi-d) | | | | |
| [`3.vi.e` save in disk network boot](https://ros.org/reps/rep-2008.html#vi-e) | | | | |
| **`4.` Benchmarking** | | | | |
| [`4.i` kernel benchmarking](https://ros.org/reps/rep-2008.html#id18) |||||
| [`4.ii` ROS 2 acceleration benchmarking](https://ros.org/reps/rep-2008.html#id19) | ||||
| **`5.` Documentation** | | | | |
| [`5.i` in-code documentation](https://ros.org/reps/rep-2008.html#id20) |||||
| **`6.` Testing and CI** | | | | |
| [`6.i` `acceleration_examples` ](https://ros.org/reps/rep-2008.html#id21) |||||


[^1]: Aligns with Vitis 2020.2 release.
Expand Down
7 changes: 7 additions & 0 deletions cmake/colcon_ignore.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2022, Acceleration Robotics
# Author: Víctor Mayoral Vilches <victor@accelerationrobotics.com>
#

# message("Adding COLCON_IGNORE to firmware") # debug
set(CMD "${TESTFIRMWARE} touch ${FIRMWARE_DIR}/COLCON_IGNORE")
execute_process(COMMAND bash -c ${CMD})
17 changes: 17 additions & 0 deletions cmake/firmware_setup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2022, Acceleration Robotics
# Author: Víctor Mayoral Vilches <victor@accelerationrobotics.com>
#
# Set up the firmware variables for this cmake level and define macros

set(FIRMWARE_DIR ${CMAKE_INSTALL_PREFIX}/../acceleration/firmware/kv260) # <ws>/acceleration/firmware/kv260

# definition to automate testing of a fully deployed
# vitis. The condition used is the last step of the .cmake
# scripts: the creation of the COLCON_IGNORE file.
set(TESTFIRMWARE "test -e ${FIRMWARE_DIR}/COLCON_IGNORE || ")

# run() macro
# runs the CMD passed as an argument
macro(run CMD)
execute_process(COMMAND bash -c ${CMD})
endmacro()
50 changes: 50 additions & 0 deletions cmake/generate_mixin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (c) 2022, Acceleration Robotics
# Author: Víctor Mayoral Vilches <victor@accelerationrobotics.com>
#
# generate and add mixins at build-time to further simplify embedded flows
#
# NOTE: this logic is specific to KV260

message(STATUS "Creating mixins for the overlay ROS 2 workspace")

set(TEMPLATE_MIXIN "${CMAKE_BINARY_DIR}/kv260.mixin.template")
set(TEMPLATE_YAML "${CMAKE_BINARY_DIR}/index.yaml.template")
set(MIXIN_DIR "${FIRMWARE_DIR}/mixin")
set(MIXIN "${MIXIN_DIR}/kv260.mixin")
set(INDEX_YAML "${MIXIN_DIR}/index.yaml")

# arguments
# - ARG1_*: firmware directory, resulting toolchain should be here
# - ARG2_*: vitis directory, refer to "xilinx_vitis" package for details
# - ARG3_*: root of the install directory
set(ARG1_FIRMWARE_DIR ${FIRMWARE_DIR})

if(DEFINED ENV{XILINX_VITIS})
set(ARG2_VITIS_DIR $ENV{XILINX_VITIS})
else() # assume using "xilinx_vitis" package
set(ARG2_VITIS_DIR ${FIRMWARE_DIR}/../vitis)
endif()

set(ARG3_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
message(STATUS "ARG1_FIRMWARE_DIR: " ${ARG1_FIRMWARE_DIR})
message(STATUS "ARG2_VITIS_DIR: " ${ARG2_VITIS_DIR})
message(STATUS "ARG3_INSTALL_DIR: " ${ARG3_INSTALL_DIR})

# deploy in firmware
run("${TESTFIRMWARE} mkdir -p ${MIXIN_DIR}")
run("${TESTFIRMWARE} mv ${TEMPLATE_MIXIN} ${MIXIN}")
run("${TESTFIRMWARE} mv ${TEMPLATE_YAML} ${INDEX_YAML}")
# replace placeholders
set(SEDEXP_ARG1 "s:ARG1_FIRMWARE_DIR:${ARG1_FIRMWARE_DIR}:g")
set(SEDEXP_ARG2 "s:ARG2_VITIS_DIR:${ARG2_VITIS_DIR}:g")
set(SEDEXP_ARG3 "s:ARG3_INSTALL_DIR:${ARG3_INSTALL_DIR}:g")
run("${TESTFIRMWARE} sed -i ${SEDEXP_ARG1} ${MIXIN}")
run("${TESTFIRMWARE} sed -i ${SEDEXP_ARG2} ${MIXIN}")
run("${TESTFIRMWARE} sed -i ${SEDEXP_ARG3} ${MIXIN}")

# enable mixins
set(REDIRECT_STDERR_STR "2> /dev/null")
run("${TESTFIRMWARE} colcon mixin remove kv260 2> /dev/null") # clean up prior stuff
set(ADD_MIXIN_PATH "file://${FIRMWARE_DIR}/mixin/index.yaml")
run("${TESTFIRMWARE} colcon mixin add kv260 ${ADD_MIXIN_PATH}")
run("${TESTFIRMWARE} colcon mixin update kv260")
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 <victor@accelerationrobotics.com>
#
# 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.")
13 changes: 13 additions & 0 deletions cmake/sysroot.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2022, Acceleration Robotics
# Author: Víctor Mayoral Vilches <victor@accelerationrobotics.com>
#
# Deploy Ubuntu sysroot

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}/${SYSROOTNAME} -C ${FIRMWARE_DIR}")

message(STATUS "Ubuntu sysroot deployed.")
Empty file added firmware/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions firmware/BOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kv260
1 change: 1 addition & 0 deletions firmware/SOC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xck26-sfvc784-2lv-c
Binary file added firmware/device_tree/kernel_default.dtbo
Binary file not shown.
Loading

0 comments on commit 00d4966

Please sign in to comment.