## Software Setup

In most instances, there are two pieces of software that you will be needing: libUHD and gnuradio. Most package managers have a version of libUHD that is compiled by Ettus for their radio products. At Per Vices, we maintain our own fork of libUHD. This allows for easy interfacing with software devices, and provides some compatibility with USRP devices. For more on these differences, check out our application note on use and operations. While you are unlikely to notice these differences when using the software, you will have to take some care to make sure that the correct (Per vices) version of UHD is what gets installed.

In most instances, there are two pieces of software that you will be needing: libUHD and gnuradio. Most package managers have a version of libUHD that is compiled by Ettus for their radio products. At Per Vices, we maintain our own fork of libUHD that looks and operates similarly with one main exception: it supports the Crimson TNG and Cyan radios that we manufacture. While you likely won’t notice the differences when using the software, you will have to take some care to make sure the correct (Per vices) version is what gets installed.

At run-time, gnuradio compares the version of the UHD library used during compilation with the presently installed version. If there is a difference, it generates an error message. This is most often caused when using a distribution provided version of gnuradio that has been compiled with the Ettus libUHD version. Ensuring that you have correctly installed the Per Vices libUHD version, and then recompiling gnuradio ensures consistency in the library versions and fixes any errors.

##### Figure 8: Overview of libUHD installation process

If you already have gnuradio installed on your host computer, you need to first uninstall it (also uninstall the Ettus libUHD library, if applicable). Next, ensure the Per Vices libUHD version is correctly installed and reboot the computer. Finally, compile and install gnuradio from source.

We use archlinux internally for development and testing. Installing uhd and gnuradio on other distributions may be slightly more challenging.

Note

## Installing libUHD

### Compiling libUHD on archlinux

On github, you will find our releases repositoy with a PKGBUILD file. We can use the makepkg tool that comes with archlinux to build our package

$wget https://raw.githubusercontent.com/pervices/releases/master/scripts/buildarch/libuhdpv/PKGBUILD$ makepkg


During the process, you might be prompted to install dependencies that you don’t already have yet. Once completed, you will see a bunch of binaries under <uhd-compile-dir>/pkg/libuhdpv/usr/bin. To make things easier going forward, consider adding this location to your system path. On bash, this can be done with

echo 'export PATH=$PATH:<uhd-compile-dir>/pkg/libuhdpv/usr/bin >> ~/.bashrc'  ### Building libUHD from source We recommend that you carefully read the UHD build instructions. However, if you are confident that you have all the dependencies, you should be able to successfully install UHD with the following command lines: 1. Download the dependencies: git clone https://github.com/pervices/uhd.git. Once you have downloaded the Per Vices UHD repository, you may want to confirm that you have all the dependencies required. Detailed instructions, including the dependencies, are available here. 2. Enter the host directory: bash$ cd <uhd-repository-directory>/host
$mkdir build$ cd build


3. Run cmake with the appropriate compile flags:

bash
$cmake .. -DCMAKE_INSTALL_PREFIX=/usr/ \ -DPYTHON_EXECUTABLE=/usr/bin/python2 \ -DENABLE_EXAMPLES=ON \ -DENABLE_UTILS=ON \ -DENABLE_TESTS=OFF$ make -j4
$makepkg ...   ### Compiling from source (with help from package manager) If you are committed to using another operating system, then you will want to build gnuradio and uhd from source, however your package manager can be useful for obtaining the necessary dependencies. We suggest installing all gnuradio and uhd dependencies using your distribution package management system, and then actually installing gnuradio and uhd from source. 1. Install all gnuradio and UHD dependencies, but do NOT actually install gnuradio or UHD. • You need to ensure that you have all the required install dependencies. • Though you will try to avoid installing gnuradio or UHD 2. After installing the required dependencies, confirm that you do NOT have any of the following installed; • gnuradio • libgnuradio • libvolk • libuhd • uhd-host 3. If you have previously attempted to install gnuradio or uhd from source, confirm that you do not have any residual files. • Ideally, if you still have the original source directory, you can run ?make uninstall? as root, to delete all the installed files. • The default installation settings see gnuradio installed in /usr/local/{bin,lib…}. Check each of the subdirectories in /usr/src to see whether you have old installation files. The presence of these files WILL cause problems down the road; either move them somewhere else, or delete them. 4. Download the Per Vices UHD driver sources code, and compile and install it. • For compatability, you may want to use the -DCMAKE_INSTALL_PREFIX=/usr cmake flag to install binaries to /usr (this is consistent with most linux distributions). • In order to successfully install the remaining components, you will need to have successfully installed the Per Vices UHD driver. • We recommend confirming that you have installed the correct uhd version, by typing; uhd_find_devices -v and confirming that the version number matches what you expect. 5. Download the gnuradio source code, compile and install it. • The gnuradio application needs to use the systems python interpreter and some accompanying python libraries to run. To ensure that our system can locate these tools, we will need to ensure that the PYTHONPATH and LD_LIBRARY_PATH are properly set. • You can verify that the LD_LIBRARY_PATH is set correctly using sudo ldconfig echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/user/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.profile
echo 'export LD_LIBRARY_PATH=/user/local/lib:$LD_LIBRARY_PATH' >> ~/.profile  ### Compiling from source (no package manager) Once you have installed Per Vices libUHD, you must obtain a version of gnuradio. If you are not familiar with git, make, and various build flow, we suggest you use the latest release. Note You should either clone the repo with git or use the release tarball. It is not necessary to do both. If you are comfortable with git, use these commands: Clone the repo: $ git clone git://github.com/gnuradio/gnuradio.git


Enter the gnuradio directory, and checkout to an appropriate release version. Here, we use v3.7.13.4

$cd gnuradio  Initialize and update the VOLK submodule, ensuring you choose the Initialize and update the VOLK submodule: $ git submodule init
$git pull --recurse-submodules=on origin v3.7.13.4$ git submodule update


Note

After obtaining the sources, you can extract them and enter the relevant source directory, and follow the the official build instructions

If you need to modify the python binary used when running gnuradio, you may attempt to do so using variants of the following sed commands;

#To rename the python binary name across all packages.
$sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env PYTHON_BIN|" \
$(find ./ -name '*.py') \$(find ./ -name 'gnuradio-companion' -o -name 'flow_graph.tmpl')
$sed -i -e "s|#![ ]*/usr/bin/env /usr/bin/python$|#!/usr/bin/env PYTHON_BIN|" \
$(find ./ -name '*.py')  Some particularly helpful CMake flags follow. In this invocation, we use the internal libVolk version - this requires you to have uninstalled the volk version - and also install to /usr. $ cmake .. \
-DPYTHON_EXECUTABLE=$(which python2) \ -DPYTHON_INCLUDE_DIR=$(echo /usr/include/python2*) \
-DPYTHON_LIBRARY=\$(echo /usr/lib/libpython2.*.so) \
-DENABLE_INTERNAL_VOLK=ON \
-DENABLE_GRC=ON \
-DENABLE_GR_WXGUI=OFF \
-DENABLE_GR_QTGUI=ON \
-DCMAKE_INSTALL_PREFIX=/usr \
-Wno-dev ..


Now you all set!