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

XIMEA Linux API on Nvidia Jetson TX1/TX2

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.

Developer Kit setup

Follow the official quick start guide that can be found here: https://developer.nvidia.com/embedded/linux-tegra
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 ./flash.sh ${BOARD} mmcblk0p1

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

Installing XIMEA API package

sudo apt-get update
sudo apt-get install curl
curl -LO https://www.ximea.com/downloads/recent/XIMEA_Linux_SP.tgz
tar -xf XIMEA_Linux_SP.tgz
cd package
./install
sudo gpasswd -a "$(whoami)" plugdev
if [ -f /etc/rc.local ]
then
sudo sed -i '/^exit/ d' /etc/rc.local
else
echo '#!/bin/bash'                                             | sudo tee    /etc/rc.local > /dev/null
fi
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
#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
#reboot
sudo reboot

Running sample applications

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

/opt/XIMEA/bin/xiSample

If you want to view a live picture from camera, then 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 run it:

/opt/XIMEA/bin/streamViewer

TX2 PCIe support

Linux For Tegra R27.1

In order to have support for PCIe XIMEA cameras with L4T 27.1 you need to recompile the kernel using the instructions on this web page: http://www.jetsonhacks.com/2017/03/25/build-kernel-and-modules-nvidia-jetson-tx2/

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

./install -pcie

Linux For Tegra R28.1 or later

To have support for PCIe XIMEA cameras on TX2 you need to prepare the system for kernel module compilation and run install script with -pcie flag:

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

TX1 PCIe support

On 64-bit version of Linux For Tegra (available since R24.1) it is possible to use xiB 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
#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
#reboot
sudo reboot

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

#!/bin/bash
# root@tegra-ubuntu:~# cat /sys/kernel/debug/clock/emc/possible_rates
# 40800 68000 102000 204000 408000 665600 800000 1065600 1331200 1600000 (kHz)
EMC_FREQ=1600000
exec 3>/dev/emc_freq_min
printf '%x' $EMC_FREQ >&3
exec "$@" 

Save it to ~/pcie_wrapper.sh file and execute the following commands to try the script out:

chmod a+x ~/pcie_wrapper.sh
~/pcie_wrapper.sh /opt/XIMEA/bin/xiSample
~/pcie_wrapper.sh /opt/XIMEA/bin/streamViewer

Maximum frequency of 1600000 kHz seems to be an over-kill, xiSample and streamViewer work fine with 665600 kHz setting. But other activity in the system may influence minimally required value, so lower this setting at your own risk.

Linux For Tegra R24.2 issues

Due to a bug in the L4T 24.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