usrp b210的环境搭建
我的环境VM14+ubuntu16.04虚拟机
官方文档:https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux
新的ubuntu还需要下最新的cmake和python3
cmake15安装:
1 | wget https://cmake.org/files/v3.15/cmake-3.15.3-Linux-x86_64.tar.gz |
python3更新(后来发现也不用):
1 | wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4rc2.tgz |
2019-9-29在实体ubuntu上安装遇到了问题:gnuradio make的时候报错,make test后发现qa_uhd之后的模块全部失败,网上没有这个问题,我怀疑是我ubuntu python的问题,因为之前pip的时候就报错了,后来找到一条命令ctest -V -R qa_uhd
可以查看报错信息,是import uhd_swig时报错了,然后无解,重装系统。还是同样的问题,这时候我陷入了迷茫,去安装成功的虚拟机看了一遍history,突然发现uhd也是可以git checkout指定版本的,我实体机都是默认安的uhd3.15.0,然后我的gnuradio并不是默认版本,而是自己改成了maint-3.7,而以前虚拟机安的uhd版本是3.14,我怀疑是版本不兼容,重新安装了uhd3.14果然就成功编译了。
在gnuradio make完后又出现了qa_zeromq_sub fail的问题,还好网上有类似问题,pip install zmq后成功解决。
UHD驱动安装
更新源
1 | sudo apt-get update |
安装UHD和GNURADIO的必要环境
1 | 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.13-0v5 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-core 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 libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4 cmake git-core wget libxi-dev gtk2-engines-pixbuf r-base-dev python-tk liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libzmq-dev libzmq1 python-requests python-sphinx libcomedi-dev python-zmq python-setuptools |
到这一步都顺利安装,接着便是安装UHD
1 | cd $HOME |
至此UHD安装完成
下面是官网原始过程,包括了各种查错步骤
1 | cd $HOME |
Next, checkout the desired UHD version. You can get a full listing of tagged releases by running the command:
1 | git tag -l |
Example truncated output of git tag -l:
1 | $ git tag -l |
Note: As of UHD Version 3.10.0.0, the versioning scheme has changed to be a quadruplet format. Each element and version will follow the format of: Major.API.ABI.Patch. Additional details on this versioning change can be found here.
After identifying the version and corresponding release tag you need, check it out:
1 | # Example: For UHD 3.9.5: |
Next, create a build folder within the repository.
1 | cd host |
Next, invoke CMake to create the Makefiles.
1 | cmake ../ |
Next, run Make to build UHD.
1 | make |
Next, you can optionally run some basic tests to verify that the build process completed properly.
1 | make test |
Next, install UHD, using the default install prefix, which will install UHD under the /usr/local/lib folder. You need to run this as root due to the permissions on that folder.
1 | sudo make install |
Next, update the system’s shared library cache.
1 | 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:
1 | export LD_LIBRARY_PATH=/usr/local/lib |
If the LD_LIBRARY_PATH environment variable is already defined with other folders in your $HOME/.bashrc file, then add the line below to the end of your $HOME/.bashrc file to preserve the current settings.
1 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib |
For this change to take effect, you will need to close the current terminal window, and open a new terminal.
At this point, UHD should be installed and ready to use. You can quickly test this, with no USRP device attached, by running uhd_find_devices. You should see something similar to the following.
1 | linux; GNU C++ version 4.8.4; Boost_105400; UHD_003.010.000.HEAD-0-g6e1ac3fc |
下载FPGA images
然后是下载FPGA images,设备运行的时候需要加载,我一开始没有下载就报错了
直接sudo uhd_images_downloader
就行了
下面是官网的下载及查错步骤:
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.
Example ouput for UHD 3.13.3.0:
$ sudo uhd_images_downloader
Images destination: /usr/local/share/uhd/images
Downloading images from: http://files.ettus.com/binaries/images/uhd-images_003.010.003.000-release.zip
Downloading images to: /tmp/tmpm46JDg/uhd-images_003.010.003.000-release.zip
57009 kB / 57009 kB (100%)
Images successfully installed to: /usr/local/share/uhd/images
Example output for UHD 3.13:
$ sudo uhd_images_downloader
[INFO] Images destination: /usr/local/share/uhd/images
[INFO] No inventory file found at /usr/local/share/uhd/images/inventory.json. Creating an empty one.
00006 kB / 00006 kB (100%) usrp1_b100_fw_default-g6bea23d.zip
19484 kB / 19484 kB (100%) x3xx_x310_fpga_default-g494ae8bb.zip
02757 kB / 02757 kB (100%) usrp2_n210_fpga_default-g6bea23d.zip
02109 kB / 02109 kB (100%) n230_n230_fpga_default-g494ae8bb.zip
00522 kB / 00522 kB (100%) usrp1_b100_fpga_default-g6bea23d.zip
00474 kB / 00474 kB (100%) b2xx_b200_fpga_default-g494ae8bb.zip
02415 kB / 02415 kB (100%) usrp2_n200_fpga_default-g6bea23d.zip
05920 kB / 05920 kB (100%) e3xx_e320_fpga_default-g494ae8bb.zip
15883 kB / 15883 kB (100%) n3xx_n310_fpga_default-g494ae8bb.zip
00506 kB / 00506 kB (100%) b2xx_b205mini_fpga_default-g494ae8bb.zip
18676 kB / 18676 kB (100%) x3xx_x300_fpga_default-g494ae8bb.zip
00017 kB / 00017 kB (100%) octoclock_octoclock_fw_default-g14000041.zip
04839 kB / 04839 kB (100%) usb_common_windrv_default-g14000041.zip
00007 kB / 00007 kB (100%) usrp2_usrp2_fw_default-g6bea23d.zip
00009 kB / 00009 kB (100%) usrp2_n200_fw_default-g6bea23d.zip
00450 kB / 00450 kB (100%) usrp2_usrp2_fpga_default-g6bea23d.zip
00142 kB / 00142 kB (100%) b2xx_common_fw_default-g3ff4186b.zip
00460 kB / 00460 kB (100%) b2xx_b200mini_fpga_default-g494ae8bb.zip
00319 kB / 00319 kB (100%) usrp1_usrp1_fpga_default-g6bea23d.zip
00009 kB / 00009 kB (100%) usrp2_n210_fw_default-g6bea23d.zip
11537 kB / 11537 kB (100%) n3xx_n300_fpga_default-g494ae8bb.zip
05349 kB / 05349 kB (100%) e3xx_e310_fpga_default-g494ae8bb.zip
00866 kB / 00866 kB (100%) b2xx_b210_fpga_default-g494ae8bb.zip
[INFO] Images download complete.
安装GNURadio
接下来就是安装GNU
1 | cd $HOME |
启动GNURadio命令:gnuradio-companion
下面是官网的安装及查错步骤:
First, make a folder to hold the repository.
1 | cd $HOME |
Next, clone the repository.
1 | git clone --recursive https://github.com/gnuradio/gnuradio |
Next, go into the repository and check out the desired GNU Radio version.
1 | cd gnuradio |
To checkout the v3.7.13.4 branch:
1 | git checkout v3.7.13.4 |
Or to checkout the maint-3.7 branch:
1 | git checkout maint-3.7 |
Next, update the submodules:
1 | git submodule update --init --recursive ;这里出现了Submodule path 'volk': checked out,不知道什么原因,但似乎不影响之后的步骤 |
Next, create a build folder within the repository.
1 | mkdir build |
Next, invoke CMake to create the Makefiles.
1 | cmake ../ |
Next, run Make to build GNU Radio.
1 | make |
Next, you can optionally run some basic tests to verify that the build process completed properly.
1 | make test |
Next, install GNU Radio, using the default install prefix, which will install GNU Radio under the /usr/local/lib folder. You need to run this as root due to the permissions on that folder.
1 | sudo make install |
Finally, update the system’s shared library cache.
1 | sudo ldconfig |
At this point, GNU Radio should be installed and ready to use. You can quickly test this, with no USRP device attached, by running the following quick tests.
1 | gnuradio-config-info --version |
There is a simple flowgraph that you can run that does not require any USRP hardware. It’s called the dialtone test, and it produces a PSTN dial tone on the computer’s speakers. Running it verifies that all the libraries can be found, and that the GNU Radio run-time is working.
1 | python $HOME/workarea-gnuradio/gnuradio/gr-audio/examples/python/dial_tone.py |
You can try launching the GNU Radio Companion (GRC) tool, a visual tool for building and running GNU Radio flowgraphs.
1 | gnuradio-companion |
If “gnuradio-companion” does not start and complains about the PYTHONPATH environment variable, then you may have to set this in your $HOME/.bashrc file, as shown below.
1 | export PYTHONPATH=/usr/local/lib/python2.7/dist-packages |
运行
UHD和GNU安装好后,插入设备,尝试运行uhd_find_devices,出现了“USB device 2500:0020 无法连接到理想的主机控制器”的报错,我原本以为是设备出了问题,因为官网上似乎说b210的信号是2500:0021,镜像加载也是加载了b200,谷歌了之后发现这是因为usb兼容性的问题,在虚拟机设置的USB控制器里把usb兼容性改为usb3.0后解决了问题
运行正常
最后这里有一点搞不懂
uhd_find_devices和uhd_usrp_probe两个命令加载的FPGA images不一样,前者是b200,后者是b210,不过都正确识别出了b210的设备,目前对这个问题没有头绪。
评论加载中