Update and Install dependnceies
Before building UHD and GNU Radio, you need to make sure that all the dependencies are first installed.
However, before installing any dependencies, you should first make sure that all the packages that are already installed on your system are up-to-date. You can do this from a GUI, or from the command-line, as shown below.
Update:
On Ubuntu systems,run:
sudo apt-get update
Install dependnceies
On Ubuntu 18.04 systems,run:
sudo apt-get -y install git swig cmake doxygen build-essential libboost-all-dev libtool libusb-1.0-0 libusb-1.0-0-dev libudev-dev libncurses5-dev libfftw3-bin libfftw3-dev libfftw3-doc libcppunit-1.14-0 libcppunit-dev libcppunit-doc ncurses-bin cpufrequtils python-numpy python-numpy-doc python-numpy-dbg python-scipy python-docutils qt4-bin-dbg qt4-default qt4-doc libqt4-dev libqt4-dev-bin python-qt4 python-qt4-dbg python-qt4-dev python-qt4-doc python-qt4-doc libqwt6abi1 libfftw3-bin libfftw3-dev libfftw3-doc ncurses-bin libncurses5 libncurses5-dev libncurses5-dbg libfontconfig1-dev libxrender-dev libpulse-dev swig g++ automake autoconf libtool python-dev libfftw3-dev libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77 libsdl1.2-dev python-wxgtk3.0 git libqt4-dev python-numpy ccache python-opengl libgsl-dev python-cheetah python-mako python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev libqwtplot3d-qt5-dev pyqt4-dev-tools python-qwt5-qt4 cmake git wget libxi-dev gtk2-engines-pixbuf r-base-dev python-tk liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq3-dev libzmq5 python-requests python-sphinx libcomedi-dev python-zmq libqwt-dev libqwt6abi1 python-six libgps-dev libgps23 gpsd gpsd-clients python-gps python-setuptools
After installing the dependencies, you should reboot the system.
If the installation of the dependencies without any errors, then you can proceed to build and install UHD and GNU Radio.
安裝UHD3.15.0.0
Make sure that no USRP device is connected to the system at this point.
cd $HOME
mkdir workarea
cd workarea
git clone https://github.com/EttusResearch/uhd
cd uhd
git checkout v3.15.0.0
cd host
mkdir build
cd build
cmake ../
make
make test
sudo make install
sudo ldconfig
Finally, make sure that the LD_LIBRARY_PATH environment variable is defined and includes the folder under which UHD was installed. Most commonly, you can add the line below to the end of your $HOME/.bashrc file:
gedit $HOME/.bashrc
# add the line below to the end of ./bashrc file:
export LD_LIBRARY_PATH=/usr/local/lib
Downloading the UHD FPGA Images
You can now download the UHD FPGA Images for this installation. This can be done by running the command uhd_images_downloader.
sudo uhd_images_downloader
Note: Since this installation is being installed to a system level directory (e.g. /usr/local), the uhd_images_downloader command requires sudo privileges.
Building and installing GNU Radio3.8
GNU Radio version 3.8.x with Python 3 support:
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
Installing GNU Radio
For this example, we will start in the workarea directory; you can, of course, use any directory you wish and the results will be the same.
cd workarea
git clone --recursive https://github.com/gnuradio/gnuradio.git
cd gnuradio
git clone https://github.com/gnuradio/volk.git
# 選擇版本3.8
git checkout maint-3.8
cd volk
git checkout v2.2.1
cd ..
mkdir build
cd build
Note: In the following command, you can use -DCMAKE_INSTALL_PREFIX=XXX to install GNU Radio into the PREFIX XXX; if not specified, then the PREFIX is /usr/local.
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
make -j4 # make -j4 will use 4 threads in the build
make test
sudo make install
sudo ldconfig
set your PYTHONPATH and LD_LIBRARY_PATH. (此步驟很重要,否則會打不開gunradio)
gedit $HOME/.bashrc
# add the line below to the end of ./bashrc file:
export PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/local/lib/python3.6/dist-packages:$PYTHONPATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
After setting these environment variables, you need to do sudo ldconfig again for the Linux dynamic library loader to find the just-installed GNU Radio libraries.
sudo ldconfig
到此就安裝完畢了。
UHD錯誤:
1. 執行make時,最后報錯:
[ 97%] Built target man_page_gzips
Scanning dependencies of target doxygen_docs
[ 98%] Generating documentation with doxygen
/home/nlj/workarea/uhd/host/docs/block_desc_files.dox:12: warning: unable to resolve reference to 'page_nocscript_funcs' for \ref command
/home/nlj/workarea/uhd/host/docs/usrp_b200.dox:48: warning: unable to resolve reference to 'md_fpga' for \ref command
/home/nlj/workarea/uhd/host/build/docs/build.dox:257: warning: Found unknown command '\build'
[ 98%] Built target doxygen_docs
Scanning dependencies of target pyuhd
[ 98%] Building CXX object python/CMakeFiles/pyuhd.dir/pyuhd.cpp.o
[ 98%] Linking CXX shared library libpyuhd.so
[ 98%] Built target pyuhd
Scanning dependencies of target pyuhd_library
[100%] Generating build/timestamp
Traceback (most recent call last):
File "/home/nlj/workarea/uhd/host/build/python/setup.py", line 9, in
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
python/CMakeFiles/pyuhd_library.dir/build.make:64: recipe for target 'python/build/timestamp' failed
make[2]: *** [python/build/timestamp] Error 1
CMakeFiles/Makefile2:4719: recipe for target 'python/CMakeFiles/pyuhd_library.dir/all' failed
make[1]: *** [python/CMakeFiles/pyuhd_library.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
意思大致為:執行python時沒有找到setuptools
查看自己的python版本:
python -V
python3 -V
我是有python2.7.11和python3.6.9兩個版本的,
對於python2.x版本,執行
sudo apt-get install python-setuptools
對於python3.x版本,執行:
sudo apt-get install python3-setuptools
執行第一句時,顯示已經安裝過了,嘗試make還是失敗,故又執行了第二句,再次make時,沒有報錯。
猜測是由於make是使用python3執行的。
安裝GNU Radio3.8時出現的錯誤
執行make時出現以下報錯:
[ 8%] Generating gui/Actions.pyo, gui/Application.pyo, gui/Bars.pyo, gui/BlockTreeWindow.pyo, gui/Config.pyo, gui/Console.pyo, gui/Constants.pyo, gui/Dialogs.pyo, gui/DrawingArea.pyo, gui/Executor.pyo, gui/FileDialogs.pyo, gui/MainWindow.pyo, gui/Notebook.pyo, gui/ParamWidgets.pyo, gui/ParserErrorsDialog.pyo, gui/Platform.pyo, gui/PropsDialog.pyo, gui/StateCache.pyo, gui/Utils.pyo, gui/VariableEditor.pyo, gui/init.pyo, gui/canvas/init.pyo, gui/canvas/block.pyo, gui/canvas/colors.pyo, gui/canvas/connection.pyo, gui/canvas/drawable.pyo, gui/canvas/flowgraph.pyo, gui/canvas/param.pyo, gui/canvas/port.pyo, gui/external_editor.pyo
sh: 1: latex: not found
error: Problems running latex. Check your installation or look for typos in _formulas.tex and check _formulas.log!
sh: 1: dvips: not found
error: Problems running dvips. Check your installation!
[ 8%] Built target pygen_grc_daa41
雖然最后make執行成功,沒有報錯:
[ 99%] Generating trellis_swig0.pyc
[100%] Generating trellis_swig0.pyo
[100%] Built target pygen_gr_trellis_swig_d7c99
[100%] Linking CXX shared module _dtv_swig.so
[100%] Built target dtv_swig
Scanning dependencies of target pygen_gr_dtv_swig_48196
[100%] Generating dtv_swig.pyc
[100%] Generating dtv_swig.pyo
[100%] Built target pygen_gr_dtv_swig_48196
[100%] Linking CXX shared module _trellis_swig1.so
[100%] Built target trellis_swig1
Scanning dependencies of target pygen_gr_trellis_swig_8d07c
[100%] Generating trellis_swig1.pyc
[100%] Generating trellis_swig1.pyo
[100%] Built target pygen_gr_trellis_swig_8d07c
完美主義者想解決此問題請參考我的另一篇博客:GNURADIO 安裝時報錯
即,終端上安裝latex依賴包即可:
sudo apt-get install texlive-latex-recommended
安裝完畢后再執行make,不會再出現此報錯。
關於下載uhd_images_downloader
對於UHD版本>=3.13.1.0,可以使用命令行選項--list-targets --url-only可打印出以下網址 FPGA軟件包:
$ uhd_images_downloader --url-only --list-targets
列出所有的安裝包位置:
UHD3.15.0.0的鏡像文件:uhd_images_download
可使用 wget 獲取FPGA映像:
mkdir ~/fpga_images #創建一個文件夾,將所有的zip包都下載到這個文件夾下
cd fpga_images
wget http://files.ettus.com/binaries/cache/x3xx/fpga-fde2a94eb/x3xx_x310_fpga_default-gfde2a94e.zip
...
將所有的zip包都下載完畢后,解壓到同一個文件夾下:
mkdir ~/images #最后解壓完的文件都在這里
cd ~/fpga_images
unzip -o '*.zip' -d ~/images
接下來,在UHD安裝前綴中創建images/文件夾。
$ cd /usr/local/share/uhd/
$ mkdir images
$ cd images
將上面解壓縮的FPGA映像復制到對應的位置。
$ sudo cp -v ~/images/* .
安裝UHD后出現非root用戶權限的問題
在Linux上,udev處理USB插拔事件。以下命令將安裝udev規則,以便非root用戶可以訪問設備。僅對於使用USB連接到主機的設備(例如B200,B210和B205mini),才需要執行此步驟。此設置應立即生效,不需要重新啟動或注銷/登錄。運行這些命令時,請確保沒有通過USB連接USRP設備。
cd /usr/local/lib/uhd/utils #默認安裝位置
sudo cp uhd-usrp.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
參考鏈接:
Building and Installing the USRP Open-Source Toolchain (UHD and GNU Radio) on Linux
Ubuntu Install GNU Radio
Installing GR
ModuleNotFoundError