Cross-Compiling Guide for Hailort and Hailort Driver

I’d like to share a comprehensive guide for cross-compiling Hailort and the associated driver. This guide covers the necessary steps and commands for building the Hailort driver file (hailo_pci.ko) and library using a cross-compilation setup. The instructions are tailored for an ARM64 architecture.

Hailort Driver Compilation:

Using GCC:

bashCopy code

make ARCH=arm64 KERNEL_DIR=../RK3588_suit/rk3588_5.10.66/ CROSS_COMPILE=/opt/toolchain/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- all

Using Clang (vendor-specific):

bashCopy code

export PATH=..//tb-rk3588x/prebuilts/clang/bin:$PATH
KERNEL_DIR=..//tb-rk3588x/kernel/linux-5.10 make ARCH=arm64 CROSS_COMPILE=/opt/tb-rk3588x/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- LLVM=1 LLVM_IAS=1  all

Hailort Library Compilation:

  1. Add the following section to the “CMakeLists.txt” file:

cmakeCopy code

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(tools /opt/toolchain/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-none-linux-gnu-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
  1. Compile the source code using the following commands:

bashCopy code

# Compiling HailoRT source
cd ../../../hailort/
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_EXAMPLES=1
cmake --build build --config release
5 Likes

Wow… hailo is from RK??? :heart_eyes: :star_struck:

Why not post how you build hailort-driver on raspberry pi 5 directly, instead of cross compile???