Skip to content
This repository was archived by the owner on Sep 15, 2026. It is now read-only.

Latest commit

 

History

History
425 lines (295 loc) · 12.7 KB

SETUP.md

File metadata and controls

425 lines (295 loc) · 12.7 KB

QNX AI Camera Development Environment Setup

This document prepares a Fedora x86_64 Linux computer to build the QNX AI Camera sample and a custom traffic-warning application using:

  • QNX SDP 8.0
  • QNX Sensor Framework camera APIs
  • TensorFlow Lite
  • OpenCV
  • Raspberry Pi running QNX OS 8.0

The libraries and application are cross-compiled on the Fedora computer. SSH/SCP are used only to copy files to the Raspberry Pi and run them.

Note on host OS: The upstream AI Camera App project officially tests on Ubuntu, but this workspace is set up and verified on Fedora. The steps below are Fedora-specific and include fixes for host-package differences (notably a newer CMake and a missing patch tool) that the Ubuntu instructions do not need.


1. What is required

Each developer needs:

  • An x86_64 Fedora computer
  • A myQNX account
  • A valid QNX SDP 8.0 license
  • QNX Software Center for Linux
  • QNX SDP 8.0 installed locally
  • Access to the QNX Raspberry Pi over SSH
  • Git and standard C/C++ build tools
  • At least 20 GB of free disk space
  • Preferably 16 GB or more RAM

QNX SDP and its license files are proprietary. Do not copy another developer's qnx800 directory or license files. Every developer must install and activate QNX through their own authorized account.


2. Obtain and activate the QNX license

  1. Create or sign in to a myQNX account:

  2. Make sure a QNX SDP 8.0 license is deployed to that account.

    • Organization users: ask the organization's QNX license administrator.
    • Students, hobbyists, and non-commercial users can check:
  3. In the myQNX License Manager:

    • Accept the license agreement.
    • Deploy the license to your own user account.
  4. Download QNX Software Center for Linux:

  5. Run the downloaded installer:

cd ~/Downloads
chmod +x qnx-setup-*-linux.run
./qnx-setup-*-linux.run
  1. Launch QNX Software Center and sign in using the licensed myQNX account.

3. Install QNX SDP 8.0 and required packages

Using QNX Software Center, create a QNX SDP 8.0 installation.

Recommended installation directory:

~/qnx800

Install these packages into the same SDP installation:

com.qnx.qnx800.target.sf.camapi
com.qnx.qnx800.target.sf.base
com.qnx.qnx800.target.mm.aoi
com.qnx.qnx800.target.mm.mmf.core
com.qnx.qnx800.target.screen.img_codecs

These provide the camera APIs, QNX Sensor Framework components, multimedia support, and Screen image codecs required by the AI Camera App and OpenCV port.

After installation, confirm this file exists:

ls ~/qnx800/qnxsdp-env.sh

If QNX was installed somewhere else, use that path in all later commands.

Heads-up — target Python version. The current QNX SDP 8.0 ships Python 3.13 in its target sysroot ($QNX_TARGET/usr/include/python3.13, libpython3.13.so), but the build-files ports are pinned to Python 3.11. This mismatch does not need to be solved, because the C++ AI Camera App does not use any Python bindings — see Section 7, which disables the bindings entirely.


4. Install Fedora host dependencies

sudo dnf install -y \
  git make cmake gcc gcc-c++ gcc-gfortran \
  python3.11 python3.11-devel python3-pip \
  ninja-build pkgconf-pkg-config \
  patch

patch is required and easy to miss. The TensorFlow Lite build applies patches to third-party dependencies (e.g. pthreadpool). Fedora does not install patch by default, and without it the TFLite build fails with patch: command not found (exit 127).

Verify:

git --version
cmake --version
python3.11 --version
patch --version

CMake note. Recent Fedora ships CMake 4.x, which has removed compatibility with the very old cmake_minimum_required versions used by some TFLite dependencies (FP16, pthreadpool). The build will fail at configure time with Compatibility with CMake < 3.5 has been removed. This is fixed by installing an older CMake into the project virtualenv in Section 6 — do not attempt to downgrade the system CMake.


5. Clone the source repositories

Create the workspace:

mkdir -p ~/qnx_workspace
cd ~/qnx_workspace

Clone the AI Camera sample:

git clone --depth 1 \
  https://gitlab.com/qnx/projects/ai-camera-app.git

Clone the QNX port build files:

git clone --depth 1 \
  https://github.com/qnx-ports/build-files.git

Clone the QNX TensorFlow fork using a shallow clone:

git clone \
  --depth 1 \
  --single-branch \
  --no-tags \
  --branch qnx_v2.16.1 \
  https://github.com/qnx-ports/tensorflow.git

Clone OpenCV, NumPy, and muslflt:

git clone --depth 1 https://github.com/qnx-ports/opencv.git
git clone --depth 1 https://github.com/qnx-ports/numpy.git
git clone --depth 1 https://github.com/qnx-ports/muslflt.git

Initialize NumPy submodules:

cd ~/qnx_workspace/numpy
git submodule update --init --recursive
cd ~/qnx_workspace

The workspace must look like this:

~/qnx_workspace/
├── ai-camera-app/
├── build-files/
├── muslflt/
├── numpy/
├── opencv/
└── tensorflow/

Do not rename these directories. The build files expect this sibling-directory layout.


6. Create the Python build environment

cd ~/qnx_workspace

python3.11 -m venv env
source env/bin/activate

python -m pip install --upgrade pip
python -m pip install \
  "Cython==0.29.35" \
  wheel requests pybind11

Install an older CMake into the virtualenv (fixes the CMake 4.x incompatibility from Section 4). Because the venv's bin is first on PATH while it is active, this CMake takes precedence over the system one during the build:

python -m pip install "cmake<4"
cmake --version   # should now report 3.31.x while the venv is active

Whenever opening a new terminal for this project, reactivate the venv:

source ~/qnx_workspace/env/bin/activate

7. Apply QNX port build fixes

The AI Camera App is a C++ program. It links libtensorflow-lite.so and OpenCV's C++ modules and does not use numpy or any Python bindings (see ai-camera-app/common.mk LIBS). The stock ports, however, try to build the numpy / TFLite / OpenCV Python bindings, which require Python 3.11 headers on the QNX target — the exact thing the SDP no longer ships (see the note in Section 3).

The fix is to disable the Python bindings in the three ports. This removes the need for any target Python (3.11 or 3.13) and lets the build proceed. All three edits are reversible.

7.1 Skip NumPy (scripts/build_all.sh)

NumPy is only an input to the TFLite/OpenCV Python bindings. Skip its build step. The provided scripts/build_all.sh in this workspace already does this — if you are wiring up your own script, replace the NumPy build step with a no-op.

7.2 TensorFlow Lite — build the C++ library only

Edit build-files/ports/tensorflow/common.mk. Gate the Python-binding steps behind a flag that defaults to off, so tflite_all builds only the C++ library:

# TFLITE_PYTHON=true also builds the Python bindings (needs target numpy + python3.x headers).
# Default false: the ai-camera-app is C++ and only needs libtensorflow-lite.so.
TFLITE_PYTHON ?= false

tflite_all:
	@mkdir -p build
	cd build && cmake $(CMAKE_ARGS) $(QNX_PROJECT_ROOT)/tensorflow/lite/
	cd build && make all $(MAKE_ARGS)
ifeq ($(TFLITE_PYTHON),true)
	cd build && make _pywrap_tensorflow_interpreter_wrapper $(MAKE_ARGS)
	BUILD_DIR=$(PWD)/build/python_loader CMAKE_BUILD_DIR=$(PWD)/build $(QNX_PROJECT_ROOT)/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh nto
	mkdir -p $(INSTALL_ROOT)/$(CPUVARDIR)/$(PREFIX)/lib/python3.11/site-packages && cp -r $(PWD)/build/python_loader/tflite_runtime $(PWD)/build/python_loader/tflite_runtime.egg-info $(INSTALL_ROOT)/$(CPUVARDIR)/$(PREFIX)/lib/python3.11/site-packages
endif

7.3 OpenCV — turn Python bindings off

Edit build-files/ports/opencv/common.mk and flip these CMake flags:

-DBUILD_opencv_python3=OFF \
-DBUILD_opencv_python_bindings_generator=OFF \
-DOPENCV_PYTHON_INSTALL_TARGET=OFF \

To re-enable the Python bindings later, you must provide a matching target Python (3.11) + a cross-built numpy, then set TFLITE_PYTHON=true and flip the OpenCV flags back to ON.


8. Load the QNX cross-compilation environment

Run:

source ~/qnx800/qnxsdp-env.sh

Verify:

echo "$QNX_HOST"
echo "$QNX_TARGET"
which qcc
qcc -Vgcc_ntoaarch64le

QNX_HOST and QNX_TARGET must not be empty, and qcc must be found inside the QNX SDP installation.

Whenever opening a new terminal, run both:

source ~/qnx_workspace/env/bin/activate
source ~/qnx800/qnxsdp-env.sh

scripts/build_all.sh sources ~/qnx800/qnxsdp-env.sh itself, so you do not have to source it manually before running the script. You still need the venv active (for the older CMake).


9. Build everything

With the venv active and the fixes from Section 7 applied:

cd ~/qnx_workspace
JOBS=4 ./scripts/build_all.sh

The script builds in this order (NumPy is intentionally skipped):

1. flatc          (native host FlatBuffers compiler)
2. TensorFlow Lite (C++ library only)
3. muslflt
4. OpenCV         (C++ modules, no Python)
5. ai-camera-app

JOBS controls parallelism. Use JOBS=4 for the first build unless the host has plenty of RAM; TFLite and OpenCV are memory-hungry.

On success the application binary is at:

~/qnx_workspace/ai-camera-app/nto/aarch64/o.le/ai-camera-app

10. Confirm SSH access to the Raspberry Pi

Replace PI_IP with the target address:

ssh qnxuser@PI_IP

On the Pi, check:

uname -a
uname -m

The target should be an AArch64 QNX system.

Return to the host:

exit

The Pi is used to run the software. TensorFlow Lite, OpenCV, and the application are built on Fedora.


11. Important Raspberry Pi camera warning

The QNX Raspberry Pi image already contains the required camera and Sensor Framework setup.

Do not reinstall the Sensor Framework using apk. Doing so may break the provided image and require reflashing it.

The Camera Module 3 startup entry must be enabled in:

/etc/startup/post_startup.sh

Follow the Raspberry Pi image or event instructions for the exact camera configuration. On the provided Raspberry Pi 5 setup, use the camera connector nearest the USB ports.

Package commands such as these run on the QNX Pi, not on Fedora:

sudo apk update
sudo apk list
sudo apk add <package>

Do not use them to reinstall camera or sensor-framework components.


12. Environment completion check

The setup is complete when all of these succeed on the Fedora host:

test -d ~/qnx_workspace/ai-camera-app
test -d ~/qnx_workspace/build-files
test -d ~/qnx_workspace/tensorflow
test -d ~/qnx_workspace/opencv
test -d ~/qnx_workspace/numpy
test -d ~/qnx_workspace/muslflt

source ~/qnx_workspace/env/bin/activate
source ~/qnx800/qnxsdp-env.sh

python --version           # Python 3.11.x
cmake --version            # 3.31.x (from the venv)
patch --version            # present
qcc -Vgcc_ntoaarch64le

Expected result:

  • Python 3.11 virtual environment is active
  • CMake 3.x (from the venv) shadows the system CMake 4.x
  • patch is installed
  • QNX SDP variables are loaded
  • The AArch64 QNX compiler is available
  • All six source repositories exist
  • The port build fixes from Section 7 are applied
  • SSH access to the QNX Pi works

Troubleshooting

  • patch: command not found / Error 127 during the TFLite build — install patch (Section 4).
  • Compatibility with CMake < 3.5 has been removed — the system CMake 4.x is being used; activate the venv and install cmake<4 (Section 6). If a build dir was already configured with CMake 4.x, delete it (rm -rf the port's nto-*/build and flatc-native-build) so it reconfigures with the older CMake.
  • Cannot compile 'Python.h' during a NumPy or Python-binding build — you are building a Python binding against a target Python that is not present (SDP ships 3.13, ports expect 3.11). Apply the Section 7 fixes to disable the bindings.

References