Installing NXDRV-SPI-Driver on a Raspberry Pi
This installing guide provides the installation requirements.
Requirements
Installing requirements
Install cmake
Install ccmake (optional)
$ apt-get install cmake-curses-gui
Installing libcifx
Extract the sources from the zip-file.
$ tar xf <driver_version>.tar.gz
Change to the libcifx directory.
$ cd <driver_version>/driver/libcifx/
(Optional) Create a build directory.
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/driver/libcifx $ mkdir build && cd build
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/driver/libcifx/build $
Configure CMake environment with ccmake (optional).
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/driver/libcifx/build $ ccmake ..
Enable SPM_PLUGIN and DISABLE_PCI.
Press "c" to configure cmake and then "g" to generate make file.
Configure CMake environment without ccmake.
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/driver/libcifx/build $ cmake .. -DDISABLE_PCI=ON -DSPM_PLUGIN=ON
Build and install libcifx.
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/driver/libcifx/build $ make all
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/driver/libcifx/build $ make install
Create the necessary links and cache to the most recent shared libraries found.
Compiling the example programs
Go to the examples folder.
pi@raspberrypi:~ $ cd V2.1.1.0/V2.1.1.0/examples/
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples $
Create a build directory.
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples $ mkdir build && cd build
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $
Configure CMake environment
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $ cmake ..
Build all source modules
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $ make all
Issues during build process
While compiling cifxtcpserver example, this error appears.
Error: multiple definition of 'g_ptMutex'
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.
Connect a netX90 based device to the Raspberry Pi
netSHIELD90 and Raspberry Pi pinout
Run cifxspisample. You should get a similar output
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $ sudo ./cifxsample
---------- Display Driver Version ----------
Driver Version: LinuxCIFXDrv V2.1.0.0, based on cifX Toolkit 2.6.0.0
State = 0x00000000
----------------------------------------------------
---------- Board/Channel enumeration demo ----------
Found Board cifX0
DeviceNumber : 7833000
SerialNumber : 20000
Board ID : 0
System Error : 0x00000000
Channels : 2
DPM Size : 65536
- Channel 0:
Firmware : PROFINET IO Device
Version : 5.4.0 build 0
Date : 10/18/2021
Device Nr. : 7833000
Serial Nr. : 20000
netX Flags : 0x00000038
Host Flags : 0x00000038
Host COS : 0x00000000
Device COS : 0x00000001
- Channel 1:
Firmware : Network Services
Version : 1.0.0 build 0
Date : 10/18/2021
Device Nr. : 7833000
Serial Nr. : 20000
netX Flags : 0x00000038
Host Flags : 0x00000038
Host COS : 0x00000000
Device COS : 0x00000001
State = 0x00000000
----------------------------------------------------
---------- System Device handling demo ----------
System Channel Info Block:
==========================
DPM Cookie : netX
DPM Size : 32768
Device Number : 7833000
Serial Number : 20000
HW Options : 0x0080 0x0080 0x0000 0x0000
Manufacturer : 1
Production Date : 4395
Device Class : 60
HW Revision : 3
HW Compatibility : 0
License Flags 1 : 0x00000000
License Flags 2 : 0x00000003
LicenseID : 0x0000
LicenseFlags : 0x0000
==========================
System Information:
===================
System Error : 0x00000000
DPM Size : 32768
Mailbox size : 124
Device Number : 7833000
Serial Number : 20000
Open Count : 1
===================
System Control Block:
=====================
Command COS : 0x00000000
System Control : 0x00000000
=====================
Waiting 2s to let cifX card calculate CPU load!
System Status Block:
====================
System COS : 0x00000000
System Status : 0x22000001
System Error : 0x00000000
Time since start : 20899
CPU Load [%] : 4.00
====================
Trying to read Security Eeprom:
===============================
System Mailbox State: MaxSend = 16, Pending Receive = 0
Send Packet (Read Crypto Flash Zone 1):
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00001EBC
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000004 Rout : 0x00000000
Data:
01 00 00 00
System Mailbox State: MaxSend = 16, Pending Receive = 1
Received Packet (Read Crypto Flash Zone 1):
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00001EBD
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
System Mailbox State: MaxSend = 16, Pending Receive = 0
===============================
State = 0x00000000
----------------------------------------------------
---------- Communication Channel demo ----------
Communication Channel Info:
Device Number : 7833000
Serial Number : 20000
Firmware : PROFINET IO Device
FW Version : 5.4.0 build 0
FW Date : 10/18/2021
Mailbox Size : 1596
Start put/get packet Demo!
Channel Mailbox State: MaxSend = 1, Pending Receive = 0
Send Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00000000
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
Received Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00000001
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
Start read/write IO-Data!
Error setting Bus state lRet = 0x800C0012!
--- Read / Write Block Information ---
Read CONTROL Block
00 00 00 00
Write CONTROL Block
Read COMMON Status Block
01 00 00 00
Write COMMON Status Block
Error writing to common status block. lRet = 0x800A0006
Read EXTENDED Status Block
00 00 00 00
Write EXTENDED Status Block
Error writing to extended status block. lRet = 0x800A0006
--- Event handling demo ---
Sync-handshake mode: 0x02 (host controlled)
Error: 0x800A001A, <Interrupt is disabled>
--- Set Bus / Host State Demo ---
Set CIFX_HOST_STATE_READY!
CIFX_HOST_STATE_READ, state 1 !
Error CIFX_BUS_STATE_ON, state 0, error 0x800C0012 !
CIFX_BUS_STATE_OFF, state 0 !
Set CIFX_HOST_STATE_NOT_READY!
CIFX_HOST_STATE_READ, state 0 !
State = 0x00000000
----------------------------------------------------
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $
Run Python script example
If you do not want to compile the examples. You can run our python script to verify if the driver and the device work.
Download pycifx here.
Extract the sources from the zip-file and go in to pycifx folder.
pi@raspberrypi:~ $ cd pycifx/
pi@raspberrypi:~/pycifx $
run main.py and you should get a similar output
pi@raspberrypi:~/pycifx $ sudo python3 main.py
---------- Display Driver Version ----------
Driver Version: LinuxCIFXDrv V2.1.0.0, based on cifX Toolkit 2.6.0.0
---------- Board/Channel enumeration demo ----------
Found Board cifX0
Alias :
DeviceNumber : 7833000
SerialNumber : 20000
Board ID : 0
System Error : 0
Channels : 2
DPM Size : 65536
- Channel 0
Firmware : PROFINET IO Device
Version : 5.4.0 build 0
Date : 10/18/2021
Device Nr. : 7833000
Serial Nr. : 20000
netX Flags : 0x00000038
Host Flags : 0x00000038
Host COS : 0x00000001
Device COS : 0x00000001
- Channel 1
Firmware : Network Services
Version : 1.0.0 build 0
Date : 10/18/2021
Device Nr. : 7833000
Serial Nr. : 20000
netX Flags : 0x00000038
Host Flags : 0x00000038
Host COS : 0x00000000
Device COS : 0x00000001
----------------------------------------------------
---------- System Device handling demo ----------
System Channel Info Block:
==========================
DPM Cookie : netX
DPM Size : 32768
Device Number : 7833000
Serial Number : 20000
Manufacturer : 1
Production Date : 4395
Device Class : 60
HW Revision : 3
HW Compatibility : 0
License Flags 1 : 0x00000000
License Flags 2 : 0x00000003
LicenseID : 0x0000
LicenseFlags : 0x0000
==========================
System information:
===================
System Error : 0x00000000
DPM Size : 32768
Mailbox size : 124
Device Number : 7833000
Serial Number : 20000
Open Count : 1
===================
System Control Block:
=====================
Command COS : 0x00000000
System Control : 0x00000000
=====================
Waiting 2s to let cifX card calculate CPU load!
System Status Block:
====================
System COS : 0x00000000
System Status : 0x22000001
System Error : 0x00000000
Time since start : 21921
CPU Load [%] : 4.00
====================
System Mailbox State: MaxSend = 16, Pending Receive = 0
Send Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00000000
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
System Mailbox State: MaxSend = 16, Pending Receive = 1
Received Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00000001
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
System Mailbox State: MaxSend = 16, Pending Receive = 0
State = 0x00000000 ->
----------------------------------------------------
Communication Channel Info:
===========================
Device Number : 7833000
Serial Number : 20000
Firmware : PROFINET IO Device
FW Version : 5.4.0 build 0
===========================
Mailbox Size : 1596
Start put/get packet Demo!
Send Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00000000
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
Receive Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00000001
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
IO Demo running <Strg + c> to stop:
Error reading IO Data area!
State = 0x800c0012 -> Device not running (running flag failed)
----------------------------------------------------
--- Read / Write Block Information ---
Read CONTROL Block
01 00 00 00
Write CONTROL Block
Read COMMON Status Block
01 00 00 00
Write COMMON Status Block
Error writing to common status block
State = 0x800a0006 -> Invalid command
Read EXTENDED Status Block
00 00 00 00
Write EXTENDED Status Block
Error writing to extended status block.
State = 0x800a0006 -> Invalid command
----------------------------------------------------
pi@raspberrypi:~/pycifx $