As mentioned earlier, if you have a device with a 64-bit ARM processor (like NanoPi NEO2 with ARM Cortex-A53 (Allwinner H5)), in order to SpyServer worked fine – you need to compile libairspy library for the armhf (ARM hard-float) architecture, because the spyserver itself compiled for the same architecture.

If you have a 32-bit ARM CPU, you can use the previous instruction, but if you have a 64-bit ARM CPU, then when you build according to the official instruction – the libairspy library will compile for the aarch64 architecture and when you connect to spyserver – you will receive Could not acquire the device error.

Installing required libraries

Install the necessary utilities to compile 32-bit libraries on a 64-bit system:

$ sudo apt install build-essential cmake pkg-config gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf

Then proceed to download and build the library libairspy and utilities for SDR-receivers AirSpy mini / R2:

$ wget https://github.com/airspy/airspyone_host/archive/master.zip
$ unzip master.zip
$ rm -f master.zip
$ cd airspyone_host-master/
$ nano -w toolchain-arm32.cmake
  SET(CMAKE_SYSTEM_NAME Linux)
  SET(CMAKE_SYSTEM_PROCESSOR arm)
  SET(TARGET_ABI "linux-gnueabihf")
  SET(CMAKE_C_COMPILER   arm-${TARGET_ABI}-gcc)
  SET(CMAKE_CXX_COMPILER arm-${TARGET_ABI}-g++)
  SET(CMAKE_FIND_ROOT_PATH /usr/arm-${TARGET_ABI})
$ mkdir build
$ cd build/
$ cmake ../ -DINSTALL_UDEV_RULES=ON -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm32.cmake
$ make
$ sudo make install
$ sudo ldconfig
$ cd ../../
$ rm -rf airspyone_host-master/

Then check if the SDR-receiver has been determined:

$ sudo airspy_info
airspy_lib_version: 1.0.9

Found AirSpy board 1
Board ID Number: 0 (AIRSPY)
Firmware Version: AirSpy MINI v1.0.0-rc9-0-ga56adfd 2016-06-12V
Part ID Number: 0x6906002B 0x00000030
Serial Number: 0x061C67DC286C91A3
Supported sample rates:
    6.000000 MSPS
    3.000000 MSPS
Close board 1

Next, try to run this command as a normal user:

$ airspy_info 
airspy_lib_version: 1.0.9
airspy_open() board 1 failed: AIRSPY_ERROR_NOT_FOUND (-5)

If you run this command as a standard user, you receive an AIRSPY_ERROR_NOT_FOUND (-5) error, which means that the user does not have sufficient rights to access the SDR receiver. Let's correct this situation:

$ sudo usermod -a -G plugdev `whoami`

After including the user in the plugdev group, you need to log out and log in again and you can try again:

$ airspy_info
airspy_lib_version: 1.0.9

Found AirSpy board 1
Board ID Number: 0 (AIRSPY)
Firmware Version: AirSpy MINI v1.0.0-rc9-0-ga56adfd 2016-06-12V
Part ID Number: 0x6906002B 0x00000030
Serial Number: 0x061C67DC286C91A3
Supported sample rates:
    6.000000 MSPS
    3.000000 MSPS
Close board 1

Now you can use SDR receiver with normal users rights.

If you have an AirSpy HF+ SDR receiver, you must install the HF+ libraries and utilities in the same way:

$ wget https://github.com/airspy/airspyhf/archive/master.zip
$ unzip master.zip
$ rm -f master.zip
$ cd airspyhf-master/
$ nano -w toolchain-arm32.cmake
  SET(CMAKE_SYSTEM_NAME Linux)
  SET(CMAKE_SYSTEM_PROCESSOR arm)
  SET(TARGET_ABI "linux-gnueabihf")
  SET(CMAKE_C_COMPILER   arm-${TARGET_ABI}-gcc)
  SET(CMAKE_CXX_COMPILER arm-${TARGET_ABI}-g++)
  SET(CMAKE_FIND_ROOT_PATH /usr/arm-${TARGET_ABI})
$ mkdir build
$ cd build/
$ cmake ../ -DINSTALL_UDEV_RULES=ON -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm32.cmake
$ make
$ sudo make install
$ sudo ldconfig
$ cd ../../
$ rm -rf airspyhf-master/

Then check if the SDR receiver has been determined:

$ sudo airspyhf_info 
AirSpy HF library version: 1.4.2

S/N: 0x3652948040D23FD2
Part ID: 0x00000001
Firmware Version: R1.6.1
Available sample rate: 768 kS/s

Next, try to run this command as a normal user:

$ airspyhf_info 
AirSpy HF library version: 1.4.2
No devices attached.

If you run this command as a normal user and you receive error No devices attached, that means that the user does not have enough rights to access the SDR receiver. Since we have already added ourselves to the plugdev group – just try to reconnect the SDR receiver to the USB port. This should help, because when you install the libairspyhf library in the /etc/udev/rules.d/ folder was placed the special rules. And when you reconnect SDR-receiver device, the file /dev/airspyhf-* will be created with special rights for the group plugdev to work with this device.

Installing and configuring SpyServer

Now open the page https://airspy.com/download/ and install SpyServer. To do this, download the file spyserver-arm32.tgz for systems with ARM CPU (Raspberry Pi, ASUS Tinker Board, Odroid, NanoPi NEO, etc.).

$ wget https://airspy.com/downloads/spyserver-arm32.tgz
$ tar zxvf spyserver-arm32.tgz
$ rm -f spyserver-arm32.tgz
$ sudo mv spyserver /usr/local/bin/
$ sudo mv spyserver_ping /usr/local/bin/
$ sed -i 's/\r//g' spyserver.config
$ mkdir -p ~/.config/spyserver
$ mv spyserver.config ~/.config/spyserver/

It is best way to create own configuration file for each device:

$ cp ~/.config/spyserver/spyserver.config ~/.config/spyserver/spyserver.mini.config
$ nano -w ~/.config/spyserver/spyserver.mini.config
bind_host = 0.0.0.0
bind_port = 5555
list_in_directory = 0
maximum_clients = 1
allow_control = 1
device_type = AirspyOne
device_serial = 0x061C67DC286C91A3
minimum_frequency = 24000000
maximum_frequency = 1750000000
initial_gain = 17
enable_bias_tee = 0

Option initial_gain will need later to find experimentally. In the name of the configuration file instead of mini - you can specify any alias, I have myself using aliases mini (AirSpy mini), mini-gain (AirSpy mini for which the Bias-Tee parameter is enabled, since LNA is connected to this SDR receiver), hf (AirSpy HF+), rtl1 (RTL-SDR), rtl2 (RTL-SDR), etc. These aliases will be further used to create services in systemd, for autorun of SpyServer.

Try to start SpyServer and connect to it from SDR#. Everything should work and the output in the console will be like this:

$ spyserver ~/.config/spyserver/spyserver.mini.config
SPY Server v2.0.1700
Copyright (C) 2016-2018 Youssef Touil - https://airspy.com
Reading the configuration file: /home/wakko/.config/spyserver/spyserver.mini.config
Listening for connections on 0.0.0.0:5555
Accepted client 192.168.255.20:52246 running SDR# v1.0.0.1700 on Microsoft Windows NT 6.2.9200.0
Device was sleeping. Wake up!
Acquired an AirspyOne device

Setting up autorun in systemd

Create a service file systemd:

$ sudo nano -w /etc/systemd/system/spyserver@.service
[Unit]
Description=Spy Server
After=network-online.target

[Service]
Type=simple
PAMName=login
Restart=always
RestartSec=2
ExecStartPre=/usr/bin/test -f ${HOME}/.config/spyserver/spyserver.%i.config
ExecStart=/usr/local/bin/spyserver ${HOME}/.config/spyserver/spyserver.%i.config
User=wakko

[Install]
WantedBy=multi-user.target

$ sudo systemctl daemon-reload

Now you can create services for each SDR receiver. As mentioned earlier, the configuration file names for SpyServer contain a device alias that is used to create the appropriate service in systemd. The example below uses a device with a mini alias:

$ sudo systemctl enable spyserver@mini.service
Created symlink /etc/systemd/system/multi-user.target.wants/spyserver@mini.service → /etc/systemd/system/spyserver@.service.
$ sudo systemctl start spyserver@mini.service
$ sudo systemctl status spyserver@mini.service
● spyserver@mini.service - Spy Server
   Loaded: loaded (/etc/systemd/system/spyserver@.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-02-23 13:12:08 MSK; 5s ago
 Main PID: 3245 (spyserver)
   CGroup: /system.slice/system-spyserver.slice/spyserver@mini.service
           ‣ 3245 /usr/local/bin/spyserver /home/wakko/.config/spyserver/spyserver.mini.config

Feb 23 13:12:08 NanoPi systemd[1]: Started Spy Server.
Feb 23 13:12:08 NanoPi systemd[3245]: pam_unix(login:session): session opened for user wakko by (uid=0)

For each device you need to create and run your copy of the service commands:

$ sudo systemctl enable spyserver@alias.service
$ sudo systemctl start spyserver@alias.service
$ sudo systemctl status spyserver@alias.service

Next Post Previous Post