diff --git a/Kconfig b/Kconfig index d1b053b0c..36f623ab4 100644 --- a/Kconfig +++ b/Kconfig @@ -119,6 +119,17 @@ config KAS_INCLUDE_EIO default "kas/opt/eio.yml" depends on EIO +config META_HAILO + bool "Meta-Hailo AI card support" + help + Enable building of meta-hailo, which includes the hailo driver, + firmware and userspace runtime libraries. + +config KAS_INCLUDE_META_HAILO + string + default "kas/opt/meta-hailo.yml" + depends on META_HAILO + endif # Provide two entries so that the help text can be adjusted to the image. diff --git a/README.md b/README.md index e5bf4f22f..a6656487a 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,22 @@ Then build with ``` (or select `EIO subsystem support` in `kas menu`) +A tool to upgrade the customized signal module (SENS SM) firmware is also +avaiable, to build it with: + +```shell +./kas-container build kas-iot2050-example.yml:kas/opt/eio.yml:kas/opt/module.yml +``` + +### Build with Hailo8 AI card support + +To build the example image with the Hailo8 AI card support: + +```shell +./kas-container build kas-iot2050-example.yml:kas/opt/meta-hailo.yml +``` + +Please visit [meta-hailo](./meta-hailo/README.md) for the details. ## Build user SDK >>> diff --git a/kas/iot2050.yml b/kas/iot2050.yml index ba472229f..4a21a1386 100644 --- a/kas/iot2050.yml +++ b/kas/iot2050.yml @@ -24,6 +24,8 @@ defaults: repos: meta-iot2050: + layers: + .: isar: url: https://github.com/ilbers/isar diff --git a/kas/opt/eio.yml b/kas/opt/eio.yml index d81f05877..cd127e17b 100644 --- a/kas/opt/eio.yml +++ b/kas/opt/eio.yml @@ -12,5 +12,5 @@ header: version: 14 local_conf_header: - no-eio: | + eio: | IOT2050_EIO_SUPPORT = "1" diff --git a/kas/opt/meta-hailo.yml b/kas/opt/meta-hailo.yml new file mode 100644 index 000000000..e7c0b490c --- /dev/null +++ b/kas/opt/meta-hailo.yml @@ -0,0 +1,23 @@ +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Li Hua Qian +# +# This file is subject to the terms and conditions of the MIT License. See +# COPYING.MIT file in the top-level directory. +# + +header: + version: 15 + +local_conf_header: + hailo: | + IOT2050_META_HAILO = "1" + hailo_override: | + OVERRIDES .= ":meta-hailo" + +repos: + meta-iot2050: + layers: + meta-hailo: diff --git a/kas/opt/module.yml b/kas/opt/module.yml index 5cf905aa3..b20544f1d 100644 --- a/kas/opt/module.yml +++ b/kas/opt/module.yml @@ -12,5 +12,5 @@ header: version: 14 local_conf_header: - no-module: | + module: | IOT2050_MODULE_FWU = "1" diff --git a/kas/opt/secure-boot.yml b/kas/opt/secure-boot.yml index d3327ffe7..c30f74522 100644 --- a/kas/opt/secure-boot.yml +++ b/kas/opt/secure-boot.yml @@ -12,6 +12,7 @@ local_conf_header: secureboot_override: | OVERRIDES .= ":uefi-stmm" OVERRIDES .= ":secureboot" + OVERRIDES .= ":pvu-dma" secure-boot-signer: | IMAGER_BUILD_DEPS += "ebg-secure-boot-signer" IMAGER_INSTALL += "ebg-secure-boot-signer" diff --git a/meta-hailo/MAINTAINERS.md b/meta-hailo/MAINTAINERS.md new file mode 100644 index 000000000..fe92465c2 --- /dev/null +++ b/meta-hailo/MAINTAINERS.md @@ -0,0 +1,3 @@ +# Maintainers + +- Li Hua Qian diff --git a/meta-hailo/README.md b/meta-hailo/README.md new file mode 100644 index 000000000..c0761a3bb --- /dev/null +++ b/meta-hailo/README.md @@ -0,0 +1,25 @@ +# meta-hailo - Support for HAILO NPU chips + +This repo provides recipes to build the kernel and userspace drivers and utilities +(V4.18) for the Hailo-8 NPU chip. +This includes the following main components: + +- hailo-pci (OSS kernel module) +- hailo-firmware (proprietary firmware for hailo8 chip) +- hailort (Userspace API) + - hailortcli (tool) + - hailort (service) + - libhailort (c library) + - libhailort-dev (dev package) + - python3-hailort (python library) + +> Note: `numpy==1.23.3` is preinstalled. Please do not upgrade it, as +> `hailort v4.18.0` requires this specific version. Upgrading `numpy` may cause +> `pyhailort` to fail to execute. + +## Versioning + +This layer is versioned according to the major hailo driver version. +Note, that the kernel ABI is not stable and by that the version of the +userspace components need to perfectly match the version of the firmware +and the kernel module. diff --git a/meta-hailo/conf/layer.conf b/meta-hailo/conf/layer.conf new file mode 100644 index 000000000..ff3f682e4 --- /dev/null +++ b/meta-hailo/conf/layer.conf @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: Copyright 2023-2024 Siemens AG +# SPDX-License-Identifier: MIT +BBPATH .= ":${LAYERDIR}" + +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "hailo" +BBFILE_PATTERN_hailo = "^${LAYERDIR}/recipes-" +BBFILE_PRIORITY_hailo = "6" +LAYERVERSION_hailo = "3" + +LAYERSERIES_COMPAT_hailo = "next" + +LAYERDIR_hailo = "${LAYERDIR}" diff --git a/meta-hailo/recipes-app/hailort/files/debian/control b/meta-hailo/recipes-app/hailort/files/debian/control new file mode 100644 index 000000000..bc2771f04 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/control @@ -0,0 +1,94 @@ +Source: hailort +Maintainer: Felix Moessbauer , Li Hua Qian +Section: devel +Priority: optional +Standards-Version: 4.6.1 +Build-Depends: + debhelper-compat (=13), + cmake, + bash-completion, + libspdlog-dev, + libprotobuf-dev, + nlohmann-json3-dev, + libgrpc-dev, + libgrpc++-dev, + libreaderwriterqueue-dev:native, + protobuf-compiler, + protobuf-compiler-grpc, + libbenchmark-dev, + dh-python, + libpython3-all-dev, + python3-all-dev:any, + pybind11-dev, + python3-setuptools, + python3-wheel:native, + python3-verboselogs (>= 1.7~), + libeigen3-dev, + pkg-config, + libglib2.0-dev, + libgstreamer1.0-dev, + libgstreamer-plugins-base1.0-dev + +Package: hailortcli +Architecture: any +Multi-Arch: foreign +Description: userspace API for running inference on the hailo8 chip (tool) +Depends: + libhailort, + ${misc:Depends}, + ${shlibs:Depends} +Suggests: + bash-completion + +Package: hailort +Architecture: any +Multi-Arch: foreign +Description: userspace API for running inference on the hailo8 chip (service) +Depends: + libhailort, + ${misc:Depends}, + ${shlibs:Depends} + +Package: libhailort +Architecture: any +Multi-Arch: same +Description: userspace API for running inference on the hailo8 chip (lib) +Depends: + ${misc:Depends}, + ${shlibs:Depends} + +Package: python3-hailort +Architecture: any +Multi-Arch: same +Description: userspace API for running inference on the hailo8 chip (python package) +Depends: + ${python3:Depends}, + ${misc:Depends}, + ${shlibs:Depends}, + python3-numpy (= 1.23.3) + +Package: libhailort-dev +Architecture: any +Multi-Arch: foreign +Description: userspace API for running inference on the hailo8 chip (dev) +Depends: + libhailort (=${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} + +Package: libgsthailo +Architecture: any +Multi-Arch: same +Description: hailort GStreamer element (HailoNet) (lib) +Depends: + ${misc:Depends}, + ${shlibs:Depends} + +Package: libgsthailo-dev +Architecture: any +Multi-Arch: foreign +Description: hailort GStreamer element (HailoNet) (dev) +Depends: + libgsthailo (=${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} \ No newline at end of file diff --git a/meta-hailo/recipes-app/hailort/files/debian/hailort.install b/meta-hailo/recipes-app/hailort/files/debian/hailort.install new file mode 100644 index 000000000..f093e5abc --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/hailort.install @@ -0,0 +1,5 @@ +etc/default/hailort_service +usr/bin/hailort_service +# erronous upstream install path, fix here +usr/usr/share/bash-completion/completions/hailortcli usr/share/bash-completion/completions/ +debian/python-numpy.pref etc/apt/preferences.d/ diff --git a/meta-hailo/recipes-app/hailort/files/debian/hailort.service b/meta-hailo/recipes-app/hailort/files/debian/hailort.service new file mode 100644 index 000000000..c9ec090b2 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/hailort.service @@ -0,0 +1,16 @@ +[Unit] +Description=HailoRT service +Documentation=https://github.com/hailo-ai/hailort + +[Service] +Type=forking +EnvironmentFile=/etc/default/hailort_service +ExecStart=/usr/bin/hailort_service +Restart=on-failure +RemainAfterExit=yes +PIDFile=/run/hailo/hailort_service.pid +ExecReload=/bin/kill -HUP $MAINPID +ExecStartPost=/bin/sleep 0.1 + +[Install] +WantedBy=multi-user.target diff --git a/meta-hailo/recipes-app/hailort/files/debian/hailortcli.install b/meta-hailo/recipes-app/hailort/files/debian/hailortcli.install new file mode 100644 index 000000000..eb44e2a89 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/hailortcli.install @@ -0,0 +1 @@ +usr/bin/hailortcli diff --git a/meta-hailo/recipes-app/hailort/files/debian/libgsthailo-dev.install b/meta-hailo/recipes-app/hailort/files/debian/libgsthailo-dev.install new file mode 100644 index 000000000..214678390 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/libgsthailo-dev.install @@ -0,0 +1 @@ +usr/include/gstreamer-1.0/gst/hailo/tensor_meta.hpp \ No newline at end of file diff --git a/meta-hailo/recipes-app/hailort/files/debian/libgsthailo.install b/meta-hailo/recipes-app/hailort/files/debian/libgsthailo.install new file mode 100644 index 000000000..dc69f1301 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/libgsthailo.install @@ -0,0 +1 @@ +usr/lib/aarch64-linux-gnu/libgsthailo.so \ No newline at end of file diff --git a/meta-hailo/recipes-app/hailort/files/debian/libhailort-dev.install b/meta-hailo/recipes-app/hailort/files/debian/libhailort-dev.install new file mode 100644 index 000000000..5527f1029 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/libhailort-dev.install @@ -0,0 +1,3 @@ +usr/include/hailo +usr/lib/*/libhailort.so +usr/lib/*/cmake/HailoRT diff --git a/meta-hailo/recipes-app/hailort/files/debian/libhailort.install b/meta-hailo/recipes-app/hailort/files/debian/libhailort.install new file mode 100644 index 000000000..e98bce3f8 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/libhailort.install @@ -0,0 +1 @@ +usr/lib/*/libhailort.so.* diff --git a/meta-hailo/recipes-app/hailort/files/debian/not-installed b/meta-hailo/recipes-app/hailort/files/debian/not-installed new file mode 100644 index 000000000..1406d22b8 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/not-installed @@ -0,0 +1,3 @@ +usr/bin/hailo +usr/lib/systemd/system/hailort.service +usr/lib/python3.*/dist-packages/hailo_tutorials/* diff --git a/meta-hailo/recipes-app/hailort/files/debian/python-numpy.pref b/meta-hailo/recipes-app/hailort/files/debian/python-numpy.pref new file mode 100644 index 000000000..96aaf264c --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/python-numpy.pref @@ -0,0 +1,3 @@ +Package: python3-numpy +Pin: version 1.23.3 +Pin-Priority: 1001 diff --git a/meta-hailo/recipes-app/hailort/files/debian/python3-hailort.install b/meta-hailo/recipes-app/hailort/files/debian/python3-hailort.install new file mode 100644 index 000000000..cb668641a --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/python3-hailort.install @@ -0,0 +1,2 @@ +usr/lib/python3*/dist-packages/hailort-*.egg-info +usr/lib/python3*/dist-packages/hailo_platform diff --git a/meta-hailo/recipes-app/hailort/files/debian/rules b/meta-hailo/recipes-app/hailort/files/debian/rules new file mode 100644 index 000000000..859bdf59a --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/debian/rules @@ -0,0 +1,27 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS=hardening=+all + +%: + dh $@ --with python3 + +ifeq ($(DEB_HOST_ARCH),arm64) + CMAKE_TOOLCHAIN_FILE := $(CURDIR)/hailort/libhailort/cmake/toolchains/linux.aarch64.cmake +endif + +override_dh_auto_configure: + dh_auto_configure --buildsystem=pybuild --sourcedir=hailort/libhailort/bindings/python/platform + dh_auto_configure --buildsystem=cmake -- \ + -DHAILO_BUILD_SERVICE=ON \ + -DHAILO_BUILD_GSTREAMER=ON \ + -DCMAKE_BUILD_TYPE=Release + +override_dh_auto_build: + CMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_FILE) \ + dh_auto_build --buildsystem=pybuild --sourcedir=hailort/libhailort/bindings/python/platform + dh_auto_build --buildsystem=cmake + +override_dh_auto_install: + CMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_FILE) \ + dh_auto_install --buildsystem=pybuild --sourcedirectory=hailort/libhailort/bindings/python/platform + dh_auto_install --buildsystem=cmake diff --git a/meta-hailo/recipes-app/hailort/files/patches/0001-do-not-use-spdlog-formatting-internals.patch b/meta-hailo/recipes-app/hailort/files/patches/0001-do-not-use-spdlog-formatting-internals.patch new file mode 100644 index 000000000..252a73e60 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/patches/0001-do-not-use-spdlog-formatting-internals.patch @@ -0,0 +1,122 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Felix Moessbauer +Date: Fri, 12 Jan 2024 18:56:16 +0100 +Subject: [PATCH] do not use spdlog formatting internals + +As a preparation for using the packaged versions of spdlog, we need +to avoid including spdlog internal headers. These headers are only +available when using the builtin fmt library, but distros ususally +ship an external version of libfmt. Also, the external version is more +strict w.r.t formatting of enums by requiring either a formatter, or +an explicit cast to the underlaying integer type. For the sake of +simplicity, we introduce the cast. + +Signed-off-by: Felix Moessbauer +Signed-off-by: Li Hua Qian +--- + hailort/common/utils.hpp | 4 +++- + .../resource_manager/resource_manager_builder.cpp | 3 ++- + .../libhailort/src/stream_common/nms_stream.cpp | 15 ++++++++++----- + .../libhailort/src/vdma/channel/channel_id.hpp | 2 +- + 4 files changed, 16 insertions(+), 8 deletions(-) + +diff --git a/hailort/common/utils.hpp b/hailort/common/utils.hpp +index 3eb719e2c13c..1de45bd0b325 100644 +--- a/hailort/common/utils.hpp ++++ b/hailort/common/utils.hpp +@@ -17,7 +17,8 @@ + #include "hailo/buffer.hpp" + + #include "common/logger_macros.hpp" +-#include ++#include ++#include + + #include + #include +@@ -26,6 +27,7 @@ + #include + #include + #include ++#include + + + namespace hailort +diff --git a/hailort/libhailort/src/core_op/resource_manager/resource_manager_builder.cpp b/hailort/libhailort/src/core_op/resource_manager/resource_manager_builder.cpp +index 0f8985f0ae77..627273b8bfe5 100644 +--- a/hailort/libhailort/src/core_op/resource_manager/resource_manager_builder.cpp ++++ b/hailort/libhailort/src/core_op/resource_manager/resource_manager_builder.cpp +@@ -1096,7 +1096,8 @@ static Expected create_switch_lcu_batch_action(con + CHECK_AS_EXPECTED((ContextSwitchConfigAction::Type::EnableLcuDefault == action->get_type()) || + (ContextSwitchConfigAction::Type::SwitchLcuBatch == action->get_type()) || + (ContextSwitchConfigAction::Type::EnableLcuNonDefault == action->get_type()), HAILO_INVALID_ARGUMENT, +- "Invalid action type - must be enable lcu (default or non default) or switch lcu batch, Received type {}", action->get_type()); ++ "Invalid action type - must be enable lcu (default or non default), Received type {}", ++ static_cast(action->get_type())); + + TRY(const auto params_buffer, action->serialize_params(context_resources)); + +diff --git a/hailort/libhailort/src/stream_common/nms_stream.cpp b/hailort/libhailort/src/stream_common/nms_stream.cpp +index 79aa29c4b4d8..7d43948a1f1a 100644 +--- a/hailort/libhailort/src/stream_common/nms_stream.cpp ++++ b/hailort/libhailort/src/stream_common/nms_stream.cpp +@@ -77,7 +77,8 @@ hailo_status NMSStreamReader::advance_state_machine(NMSBurstState *burst_state, + if (HAILO_BURST_TYPE_H8_PER_CLASS == burst_type) { + CHECK_IN_DEBUG((NMSBurstState::NMS_BURST_STATE_WAITING_FOR_DELIMETER == (*burst_state)) || + (NMSBurstState::NMS_BURST_STATE_WAITING_FOR_PADDING == (*burst_state)), HAILO_NMS_BURST_INVALID_DATA, +- "Invalid state, H8 NMS burst cannot receive delimeter while in state {}", (*burst_state)); ++ "Invalid state, H8 NMS burst cannot receive delimeter while in state {}", ++ static_cast(*burst_state)); + // To differentiate from H8 padding - where we should not increment amount of delimeters found + if ((*burst_state) == NMSBurstState::NMS_BURST_STATE_WAITING_FOR_DELIMETER) { + (*num_delimeters_received)++; +@@ -99,12 +100,14 @@ hailo_status NMSStreamReader::advance_state_machine(NMSBurstState *burst_state, + + } else if (HAILO_BURST_TYPE_H15_PER_CLASS == burst_type) { + CHECK_IN_DEBUG(NMSBurstState::NMS_BURST_STATE_WAITING_FOR_DELIMETER == (*burst_state), HAILO_NMS_BURST_INVALID_DATA, +- "Invalid state, H15 Per class NMS burst cannot receive delimeter while in state {}", (*burst_state)); ++ "Invalid state, H15 Per class NMS burst cannot receive delimeter while in state {}", ++ static_cast(*burst_state)); + (*num_delimeters_received)++; + *burst_state = NMSBurstState::NMS_BURST_STATE_WAITING_FOR_IMAGE_DELIMETER; + } else { + CHECK_IN_DEBUG(NMSBurstState::NMS_BURST_STATE_WAITING_FOR_DELIMETER == (*burst_state), HAILO_NMS_BURST_INVALID_DATA, +- "Invalid state, H15 Per Frame NMS burst cannot receive delimeter while in state {}", (*burst_state)); ++ "Invalid state, H15 Per Frame NMS burst cannot receive delimeter while in state {}", ++ static_cast(*burst_state)); + // in hailo15 per frame - if number of delimeter is same as num classes - we expect image delimeter next + // otherwise expect another delimeter + (*num_delimeters_received)++; +@@ -121,7 +124,8 @@ hailo_status NMSStreamReader::advance_state_machine(NMSBurstState *burst_state, + "Invalid state, H8 NMS burst cannot receive image delimeter"); + + CHECK_IN_DEBUG(NMSBurstState::NMS_BURST_STATE_WAITING_FOR_IMAGE_DELIMETER == (*burst_state), HAILO_NMS_BURST_INVALID_DATA, +- "Invalid state, H15 NMS burst cannot receive image delimeter in state {}", (*burst_state)); ++ "Invalid state, H15 NMS burst cannot receive image delimeter in state {}", ++ static_cast(*burst_state)); + + // in both hailo15 per class and per frame - when receiving image delimeter we move to expecting padding + *burst_state = NMSBurstState::NMS_BURST_STATE_WAITING_FOR_PADDING; +@@ -143,7 +147,8 @@ hailo_status NMSStreamReader::advance_state_machine(NMSBurstState *burst_state, + { + if ((HAILO_BURST_TYPE_H15_PER_CLASS == burst_type) || (HAILO_BURST_TYPE_H15_PER_FRAME == burst_type)) { + CHECK_IN_DEBUG(NMSBurstState::NMS_BURST_STATE_WAITING_FOR_PADDING == (*burst_state), HAILO_NMS_BURST_INVALID_DATA, +- "Invalid state, H15 NMS burst cannot receive padding in state {}", (*burst_state)); ++ "Invalid state, H15 NMS burst cannot receive padding in state {}", ++ static_cast(*burst_state)); + } + // In case of padding next state is wait for padding unless it is last padding of burst - then next state will be + // Wait for delimeter - will only get to this stage in debug - in release once image delimeter is read we ignore rest of +diff --git a/hailort/libhailort/src/vdma/channel/channel_id.hpp b/hailort/libhailort/src/vdma/channel/channel_id.hpp +index 09fb0432edd3..9928c31a343a 100644 +--- a/hailort/libhailort/src/vdma/channel/channel_id.hpp ++++ b/hailort/libhailort/src/vdma/channel/channel_id.hpp +@@ -12,7 +12,7 @@ + + #include "hailo/hailort.h" + #include "common/logger_macros.hpp" +-#include ++#include + #include + + diff --git a/meta-hailo/recipes-app/hailort/files/patches/0002-use-distro-version-of-packages-if-possible.patch b/meta-hailo/recipes-app/hailort/files/patches/0002-use-distro-version-of-packages-if-possible.patch new file mode 100644 index 000000000..8ade3fed3 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/patches/0002-use-distro-version-of-packages-if-possible.patch @@ -0,0 +1,451 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Felix Moessbauer +Date: Fri, 12 Jan 2024 18:12:26 +0100 +Subject: [PATCH] use distro version of packages if possible + +This patch replaces the vendored components with the version shipped +by the linux distribution (if possible). + +Signed-off-by: Felix Moessbauer +Signed-off-by: Li Hua Qian +--- + hailort/CMakeLists.txt | 15 +++++- + hailort/hailort_server/CMakeLists.txt | 3 +- + hailort/hailort_service/CMakeLists.txt | 5 +- + hailort/hailortcli/CMakeLists.txt | 7 +-- + hailort/hrpc/server.cpp | 33 ++++++++++++ + hailort/hrpc_protocol/CMakeLists.txt | 2 +- + hailort/libhailort/CMakeLists.txt | 6 +-- + .../bindings/python/src/CMakeLists.txt | 21 +++----- + hailort/libhailort/src/CMakeLists.txt | 7 +-- + .../src/network_group/network_group.cpp | 33 ++++++++++++ + .../src/utils/measurement_utils.hpp | 2 +- + .../src/vdma/driver/hailort_driver.cpp | 52 +++++++++++++++++++ + hailort/prepare_externals/CMakeLists.txt | 11 ---- + hailort/rpc/CMakeLists.txt | 4 +- + 14 files changed, 149 insertions(+), 52 deletions(-) + +diff --git a/hailort/CMakeLists.txt b/hailort/CMakeLists.txt +index 5dcaa06c2537..edea76ee3804 100644 +--- a/hailort/CMakeLists.txt ++++ b/hailort/CMakeLists.txt +@@ -46,9 +46,20 @@ endif() + # TODO: move protobuf and grpc to inner cmake files + set(HAILO_EXTERNAL_DIR ${CMAKE_CURRENT_LIST_DIR}/external) + set(HAILO_EXTERNALS_CMAKE_SCRIPTS ${CMAKE_CURRENT_LIST_DIR}/cmake/external/) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/protobuf.cmake) ++find_package(Protobuf REQUIRED) ++find_package(nlohmann_json 3.9.1 REQUIRED) ++find_package(benchmark REQUIRED) ++find_package(spdlog 1.8 REQUIRED) ++find_package(Eigen3 REQUIRED) ++find_path(RWQ_FOUND name readerwriterqueue.h REQUIRED) + if(HAILO_BUILD_SERVICE) +- include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/grpc.cmake) ++ find_package(gRPC REQUIRED) ++endif() ++if(HAILO_BUILD_PYBIND) ++ find_package(pybind11 REQUIRED) ++endif() ++if(ENABLE_TESTING) ++ find_package(Catch2 REQUIRED) + endif() + + set(HAILORT_INC_DIR ${PROJECT_SOURCE_DIR}/hailort/libhailort/include) +diff --git a/hailort/hailort_server/CMakeLists.txt b/hailort/hailort_server/CMakeLists.txt +index d288066dc741..b9263c8282dc 100644 +--- a/hailort/hailort_server/CMakeLists.txt ++++ b/hailort/hailort_server/CMakeLists.txt +@@ -1,6 +1,5 @@ + cmake_minimum_required(VERSION 3.0.0) + +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/spdlog.cmake) + include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/readerwriterqueue.cmake) + + set(THREADS_PREFER_PTHREAD_FLAG ON) +@@ -52,4 +51,4 @@ target_link_libraries(hailort_server PRIVATE + rpc_proto + spdlog::spdlog + readerwriterqueue +-) +\ No newline at end of file ++) +diff --git a/hailort/hailort_service/CMakeLists.txt b/hailort/hailort_service/CMakeLists.txt +index a470a3ddf0a0..4d3c52095f58 100644 +--- a/hailort/hailort_service/CMakeLists.txt ++++ b/hailort/hailort_service/CMakeLists.txt +@@ -1,7 +1,5 @@ + cmake_minimum_required(VERSION 3.0.0) + +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/spdlog.cmake) +- + if(WIN32) + set(HAILORT_SERVICE_OS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/windows") + elseif(UNIX) +@@ -23,9 +21,8 @@ set_property(TARGET hailort_service PROPERTY CXX_STANDARD 14) + target_link_libraries(hailort_service + libhailort + spdlog::spdlog +- grpc++_unsecure ++ gRPC::grpc++_unsecure + hailort_rpc_grpc_proto +- readerwriterqueue + ) + if(WIN32) + # Needed in order to compile eth utils (we compile here ${HAILORT_COMMON_CPP_SOURCES}, consider removing) +diff --git a/hailort/hailortcli/CMakeLists.txt b/hailort/hailortcli/CMakeLists.txt +index 8b180dadc291..1add7146af56 100644 +--- a/hailort/hailortcli/CMakeLists.txt ++++ b/hailort/hailortcli/CMakeLists.txt +@@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.0.0) + + include(GNUInstallDirs) + include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/cli11.cmake) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/json.cmake) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/spdlog.cmake) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/readerwriterqueue.cmake) + include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/dotwriter.cmake) + + set(HAILORTCLI_CPP_FILES +@@ -69,10 +66,8 @@ set_property(TARGET hailortcli PROPERTY INSTALL_RPATH "$ORIGIN" "../lib/") # Lin + target_link_libraries(hailortcli + libhailort + CLI11::CLI11 +- nlohmann_json ++ nlohmann_json::nlohmann_json + spdlog::spdlog +- readerwriterqueue +- eigen + DotWriter + scheduler_mon_proto + profiler_proto) +diff --git a/hailort/hrpc/server.cpp b/hailort/hrpc/server.cpp +index 304c41c67a25..e72de4112f1a 100644 +--- a/hailort/hrpc/server.cpp ++++ b/hailort/hrpc/server.cpp +@@ -9,6 +9,39 @@ + + #include "server.hpp" + ++// Add a formatter spec for HailoRpcActionID ++template <> ++struct fmt::formatter { ++ constexpr auto parse(format_parse_context& ctx) { ++ return ctx.begin(); ++ } ++ ++ template ++ auto format(const HailoRpcActionID& id, FormatContext& ctx) { ++ std::string name; ++ switch (id) { ++ case HailoRpcActionID::VDEVICE__CREATE: name = "VDEVICE__CREATE"; break; ++ case HailoRpcActionID::VDEVICE__DESTROY: name = "VDEVICE__DESTROY"; break; ++ case HailoRpcActionID::VDEVICE__CREATE_INFER_MODEL: name = "VDEVICE__CREATE_INFER_MODEL"; break; ++ case HailoRpcActionID::INFER_MODEL__DESTROY: name = "INFER_MODEL__DESTROY"; break; ++ case HailoRpcActionID::INFER_MODEL__CREATE_CONFIGURED_INFER_MODEL: name = "INFER_MODEL__CREATE_CONFIGURED_INFER_MODEL"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__DESTROY: name = "CONFIGURED_INFER_MODEL__DESTROY"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__SET_SCHEDULER_TIMEOUT: name = "CONFIGURED_INFER_MODEL__SET_SCHEDULER_TIMEOUT"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__SET_SCHEDULER_THRESHOLD: name = "CONFIGURED_INFER_MODEL__SET_SCHEDULER_THRESHOLD"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__SET_SCHEDULER_PRIORITY: name = "CONFIGURED_INFER_MODEL__SET_SCHEDULER_PRIORITY"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__GET_HW_LATENCY_MEASUREMENT: name = "CONFIGURED_INFER_MODEL__GET_HW_LATENCY_MEASUREMENT"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__ACTIVATE: name = "CONFIGURED_INFER_MODEL__ACTIVATE"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__DEACTIVATE: name = "CONFIGURED_INFER_MODEL__DEACTIVATE"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__SHUTDOWN: name = "CONFIGURED_INFER_MODEL__SHUTDOWN"; break; ++ case HailoRpcActionID::CONFIGURED_INFER_MODEL__RUN_ASYNC: name = "CONFIGURED_INFER_MODEL__RUN_ASYNC"; break; ++ case HailoRpcActionID::CALLBACK_CALLED: name = "CALLBACK_CALLED"; break; ++ case HailoRpcActionID::MAX_VALUE: name = "MAX_VALUE"; break; ++ default: name = "UNKNOWN"; break; ++ } ++ return format_to(ctx.out(), "{}", name); ++ } ++}; ++ + namespace hrpc + { + +diff --git a/hailort/hrpc_protocol/CMakeLists.txt b/hailort/hrpc_protocol/CMakeLists.txt +index d6b925ad1b87..591b3928be91 100644 +--- a/hailort/hrpc_protocol/CMakeLists.txt ++++ b/hailort/hrpc_protocol/CMakeLists.txt +@@ -4,7 +4,7 @@ protobuf_generate_cpp(PROTO_RPC_SRC PROTO_RPC_HEADER rpc.proto) + get_filename_component(PROTO_HEADER_DIRECTORY ${PROTO_RPC_HEADER} DIRECTORY) + + add_library(rpc_proto STATIC EXCLUDE_FROM_ALL ${PROTO_RPC_SRC} ${PROTO_RPC_HEADER}) +-target_link_libraries(rpc_proto libprotobuf-lite) ++target_link_libraries(rpc_proto protobuf::libprotobuf-lite) + set_target_properties(rpc_proto PROPERTIES CXX_STANDARD 14 GENERATED TRUE POSITION_INDEPENDENT_CODE ON) + if(CMAKE_HOST_WIN32) + # https://github.com/protocolbuffers/protobuf/tree/master/cmake#notes-on-compiler-warnings +diff --git a/hailort/libhailort/CMakeLists.txt b/hailort/libhailort/CMakeLists.txt +index 33e183a98910..ab46f83483ad 100644 +--- a/hailort/libhailort/CMakeLists.txt ++++ b/hailort/libhailort/CMakeLists.txt +@@ -14,7 +14,7 @@ protobuf_generate_python(PROTO_HEF_PY hef.proto) # TODO (HRT-12504): Copy hef_pb + protobuf_generate_python(PROTO_HEF_PY tracer_profiler.proto) + + add_library(hef_proto ${PROTO_HEF_SRC} ${PROTO_HEF_HEADER} ${PROTO_HEF_PY}) +-target_link_libraries(hef_proto libprotobuf-lite) ++target_link_libraries(hef_proto protobuf::libprotobuf-lite) + set_target_properties(hef_proto PROPERTIES CXX_STANDARD 14 GENERATED TRUE POSITION_INDEPENDENT_CODE ON) + if(CMAKE_HOST_WIN32) + # https://github.com/protocolbuffers/protobuf/tree/master/cmake#notes-on-compiler-warnings +@@ -33,7 +33,7 @@ endif() + + protobuf_generate_cpp(PROTO_SCHEDULER_MON_SRC PROTO_SCHEDULER_MON_HEADR scheduler_mon.proto) + add_library(scheduler_mon_proto ${PROTO_SCHEDULER_MON_SRC} ${PROTO_SCHEDULER_MON_HEADR}) +-target_link_libraries(scheduler_mon_proto libprotobuf-lite) ++target_link_libraries(scheduler_mon_proto protobuf::libprotobuf-lite) + set_target_properties(scheduler_mon_proto PROPERTIES CXX_STANDARD 14 GENERATED TRUE POSITION_INDEPENDENT_CODE ON) + if(CMAKE_HOST_WIN32) + target_compile_options(scheduler_mon_proto PRIVATE /wd4244) +@@ -47,7 +47,7 @@ target_include_directories(scheduler_mon_proto + + protobuf_generate_cpp(PROTO_PROFILER_SRC PROTO_PROFILER_HEADR tracer_profiler.proto) + add_library(profiler_proto ${PROTO_PROFILER_SRC} ${PROTO_PROFILER_HEADR}) +-target_link_libraries(profiler_proto libprotobuf-lite) ++target_link_libraries(profiler_proto protobuf::libprotobuf-lite) + set_target_properties(profiler_proto PROPERTIES CXX_STANDARD 14 GENERATED TRUE POSITION_INDEPENDENT_CODE ON) + if(CMAKE_HOST_WIN32) + target_compile_options(profiler_proto PRIVATE /wd4244) +diff --git a/hailort/libhailort/bindings/python/src/CMakeLists.txt b/hailort/libhailort/bindings/python/src/CMakeLists.txt +index 1b5706c98862..913716297564 100644 +--- a/hailort/libhailort/bindings/python/src/CMakeLists.txt ++++ b/hailort/libhailort/bindings/python/src/CMakeLists.txt +@@ -13,7 +13,6 @@ option(HAILORT_INCLUDE_DIR "Path to include dir of libhailort" "") + + include(ExternalProject) + include(GNUInstallDirs) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/pybind11.cmake) + include_directories(${HAILORT_COMMON_DIR}) + + FUNCTION(exclude_archive_libs_symbols target) # should be same as in common_compiler_options.cmake +@@ -26,19 +25,7 @@ FUNCTION(exclude_archive_libs_symbols target) # should be same as in common_comp + endif() + ENDFUNCTION() + +-if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +- if(NOT DEFINED PYBIND11_PYTHON_VERSION) +- message(FATAL_ERROR "PYBIND11_PYTHON_VERSION is not defined. To build _pyhailort, pass python version") +- endif() +- string(REPLACE "." "" dpython ${PYBIND11_PYTHON_VERSION}) # E.g "3.5" -> "35" +- if(${dpython} LESS "38") +- set(m_flag "m") +- else() +- set(m_flag "") +- endif() +- set(PYTHON_MODULE_EXTENSION ".cpython-${dpython}${m_flag}-${CMAKE_SYSTEM_PROCESSOR}-linux-gnu.so") +-endif() +- ++find_package(pybind11 REQUIRED) + pybind11_add_module(_pyhailort + pyhailort.cpp + device_api.cpp +@@ -82,8 +69,12 @@ if(LIBHAILORT_PATH AND HAILORT_INCLUDE_DIR) + elseif(LIBHAILORT_PATH OR HAILORT_INCLUDE_DIR) + message(FATAL_ERROR "Both LIBHAILORT_PATH and HAILORT_INCLUDE_DIR must be defined or none of them") + else() ++ message(STATUS "skip find_package, CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}") ++ message(STATUS "CMAKE_SYSTEM_PROCESSOR is ${CMAKE_SYSTEM_PROCESSOR}") + find_package(HailoRT 4.18.0 EXACT REQUIRED) +- target_link_libraries(_pyhailort PRIVATE HailoRT::libhailort) ++ ++ include_directories("${HAILORT_PROJECT_SOURCE_DIR}/hailort/libhailort/include") ++ target_link_libraries(_pyhailort PRIVATE libhailort) + endif() + + if(WIN32) +diff --git a/hailort/libhailort/src/CMakeLists.txt b/hailort/libhailort/src/CMakeLists.txt +index 5136024403c5..8a3e9b8e0a50 100644 +--- a/hailort/libhailort/src/CMakeLists.txt ++++ b/hailort/libhailort/src/CMakeLists.txt +@@ -5,9 +5,6 @@ find_package(Threads REQUIRED) + include(GNUInstallDirs) + include(CMakePackageConfigHelpers) + include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/common_compiler_options.cmake) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/spdlog.cmake) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/readerwriterqueue.cmake) +-include(${HAILO_EXTERNALS_CMAKE_SCRIPTS}/eigen.cmake) + + FUNCTION(relative_to_absolute_paths output) + SET(listVar "") +@@ -91,11 +88,11 @@ target_link_libraries(libhailort PRIVATE hef_proto) + target_link_libraries(libhailort PRIVATE profiler_proto) + target_link_libraries(libhailort PRIVATE scheduler_mon_proto) + target_link_libraries(libhailort PRIVATE spdlog::spdlog) +-target_link_libraries(libhailort PRIVATE readerwriterqueue) + target_link_libraries(libhailort PRIVATE Eigen3::Eigen) ++ + target_link_libraries(libhailort PRIVATE rpc_proto) + if(HAILO_BUILD_SERVICE) +- target_link_libraries(libhailort PRIVATE grpc++_unsecure) ++ target_link_libraries(libhailort PRIVATE gRPC::grpc++_unsecure) + target_link_libraries(libhailort PRIVATE hailort_rpc_grpc_proto) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL QNX) +diff --git a/hailort/libhailort/src/network_group/network_group.cpp b/hailort/libhailort/src/network_group/network_group.cpp +index bc3de09bae4c..de1a2a06cd58 100644 +--- a/hailort/libhailort/src/network_group/network_group.cpp ++++ b/hailort/libhailort/src/network_group/network_group.cpp +@@ -27,6 +27,39 @@ + #include "utils/buffer_storage.hpp" + #include "hef/hef_internal.hpp" + ++namespace fmt { ++ // Add a formatter spec for BufferType ++ template <> ++ struct formatter { ++ constexpr auto parse(format_parse_context& ctx) { ++ return ctx.begin(); ++ } ++ ++ template ++ auto format(const hailort::BufferType& type, FormatContext& ctx) { ++ std::string type_str; ++ switch (type) { ++ case hailort::BufferType::UNINITIALIZED: ++ type_str = "UNINITIALIZED"; ++ break; ++ case hailort::BufferType::VIEW: ++ type_str = "VIEW"; ++ break; ++ case hailort::BufferType::PIX_BUFFER: ++ type_str = "PIX_BUFFER"; ++ break; ++ case hailort::BufferType::DMA_BUFFER: ++ type_str = "DMA_BUFFER"; ++ break; ++ default: ++ type_str = "UNKNOWN"; ++ break; ++ } ++ return fmt::format_to(ctx.out(), "{}", type_str); ++ } ++ }; ++} ++ + namespace hailort + { + +diff --git a/hailort/libhailort/src/utils/measurement_utils.hpp b/hailort/libhailort/src/utils/measurement_utils.hpp +index ae9e3fbfe8b5..6923c6d13e49 100644 +--- a/hailort/libhailort/src/utils/measurement_utils.hpp ++++ b/hailort/libhailort/src/utils/measurement_utils.hpp +@@ -87,7 +87,7 @@ + #define _HAILO_MEASUREMENT_UTILS_HPP_ + + #include "measurement_utils_internal.hpp" +-#include ++#include + + namespace hailort { + namespace utils { +diff --git a/hailort/libhailort/src/vdma/driver/hailort_driver.cpp b/hailort/libhailort/src/vdma/driver/hailort_driver.cpp +index 891eb92eb379..f7d3f1263f25 100755 +--- a/hailort/libhailort/src/vdma/driver/hailort_driver.cpp ++++ b/hailort/libhailort/src/vdma/driver/hailort_driver.cpp +@@ -25,6 +25,58 @@ + #error "unsupported platform!" + #endif + ++namespace fmt { ++ // Add a formatter spec for HailoRTDriver::PcieSessionType ++ template <> ++ struct formatter { ++ constexpr auto parse(format_parse_context& ctx) { ++ return ctx.begin(); ++ } ++ ++ template ++ auto format(const hailort::HailoRTDriver::PcieSessionType& type, FormatContext& ctx) { ++ std::string type_str; ++ switch (type) { ++ case hailort::HailoRTDriver::PcieSessionType::CLIENT: ++ type_str = "CLIENT"; ++ break; ++ case hailort::HailoRTDriver::PcieSessionType::SERVER: ++ type_str = "SERVER"; ++ break; ++ default: ++ type_str = "UNKNOWN"; ++ break; ++ } ++ return fmt::format_to(ctx.out(), "{}", type_str); ++ } ++ }; ++ ++ // Add a formatter spec for HailoRTDriver::DmaDirection ++ template <> ++ struct formatter { ++ constexpr auto parse(format_parse_context& ctx) { ++ return ctx.begin(); ++ } ++ ++ template ++ auto format(const hailort::HailoRTDriver::DmaBufferType& type, FormatContext& ctx) { ++ std::string type_str; ++ switch (type) { ++ case hailort::HailoRTDriver::DmaBufferType::USER_PTR_BUFFER: ++ type_str = "USER_PTR_BUFFER"; ++ break; ++ case hailort::HailoRTDriver::DmaBufferType::DMABUF_BUFFER: ++ type_str = "DMABUF_BUFFER"; ++ break; ++ default: ++ type_str = "UNKNOWN"; ++ break; ++ } ++ return fmt::format_to(ctx.out(), "{}", type_str); ++ } ++ }; ++} ++ + namespace hailort + { + +diff --git a/hailort/prepare_externals/CMakeLists.txt b/hailort/prepare_externals/CMakeLists.txt +index 6166c4ce4f0c..6f518610689f 100644 +--- a/hailort/prepare_externals/CMakeLists.txt ++++ b/hailort/prepare_externals/CMakeLists.txt +@@ -4,19 +4,8 @@ project(hailort_prebuild) + set(HAILO_EXTERNALS_EXCLUDE_TARGETS ON) + + message("Downloading dependencies to ${HAILO_EXTERNAL_DIR} ...") +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/pybind11.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/catch2.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/spdlog.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/json.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/dotwriter.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/benchmark.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/readerwriterqueue.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/eigen.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/cli11.cmake) +-include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/protobuf.cmake) +-if(HAILO_BUILD_SERVICE) +- include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/grpc.cmake) +-endif() + if(CMAKE_SYSTEM_NAME STREQUAL QNX) + include(${CMAKE_CURRENT_LIST_DIR}/../cmake/external/pevents.cmake) + endif() +diff --git a/hailort/rpc/CMakeLists.txt b/hailort/rpc/CMakeLists.txt +index 7823cb57f0ba..c2a89df1de43 100644 +--- a/hailort/rpc/CMakeLists.txt ++++ b/hailort/rpc/CMakeLists.txt +@@ -12,7 +12,7 @@ set(hailort_rpc_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/hailort_rpc.grpc.pb.h") + set(HAILO_PROTOBUF_PROTOC $) + if(HAILO_BUILD_SERVICE) + if(CMAKE_HOST_UNIX) +- set(HAILO_GRPC_CPP_PLUGIN_EXECUTABLE "${HAILO_EXTERNAL_DIR}/grpc-build/grpc_cpp_plugin") ++ set(HAILO_GRPC_CPP_PLUGIN_EXECUTABLE "$") + else() + set(HAILO_GRPC_CPP_PLUGIN_EXECUTABLE "${HAILO_EXTERNAL_DIR}/grpc-build/Release/grpc_cpp_plugin.exe") + endif() +@@ -36,7 +36,7 @@ add_library(hailort_rpc_grpc_proto STATIC EXCLUDE_FROM_ALL + ${hailort_rpc_proto_hdrs}) + + set_target_properties(hailort_rpc_grpc_proto PROPERTIES POSITION_INDEPENDENT_CODE ON) +-target_link_libraries(hailort_rpc_grpc_proto libprotobuf-lite grpc++_unsecure) ++target_link_libraries(hailort_rpc_grpc_proto protobuf::libprotobuf-lite gRPC::grpc++_unsecure) + # Include generated *.pb.h files + target_include_directories(hailort_rpc_grpc_proto PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") + disable_exceptions(hailort_rpc_grpc_proto) +\ No newline at end of file diff --git a/meta-hailo/recipes-app/hailort/files/patches/0003-install-independent-of-build-target.patch b/meta-hailo/recipes-app/hailort/files/patches/0003-install-independent-of-build-target.patch new file mode 100644 index 000000000..3ac36d526 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/patches/0003-install-independent-of-build-target.patch @@ -0,0 +1,107 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Felix Moessbauer +Date: Sat, 13 Jan 2024 12:12:14 +0100 +Subject: [PATCH] install independent of build target + +Previously, cmake did only install the components when building the +Release target. However, the configuration should be selectable by the +user (or the distro). This patch removes this condition, so the user can +always install the currently built configuration. + +Signed-off-by: Felix Moessbauer +Signed-off-by: Li Hua Qian +--- + hailort/hailort_service/CMakeLists.txt | 3 --- + hailort/hailortcli/CMakeLists.txt | 1 - + hailort/libhailort/bindings/gstreamer/CMakeLists.txt | 2 +- + hailort/libhailort/bindings/python/src/CMakeLists.txt | 2 -- + hailort/libhailort/doc/CMakeLists.txt | 2 +- + hailort/libhailort/src/CMakeLists.txt | 1 - + 6 files changed, 2 insertions(+), 9 deletions(-) + +diff --git a/hailort/hailort_service/CMakeLists.txt b/hailort/hailort_service/CMakeLists.txt +index 4d3c52095f58..5f7facc48c0b 100644 +--- a/hailort/hailort_service/CMakeLists.txt ++++ b/hailort/hailort_service/CMakeLists.txt +@@ -52,7 +52,6 @@ if (UNIX) + install( + FILES "${HAILORT_SERVICE_ENV_VARS_FILE}" + DESTINATION "${ENV_VARS_FILE_DIR}" +- CONFIGURATIONS Release + COMPONENT hailort_service + ) + +@@ -61,7 +60,6 @@ if (UNIX) + install( + FILES "${HAILORT_SERVICE_UNIT_FILE}" + DESTINATION "${SYSTEMD_UNIT_DIR}" +- CONFIGURATIONS Release + COMPONENT hailort_service + ) + endif() +@@ -69,7 +67,6 @@ endif() + install( + TARGETS hailort_service + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- CONFIGURATIONS Release + ) + + set(DAEMON_PID_DIR "/run/hailo") +diff --git a/hailort/hailortcli/CMakeLists.txt b/hailort/hailortcli/CMakeLists.txt +index 1add7146af56..4a2d5e751802 100644 +--- a/hailort/hailortcli/CMakeLists.txt ++++ b/hailort/hailortcli/CMakeLists.txt +@@ -88,6 +88,5 @@ target_include_directories(hailortcli + + install(TARGETS hailortcli + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- CONFIGURATIONS Release + ) + cli11_install_completion_file(hailortcli) +\ No newline at end of file +diff --git a/hailort/libhailort/bindings/gstreamer/CMakeLists.txt b/hailort/libhailort/bindings/gstreamer/CMakeLists.txt +index 5a601802738a..012e17c4bfea 100644 +--- a/hailort/libhailort/bindings/gstreamer/CMakeLists.txt ++++ b/hailort/libhailort/bindings/gstreamer/CMakeLists.txt +@@ -61,4 +61,4 @@ install(TARGETS gsthailo + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + # TODO: get gstreamer-1.0 in an automate way + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/gstreamer-1.0/gst/hailo/" +- CONFIGURATIONS Release) ++) +diff --git a/hailort/libhailort/bindings/python/src/CMakeLists.txt b/hailort/libhailort/bindings/python/src/CMakeLists.txt +index 913716297564..4d25762df8d9 100644 +--- a/hailort/libhailort/bindings/python/src/CMakeLists.txt ++++ b/hailort/libhailort/bindings/python/src/CMakeLists.txt +@@ -99,6 +99,4 @@ add_dependencies(pyhailort_venv _pyhailort) + + install(TARGETS _pyhailort + LIBRARY DESTINATION ${HAILO_PYHAILORT_TARGET_DIR} +- CONFIGURATIONS Release + ) +- +diff --git a/hailort/libhailort/doc/CMakeLists.txt b/hailort/libhailort/doc/CMakeLists.txt +index 73d0964c5e6f..9f2ea9c2778c 100644 +--- a/hailort/libhailort/doc/CMakeLists.txt ++++ b/hailort/libhailort/doc/CMakeLists.txt +@@ -25,7 +25,7 @@ if(DOXYGEN_FOUND) + + install( + DIRECTORY "${DOXYGEN_OUTPUT_DIR}" DESTINATION "doc/" +- CONFIGURATIONS Release) ++ ) + + add_custom_target(doc ALL DEPENDS doxygen) + +diff --git a/hailort/libhailort/src/CMakeLists.txt b/hailort/libhailort/src/CMakeLists.txt +index 8a3e9b8e0a50..048fdd0ffe38 100644 +--- a/hailort/libhailort/src/CMakeLists.txt ++++ b/hailort/libhailort/src/CMakeLists.txt +@@ -163,7 +163,6 @@ target_compile_definitions(libhailort PUBLIC + + install(TARGETS libhailort + EXPORT HailoRTTargets +- CONFIGURATIONS Release + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/meta-hailo/recipes-app/hailort/files/patches/0004-install-python-bindings-into-dist-packages.patch b/meta-hailo/recipes-app/hailort/files/patches/0004-install-python-bindings-into-dist-packages.patch new file mode 100644 index 000000000..e20029fa1 --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/patches/0004-install-python-bindings-into-dist-packages.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Felix Moessbauer +Date: Tue, 16 Jan 2024 16:28:15 +0100 +Subject: [PATCH] install python bindings into dist-packages + +This patch installs the hailort python bindings into the python +site-packages location, so python can automatically find this +dependency. + +Signed-off-by: Felix Moessbauer +Signed-off-by: Li Hua Qian +--- + .../bindings/python/src/CMakeLists.txt | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +diff --git a/hailort/libhailort/bindings/python/src/CMakeLists.txt b/hailort/libhailort/bindings/python/src/CMakeLists.txt +index 4d25762df8d9..b96d64a77895 100644 +--- a/hailort/libhailort/bindings/python/src/CMakeLists.txt ++++ b/hailort/libhailort/bindings/python/src/CMakeLists.txt +@@ -90,12 +90,19 @@ target_compile_options(_pyhailort PRIVATE ${HAILORT_COMPILE_OPTIONS}) + exclude_archive_libs_symbols(_pyhailort) + + # TODO (HRT-8637): change this hard-coded path +-set(HAILO_PYHAILORT_TARGET_DIR ${CMAKE_CURRENT_LIST_DIR}/../platform/hailo_platform/pyhailort/) ++if(WIN32) ++ set(HAILO_PYHAILORT_TARGET_DIR ${CMAKE_CURRENT_LIST_DIR}/../platform/hailo_platform/pyhailort/) ++else() ++ find_package(Python3 COMPONENTS Interpreter Development REQUIRED) ++ set(HAILO_PYHAILORT_TARGET_DIR "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/dist-packages/hailo_platform/pyhailort") ++endif() + +-add_custom_target(pyhailort_venv ALL +- COMMAND ${CMAKE_COMMAND} -E copy $ ${HAILO_PYHAILORT_TARGET_DIR} +-) +-add_dependencies(pyhailort_venv _pyhailort) ++if(WIN32) ++ add_custom_target(pyhailort_venv ALL ++ COMMAND ${CMAKE_COMMAND} -E copy $ ${HAILO_PYHAILORT_TARGET_DIR} ++ ) ++ add_dependencies(pyhailort_venv _pyhailort) ++endif() + + install(TARGETS _pyhailort + LIBRARY DESTINATION ${HAILO_PYHAILORT_TARGET_DIR} diff --git a/meta-hailo/recipes-app/hailort/files/patches/0005-Fix-cross-compilation-issue-for-pybuild.patch b/meta-hailo/recipes-app/hailort/files/patches/0005-Fix-cross-compilation-issue-for-pybuild.patch new file mode 100644 index 000000000..ec657e68c --- /dev/null +++ b/meta-hailo/recipes-app/hailort/files/patches/0005-Fix-cross-compilation-issue-for-pybuild.patch @@ -0,0 +1,138 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Li Hua Qian +Date: Tue, 12 Nov 2024 16:56:33 +0800 +Subject: [PATCH] Fix cross-compilation issue for pybuild + +This patch fix the pybuild cross-comiplation issue. Since it is not +possible to use the previous intermediate artifacts in Isar, we rebuild +the libhailort in pybuild. + +Signed-off-by: Li Hua Qian +--- + hailort/libhailort/CMakeLists.txt | 3 ++ + .../bindings/python/src/CMakeLists.txt | 16 ++++++++- + hailort/libhailort/src/CMakeLists.txt | 35 ++++++++++++++++++- + 3 files changed, 52 insertions(+), 2 deletions(-) + +diff --git a/hailort/libhailort/CMakeLists.txt b/hailort/libhailort/CMakeLists.txt +index ab46f83483ad..259debb87301 100644 +--- a/hailort/libhailort/CMakeLists.txt ++++ b/hailort/libhailort/CMakeLists.txt +@@ -27,6 +27,9 @@ target_include_directories(hef_proto + $ + ) + ++if(NOT HAILO_BUILD_PROFILER) ++ option(HAILO_BUILD_PROFILER "Build hailort profiler" ON) ++endif() + if(HAILO_BUILD_PROFILER) + add_definitions( -DHAILO_ENABLE_PROFILER_BUILD ) + endif() +diff --git a/hailort/libhailort/bindings/python/src/CMakeLists.txt b/hailort/libhailort/bindings/python/src/CMakeLists.txt +index b96d64a77895..920c9395fd97 100644 +--- a/hailort/libhailort/bindings/python/src/CMakeLists.txt ++++ b/hailort/libhailort/bindings/python/src/CMakeLists.txt +@@ -15,6 +15,14 @@ include(ExternalProject) + include(GNUInstallDirs) + include_directories(${HAILORT_COMMON_DIR}) + ++if(NOT Protobuf_FOUND) ++ find_package(Protobuf REQUIRED) ++endif() ++if(NOT TARGET libhailort) ++ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../../hrpc_protocol/ ${CMAKE_BINARY_DIR}/rpc_proto) ++ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../ ${CMAKE_BINARY_DIR}/libhailort) ++endif() ++ + FUNCTION(exclude_archive_libs_symbols target) # should be same as in common_compiler_options.cmake + if(WIN32) + # TODO: check if there are required actions for Windows +@@ -71,10 +79,16 @@ elseif(LIBHAILORT_PATH OR HAILORT_INCLUDE_DIR) + else() + message(STATUS "skip find_package, CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}") + message(STATUS "CMAKE_SYSTEM_PROCESSOR is ${CMAKE_SYSTEM_PROCESSOR}") +- find_package(HailoRT 4.18.0 EXACT REQUIRED) + + include_directories("${HAILORT_PROJECT_SOURCE_DIR}/hailort/libhailort/include") + target_link_libraries(_pyhailort PRIVATE libhailort) ++ target_compile_definitions( ++ _pyhailort ++ PUBLIC ++ HAILORT_MAJOR_VERSION=4 ++ HAILORT_MINOR_VERSION=18 ++ HAILORT_REVISION_VERSION=0 ++ ) + endif() + + if(WIN32) +diff --git a/hailort/libhailort/src/CMakeLists.txt b/hailort/libhailort/src/CMakeLists.txt +index 048fdd0ffe38..10809b150694 100644 +--- a/hailort/libhailort/src/CMakeLists.txt ++++ b/hailort/libhailort/src/CMakeLists.txt +@@ -38,7 +38,7 @@ if(HAILO_BUILD_SERVICE) + add_subdirectory(service) + endif() + +-set(common_dir "${PROJECT_SOURCE_DIR}/common/src") ++set(common_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src") + set(COMMON_C_SOURCES + ${common_dir}/firmware_status.c + ${common_dir}/md5.c +@@ -64,6 +64,12 @@ set(HAILORT_SRCS_ABS ${HAILORT_CPP_SOURCES} ${HAILORT_COMMON_CPP_SOURCES} ${COMM + SET_SOURCE_FILES_PROPERTIES(${C_SOURCES} PROPERTIES LANGUAGE CXX) + add_library(libhailort SHARED ${HAILORT_SRCS_ABS}) + ++if(NOT DEFINED FIRMWARE_VERSION_MAJOR) ++ add_definitions( -DFIRMWARE_VERSION_MAJOR=4 ) ++ add_definitions( -DFIRMWARE_VERSION_MINOR=18 ) ++ add_definitions( -DFIRMWARE_VERSION_REVISION=0 ) ++endif() ++ + # Include libraries + if(WIN32) + target_link_libraries(libhailort PRIVATE +@@ -87,7 +93,13 @@ target_link_libraries(libhailort PRIVATE Threads::Threads) + target_link_libraries(libhailort PRIVATE hef_proto) + target_link_libraries(libhailort PRIVATE profiler_proto) + target_link_libraries(libhailort PRIVATE scheduler_mon_proto) ++if(NOT spdlog_FOUND) ++ find_package(spdlog REQUIRED) ++endif() + target_link_libraries(libhailort PRIVATE spdlog::spdlog) ++if(NOT Eigen3_FOUND) ++ find_package(Eigen3 REQUIRED) ++endif() + target_link_libraries(libhailort PRIVATE Eigen3::Eigen) + + target_link_libraries(libhailort PRIVATE rpc_proto) +@@ -143,6 +155,27 @@ target_compile_options(libhailort PRIVATE ${HAILORT_COMPILE_OPTIONS}) + disable_exceptions(libhailort) + exclude_archive_libs_symbols(libhailort) + ++if(NOT HAILORT_INC_DIR) ++ set(HAILORT_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include") ++endif() ++if(NOT HAILORT_COMMON_DIR) ++ set(HAILORT_COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../") ++endif() ++if(NOT HAILORT_SRC_DIR) ++ set(HAILORT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ++endif() ++if(NOT COMMON_INC_DIR) ++ set(COMMON_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../common/include") ++endif() ++if(NOT DRIVER_INC_DIR) ++ set(DRIVER_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../drivers/common") ++endif() ++if(NOT RPC_DIR) ++ set(RPC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../rpc") ++endif() ++if(NOT HRPC_DIR) ++ set(HRPC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../hrpc") ++endif() + target_include_directories(libhailort + PUBLIC + $ +-- +2.34.1 + diff --git a/meta-hailo/recipes-app/hailort/hailort_4.18.0.bb b/meta-hailo/recipes-app/hailort/hailort_4.18.0.bb new file mode 100644 index 000000000..1946124ee --- /dev/null +++ b/meta-hailo/recipes-app/hailort/hailort_4.18.0.bb @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: Copyright 2023-2024 Siemens AG +# SPDX-License-Identifier: MIT +DESCRIPTION = "userspace API for running inference on the hailo8 chip" + +LICENSE = "MIT" + +inherit dpkg + +HAILO_EXTERNAL_DIR = "${P}/hailort/external" + +SRC_URI = " \ + git://git@github.com/hailo-ai/hailort.git;protocol=https;branch=master;name=hailort;destsuffix=${P} \ + git://github.com/hailo-ai/CLI11.git;protocol=https;nobranch=1;name=cli11;destsuffix=${HAILO_EXTERNAL_DIR}/cli11-src \ + git://github.com/hailo-ai/DotWriter.git;protocol=https;nobranch=1;name=dotwriter;destsuffix=${HAILO_EXTERNAL_DIR}/dotwriter-src" +SRC_URI += " \ + file://patches/0001-do-not-use-spdlog-formatting-internals.patch \ + file://patches/0002-use-distro-version-of-packages-if-possible.patch \ + file://patches/0003-install-independent-of-build-target.patch \ + file://patches/0004-install-python-bindings-into-dist-packages.patch \ + file://patches/0005-Fix-cross-compilation-issue-for-pybuild.patch \ +" + +SRC_URI += " \ + file://debian/control \ + file://debian/hailort.install \ + file://debian/hailort.service \ + file://debian/hailortcli.install \ + file://debian/libhailort-dev.install \ + file://debian/libhailort.install \ + file://debian/python3-hailort.install \ + file://debian/libgsthailo.install \ + file://debian/libgsthailo-dev.install \ + file://debian/not-installed \ + file://debian/rules \ + file://debian/python-numpy.pref \ +" + +DEPENDS += "python3-verboselogs python3-numpy" +PROVIDES += "hailortcli libhailort libhailort-dev python3-hailort libgsthailo libgsthailo-dev" + +SRCREV_hailort = "01e4c7f5a7463cc61ef1b2d22c31dd80a3a07d95" +SRCREV_cli11 = "ae78ac41cf225706e83f57da45117e3e90d4a5b4" +SRCREV_dotwriter = "e5fa8f281adca10dd342b1d32e981499b8681daf" + +S = "${WORKDIR}/${P}" + +do_prepare_build[cleandirs] += "${S}/debian" +do_prepare_build() { + deb_debianize + rm -f ${S}/debian/compat + cp -r ${WORKDIR}/debian/* ${S}/debian/ +} diff --git a/meta-hailo/recipes-bsp/hailo-firmware/hailo-firmware_4.18.0.bb b/meta-hailo/recipes-bsp/hailo-firmware/hailo-firmware_4.18.0.bb new file mode 100644 index 000000000..e4a9773ae --- /dev/null +++ b/meta-hailo/recipes-bsp/hailo-firmware/hailo-firmware_4.18.0.bb @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: Copyright 2023-2024 Siemens AG +# SPDX-License-Identifier: MIT +DESCRIPTION = "hailo firmware - hailo8 chip firmware (hailo_fw.bin)" + +BASE_URI = "https://hailo-hailort.s3.eu-west-2.amazonaws.com" +FW_AWS_DIR = "Hailo8/${PV}/FW" +FW = "hailo8_fw.${PV}.bin" +LICENSE_FILE = "LICENSE" + +SRC_URI = "${BASE_URI}/${FW_AWS_DIR}/${FW};name=firmware \ + ${BASE_URI}/${FW_AWS_DIR}/${LICENSE_FILE};name=license" +SRC_URI[firmware.sha256sum] = "bfa576dd782359d74cabcb19e87c3a934dce03dea0785e41f86fecc9a687a92b" +SRC_URI[license.md5sum] = "263ee034adc02556d59ab1ebdaea2cda" + +LICENSE = "LICENSE" +LIC_FILES_CHKSUM = "file://${WORKDIR}/${LICENSE_FILE};md5=263ee034adc02556d59ab1ebdaea2cda" + +FW_PATH = "${WORKDIR}/${FW}" + +DPKG_ARCH = "all" + +inherit dpkg-raw + +do_install() { + # Stores hailo8_fw.bin in the rootfs under /lib/firmware/hailo/ + install -d ${D}/lib/firmware/hailo + install -m 0644 ${FW_PATH} ${D}/lib/firmware/hailo/hailo8_fw.bin +} diff --git a/meta-hailo/recipes-kernel/hailo-pci/hailo-pci_4.18.0.bb b/meta-hailo/recipes-kernel/hailo-pci/hailo-pci_4.18.0.bb new file mode 100644 index 000000000..3d19a478d --- /dev/null +++ b/meta-hailo/recipes-kernel/hailo-pci/hailo-pci_4.18.0.bb @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: Copyright 2023-2024 Siemens AG +# SPDX-License-Identifier: MIT +DESCRIPTION = "hailo pcie driver - the kernel driver for pci communication with hailo8" + +LICENSE = "gpl-2.0" +LIC_FILES_CHKSUM = "file://${LAYERDIR_core}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe" + +SRC_URI = "git://git@github.com/hailo-ai/hailort-drivers.git;protocol=https;branch=master" +SRCREV = "7161f9ee5918029bd4497f590003c2f87ec32507" + +require recipes-kernel/linux-module/module.inc + +S = "${WORKDIR}/git" +MODULE_DIR = "$(PWD)/linux/pcie" + +do_prepare_build:append() { + cp ${S}/linux/pcie/51-hailo-udev.rules ${S}/debian/${BPN}.udev +} diff --git a/meta-hailo/recipes-python/python-numpy/files/debian/control b/meta-hailo/recipes-python/python-numpy/files/debian/control new file mode 100644 index 000000000..d177df477 --- /dev/null +++ b/meta-hailo/recipes-python/python-numpy/files/debian/control @@ -0,0 +1,26 @@ +Source: python-numpy +Section: python +Priority: optional +Maintainer: Li Hua Qian +Build-Depends: debhelper-compat (= 13), + dh-python, + python3-setuptools (>= 42), + libpython3-all-dev (>= 3.2), + python3-all-dev:any (>= 3.2), + python3-wheel:native, + cython3 +Standards-Version: 4.6.1 +Homepage: https://numpy.org/ +Vcs-Browser: https://github.com/numpy/numpy +Vcs-Git: https://github.com/numpy/numpy.git +Rules-Requires-Root: no + +Package: python3-numpy +Architecture: all +Multi-Arch: foreign +Depends: + ${python3:Depends}, + ${misc:Depends} +Description: NumPy is the fundamental package for array computing with Python. + NumPy is the fundamental package needed for scientific computing with Python. + This package contains the Python 3 version of NumPy. diff --git a/meta-hailo/recipes-python/python-numpy/files/debian/rules b/meta-hailo/recipes-python/python-numpy/files/debian/rules new file mode 100644 index 000000000..7e885da82 --- /dev/null +++ b/meta-hailo/recipes-python/python-numpy/files/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f + +export PYBUILD_NAME=numpy + +%: + set -x + dh $@ --with python3 --buildsystem=pybuild + +override_dh_auto_configure: + python3 setup.py build + +override_dh_auto_clean: + echo "setup.py clean is not supported" \ No newline at end of file diff --git a/meta-hailo/recipes-python/python-numpy/python-numpy_1.23.3.bb b/meta-hailo/recipes-python/python-numpy/python-numpy_1.23.3.bb new file mode 100644 index 000000000..ba3a01a71 --- /dev/null +++ b/meta-hailo/recipes-python/python-numpy/python-numpy_1.23.3.bb @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: Copyright 2024 Siemens AG +# SPDX-License-Identifier: MIT + +inherit dpkg + +SRC_URI = "https://github.com/numpy/numpy/archive/refs/tags/v1.23.3.tar.gz" +SRC_URI[sha256sum] = "d55da69341fd6e617ada55feec6798730457f26f08300956625c086499aced7e" + +SRC_URI += " \ + file://debian/control \ + file://debian/rules \ +" + +S = "${WORKDIR}/numpy-1.23.3" + +PROVIDES += "python3-numpy" + +DEB_BUILD_PROFILES = "nocheck" +DEB_BUILD_OPTIONS = "nocheck" + +do_prepare_build[cleandirs] += "${S}/debian" +do_prepare_build() { + deb_debianize + rm -f ${S}/debian/compat + cp ${WORKDIR}/debian/control \ + ${WORKDIR}/debian/rules \ + ${S}/debian/ +} \ No newline at end of file diff --git a/meta-hailo/recipes-python/python-verboselogs/files/debian/control b/meta-hailo/recipes-python/python-verboselogs/files/debian/control new file mode 100644 index 000000000..4c5e47fef --- /dev/null +++ b/meta-hailo/recipes-python/python-verboselogs/files/debian/control @@ -0,0 +1,22 @@ +Source: python-verboselogs +Section: python +Priority: optional +Maintainer: Li Hua Qian +Build-Depends: debhelper-compat (= 13), + dh-python, + python3-setuptools (>=42), + libpython3-all-dev (>=3.2), + python3-all-dev:any (>=3.2), + python3-wheel:native, +Standards-Version: 4.6.1 +Homepage: https://verboselogs.readthedocs.io/ +Vcs-Browser: https://github.com/xolox/python-verboselogs +Vcs-Git: https://github.com/xolox/python-verboselogs.git +Rules-Requires-Root: no + +Package: python3-verboselogs +Architecture: all +Multi-Arch: foreign +Depends: ${python3:Depends}, ${misc:Depends} +Description: extends Pythons logging module to add the log levels + The levels NOTICE, SPAM, SUCCESS and VERBOSE are added diff --git a/meta-hailo/recipes-python/python-verboselogs/files/debian/rules b/meta-hailo/recipes-python/python-verboselogs/files/debian/rules new file mode 100644 index 000000000..a6e3156fe --- /dev/null +++ b/meta-hailo/recipes-python/python-verboselogs/files/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +export PYBUILD_NAME=verboselogs + +%: + dh $@ --with python3 --buildsystem=pybuild diff --git a/meta-hailo/recipes-python/python-verboselogs/python-verboselogs_1.7.bb b/meta-hailo/recipes-python/python-verboselogs/python-verboselogs_1.7.bb new file mode 100644 index 000000000..f84057996 --- /dev/null +++ b/meta-hailo/recipes-python/python-verboselogs/python-verboselogs_1.7.bb @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: Copyright 2024 Siemens AG +# SPDX-License-Identifier: MIT + +# Warning: This package seems abandoned. Latest commit is from 7 years ago + +inherit dpkg + +SRC_URI = "git://github.com/xolox/python-verboselogs.git;protocol=https;branch=master" +SRCREV ="3cebc69e03588bb6c3726c38c324b12732989292" + +SRC_URI += " \ + file://debian/control \ + file://debian/rules \ +" + +S = "${WORKDIR}/git" + +PROVIDES += "python3-verboselogs" + +DEB_BUILD_PROFILES = "nocheck" +DEB_BUILD_OPTIONS = "nocheck" + +do_prepare_build[cleandirs] += "${S}/debian" +do_prepare_build() { + deb_debianize + rm -f ${S}/debian/compat + cp ${WORKDIR}/debian/control \ + ${WORKDIR}/debian/rules \ + ${S}/debian/ +} diff --git a/recipes-app/iot2050-conf-webui/files/src/components/ExtendedModules/SM1231_AI/SM1231AIConf.js b/recipes-app/iot2050-conf-webui/files/src/components/ExtendedModules/SM1231_AI/SM1231AIConf.js index e29393dc0..95041173c 100644 --- a/recipes-app/iot2050-conf-webui/files/src/components/ExtendedModules/SM1231_AI/SM1231AIConf.js +++ b/recipes-app/iot2050-conf-webui/files/src/components/ExtendedModules/SM1231_AI/SM1231AIConf.js @@ -233,7 +233,7 @@ export default function SM1231AIConf ({ slotNum, configData, updateConfig, chTot > diff --git a/recipes-bsp/u-boot/files/0015-arm-dts-iot2050-Add-overlay-for-DMA-isolation-for-de.patch b/recipes-bsp/u-boot/files/0015-arm-dts-iot2050-Add-overlay-for-DMA-isolation-for-de.patch new file mode 100644 index 000000000..6e84077fb --- /dev/null +++ b/recipes-bsp/u-boot/files/0015-arm-dts-iot2050-Add-overlay-for-DMA-isolation-for-de.patch @@ -0,0 +1,76 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Li Hua Qian +Date: Wed, 4 Dec 2024 13:52:02 +0800 +Subject: [PATCH] arm: dts: iot2050: Add overlay for DMA isolation for devices + behind PCI RC + +Reserve a 64M memory region and ensure that all PCI devices do their DMA +only inside that region. This is configured via a restricted-dma-pool +and enforced with the help of the first PVU. + +Applying this isolation is not totally free in terms of overhead and +memory consumption. It makes only sense for variants that support +secure booting, and generally only when this is actually enable. +Therefore model it as overlay that can be activated on demand. The +firmware will take care of this via DT fixup during boot and will also +provide a way to adjust the pool size. + +Signed-off-by: Jan Kiszka +Signed-off-by: Li Hua Qian +--- + arch/arm/dts/Makefile | 1 + + ...iot2050-advanced-dma-isolation-overlay.dts | 33 +++++++++++++++++++ + 2 files changed, 34 insertions(+) + create mode 100644 arch/arm/dts/k3-am6548-iot2050-advanced-dma-isolation-overlay.dts + +diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile +index 0edd5b73a414..6ea916c16cc2 100644 +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -1317,6 +1317,7 @@ dtb-$(CONFIG_SOC_K3_AM654) += \ + k3-am6548-iot2050-advanced-m2.dtb \ + k3-am6548-iot2050-advanced-m2-bkey-usb3-overlay.dtbo \ + k3-am6548-iot2050-advanced-m2-bkey-ekey-pcie-overlay.dtbo \ ++ k3-am6548-iot2050-advanced-dma-isolation-overlay.dtbo \ + k3-am6548-iot2050-advanced-sm.dtb + + dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \ +diff --git a/arch/arm/dts/k3-am6548-iot2050-advanced-dma-isolation-overlay.dts b/arch/arm/dts/k3-am6548-iot2050-advanced-dma-isolation-overlay.dts +new file mode 100644 +index 000000000000..dfd75d2dc245 +--- /dev/null ++++ b/arch/arm/dts/k3-am6548-iot2050-advanced-dma-isolation-overlay.dts +@@ -0,0 +1,33 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * IOT2050, overlay for isolating DMA requests via PVU ++ * Copyright (c) Siemens AG, 2024 ++ * ++ * Authors: ++ * Jan Kiszka ++ */ ++ ++/dts-v1/; ++/plugin/; ++ ++&{/reserved-memory} { ++ #address-cells = <2>; ++ #size-cells = <2>; ++ ++ pci_restricted_dma_region: restricted-dma@c0000000 { ++ compatible = "restricted-dma-pool"; ++ reg = <0 0xc0000000 0 0x4000000>; ++ }; ++}; ++ ++&pcie0_rc { ++ memory-region = <&pci_restricted_dma_region>; ++}; ++ ++&pcie1_rc { ++ memory-region = <&pci_restricted_dma_region>; ++}; ++ ++&ti_pvu0 { ++ status = "okay"; ++}; diff --git a/recipes-bsp/u-boot/files/0016-board-siemens-iot2050-Generalize-overlay_prepare.patch b/recipes-bsp/u-boot/files/0016-board-siemens-iot2050-Generalize-overlay_prepare.patch new file mode 100644 index 000000000..79e2cb2e0 --- /dev/null +++ b/recipes-bsp/u-boot/files/0016-board-siemens-iot2050-Generalize-overlay_prepare.patch @@ -0,0 +1,74 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +Date: Sun, 8 Sep 2024 09:22:41 +0200 +Subject: [PATCH] board: siemens: iot2050: Generalize overlay_prepare + +Will be reused for another upcoming overlay. + +Signed-off-by: Jan Kiszka +--- + board/siemens/iot2050/board.c | 25 +++++++++++++++---------- + 1 file changed, 15 insertions(+), 10 deletions(-) + +diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c +index 8497212ab890..ee6456be968c 100644 +--- a/board/siemens/iot2050/board.c ++++ b/board/siemens/iot2050/board.c +@@ -258,12 +258,13 @@ void set_board_info_env(void) + env_save(); + } + +-static void do_overlay_prepare(const char *overlay_path) ++static void *overlay_prepare(const char *overlay_path, u32 *poverlay_size) + { + #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) +- void *overlay; ++ void *overlay, *result; + u64 loadaddr; + ofnode node; ++ u32 size; + int ret; + + node = ofnode_path(overlay_path); +@@ -274,21 +275,24 @@ static void do_overlay_prepare(const char *overlay_path) + if (ret) + goto fit_error; + +- ret = ofnode_read_u32(node, "size", &connector_overlay_size); ++ ret = ret = ofnode_read_u32(node, "size", &size); + if (ret) + goto fit_error; + +- overlay = map_sysmem(loadaddr, connector_overlay_size); ++ overlay = map_sysmem(loadaddr, size); + +- connector_overlay = malloc(connector_overlay_size); +- if (!connector_overlay) ++ result = malloc(size); ++ if (!result) + goto fit_error; + +- memcpy(connector_overlay, overlay, connector_overlay_size); +- return; ++ memcpy(result, overlay, size); ++ *poverlay_size = size; ++ ++ return result; + + fit_error: +- pr_err("M.2 device tree overlay %s not available,\n", overlay_path); ++ pr_err("Device tree overlay %s not available.\n", overlay_path); ++ return NULL; + #endif + } + +@@ -304,7 +308,8 @@ static void m2_overlay_prepare(void) + else + overlay_path = "/fit-images/bkey-usb3-overlay"; + +- do_overlay_prepare(overlay_path); ++ connector_overlay = overlay_prepare(overlay_path, ++ &connector_overlay_size); + } + + static void m2_connector_setup(void) diff --git a/recipes-bsp/u-boot/files/0017-board-siemens-iot2050-Allow-to-enable-and-adjust-res.patch b/recipes-bsp/u-boot/files/0017-board-siemens-iot2050-Allow-to-enable-and-adjust-res.patch new file mode 100644 index 000000000..cad071808 --- /dev/null +++ b/recipes-bsp/u-boot/files/0017-board-siemens-iot2050-Allow-to-enable-and-adjust-res.patch @@ -0,0 +1,284 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +Date: Tue, 3 Sep 2024 21:56:26 +0200 +Subject: [PATCH] board: siemens: iot2050: Allow to enable and adjust + restricted DMA pool size + +Read from an environment variable alternative pool sizes for isolating +DMA requests from main memory. If the variable is unset or 0 and +CONFIG_IOT2050_REQUIRE_DMA_ISOLATION is not enable, DMA isolation will +not be configured into the device tree. + +The kernel can handle a maximum of 320 MB due to constraints of its +swiotlb subsystem. Limit the size to this value. Also, less than 64 MB +is easily causing DMA allocation issues. Therefore, this is the minimum +when enabling the DMA isolation. + +Signed-off-by: Jan Kiszka +Signed-off-by: Li Hua Qian +--- + arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 35 +++++++- + board/siemens/iot2050/Kconfig | 9 ++ + board/siemens/iot2050/board.c | 89 +++++++++++++++----- + configs/iot2050_defconfig | 1 + + include/configs/iot2050.h | 2 +- + 5 files changed, 114 insertions(+), 22 deletions(-) + +diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi +index 5d83109389cc..0e1fee5b8fe7 100644 +--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi ++++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi +@@ -207,6 +207,22 @@ + fit@380000 { + fit,fdt-list-val = "k3-am6528-iot2050-basic", "k3-am6548-iot2050-advanced"; + ++ images { ++ dma-isolation-overlay { ++ description = "DMA isolation overlay"; ++ type = "blob"; ++ load = <0x82120000>; ++ arch = "arm64"; ++ compression = "none"; ++ blob-ext { ++ filename = "k3-am6548-iot2050-advanced-dma-isolation-overlay.dtbo"; ++ }; ++ hash { ++ algo = "sha256"; ++ }; ++ }; ++ }; ++ + configurations { + default = "k3-am6528-iot2050-basic"; + @config-SEQ { +@@ -214,7 +230,7 @@ + #ifdef CONFIG_WDT_K3_RTI_FW_FILE + "k3-rti-wdt-firmware", + #endif +- <>; ++ "dma-isolation-overlay"; + }; + }; + }; +@@ -262,6 +278,20 @@ + algo = "sha256"; + }; + }; ++ ++ dma-isolation-overlay { ++ description = "DMA isolation overlay"; ++ type = "blob"; ++ load = <0x82120000>; ++ arch = "arm64"; ++ compression = "none"; ++ blob-ext { ++ filename = "k3-am6548-iot2050-advanced-dma-isolation-overlay.dtbo"; ++ }; ++ hash { ++ algo = "sha256"; ++ }; ++ }; + }; + + configurations { +@@ -272,7 +302,8 @@ + "k3-rti-wdt-firmware", + #endif + "bkey-usb3-overlay", +- "bkey-ekey-pcie-overlay"; ++ "bkey-ekey-pcie-overlay", ++ "dma-isolation-overlay"; + }; + }; + }; +diff --git a/board/siemens/iot2050/Kconfig b/board/siemens/iot2050/Kconfig +index a6170aae8079..07ca36f0cd27 100644 +--- a/board/siemens/iot2050/Kconfig ++++ b/board/siemens/iot2050/Kconfig +@@ -21,6 +21,15 @@ if TARGET_IOT2050_A53 + config SYS_BOARD + default "iot2050" + ++config IOT2050_REQUIRE_DMA_ISOLATION ++ bool "Always configure DMA isolation into device tree (Advanced version only)" ++ help ++ When enabled, DMA isolation is always enabled for Advanced devices in ++ their device trees. This means that the environment variable ++ 'restricted_dma_pool_mb' can only control the size of restricted DMA ++ pool, but it can no longer we used to disable this by setting it to ++ 0. ++ + config SYS_VENDOR + default "siemens" + +diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c +index ee6456be968c..f6fc7bcdca94 100644 +--- a/board/siemens/iot2050/board.c ++++ b/board/siemens/iot2050/board.c +@@ -118,8 +118,8 @@ static const char *m2_connector_mode_name[] = { + static enum m2_connector_mode connector_mode; + + #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) +-static void *connector_overlay; +-static u32 connector_overlay_size; ++static void *connector_overlay, *dma_isolation_overlay; ++static u32 connector_overlay_size, dma_isolation_overlay_size; + #endif + + static int get_pinvalue(const char *gpio_name, const char *label) +@@ -360,6 +360,47 @@ static void m2_connector_setup(void) + m2_overlay_prepare(); + } + ++static __noreturn void dma_isolation_panic(void) ++{ ++ panic("Cannot enforce DMA isolation as requested!\n"); ++} ++ ++static void dma_isolation_setup(void) ++{ ++ u32 val[] = {0, cpu_to_fdt32(0xc0000000), 0, 0}; ++ unsigned long pool_size; ++ ++ pool_size = env_get_ulong("restricted_dma_pool_mb", 10, 0); ++ ++ if (pool_size > 0) { ++ pool_size = round_up(pool_size, 32); ++ if (pool_size < 64) ++ pool_size = 64; ++ if (pool_size > 320) ++ pool_size = 320; ++ } ++ if (IS_ENABLED(CONFIG_IOT2050_REQUIRE_DMA_ISOLATION) && pool_size == 0) ++ pool_size = 64; ++ ++ if (pool_size == 0) ++ return; ++ ++ dma_isolation_overlay = ++ overlay_prepare("/fit-images/dma-isolation-overlay", ++ &dma_isolation_overlay_size); ++ ++ if (IS_ENABLED(CONFIG_IOT2050_REQUIRE_DMA_ISOLATION) && ++ !dma_isolation_overlay) ++ dma_isolation_panic(); ++ ++ val[3] = cpu_to_fdt32(pool_size * 1024 *1024); ++ do_fixup_by_path(dma_isolation_overlay, ++ "/fragment@0/__overlay__/restricted-dma@c0000000", ++ "reg", val, sizeof(val), 0); ++ ++ printf("Using restricted DMA pool, size %ld MB\n", pool_size); ++} ++ + int board_init(void) + { + return 0; +@@ -479,6 +520,9 @@ int board_late_init(void) + if (board_is_m2()) + m2_connector_setup(); + ++ if (board_is_advanced() && !board_is_pg1()) ++ dma_isolation_setup(); ++ + set_board_info_env(); + + /* remove the eMMC if requested via button */ +@@ -490,15 +534,15 @@ int board_late_init(void) + } + + #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) +-static void variants_fdt_fixup(void *blob) ++int ft_board_setup(void *blob, struct bd_info *bd) + { + void *overlay_copy = NULL; + void *fdt_copy = NULL; + u32 fdt_size; + int err; + +- if (!connector_overlay) +- return; ++ if (!connector_overlay && !dma_isolation_overlay) ++ return 0; + + /* + * We need to work with temporary copies here because fdt_overlay_apply +@@ -512,35 +556,42 @@ static void variants_fdt_fixup(void *blob) + + memcpy(fdt_copy, blob, fdt_size); + +- overlay_copy = malloc(connector_overlay_size); ++ overlay_copy = malloc(max(connector_overlay_size, ++ dma_isolation_overlay_size)); + if (!overlay_copy) + goto fixup_error; + +- memcpy(overlay_copy, connector_overlay, connector_overlay_size); ++ if (connector_overlay) { ++ memcpy(overlay_copy, connector_overlay, ++ connector_overlay_size); + +- err = fdt_overlay_apply_verbose(fdt_copy, overlay_copy); +- if (err) +- goto fixup_error; ++ err = fdt_overlay_apply_verbose(fdt_copy, overlay_copy); ++ if (err) ++ goto fixup_error; ++ } ++ if (dma_isolation_overlay) { ++ memcpy(overlay_copy, dma_isolation_overlay, ++ dma_isolation_overlay_size); ++ ++ err = fdt_overlay_apply_verbose(fdt_copy, overlay_copy); ++ if (err) ++ goto fixup_error; ++ } + + memcpy(blob, fdt_copy, fdt_size); + + cleanup: + free(fdt_copy); + free(overlay_copy); +- return; ++ return 0; + + fixup_error: + pr_err("Could not apply device tree overlay\n"); ++ if (dma_isolation_overlay && ++ IS_ENABLED(CONFIG_IOT2050_REQUIRE_DMA_ISOLATION)) ++ dma_isolation_panic(); + goto cleanup; + } +- +-int ft_board_setup(void *blob, struct bd_info *bd) +-{ +- if (board_is_m2()) +- variants_fdt_fixup(blob); +- +- return 0; +-} + #endif + + void spl_board_init(void) +diff --git a/configs/iot2050_defconfig b/configs/iot2050_defconfig +index 4fc3bcb56b8f..93f3e0ab72cd 100644 +--- a/configs/iot2050_defconfig ++++ b/configs/iot2050_defconfig +@@ -151,3 +151,4 @@ CONFIG_WDT=y + CONFIG_WDT_K3_RTI=y + CONFIG_WDT_K3_RTI_LOAD_FW=y + CONFIG_EFI_SCROLL_ON_CLEAR_SCREEN=y ++CONFIG_OF_OVERLAY_LIST="ti/k3-am6548-iot2050-advanced-m2-bkey-usb3 ti/k3-am6548-iot2050-advanced-m2-bkey-ekey-pcie ti/k3-am6548-iot2050-advanced-dma-isolation" +diff --git a/include/configs/iot2050.h b/include/configs/iot2050.h +index 5e97ea0d9438..d155ee10be2f 100644 +--- a/include/configs/iot2050.h ++++ b/include/configs/iot2050.h +@@ -42,7 +42,7 @@ + #define CFG_ENV_FLAGS_LIST_STATIC \ + "board_uuid:sw,board_name:sw,board_serial:sw,board_a5e:sw," \ + "mlfb:sw,fw_version:sw,seboot_version:sw," \ +- "m2_manuel_config:sw," \ ++ "m2_manual_config:sw,restricted_dma_pool_mb:sw," \ + "eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw" + #endif + diff --git a/recipes-bsp/u-boot/files/secure-boot.cfg b/recipes-bsp/u-boot/files/secure-boot.cfg index 594f95e6b..db6dee45b 100644 --- a/recipes-bsp/u-boot/files/secure-boot.cfg +++ b/recipes-bsp/u-boot/files/secure-boot.cfg @@ -30,3 +30,4 @@ CONFIG_OPTEE=y CONFIG_SUPPORT_EMMC_RPMB=y CONFIG_EFI_MM_COMM_TEE=y # CONFIG_CMD_MMC_RPMB is not set +CONFIG_IOT2050_REQUIRE_DMA_ISOLATION=y diff --git a/recipes-bsp/u-boot/u-boot-iot2050_2023.10.bb b/recipes-bsp/u-boot/u-boot-iot2050_2023.10.bb index 38879be57..38d61cb66 100644 --- a/recipes-bsp/u-boot/u-boot-iot2050_2023.10.bb +++ b/recipes-bsp/u-boot/u-boot-iot2050_2023.10.bb @@ -26,6 +26,9 @@ SRC_URI += " \ file://0012-spi-cadence-quadspi-Fix-error-message-on-stuck-busy-.patch \ file://0013-spi-cadence-quadspi-fix-potential-malfunction-after-.patch \ file://0014-mmc-Fix-potential-timer-value-truncation.patch \ + file://0015-arm-dts-iot2050-Add-overlay-for-DMA-isolation-for-de.patch \ + file://0016-board-siemens-iot2050-Generalize-overlay_prepare.patch \ + file://0017-board-siemens-iot2050-Allow-to-enable-and-adjust-res.patch \ " SRC_URI[sha256sum] = "e00e6c6f014e046101739d08d06f328811cebcf5ae101348f409cbbd55ce6900" diff --git a/recipes-core/images/iot2050-image-example.bb b/recipes-core/images/iot2050-image-example.bb index a3195aa83..e4de2f609 100644 --- a/recipes-core/images/iot2050-image-example.bb +++ b/recipes-core/images/iot2050-image-example.bb @@ -64,3 +64,16 @@ IOT2050_MODULE_FWU ?= "0" IMAGE_INSTALL += "${@ ' \ iot2050-module-firmware-update \ ' if d.getVar('IOT2050_MODULE_FWU') == '1' else '' }" + +IOT2050_META_HAILO ?= "0" +IMAGE_INSTALL += "${@ ' \ + hailo-pci-${KERNEL_NAME} \ + hailo-firmware \ + hailortcli \ + libhailort \ + libhailort-dev \ + libgsthailo \ + libgsthailo-dev \ + python3-hailort \ + hailort \ + ' if d.getVar('IOT2050_META_HAILO') == '1' else '' }" diff --git a/recipes-kernel/linux/files/iot2050_defconfig_base b/recipes-kernel/linux/files/iot2050_defconfig_base index ec1358f6a..c07b93df4 100644 --- a/recipes-kernel/linux/files/iot2050_defconfig_base +++ b/recipes-kernel/linux/files/iot2050_defconfig_base @@ -609,7 +609,6 @@ CONFIG_RPMSG_QCOM_GLINK_RPM=y CONFIG_RPMSG_VIRTIO=m CONFIG_TI_SCI_PM_DOMAINS=y CONFIG_TI_PRUSS=y -CONFIG_TI_PVU=y CONFIG_EXTCON_PALMAS=m CONFIG_EXTCON_USB_GPIO=m CONFIG_MEMORY=y diff --git a/recipes-kernel/linux/files/iot2050_defconfig_hailo.cfg b/recipes-kernel/linux/files/iot2050_defconfig_hailo.cfg new file mode 100644 index 000000000..2a0ce3004 --- /dev/null +++ b/recipes-kernel/linux/files/iot2050_defconfig_hailo.cfg @@ -0,0 +1 @@ +CONFIG_SWIOTLB_SEGSIZE=256 diff --git a/recipes-kernel/linux/files/iot2050_defconfig_pvu.cfg b/recipes-kernel/linux/files/iot2050_defconfig_pvu.cfg new file mode 100644 index 000000000..fd7bbef38 --- /dev/null +++ b/recipes-kernel/linux/files/iot2050_defconfig_pvu.cfg @@ -0,0 +1 @@ +CONFIG_TI_PVU=y diff --git a/recipes-kernel/linux/files/patches-6.1/0094-dt-bindings-soc-ti-Add-AM65-peripheral-virtualizatio.patch b/recipes-kernel/linux/files/patches-6.1/0094-dt-bindings-soc-ti-Add-AM65-peripheral-virtualizatio.patch new file mode 100644 index 000000000..9fdf3e357 --- /dev/null +++ b/recipes-kernel/linux/files/patches-6.1/0094-dt-bindings-soc-ti-Add-AM65-peripheral-virtualizatio.patch @@ -0,0 +1,72 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +Date: Mon, 24 Jun 2024 13:40:26 +0200 +Subject: [PATCH] dt-bindings: soc: ti: Add AM65 peripheral virtualization unit + +The PVU allows to define a limited set of mappings for incoming DMA +requests to the system memory. It is not a real IOMMU, thus hooked up +under the TI SoC bindings. + +Signed-off-by: Jan Kiszka +--- + .../bindings/soc/ti/ti,am654-pvu.yaml | 51 +++++++++++++++++++ + 1 file changed, 51 insertions(+) + create mode 100644 Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml + +diff --git a/Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml b/Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml +new file mode 100644 +index 000000000000..fd0f86fa27b0 +--- /dev/null ++++ b/Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml +@@ -0,0 +1,51 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++# Copyright (c) Siemens AG, 2024 ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/soc/ti/ti,am654-pvu.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: TI AM654 Peripheral Virtualization Unit ++ ++maintainers: ++ - Jan Kiszka ++ ++properties: ++ compatible: ++ enum: ++ - ti,am654-pvu ++ ++ reg: ++ minItems: 2 ++ ++ reg-names: ++ items: ++ - const: cfg ++ - const: tlbif ++ ++ interrupts: ++ items: ++ - description: fault interrupt ++ ++ interrupt-names: ++ items: ++ - const: pvu ++ ++required: ++ - compatible ++ - reg ++ - interrupts ++ - interrupt-names ++ ++additionalProperties: false ++ ++examples: ++ - | ++ ti-pvu@30f80000 { ++ compatible = "ti,am654-pvu"; ++ reg = <0x30f80000 0x1000>, ++ <0x36000000 0x100000>; ++ reg-names = "cfg", "tlbif"; ++ interrupts-extended = <&intr_main_navss 390>; ++ interrupt-names = "pvu"; ++ }; diff --git a/recipes-kernel/linux/files/patches-6.1/0094-soc-ti-Add-IOMPU-like-PVU-driver.patch b/recipes-kernel/linux/files/patches-6.1/0095-soc-ti-Add-IOMPU-like-PVU-driver.patch similarity index 98% rename from recipes-kernel/linux/files/patches-6.1/0094-soc-ti-Add-IOMPU-like-PVU-driver.patch rename to recipes-kernel/linux/files/patches-6.1/0095-soc-ti-Add-IOMPU-like-PVU-driver.patch index 2aac51656..5b6a49ada 100644 --- a/recipes-kernel/linux/files/patches-6.1/0094-soc-ti-Add-IOMPU-like-PVU-driver.patch +++ b/recipes-kernel/linux/files/patches-6.1/0095-soc-ti-Add-IOMPU-like-PVU-driver.patch @@ -26,8 +26,8 @@ Signed-off-by: Jan Kiszka drivers/soc/ti/Kconfig | 4 + drivers/soc/ti/Makefile | 1 + drivers/soc/ti/ti-pvu.c | 487 ++++++++++++++++++++++++++++++++++++++++ - include/linux/ti-pvu.h | 11 + - 4 files changed, 503 insertions(+) + include/linux/ti-pvu.h | 16 ++ + 4 files changed, 508 insertions(+) create mode 100644 drivers/soc/ti/ti-pvu.c create mode 100644 include/linux/ti-pvu.h @@ -57,7 +57,7 @@ index cc3c972fad2e..15a0d598ac60 100644 +obj-$(CONFIG_TI_PVU) += ti-pvu.o diff --git a/drivers/soc/ti/ti-pvu.c b/drivers/soc/ti/ti-pvu.c new file mode 100644 -index 000000000000..af1cadc2f4bc +index 000000000000..5b71d503051f --- /dev/null +++ b/drivers/soc/ti/ti-pvu.c @@ -0,0 +1,487 @@ @@ -446,7 +446,7 @@ index 000000000000..af1cadc2f4bc + u32 val; + int ret; + -+ pvu = devm_kzalloc(dev, sizeof(struct ti_pvu), GFP_KERNEL); ++ pvu = devm_kzalloc(dev, sizeof(*pvu), GFP_KERNEL); + if (!pvu) + return -ENOMEM; + @@ -550,10 +550,10 @@ index 000000000000..af1cadc2f4bc +module_platform_driver(ti_pvu_driver); diff --git a/include/linux/ti-pvu.h b/include/linux/ti-pvu.h new file mode 100644 -index 000000000000..d40642522cf0 +index 000000000000..acd4d9e0dc86 --- /dev/null +++ b/include/linux/ti-pvu.h -@@ -0,0 +1,11 @@ +@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * TI Peripheral Virtualization Unit driver for static DMA isolation @@ -561,7 +561,12 @@ index 000000000000..d40642522cf0 + * Copyright (c) 2024, Siemens AG + */ + ++#ifndef _LINUX_TI_PVU_H ++#define _LINUX_TI_PVU_H ++ +#include + +int ti_pvu_create_region(unsigned int virt_id, const struct resource *region); +int ti_pvu_remove_region(unsigned int virt_id, const struct resource *region); ++ ++#endif /* _LINUX_TI_PVU_H */ diff --git a/recipes-kernel/linux/files/patches-6.1/0096-dt-bindings-PCI-ti-am65-Extend-for-use-with-PVU.patch b/recipes-kernel/linux/files/patches-6.1/0096-dt-bindings-PCI-ti-am65-Extend-for-use-with-PVU.patch new file mode 100644 index 000000000..50aef23d5 --- /dev/null +++ b/recipes-kernel/linux/files/patches-6.1/0096-dt-bindings-PCI-ti-am65-Extend-for-use-with-PVU.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +Date: Mon, 26 Aug 2024 22:53:40 +0200 +Subject: [PATCH] dt-bindings: PCI: ti,am65: Extend for use with PVU + +Describe also the VMAP registers which are needed in order to make use +of the PVU with this PCI host. Furthermore, permit to specify a +restricted DMA pool by phandle. + +Signed-off-by: Jan Kiszka +--- + .../devicetree/bindings/pci/ti,am65-pci-host.yaml | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml b/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml +index a20dccbafd94..8cd2c327da48 100644 +--- a/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml ++++ b/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml +@@ -20,7 +20,7 @@ properties: + - ti,keystone-pcie + + reg: +- maxItems: 4 ++ maxItems: 6 + + reg-names: + items: +@@ -28,6 +28,8 @@ properties: + - const: dbics + - const: config + - const: atu ++ - const: vmap_lp ++ - const: vmap_hp + + interrupts: + maxItems: 1 +@@ -55,6 +57,9 @@ properties: + + dma-coherent: true + ++ memory-region: ++ description: phandle to restricted DMA pool to be used for all devices behind this controller ++ + required: + - compatible + - reg +@@ -88,8 +93,10 @@ examples: + reg = <0x5500000 0x1000>, + <0x5501000 0x1000>, + <0x10000000 0x2000>, +- <0x5506000 0x1000>; +- reg-names = "app", "dbics", "config", "atu"; ++ <0x5506000 0x1000>, ++ <0x2900000 0x1000>, ++ <0x2908000 0x1000>; ++ reg-names = "app", "dbics", "config", "atu", "vmap_lp", "vmap_hp"; + power-domains = <&k3_pds 120 TI_SCI_PD_EXCLUSIVE>; + #address-cells = <3>; + #size-cells = <2>; diff --git a/recipes-kernel/linux/files/patches-6.1/0095-arm64-dts-ti-k3-am65-main-Add-VMAP-registers-to-PCI-.patch b/recipes-kernel/linux/files/patches-6.1/0097-arm64-dts-ti-k3-am65-main-Add-VMAP-registers-to-PCI-.patch similarity index 100% rename from recipes-kernel/linux/files/patches-6.1/0095-arm64-dts-ti-k3-am65-main-Add-VMAP-registers-to-PCI-.patch rename to recipes-kernel/linux/files/patches-6.1/0097-arm64-dts-ti-k3-am65-main-Add-VMAP-registers-to-PCI-.patch diff --git a/recipes-kernel/linux/files/patches-6.1/0096-PCI-keystone-Add-supported-for-PVU-based-DMA-isolati.patch b/recipes-kernel/linux/files/patches-6.1/0098-PCI-keystone-Add-supported-for-PVU-based-DMA-isolati.patch similarity index 98% rename from recipes-kernel/linux/files/patches-6.1/0096-PCI-keystone-Add-supported-for-PVU-based-DMA-isolati.patch rename to recipes-kernel/linux/files/patches-6.1/0098-PCI-keystone-Add-supported-for-PVU-based-DMA-isolati.patch index 8671d768f..57638543d 100644 --- a/recipes-kernel/linux/files/patches-6.1/0096-PCI-keystone-Add-supported-for-PVU-based-DMA-isolati.patch +++ b/recipes-kernel/linux/files/patches-6.1/0098-PCI-keystone-Add-supported-for-PVU-based-DMA-isolati.patch @@ -20,17 +20,17 @@ Signed-off-by: Jan Kiszka 1 file changed, 101 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c -index 623aafc0303a..f8fe663e6e75 100644 +index 623aafc0303a..06f634f600bd 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c -@@ -19,6 +19,7 @@ - #include +@@ -20,6 +20,7 @@ #include #include -+#include #include ++#include #include #include + #include @@ -27,6 +28,7 @@ #include #include diff --git a/recipes-kernel/linux/files/patches-6.1/0097-arm64-dts-ti-iot2050-Enforce-DMA-isolation-for-devic.patch b/recipes-kernel/linux/files/patches-6.1/0099-arm64-dts-ti-iot2050-Enforce-DMA-isolation-for-devic.patch similarity index 62% rename from recipes-kernel/linux/files/patches-6.1/0097-arm64-dts-ti-iot2050-Enforce-DMA-isolation-for-devic.patch rename to recipes-kernel/linux/files/patches-6.1/0099-arm64-dts-ti-iot2050-Enforce-DMA-isolation-for-devic.patch index 03dc33471..6c53e8e3e 100644 --- a/recipes-kernel/linux/files/patches-6.1/0097-arm64-dts-ti-iot2050-Enforce-DMA-isolation-for-devic.patch +++ b/recipes-kernel/linux/files/patches-6.1/0099-arm64-dts-ti-iot2050-Enforce-DMA-isolation-for-devic.patch @@ -9,48 +9,22 @@ across the series, space left for firmware carve-outs) and ensure that all PCI devices do their DMA only inside that region. This is configured via a restricted-dma-pool and enforced with the help of the first PVU. +Modification by Li Hua Qian: +- The restricted-dma-pool is overlaid by U-Boot. +- U-Boot DTS path: + arch/arm/dts/k3-am6548-iot2050-advanced-dma-isolation-overlay.dts + Signed-off-by: Jan Kiszka +Signed-off-by: Li Hua Qian --- - .../boot/dts/ti/k3-am65-iot2050-common.dtsi | 32 +++++++++++++++++++ - 1 file changed, 32 insertions(+) + .../boot/dts/ti/k3-am65-iot2050-common.dtsi | 21 +++++++++++++++++++ + 1 file changed, 21 insertions(+) diff --git a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi -index 35675663ef1a..dbc7ddf273eb 100644 +index 35675663ef1a..a403fec1d43e 100644 --- a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi +++ b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi -@@ -72,6 +72,11 @@ wdt_reset_memory_region: wdt-memory@a2200000 { - reg = <0x00 0xa2200000 0x00 0x1000>; - no-map; - }; -+ -+ pci_restricted_dma_region: restricted-dma@ba000000 { -+ compatible = "restricted-dma-pool"; -+ reg = <0 0xba000000 0 0x4000000>; -+ }; - }; - - leds { -@@ -643,6 +648,10 @@ &pcie0_ep { - status = "disabled"; - }; - -+&pcie0_rc { -+ memory-region = <&pci_restricted_dma_region>; -+}; -+ - &pcie1_rc { - pinctrl-names = "default"; - pinctrl-0 = <&minipcie_pins_default>; -@@ -651,6 +660,8 @@ &pcie1_rc { - phys = <&serdes1 PHY_TYPE_PCIE 0>; - phy-names = "pcie-phy0"; - reset-gpios = <&wkup_gpio0 27 GPIO_ACTIVE_HIGH>; -+ -+ memory-region = <&pci_restricted_dma_region>; - }; - - &m_can0 { -@@ -785,3 +796,24 @@ &mcu_r5fss0 { +@@ -785,3 +785,24 @@ &mcu_r5fss0 { /* lock-step mode not supported on iot2050 boards */ ti,cluster-mode = <0>; }; diff --git a/recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch b/recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch new file mode 100644 index 000000000..a488c7f58 --- /dev/null +++ b/recipes-kernel/linux/files/patches-6.1/0100-swiotlb-Make-IO_TLB_SEGSIZE-configurable.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Li Hua Qian +Date: Tue, 3 Dec 2024 14:49:59 +0800 +Subject: [PATCH] swiotlb: Make IO_TLB_SEGSIZE configurable + +In some applications, the default value of 128 is not sufficient for +memory allocation and can cause runtime errors. This change makes +IO_TLB_SEGSIZE configurable, allowing it to be increased if needed. + +Signed-off-by: Li Hua Qian +--- + include/linux/swiotlb.h | 2 +- + kernel/dma/Kconfig | 7 +++++++ + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h +index 35bc4e281c21..09d0ad1304a9 100644 +--- a/include/linux/swiotlb.h ++++ b/include/linux/swiotlb.h +@@ -22,7 +22,7 @@ struct scatterlist; + * must be a power of 2. What is the appropriate value ? + * The complexity of {map,unmap}_single is linearly dependent on this value. + */ +-#define IO_TLB_SEGSIZE 128 ++#define IO_TLB_SEGSIZE CONFIG_SWIOTLB_SEGSIZE + + /* + * log of the size of each IO TLB slab. The number of slabs is command line +diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig +index 56866aaa2ae1..2eebe8836100 100644 +--- a/kernel/dma/Kconfig ++++ b/kernel/dma/Kconfig +@@ -80,6 +80,13 @@ config SWIOTLB + bool + select NEED_DMA_MAP_STATE + ++config SWIOTLB_SEGSIZE ++ int "SWIOTLB segment size" ++ default 128 ++ help ++ Set the maximum allowable number of contiguous slabs to map. ++ Must be a power of 2. ++ + config DMA_RESTRICTED_POOL + bool "DMA Restricted Pool" + depends on OF && OF_RESERVED_MEM && SWIOTLB diff --git a/recipes-kernel/linux/files/patches-6.1/0101-arm64-dts-ti-iot2050-Add-support-for-dts-overlay-for.patch b/recipes-kernel/linux/files/patches-6.1/0101-arm64-dts-ti-iot2050-Add-support-for-dts-overlay-for.patch new file mode 100644 index 000000000..4aedd11c5 --- /dev/null +++ b/recipes-kernel/linux/files/patches-6.1/0101-arm64-dts-ti-iot2050-Add-support-for-dts-overlay-for.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Li Hua Qian +Date: Fri, 3 Jan 2025 10:02:14 +0800 +Subject: [PATCH] arm64: dts: ti: iot2050: Add support for dts overlay for PG2 + and SM + +This commit adds support for device tree overlays for the IOT2050 +Advanced PG2 and SM variants. These overlays enable DMA isolation, +allowing for more flexible and secure memory management. + +Signed-off-by: Li Hua Qian +--- + arch/arm64/boot/dts/ti/Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/arch/arm64/boot/dts/ti/Makefile b/arch/arm64/boot/dts/ti/Makefile +index 725ad34cac4c..9428156c045c 100644 +--- a/arch/arm64/boot/dts/ti/Makefile ++++ b/arch/arm64/boot/dts/ti/Makefile +@@ -15,6 +15,8 @@ dtb-$(CONFIG_ARCH_K3) += k3-am6548-iot2050-advanced-pg2.dtb + dtb-$(CONFIG_ARCH_K3) += k3-am6548-iot2050-advanced-sm.dtb + + DTC_FLAGS_k3-am6548-iot2050-advanced-m2 += -@ ++DTC_FLAGS_k3-am6548-iot2050-advanced-pg2 += -@ ++DTC_FLAGS_k3-am6548-iot2050-advanced-sm += -@ + + dtb-$(CONFIG_ARCH_K3) += k3-j721e-common-proc-board.dtb + dtb-$(CONFIG_ARCH_K3) += k3-j721e-sk.dtb diff --git a/recipes-kernel/linux/linux-iot2050-6.1.inc b/recipes-kernel/linux/linux-iot2050-6.1.inc index 51ac9bc59..927e2b31e 100644 --- a/recipes-kernel/linux/linux-iot2050-6.1.inc +++ b/recipes-kernel/linux/linux-iot2050-6.1.inc @@ -17,12 +17,26 @@ def get_patches(d, patchdir): return ' '.join(['file://' + patch[len(files_dir)+1:] for patch in patches]) +def get_extra_cfg(d): + import re + + overrides = d.getVar('OVERRIDES') + extra_cfg = "" + + if re.search("meta-hailo", overrides): + extra_cfg += " file://iot2050_defconfig_hailo.cfg" + + return extra_cfg + SRC_URI += " \ https://cdn.kernel.org/pub/linux/kernel/projects/cip/6.1/linux-cip-${PV}.tar.xz \ ${@get_patches(d, 'patches-6.1')} \ file://patches-6.1/ \ file://${KERNEL_DEFCONFIG} \ file://iot2050_defconfig_extra.cfg" +SRC_URI:append:pvu-dma = " \ + file://iot2050_defconfig_pvu.cfg \ + ${@get_extra_cfg(d)}" S = "${WORKDIR}/linux-cip-${PV}"