-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to Ubuntu 22.04 as base image, adapt CMake macros
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
- Loading branch information
Showing
20 changed files
with
532 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.vscode | ||
firmware/*sysroot.tar.xz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kv260 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
xck26-sfvc784-2lv-c |
Binary file not shown.
Oops, something went wrong.