How to bring up hailort on android

Could we bring up hailort on android OS?

1 Like

Bringing Up HailoRT Driver on Android

This guide summarizes the steps to build and install the HailoRT driver for Android.

Prerequisites:

Steps:

  1. Build Hailo Driver:
  • Change directory to the Hailo driver source:
    cd hailort-drivers/linux/pcie

  • Set environment variables (adjust NDK path):
    export NDK=/opt/android-ndk-r26b
    export PATH=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
    export KERNEL_DIR=/opt/RK3588_Android12.0/kernel-5.10 # Adjust kernel directory

  • Build the driver:
    $NDK/prebuilt/linux-x86_64/bin/make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=1 all

  • Verify driver build:
    file hailo_pci.ko

  1. Download Hailo Firmware:
  • Run the script to download the firmware (assuming it exists in the project):
    ../../download_firmware.sh
  1. Install Hailo Driver on Device:
  • Connect your Android device.
  • Enable root access and remount the device (use with caution):
    adb root
    adb remount
  • Create a directory for the firmware on the device:
    adb shell "mkdir -p /vendor/etc/firmware/hailo/"
  • Push the driver and firmware files to the device:
    adb push hailo8_fw.4.xx.x.bin /vendor/etc/firmware/hailo/hailo8_fw.bin
    adb push hailo_pci.ko /vendor/lib/modules/hailo/
  • Configure automatic loading on boot:
    adb shell "echo "insmod /vendor/lib/modules/hailo_pci.ko">> /vendor/etc/init.insmod.cfg"
  1. Build HailoRT for Android :
  • Download HailoRT
    git clone https://github.com/hailo-ai/hailort.git
  • Change the CMakeLists.txt for the cross compiling.
    set(ANDROID_PLATFORM android-21) # Adjust the API level as needed
    set(ANDROID_ABI arm64-v8a) # Target ARM architecture, adjust as needed
    set(ANDROID_NDK /opt/android-ndk-r26b) # Specify Android NDK path
    set(CMAKE_TOOLCHAIN_FILE ${ANDROID_NDK}/build/cmake/android.toolchain.cmake) # Set the toolchain file for Android
    set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ABI}) # Specify the architecture for Android
    set(ANDROID_PLATFORM_VERSION ${ANDROID_PLATFORM}) # Specify the Android platform version
  • Compiling the hailort
    cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
    cmake --build build --config release
    *Pushing Compiled Files
    adb push libhailort.so /vendor/lib64/
    adb push hailortcli /vendor/bin
1 Like