Ubuntu18.04安装UHD3.15.0.0和GNU Radio3.8

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

posted @ 2020-04-16 15:18  寄生的鱼  阅读(7614)  评论(4编辑  收藏  举报