Support Support Home » APIs » XIMEA Linux Software Package » Linux TX1 and TX2 Support

XIMEA Linux API on Nvidia Jetson TX1/TX2/AGX Xavier

Jetson TX1 is an embedded module from Nvidia which includes quad-core 64 bit ARM CPU and 256-core Maxwell GPU. It delivers high performance and power efficiency in small size and can be used for deep learning, computer vision and other computing applications.

Jetson TX2 is a successor to TX1, updating GPU architecture to Pascal and improving the performance.

Jetson AGX Xavier is the most recent member of Nvidia's Jetson platform. It brings a lot of upgrades including Volta GPU architecture.

Developer Kit setup

Follow the official quick start guide that can be found here:
In case your host machine isn't running Ubuntu you should replace flashing command with the following sequence:

sudo cp /etc/mke2fs.conf .
sudo sed -i 's/64bit,//g' mke2fs.conf
MKE2FS_CONFIG="$(pwd)"/mke2fs.conf sudo -E ./ ${BOARD} mmcblk0p1

where ${BOARD} is either jetson-tx1 or jetson-tx2 or jetson-xavier.

Installing XIMEA API package

Run the following commands on Jetson:

sudo apt-get update
sudo apt-get install ca-certificates
tar -xf XIMEA_Linux_SP.tgz
cd package
sudo gpasswd -a "$(whoami)" plugdev
if [ -f /etc/rc.local ]
sudo sed -i '/^exit/ d' /etc/rc.local
echo '#!/bin/sh -e'                                            | sudo tee    /etc/rc.local > /dev/null
echo 'echo 0 > /sys/module/usbcore/parameters/usbfs_memory_mb' | sudo tee -a /etc/rc.local > /dev/null
echo 'exit 0'                                                  | sudo tee -a /etc/rc.local > /dev/null
sudo chmod a+x /etc/rc.local
#enable controlling of memory frequency by user
echo 'KERNEL=="emc_freq_min", ACTION=="add", GROUP="plugdev", MODE="0660"' | sudo tee /etc/udev/rules.d/99-emc_freq.rules > /dev/null
#optional: allow user to use realtime priorities
sudo groupadd -fr realtime
echo '*         - rtprio   0' | sudo tee    /etc/security/limits.d/ximea.conf > /dev/null
echo '@realtime - rtprio  81' | sudo tee -a /etc/security/limits.d/ximea.conf > /dev/null
echo '*         - nice     0' | sudo tee -a /etc/security/limits.d/ximea.conf > /dev/null
echo '@realtime - nice   -16' | sudo tee -a /etc/security/limits.d/ximea.conf > /dev/null
sudo gpasswd -a "$(whoami)" realtime
sudo mkdir /etc/systemd/system/user@.service.d
echo '[Service]'                                                                                 | sudo tee    /etc/systemd/system/user@.service.d/cgroup.conf > /dev/null
echo 'PermissionsStartOnly=true'                                                                 | sudo tee -a /etc/systemd/system/user@.service.d/cgroup.conf > /dev/null
echo 'ExecStartPost=-/bin/sh -c "echo 950000 > /sys/fs/cgroup/cpu/user.slice/cpu.rt_runtime_us"' | sudo tee -a /etc/systemd/system/user@.service.d/cgroup.conf > /dev/null
sudo reboot

PCIe support

On 64-bit version of Linux For Tegra (available since R24.1) it is possible to use PCIe cameras. To enable support for PCIe in XIMEA API you need to run install script (see installation section) with -pcie flag, but before that system has to be prepared for kernel module compilation:

sudo make -C /lib/modules/"$(uname -r)"/build modules_prepare
./install -pcie

Memory bandwidth problems

By default memory frequency is controlled by the kernel dynamically, which means that sufficient memory bandwidth isn't available at all times. This causes crashes, hangs and lost frames when PCIe or USB3 cameras are used. Solution is to raise lower limit for memory frequency when image acquisition is running. The following wrapper script can be used for that:

# TX1:
# # cat /sys/kernel/debug/clock/emc/possible_rates
# 40800 68000 102000 204000 408000 665600 800000 1065600 1331200 1600000 (kHz)
# TX2:
# # cat /sys/kernel/debug/bpmp/debug/emc/possible_rates
# 40800 68000 102000 204000 408000 665600 800000 1062400 1331200 1600000 1866000 (kHz)
# Xavier:
# # cat /sys/kernel/debug/bpmp/debug/emc/possible_rates
# 204000 408000 665600 800000 1065600 1331200 1600000 1866000 2133000 (kHz)
exec 3>/dev/emc_freq_min
printf '%x' "$EMC_FREQ" >&3
exec "$@" 

Save it to ~/ file and execute the following command:

chmod a+x ~/

Running sample applications

To do a simple validation that everything is working you can run xiSample:

~/ /opt/XIMEA/bin/xiSample

To view a live picture from a camera start CamTool:

~/ /opt/XIMEA/bin/xiCamTool

Alternatively streamViewer application can be used, but you need to compile it first:

cd /opt/XIMEA/examples/streamViewer
sudo apt-get update
sudo apt-get install libgtk2.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-x
sudo make GST10=1
sudo make install

Then you can start the viewer:

~/ /opt/XIMEA/bin/streamViewer

TX2 USB issues

Linux For Tegra R27.1 and R28.1

USB3 controller firmwares in L4T before R28.2 contain a bug which affects XIMEA USB3 cameras connected to TX2 module. Solution is to either upgrade to R28.2 or later version, or take the firmware from R28.2 driver package:

tar -xf Tegra186_Linux_R28.2.0_aarch64.tbz2
tar -xf Linux_for_Tegra/nv_tegra/nvidia_drivers.tbz2 lib/firmware/tegra18x_xusb_firmware

lib/firmware/tegra18x_xusb_firmware file then has to be placed in /lib/firmware/ directory on TX2 filesystem overwriting older firmware. Reboot Jetson for changes to take effect.

PCIe issues

Linux For Tegra R31.0.2

In order to have compatibility with more PCIe devices (including XIMEA cameras) a patch needs to be applied to the kernel and device tree in L4T R31.0.2 (see L4T documentation for build instructions):
Also due to broken kernel headers in L4T R31.0.2 you need to recreate kernel sources tree in order to build XIMEA PCIe driver:

cd /usr/src/
sudo wget -O public_sources_31.0.2.tbz2 ''
sudo tar --no-same-owner -xf public_sources_31.0.2.tbz2 public_sources/kernel_src.tbz2
sudo tar --no-same-owner -xf public_sources/kernel_src.tbz2
zcat /proc/config.gz | sudo tee kernel/kernel-4.9/.config >/dev/null
sudo sed -i '/^EXTRAVERSION/ c EXTRAVERSION = -tegra' kernel/kernel-4.9/Makefile
sudo cp linux-headers-4.9.108-tegra/{modules.builtin,modules.order,Module.symvers,} kernel/kernel-4.9/
sudo ln -snf /usr/src/kernel/kernel-4.9 /lib/modules/4.9.108-tegra/build

After that you can continue with installation.

Linux For Tegra R27.1

In order to have support for PCIe XIMEA cameras with L4T R27.1 you need to recompile the kernel using the instructions on this web page:

After that XIMEA API package can be installed with PCIe support by passing the -pcie option to install script:

./install -pcie

Linux For Tegra R24.2

Due to a bug in the L4T R24.2 release devices don't work correctly when they are connected through active PCIe switch (e.g. using host adapter for fiber cables). Workaround is to disable IOMMU for PCIe controller in device tree configuration file:

cd /usr/src/linux-headers-$(uname -r)
sudo make modules_prepare
sudo scripts/dtc/dtc -I dtb $(grep FDT /boot/extlinux/extlinux.conf|sed 's/.*FDT //') -o /boot/devicetree.dts
sudo sed -i~ -e '/{$/ h ; x ; /pcie-controller / { x ; /iommus/ d ; x } ; x' /boot/devicetree.dts
sudo scripts/dtc/dtc /boot/devicetree.dts -O dtb -o /boot/devicetree.dtb
sudo sed -i~ -e 's|FDT .*|FDT /boot/devicetree.dtb|' /boot/extlinux/extlinux.conf
sudo reboot