Installing NXDRV-Driver on Linux Ubuntu
This installing guide provides the installation requirements.
Overview
Support for Linux kernel >= 5.6
The cifX Linux driver runs as a library in userspace and accesses the card via a UIO kernel module (userspace I/O).
Figure 1: Linux cifX driver architecture (Linux DRV 13.EN)
Requirements
- cmake (min 2.8.9)
- libthread, librt
- libapciaccess-dev (tested with V0.10.2 / V0.13.1-2)
- always needed for cifx PCI cards
Installing NXDRV-Driver
Install cmake.
$ apt-get install cmake
Install libpciaccess-dev.
$ apt-get install libpciaccess-dev
Extract the sources from the zip-file.
$ tar xf <driver_version>.tar.gz
Change to the driver directory.
$ cd <driver_version>/driver/
Run the installation script.
$ ./build_install_driver [optional pass the build folder]
Then follow the installation instructions
Deactivate the SPI interface if you do not use it.
In case of successful installation, the driver is ready to use.
In case of a system reboot, the kernel driver needs to be reloaded
$ modprobe uio_netx
Compiling the example programs
Go to the examples folder.
$ cd <driver_version>/examples
(Optional) Create a build directory.
$ mkdir build && cd build
Run cmake.
$ cmake ..
Build all source modules
$ make all
Configuration file storage
For a cifX device (especially CIFX 50 and CIFX 90), firmware and configuration files that are not stored on the hardware, must be loaded into the hardware each time the card is powered-up.
This part describes where and how these files have to be stored.
To allow device-specific configuration, the card needs to be identified, and the firmware must be stored on the host in a specific folder structure to create a unique relation between card and configuration.
These folders locate under a global base-folder. By default, it is '/opt/cifx' (can be changed during driver initialization).
There are four different types of configuration of a card, each with its specific folder structure. For more information, please see our Linux driver manual.
This guide describes the folder structure single directory.
Go to the scripts directory.
$ cd <driver_version>/driver/scripts
Run the installation firmware script.
$ ./install_firmware create_single_dir
This script will create a basic directory, it locates by default under /opt/cifx/deviceconfig/FW/channel0
Installing driver module for the CIFX/M.2 netx90 based devices.
Building ax99100-pci-spi module
For using the CIFX/M.2 the ax99100-pci-spi module must be compiled and loaded to the kernel.
First, enable the SPM_PLUGIN option during compiling the driver. See Configuration file storage.
If you are using linux driver version V2.1.1.0 or lower, the kernel module ax99100-pci-spi does not compile out of the box.
If you get the following compiler error: -Werror=incompatible pointer-types located in moduleparam.h, please change in ax99100-pci-spi.c the following calls of module_param_named from ushort to uint.
Go to cifx_m2 folder.
$ cd <driver_version>/driver/cifx_m2/
Change in ax99100-pci-spi.c (with e.g nano) the parameter in line 497, 501 and 505 from ushort to uint.
$ nano ax99100-pci-spi.c
Then, in Makefile uncomment line 5
#obj-m += ax99100-pci-gpio.o
You cannot use Interrupt for now!
Install driver modules. This will copy the driver modules into the desired kernel library folder, which are compiled for.
$ make modules_install
Update the module dependencies in the modules.dep file.
$ depmod
Configure the SPI interface (at chip-select 0) for accessing the netX90 based cifX/M.2 card with mode 3 and a maximum speed of 25Mhz.
$ modprobe ax99100-pci-spi modalias0=spi-petra mode0=3 max_speed_hz0=25000000
(Optional) You can verify with dmesg if the ax99100-pci-spi module is successfully added to the kernel.
Run:
$ dmesg | grep "ax99"
You should see something similar to the following:
[ 208.376412] ax99100-pci-spi: AX99100 PCIe to Multi I/O Controller - SPI driver [ 208.386582] ax99100-pci-spi 0000:06:00.3: spi0 successfully initialized! [ 208.386638] ax99100-pci-spi 0000:06:00.3: SPI slave (cs=0, modalias=spi-petra, mode=3, max_speed_hz=25000000) successfully added.
(Optional) Check if spi device is created.
$ ls /dev/spi*
Terminal output:
/dev/spidev0.0
Test
Then run a simple cifx example for the initial sanity check:
Go to the example folder and build the example programs. Please see Compiling the example programs.
Then run the cifxtcpserver with -a as parameter to detect the installed CIFX/M.2 card.
An example:
$ cd <driver_version>/examples/build $ ./cifxtcpserver -a
If a firmware (e.g. PROFINET) was downloaded to the device, you should get a similar output:
---------- Available Cards ---------- 1.: cifX0 DeviceNumber : 1443100 SerialNumber : 20418 - Channel 0: Firmware : PROFINET IO Device Version : 5.4.3 build 0 - Channel 1: Firmware : Network Services Version : 1.0.0 build 0 ----------------------------------------------------
Issues during build process
While compiling cifxtcpserver example, this error appears.
Error: multiple definition of 'g_ptMutex'
Figure 2: Error while compiling
Quick solution: In TCPServer.c located under <driver_version>examples/cifXTCPServer/, line 56 replace pthread_mutex_t* g_ptMutex to e.g static pthread_mutex_t* s_ptMutex and replace g_ptMutex to s_ptMutex.