Saturday, June 3, 2017

Step by step install of the SDRPlay RSP2 under Ubuntu 16.04 and other debian based linux.


    The SDRPlay RSP2 is an excellent bit of kit.   A highly sensitive SDR with multiple antenna inputs,  input filtering, 10 Mhz bandwidth, and a range from 2Ghz all the way down to 1Khz.   On the windows side, they provide a very nice SDR program called SDR uno.

   Those of us not running windows, however, have a few choices in software.   GQRX is a popular program, built on GNU-radio.  There's a couple of others that escape my mind, but the newcomer, CubucSDR, is starting to stand out.


   After much searching and experimenting,  I have come up with a list of steps that will build and install the needed support frameworks and software to get you up and running with CubicSDR and your SDRPlay.  
CubicSDR manual is here, worth reading through, you might get confused in the software without it.
http://cubicsdr.readthedocs.io/en/latest/index.html

    There are a few software packages that are needed for the SDRPlay to work.   SoapySDR is a framework for talking to several SDR hardware types, Cubic relies on it.   We'll also need the specific soapy module for the SDRPlay, and a few other packages needed to build cubic.

   I have created two scripts that largely automate the installation.   You can download them using the following link:

                    Click to download. Let me know if this link is broken.


And here's a video where I talk about this whole project.


  Now, the instructions.

   You will need to create a folder on your desktop named 'sdrplay' and put these script files there. You will also need to download the driver for linux from the SDRPlay site and also place it in that folder.  Do not install it yet!

   Open a terminal and change into your newly created directory with the command:

cd ~/Desktop/sdrplay

    Now, you can run the first script.  This will install build software from ubuntu's repositories, along with dependencies needed by the packages we will be building.   It will also clone sever github projects, including soapySDR and CubicSDR.

   The script MUST be run as root, so use sudo to execute it:

sudo ./Install_script-pt1.sh

   It will take awhile and will ask you to type 'y' once for the installs.   Once it's completed,  you will need to run the installer from the SDRPlay site.  Again, you need to make sure you run their script as root with sudo.  If it's not executable,  you can run:

sudo chmod +x ./{scriptname}

(where {scriptname} is the name of the downloaded file)

It will show you a license agreement you need to spacebar through and hit 'y' to accept.

   After their script is done, you can run the install script part two, again with sudo:

sudo ./Install_script-pt2.sh

  This one will also take awhile while building CubicSDR.   Once done, you should be all ready to go!   CubicSDR won't automatically be added to any menus, you'll have to do that yourself.  You can also run it from within the terminal by simply typing CubicSDR.    If you had the SDRPlay plugged in during this installation,  unplug it for a few seconds and then plug it back in.  When you run Cubic, it should find the unit and list it for selection.

ADDENDUM:  These scripts also work on the raspberry Pi 3 with the current version of raspian.  Obviously you need to download the raspberry pi version of the hardware driver from the SDRPlay site.  
There's just one extra step to get pulse audio working under raspian.   You need to modify one of the autostart scripts.
In a terminal,  type:

sudo pico /etc/xdg/autostart/pulseaudio.desktop

Scroll down and find the line:

Exec=start-pulseaudio-x11

Change that line to:

Exec=/bin/sh -c "Sleep 5; start-pulseaudio-x11"

Ctrl-o to write the changes,  Ctrl-x to exit.  Now reboot the pi and the pulse audio server will start.  This probably fixes other things that rely on pulse as well.

Have fun!

Kevin,  KB9RLW

The scripts are pasted below.  you can follow through their steps manually with copy/paste into your terminal. (don't forget sudo).  Or you can copy each in it's entirety and paste it into an editor, save it, mark it as executable and then run it.

#/*    script 1 below /*

#! /bin/bash
# This script should install and build all needed stuff for
# using the SDRPlay on Ubuntu 16.04 or later.  It must be
# run as root.
#
# First we install needed dependancies.

apt-get install git build-essential automake cmake g++ swig
apt-get install libgtk2.0-dev libpulse-dev libpython-dev python-numpy.
apt-get install mesa-utils libeglw1-mesa libglw1-mesa-dev
apt-get install freeglut3-dev freeglut3

# Now we'll git the projects we need

git clone https://github.com/jgaeddert/liquid-dsp
wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.0/wxWidgets-3.1.0.tar.bz2
tar -xvjf wxWidgets-3.1.0.tar.bz2
git clone https://github.com/pothosware/SoapySDR.git
git clone https://github.com/pothosware/SoapySDRPlay.git
git clone https://github.com/pothosware/SoapyRemote.git
git clone https://github.com/cjcliffe/CubicSDR.git

# Build liquid-dsp

cd liquid-dsp
./bootstrap.sh
./configure --enable-fftoverride
make -j4
make install
ldconfig
cd ..

# Build wxwidgets

cd wxWidgets-3.1.0/
mkdir -p ~/Develop/wxWidgets-staticlib
./autogen.sh
./configure --with-opengl --disable-shared --enable-monolithic --with-libjpeg --with-libtiff --with-libpng --with-zlib --disable-sdltest --enable-unicode --enable-display --enable-propgrid --disable-webkit --disable-webview --disable-webviewwebkit --prefix=`echo ~/Develop/wxWidgets-staticlib` CXXFLAGS="-std=c++0x" --with-libiconv=/usr
make -j4
make install
cd ..

echo "."
echo "First part of installation done.   Now run the SDRPlay file you"
echo "downloaded from their site.  Be sure to use sudo to run it!"

#/* end of script 1 /*


#/* script 2 below /*

#! /bin/bash
# This script should install and build all needed stuff for
# using the SDRPlay on Ubuntu 16.04 or later.  It must be
# run as root.
#
# This is part two.
# Here we build SoapySDR

cd SoapySDR
mkdir build
cd build
cmake ..
make -j4
make install
ldconfig
cd ..
cd ..

# Now we build the SDRPlay module for Soapy

cd SoapySDRPlay
mkdir build
cd build
cmake ..
make
make install
cd ..
cd ..

# And we build SoapyRemote

cd SoapyRemote
mkdir build
cd build
cmake ..
make
make install
cd ..
cd ..

# And finally,  we build Cubic.  This takes awhile!

cd CubicSDR
mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release -DwxWidgets_CONFIG_EXECUTABLE=~/Develop/wxWidgets-staticlib/bin/wx-config
make
make install
cd ..
cd ..
rm -R ~/Develop

# now we change permissions on these root-owned folders so the user can
# delete them at their leisure.

chmod -R 0777 ./*

# And we're done.   Cubic should work with the SDRPlay.  The user can
# run it from the terminal with CubicSDR or add this command to a menu.

#/* end of script 2 /*