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 /*

29 comments:

  1. Thanks Kevin,

    Excellent write-up!

    Before I lose hours trying to replicate this, do you know if this will work for the RSP1 as well ?
    That's the one I have....

    Regards and 73,
    Hans
    PA3CRZ

    ReplyDelete
    Replies
    1. Hello Hans, yes, it will work on both models of the SDRPlay. And it should only take 15 minutes or so to complete on a moderately powered computer. ;-)

      Delete
  2. Thanks Kevin,

    Couldn't control myself and started to install on Debian 9, but couldn't get it to work yet. Will go back to Debian 8 (Jessie) and retry...

    ReplyDelete
  3. Did you get an error? And if so, what was it and in which script, part 1 or part 2?
    You might need to open script 1 in an editor and remove the two # marks ahead of the two apt-get lines mentioned for debian installs.

    ReplyDelete
    Replies
    1. I retried installing on Debian 9 (which is still in testing, ETA June 17), and everything compiles perfectly (apart from some warnings). However, when I start Cubic the RSP1 is not shown in the devices list.
      In my terminal, i see the following:

      ERROR: thread '9SDRThread' has not terminated in time ! (> 2000 ms)
      SDR enumerator starting.
      SoapySDR init..
      API Version: v0.6.0
      ABI Version: v0.6
      Install root: /usr/local
      Loading modules...
      Available factories...null, remote, sdrplay
      mir_sdr_usb_GetDevices Dev0:vid=1df7 pid=2500 rev=0206 serno=B0001P0004 bus=001 port=004 devAvail=0

      Reporting enumeration complete.
      SDR enumerator done.

      Not too sure about the error, but it looks like SoapySDR does load the plugin for SDRPlay.

      Any suggestions, please ?

      Delete
    2. OK, got it working....
      I had to blacklist some kernel modules in order to have no interference with the RSP1.
      This is specific for the RSP1 as the RSP2 uses unique identification for vid and pid.
      I ended up creating a file in /etc/modprobe.d called blacklist.conf, which contains three lines:

      blacklist sdr_msi3101
      blacklist msi001
      blacklist msi2500

      I know that blacklist.conf is not supposed to be used, and that you should use separate files for the modules you want to blacklist. I haven't even checked (sofar) if all three lines are required, but for now, it works!

      In CubicSDR, my RSP1 is visible, I can select it and I can receive audio, even from my Debian 9 Stretch machine over Nomachine (NX) to my Windows 10 machine.

      Great success !
      And thanks again for starting this topic.

      I had to change the required list of installed software slightly to be able to compile everything on Debian 9.
      Everything in your scripts stays the same, but the prerequisites are slightly different. If you use the next two lines, you'll be able to compile all packages without any problems:

      apt-get install git autoconf gcc g++ make libfftw3-dev zlib1g-dev libpng-dev libjpeg62-turbo-dev libtiff5-dev libexpat1-dev pkg-config

      apt-get install libgtk2.0-dev libglw1-mesa libglw1-mesa-dev freeglut3-dev freeglut3 cmake swig libpulse-dev

      There still is one strange thing, though. If you look into the /usr/local/bin directory at CubicSDR, it is displayed as a shared library. not as an executable.
      It WILL run, however, when you type CubicSDR fro a MATE terminal.

      Regards,
      Hans
      PA3CRZ

      Delete
    3. I had to blacklist the same three modules to get CubicSDR working with the RSP1 also. This under Ubuntu 16.04LTS.

      Delete
    4. I'm still having this problem on 16.04LTS, despite editing blacklist.conf (which already existed) to add those three module names. I note that in my case, when CubicSDR starts up, it only enumerates null and remote, there's no mention of sdrplay. lsusb shows a device with ID 1df7:2500 , which I imagine is the RSP1, but I'm at a loss why it's not even being enumerated. Any ideas?

      Ta, Rupert, GM6HVY

      Delete
    5. Rupert, I'd use modprobe to make sure those kernel modules did not load. You may have a typo in your blacklist. If those modules load, they grab hold of the RSP1 and make it invisible to all other drivers.

      Delete
  4. I have used your script to install on Mint, the Pi3 and the tinker board. the driver from SDRplay dosen't work yet on the pi and the tinkerboard but Cubic
    SDR does come up. here is what I had to run on all to get through the make errors.



    sudo apt-get install libpulse-dev libgtk-3-dev
    sudo apt-get install freeglut3 freeglut3-dev
    sudo apt-get install libxext-dev
    sudo apt-get install libpng-dev
    sudo apt-get install libimlib2-dev
    sudo apt-get install libglew-dev
    sudo apt-get install libxrender-dev
    sudo apt-get install libxrandr-dev
    sudo apt-get install libglm-dev
    sudo apt-get update
    sudo ldconfig
    Still working and will let you know how it turns out.
    Steve O
    N6HTV
    n6htv@n6htv



    ReplyDelete
    Replies
    1. They have a separate driver for the Raspberry pi on the SDRPlay site, did you download the right one?
      I'll be testing on a Pi 3 this weekend.

      Delete
  5. Remember to un comment the 2 lines in script1 for mint,Pi,and tinkerboard.

    I do get the error "unable to locate package libeglwl-mesa".
    running sudo apt-get update is always a good idea after doing a bunch of additions.

    ReplyDelete
    Replies
    1. I think I'm going to modify script 1 and just include the extra two lines by default. A lot of systems don't have the OpenGL libraries by default.

      Delete
  6. With the two lines un-commented out, the scripts and above instructions worked perfectly for me on a fresh install of Ubuntu 16.04LTS. Thanks much!

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Started a fresh install on the Tinker board with the 2 lines included. everything seems to be working with no errors. now to see if CubicSDR sees the SDRplay on startup. Thanks for the scripts as it saves a lot of headaches. PS: be sure to use the PI drivers and not the Linux drivers like I did . LOL...

    ReplyDelete
  9. It is now working on the tinkerboard. CubicSDR saw the SDRplay on startup. now I have to figure out settings so it dosen't do that oscillating thing.

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. adding the blacklist lines did allow my RSP to be recognised in cubicsdr and in gqrx but if I change the i/p sample rate from 2.048Mbps, the entire OS hangs and even ctrl+alt+F1 will not spawn a new session. This is using Linux Mint 18.1 Mate edition, 64 bit. I will try to comment out the added modprobe blacklist lines one by one to see if it fixes the problems, but it is laborious because of having to reboot many times.

    ReplyDelete
  14. Here is a presumably related problem for CubicSDR and OS lockups:

    https://github.com/cjcliffe/CubicSDR/issues/529

    ReplyDelete
    Replies
    1. And more evidence of this catastrophic OS lockup: http://www.sdrplay.com/community/viewtopic.php?t=693

      Delete
  15. Thank you very much and congratulations for the excellent piece of work. I installed on Ubuntu 17.04 flawlessly.

    ReplyDelete
  16. 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.

    goldenslot
    สูตรบาคาร่า

    ReplyDelete
  17. Did anyone get the RSP1 to actually run on the Tinker Board? All I get is a spike in the middle but no real signal.

    ReplyDelete
  18. cheers all, I am trying to get cubicSDR/SDRPlay with my SDRplay 1 working on Orange PI 2+, running armbian version of ubuntu LTS 16.04. I was able to get all cubicSDR complied and running, however can seem to get API SDRPlay driver working, I did fix the black list correctly. Any ideas? Thanks

    ReplyDelete
  19. On a fresh Ubuntu 16.04I followed all the instructions but at the end i get the following messages and my RSP1 is not seen.
    paolo@paolo-VGN-TZ31WN-B:~$ CubicSDR
    Loading:: configuration file '/home/paolo/.CubicSDR/config.xml'

    Audio Device #0 PulseAudio
    Default Output? Yes
    Default Input? Yes
    Input channels: 2
    Output channels: 2
    Duplex channels: 2
    Native formats:
    16-bit signed integer.
    32-bit signed integer.
    32-bit float normalized between plus/minus 1.0.
    Supported sample rates:
    8000hz
    16000hz
    22050hz
    32000hz
    44100hz
    48000hz
    96000hz

    Available vertical sync SwapInterval functions:
    glxSwapIntervalEXT: No
    DRI2SwapInterval: No
    glxSwapIntervalMESA: No
    glxSwapIntervalSGI: No
    No vertical sync swap interval functions available.
    Loaded font 'Bitstream Vera Sans Mono' from '/usr/local/share/cubicsdr/fonts/vera_sans_mono12_0.png', parsed 255 characters.
    Loaded font 'Bitstream Vera Sans Mono' from '/usr/local/share/cubicsdr/fonts/vera_sans_mono16_0.png', parsed 255 characters.
    Loaded font 'Bitstream Vera Sans Mono' from '/usr/local/share/cubicsdr/fonts/vera_sans_mono18_0.png', parsed 255 characters.
    Loaded font 'Bitstream Vera Sans Mono' from '/usr/local/share/cubicsdr/fonts/vera_sans_mono24_0.png', parsed 255 characters.
    Loaded font 'Bitstream Vera Sans Mono' from '/usr/local/share/cubicsdr/fonts/vera_sans_mono27_0.png', parsed 255 characters.
    SDR enumerator starting.
    SoapySDR init..
    API Version: v0.6.0
    ABI Version: v0.6
    Install root: /usr/local
    Loading modules...
    Available factories...null, remote, sdrplay
    driver = sdrplay
    label = Not Found (sdrplay)
    Make device 0

    driver = sdrplay
    label = Not Found (sdrplay)
    Make device 1


    Reporting enumeration complete.
    SDR enumerator done.

    What can I do?

    ReplyDelete
    Replies
    1. NOW IT WORKS!
      I found the directory /etc/modprobe.d
      For me it was not an easy task, since this is my FIRST experience with Ubuntu!
      then I sudo chmod a=rw blacklist.conf
      then, out of prudence, I
      cp blacklist.conf blacklist.conf.old
      and finally added the following to blacklist.conf:
      blacklist sdr_msi3101
      blacklist msi001
      blacklist msi2500
      saved and rebooted, and now it works!
      now i should re-protect blacklist.conf with a chmod, but i'm not sure of the parameters to use.
      CubicSDR works now. I'm on an old centrino, so if i do some other task while listening the audio is clipped, BUT IT WORKS!
      Thanks!

      Delete