08/25/2025
How-to | SDK

Build a snap with HAILO 8 integration

Disclaimer

This guide is not intended to be a substitution of the official documentation which is provided by the partner.

Requirements

  • A ctrlX CORE equipped with an HAILO 8 chip

  • Hailo Packets and software available here

  • Being used to build with snapcraft

  • Build natively on arm64 if using the x3

  • core22

Scaffolding

The folder structure is the following:

Folders in the hailo project

Permissions, the right plugs

In order to be able to interact with the chips we need to insert the right plugs and select them inside the app we would like to use to command the chips.

plugs:

  hailo-0:
    interface: custom-device
    custom-device: ctrlx-hailo-0
  
  hailo-1:
    interface: custom-device
    custom-device: ctrlx-hailo-1

apps:
  myfancyapp:
    command: bin/mywrapper.wrapper
    daemon: simple
    plugs:
      - hailo-0
      - hailo-1
      - ....

Include the packages in the snap

We need to first download the packages that we need depending by our firmware (linked to ctrlX OS version) and python runtime version (linked to core version). To import the Debian package we just need to link the Debian packages locally. To link the libraries the code is usually more complex and it is better to execute the code after another "python" libraries block to have the runtime automatically imported by the Snapcraft technology.

  mylibs:
    plugin: nil
    source: ./customPackages
    build-packages:
      - python3-dev
      - python3-wheel
      - build-essential
      - python3-setuptools

    after:
      - pythonlibs  
    override-build: |
        echo $SNAPCRAFT_ARCH_TRIPLET
        case "$SNAPCRAFT_ARCH_TRIPLET" in
          *aarch64*)
              WHEEL_FILE="hailort-4.15.0-cp310-cp310-linux_aarch64.whl" ;;
          *x86_64*)
              WHEEL_FILE="hailort-4.15.0-cp310-cp310-linux_x86_64.whl" ;;
          *)
              echo "Unsupported architecture!"
              exit 1 ;;
        esac
        ls
        echo "The dependencies are installed in the flask part to avoid conflicts"
        python3 -m pip install --no-deps --no-cache-dir -I $WHEEL_FILE -t $CRAFT_PART_INSTALL/lib/python3.10/site-packages/
        craftctl default


  mydeb:
      plugin: dump
      source: 
        - on arm64: ./customPackages/hailort_4.15.0_arm64.deb
        - on amd64: ./customPackages/hailort_4.15.0_amd64.deb
      source-type: deb

A complete snapcraft example

name: python-ai-toolkit
version: 0.1.8
summary: Python AI starter kit
description: 'Simple Webbased Editor'

base: core22
confinement: strict
grade: stable
architectures:
  - build-on: amd64
  - build-on: arm64


apps:
  jupyter:
    
    command: bin/jupyter.wrapper
    daemon: simple
    plugs:
      - network-bind
      - active-solution
      - network-status
      - hardware-observe
      - network-observe
      - serial-port
      - hailo-0
      - hailo-1
      - datalayer
    environment:
       "LD_LIBRARY_PATH": "$LD_LIBRARY_PATH:$SNAP/usr/include:$LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/lapack:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/blas:$SNAP/usr/lib/python3/dist-packages"
       "PATH": "$PATH:$SNAP/usr/lib/"

  desktop-launch:
    command: bin/desktop-launch
    plugs:
      - desktop  

parts:


  flask:
    plugin: python
    build-environment:
      - PYTHONPATH: "$SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages"
    python-packages: 
      - flask 
      - jupyterlab==4.0.2
      - numpy==1.23.3 #for hailo
      - opencv-python
      - pillow
      - zenlog
      - matplotlib
      - ctrlx_fbs
      - ctrlx_datalayer
      - argcomplete #for hailo
      - contextlib2 #for hailo
      - future #for hailo
      - netaddr #for hailo
      - netifaces #for hailo
      - verboselogs #for hailo

    source: .
    stage-packages:
      - wget
      - git
      - zip 
      - libssl-dev
      - libcurl4-openssl-dev
      - libcurl-dev
      - pkg-config
      - build-essential
      - libusb-1.0-0-dev
      - unzip
      - ffmpeg 
      - python3-wheel


    build-packages:
      - python3-dev
      - python3-wheel
      - build-essential
      - python3-setuptools

  mylib:
    plugin: nil
    source: ./customPackages
    build-packages:
      - python3-dev
      - python3-wheel
      - build-essential
      - python3-setuptools

    after:
      - flask
    override-build: |
        echo $SNAPCRAFT_ARCH_TRIPLET
        case "$SNAPCRAFT_ARCH_TRIPLET" in
          *aarch64*)
              WHEEL_FILE="hailort-4.15.0-cp310-cp310-linux_aarch64.whl" ;;
          *x86_64*)
              WHEEL_FILE="hailort-4.15.0-cp310-cp310-linux_x86_64.whl" ;;
          *)
              echo "Unsupported architecture!"
              exit 1 ;;
        esac
        ls
        echo "The dependencies are installed in the flask part to avoid conflicts"
        python3 -m pip install --no-deps --no-cache-dir -I $WHEEL_FILE -t $CRAFT_PART_INSTALL/lib/python3.10/site-packages/
        craftctl default


  mydeb:
      plugin: dump
      source: 
        - on arm64: ./customPackages/hailort_4.15.0_arm64.deb
        - on amd64: ./customPackages/hailort_4.15.0_amd64.deb
      source-type: deb



 
 
  shscripts:  
    source: ./shscripts/
    plugin: dump
    organize:
      '*': bin/
      

  configs:
    source: ./configs
    plugin: dump
    organize:
      'package-assets/*': package-assets/${SNAPCRAFT_PROJECT_NAME}/




plugs:
  datalayer:
    interface: content
    content: datalayer
    target: $SNAP_DATA/.datalayer 

  active-solution:
    interface: content
    content: solutions
    target: $SNAP_COMMON/solutions

  hailo-0:
    interface: custom-device
    custom-device: ctrlx-hailo-0
  
  hailo-1:
    interface: custom-device
    custom-device: ctrlx-hailo-1


slots:

  package-assets:
    interface: content
    content: package-assets
    source:
      read:
        - $SNAP/package-assets/${SNAPCRAFT_PROJECT_NAME}
  package-run:
    interface: content
    content: package-run
    source:
      write:
        - $SNAP_DATA/package-run/${SNAPCRAFT_PROJECT_NAME}
hooks:
  connect-plug-active-solution:
    plugs: [active-solution]
Types
How-to
Products
IOT
Markets
Sonstiges

Latest published/updated articles