目录
1、安装UHD依赖库及UHD
总结自:USRP Hardware Driver and USRP Manual: Building and Installing UHD from source 以及 Building and Installing the USRP Open-Source Toolchain (UHD and GNU Radio) on Linux - Ettus Knowledge Base
先安装依赖库:
sudo apt-get -y install autoconf automake build-essential ccache cmake cpufrequtils doxygen ethtool fort77 g++ gir1.2-gtk-3.0 git gobject-introspection gpsd gpsd-clients inetutils-tools libasound2-dev libboost-all-dev libcomedi-dev libcppunit-dev libfftw3-bin libfftw3-dev libfftw3-doc libfontconfig1-dev libgmp-dev libgps-dev libgsl-dev liblog4cpp5-dev libncurses5 libncurses5-dev libpulse-dev libqt5opengl5-dev libqwt-qt5-dev libsdl1.2-dev libtool libudev-dev libusb-1.0-0 libusb-1.0-0-dev libusb-dev libxi-dev libxrender-dev libzmq3-dev libzmq5 ncurses-bin python3-cheetah python3-click python3-click-plugins python3-click-threading python3-dev python3-docutils python3-gi python3-gi-cairo python3-gps python3-lxml python3-mako python3-numpy python3-numpy-dbg python3-opengl python3-pyqt5 python3-requests python3-scipy python3-setuptools python3-six python3-sphinx python3-yaml python3-zmq python3-ruamel.yaml swig wget
======================== BUG ========================
如果安装依赖过程中出现一下错误:
The following packages have unmet dependencies: libasound2-dev : Depends: libasound2 (= 1.2.2-2.1ubuntu2.4
可以执行以下命令解决:
sudo dpkg -P --force-depends libasound2 && sudo apt-get -f install
参考链接:
然后下载源代码:
git clone https://github.com/EttusResearch/uhd.git
或者在https://github.com/EttusResearch/UHD/tags里找到想要的版本下载后解压。
接着编译安装源代码,在源代码文件中依次输入以下命令:
cd uhd
cd host
mkdir build
cd build
# 如果想设置UHD的安装位置,则可使用-DCMAKE_INSTALL_PREFIX参数,如:cmake -DCMAKE_INSTALL_PREFIX=/opt/uhd ../ 默认的安装位置为/usr/local/lib
cmake ../
make
make test # This step is optional
sudo make install
之后确认是否定义环境变量LD_LIBRARY_PATH,看该环境变量是否定义了包含安装了UHD的文件夹(若在上述步骤中使用cmake的默认参数,则此处默认为/usr/local/lib),并将该变量添加到.bashrc文件的后面:
#注意替换{your-prefix}为你的UHD的安装路径
export LD_LIBRARY_PATH={your-prefix}/lib:$LD_LIBRARY_PATH
例如:export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
然后是下载 UHD FPGA 镜像文件,当连接USRP时用来烧录
sudo uhd_images_downloader
卸载UHD的方法:
在cd到uhd/host/build文件中输入以下指令即可
sudo make uninstall
2、安装GNU Radio3.9.3
首先是安装依赖:
(不同版本的Ubuntu所需的依赖不尽相同,其他版本的可查看上述链接):
GNU Radio3.8需要以下依赖
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
GNU Radio3.9 除了以上依赖外还需要安装以下依赖:
sudo apt install python3-matplotlib libsndfile1-dev
然后必须先安装 volk 再安装 GNURadio,命令如下,顺序执行一般不会有问题:
cd
git clone --recursive https://github.com/gnuradio/volk.git
cd volk
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
make
make test
sudo make install
接下来开始下载gnuradio的源码进行编译安装:
依次输入以下指令:
git clone https://github.com/gnuradio/gnuradio.git
cd gnuradio
git checkout maint-3.9
git submodule update --init --recursive
mkdir build
cd build
# 如果想设置GNU Radio的安装位置,则可使用-DCMAKE_INSTALL_PREFIX参数,默认的安装位置为/usr/local
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
# 可在终端输入proc指令查询线程数,并替换下面命令中的n,如果直接-j,则只使用单线程
make -jn
sudo make install
sudo ldconfig
======================== BUG ========================
如果安装依赖过程中出现一下错误:
CMake Error at CMakeLists.txt:344 (find_package):
By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "pybind11",
but CMake did not find one.
Could not find a package configuration file provided by "pybind11" with any
of the following names:
pybind11Config.cmake
pybind11-config.cmake
Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
"pybind11_DIR" to a directory containing one of the above files. If
"pybind11" provides a separate development package or SDK, be sure it has
been installed.
可以执行以下命令解决:
sudo apt install pybind11-dev
======================= END ========================
与安装UHD类似,这里还需要在.bashrc文件中添加PYTHONPATH环境变量:
#注意替换{your-prefix}为你的UHD的安装路径
export PYTHONPATH={your-prefix}/lib/{Py-version}/dist-packages:{your-prefix}/lib/{Py-version}/site-packages:$PYTHONPATH
例如:export PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/local/lib/python3/site-packages:$PYTHONPATH
添加完之后还需要执行一次 sudo ldconfig就可以啦~
在命令行中执行以下指令就可以启动gnuradio的gui界面啦~
gnuradio-companion
初始界面如下: