InstallingGRFromSource on Raspberry Pi: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(added ldconfig to Load prerequisites)
(reorganize and update)
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<p>These instructions have been tested with the <q>Raspbian Buster with desktop and recommended software</q> Operating System on a Raspberry Pi 3B+. A 32GB microSD card is recommended.</p>
<!-- InstallingGRFromSource_on_Raspberry_Pi -->
These instructions have been tested with the <q>Raspberry Pi OS (previously called Raspbian) (32-bit) with desktop and recommended software</q> on a Raspberry Pi 3B+. A 32GB microSD card is recommended.


== Load prerequisites ==
== Set up a swap file ==
<p>You may have some of these prerequisites already, but it doesn't hurt to get them again and check for the latest versions.</p>
 
<pre>
A swap file will improve the compile time greatly.
sudo apt-get update --allow-releaseinfo-change
sudo apt-get upgrade
sudo apt-get install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy
sudo apt-get install python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev
sudo apt-get install libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5
sudo apt-get install liblog4cpp5-dev libzmq3-dev python3-yaml
sudo apt-get install libpthread-stubs0-dev
sudo pip3 install click-plugins
sudo apt-get install python3-scipy
sudo ldconfig
</pre>


== Set up a swap file ==
<p>A swap file will improve the compile time greatly.</p>
<pre>
<pre>
sudo fallocate -l 2G /swapfile
sudo fallocate -l 2G /swapfile
Line 29: Line 17:
</pre>
</pre>


== Clone the gnuradio repository ==
== Load prerequisites ==
<p>The gnuradio directory will be built in the home directory. The current maintenance branch is 'maint-3.8'.</p>
 
You may have some of these prerequisites already, but it doesn't hurt to get them again and check for the latest versions.
 
<pre>
sudo apt update --allow-releaseinfo-change
sudo apt upgrade
sudo apt install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy \
python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev \
libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 \
liblog4cpp5-dev libzmq3-dev python3-yaml python3-click python3-click-plugins \
python3-zmq python3-scipy libpthread-stubs0-dev libusb-1.0-0 libusb-1.0-0-dev \
libudev-dev python3-setuptools python-docutils build-essential liborc-0.4-0 liborc-0.4-dev
</pre>
 
== Install UHD from source ==
 
If you want to use GNU Radio with a USRP, install the UHD package from source using the following instructions.
UHD sits at the same level as GNU Radio as an independent driver, which gr-uhd references.  So if you want gr-uhd enabled, you <b>FIRST</b> must clone and install UHD.
 
For this example, we will start in the home directory to parallel the steps in [[InstallingGR#From_Source]].
 
<pre>cd ~/</pre>
 
Clone the code into your home directory:
 
<pre>
git clone git://github.com/EttusResearch/uhd.git
cd ~/uhd
</pre>
 
<b>Note:</b> In the following command, change <code>v3.15.0.0</code> to some other branch or tag if you want to build a different version.
<pre>
<pre>
cd ~/
git tag -l
git clone --recursive https://github.com/gnuradio/gnuradio.git
git checkout v3.15.0.0
git checkout maint-3.8
</pre>
</pre>


== Build ==
<b>Note:</b> Unlike most build processes, UHD builds under the <code>host</code> directory.
<pre>
<pre>
cd ~/gnuradio
cd host
mkdir build
mkdir build
cd build
cd build
</pre>
</pre>
<p>Here are some common cmake flags you may want to use:
 
* <code>-DENABLE_GR_XXX=ON</code> This enables (or disables for =OFF) the GNU Radio component named XXX. You might not need all of them, and this way, you can compile quicker.
<b>Note:</b> In the following command, we will use <code>-DCMAKE_INSTALL_PREFIX=/usr/local</code> to install UHD into the same prefix as GNU Radio. When compiling for ARM platforms, the assumption is made that NEON extensions are available if the arm_neon.h header is found. However, for platforms such as Raspberry Pi, one must specify -DNEON_SIMD_ENABLE=OFF in the following command.
* <code>-DCMAKE_INSTALL_PREFIX=XXX</code> Install your build into XXX.
 
* <code>-DCMAKE_BUILD_TYPE=Debug</code> This causes gcc to add debug symbols to all binaries. Useful for debugging (otherwise, it decreases efficiency!)
* <code>-DPYTHON_EXECUTABLE=/usr/bin/python{2,3}</code> This selects the Python version and executable to be used during build time and will determine which Python libraries will be used for building the Python bindings.<br />
For a list of additional cmake flags, as well as minimum versions of dependencies, see https://www.gnuradio.org/doc/doxygen/build_guide.html</p>
<p>This next 'cmake' command is all on one line, starting with cmake and ending with ../</p>
<pre>
<pre>
cmake -DCMAKE_INSTALL_PREFIX="/usr/local" -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
cmake -DNEON_SIMD_ENABLE=OFF -DCMAKE_INSTALL_PREFIX=/usr/local ../
</pre>
</pre>
<p>The next steps will take two or more hours. Be patient. The terminal does show the progress.</p>
 
<b>Note:</b> In the following command, if your computer's CPU has multiple cores, you can use the argument <code>-j#</code> to speed compilation; <br> e.g., <code>make -j3</code> will use 3 threads in the build. Specify at least one less than the number of CPU cores so the system does not appear to 'freeze' during the build. If not specified, then a single thread is used for the build; this is not necessarily a bad thing, but it will take roughly 2 times as long to build as using 2 threads, and roughly 3 times as long to build as using 3 threads.<br>
 
<pre>
<pre>
make -j3
make -j3
make test
make test
sudo make install
sudo make install
sudo ldconfig
</pre>
</pre>
If you're running Linux, then always do the following command after installing any library:
<pre>sudo ldconfig</pre>
You can now download the UHD FPGA Images for this installation.
<pre>
sudo uhd_images_downloader
</pre>
On Linux, udev handles USB plug and unplug events. The following commands install a udev rule so that non-root users may access the device.
<pre>
cd ~/uhd/host/utils
sudo cp uhd-usrp.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
</pre>
The installation of UHD is now complete. At this point, connect the USRP to the host computer and run:
<pre>
uhd_usrp_probe
</pre>
== Install GNU Radio ==
<b>The next steps will take two or more hours. Be patient. The terminal does show the progress.</b>
Click [[InstallingGR#From_Source]] to go to the install instructions.

Revision as of 11:24, 7 July 2020

These instructions have been tested with the Raspberry Pi OS (previously called Raspbian) (32-bit) with desktop and recommended software on a Raspberry Pi 3B+. A 32GB microSD card is recommended.

Set up a swap file

A swap file will improve the compile time greatly.

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

To make the swap file permanent, add this line to /etc/fstab

/swapfile  none  swap  sw  0  0

Load prerequisites

You may have some of these prerequisites already, but it doesn't hurt to get them again and check for the latest versions.

sudo apt update --allow-releaseinfo-change
sudo apt upgrade
sudo apt install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy \
python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev \
libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 \
liblog4cpp5-dev libzmq3-dev python3-yaml python3-click python3-click-plugins \
python3-zmq python3-scipy libpthread-stubs0-dev libusb-1.0-0 libusb-1.0-0-dev \
libudev-dev python3-setuptools python-docutils build-essential liborc-0.4-0 liborc-0.4-dev

Install UHD from source

If you want to use GNU Radio with a USRP, install the UHD package from source using the following instructions. UHD sits at the same level as GNU Radio as an independent driver, which gr-uhd references. So if you want gr-uhd enabled, you FIRST must clone and install UHD.

For this example, we will start in the home directory to parallel the steps in InstallingGR#From_Source.

cd ~/

Clone the code into your home directory:

git clone git://github.com/EttusResearch/uhd.git
cd ~/uhd

Note: In the following command, change v3.15.0.0 to some other branch or tag if you want to build a different version.

git tag -l
git checkout v3.15.0.0

Note: Unlike most build processes, UHD builds under the host directory.

cd host
mkdir build
cd build

Note: In the following command, we will use -DCMAKE_INSTALL_PREFIX=/usr/local to install UHD into the same prefix as GNU Radio. When compiling for ARM platforms, the assumption is made that NEON extensions are available if the arm_neon.h header is found. However, for platforms such as Raspberry Pi, one must specify -DNEON_SIMD_ENABLE=OFF in the following command.

cmake -DNEON_SIMD_ENABLE=OFF -DCMAKE_INSTALL_PREFIX=/usr/local ../

Note: In the following command, if your computer's CPU has multiple cores, you can use the argument -j# to speed compilation;
e.g., make -j3 will use 3 threads in the build. Specify at least one less than the number of CPU cores so the system does not appear to 'freeze' during the build. If not specified, then a single thread is used for the build; this is not necessarily a bad thing, but it will take roughly 2 times as long to build as using 2 threads, and roughly 3 times as long to build as using 3 threads.

make -j3
make test
sudo make install

If you're running Linux, then always do the following command after installing any library:

sudo ldconfig

You can now download the UHD FPGA Images for this installation.

sudo uhd_images_downloader

On Linux, udev handles USB plug and unplug events. The following commands install a udev rule so that non-root users may access the device.

cd ~/uhd/host/utils
sudo cp uhd-usrp.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger

The installation of UHD is now complete. At this point, connect the USRP to the host computer and run:

uhd_usrp_probe

Install GNU Radio

The next steps will take two or more hours. Be patient. The terminal does show the progress.

Click InstallingGR#From_Source to go to the install instructions.