USRP B210 LINUX环境搭建

第一次接触USRP B210,搭建开发环境就废了好大的劲,来来回回折腾好了几遍,多亏软件部的同事帮忙,总算把环境搭建好了。这里简单的记录一下,虽然出现的错误忘记怎么解决了,但是大概的流程还是简单记录下。

https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux 不得不说官网的资料很给力!

一 、UHD和GNURADIO驱动安装

驱动的安装全是看官网资料一步一步进行的,出现错误的时候都是在网上搜到哦的解决方法。

1)On Ubuntu systems, run:

   sudo apt-get update
2)Once the system has been updated, then install the required dependencies for UHD and GNU Radio.
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

After installing the dependencies, you should reboot the system.

If the installation of the dependencies completes without any errors, then you can proceed to build and install UHD and GNU Radio.


3)Building and installing UHD from source code

Make sure that no USRP device is connected to the system at this point.

First, make a folder to hold the repository.

   cd $HOME
   mkdir workarea-uhd
   cd workarea-uhd

Next, clone the repository and change into the cloned directory.

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

Next, checkout the desired UHD version. You can get a full listing of tagged releases by running the command:
   git tag -l

Example truncated output of git tag -l:

$ git tag -l
...
release_003_009_004
release_003_009_005
release_003_010_000_000

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:

 
   # Example: For UHD 3.9.5:
   git checkout release_003_009_005

   # Example: For UHD 3.10.1.0: 
   git checkout release_003_010_001_000

Next, create a build folder within the repository.

   cd host
   mkdir build
   cd build

Next, invoke CMake to create the Makefiles.

 cmake ../

Next, run Make to build UHD.

   make

Next, you can optionally run some basic tests to verify that the build process completed properly.

 sudo make install
注意:有的测试会出现failed,这个时候忽略就行了。

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.

    sudo make install

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:
      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.
     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

完成之后可以在linux终端输入:uhd_fnd_devices,
没有连接板子的时候会出现
linux; GNU C++ version 4.8.4; Boost_105400; UHD_003.010.000.HEAD-0-g6e1ac3fc

No UHD Devices Found
连接上板子出现:
linux; GNU C++ version 5.4.0 20160609; Boost_105800; UHD_003.010.001.HEAD-0-g929e3b32

-- Loading firmware image: /usr/local/share/uhd/images/usrp_b200_fw.hex...
--------------------------------------------------
-- UHD Device 0
--------------------------------------------------
Device Address:
    type: b200
    name: 2000501894069
    serial: 30AA045
    product: B210


4)Building and installing GNU Radio from source code

Make sure that no USRP device is connected to the system at this point.

First, make a folder to hold the repository.

   cd $HOME
   mkdir workarea-gnuradio
   cd workarea-gnuradio

Next, clone the repository.
   git clone --recursive https://github.com/gnuradio/gnuradio

Next, go into the repository and check out the desired GNU Radio version.

   cd gnuradio
   git checkout v3.7.10.1

Next, create a build folder within the repository.

   mkdir build
   cd build

Next, invoke CMake to create the Makefiles.
   cmake ../

Next, run Make to build GNU Radio.
   make

Next, you can optionally run some basic tests to verify that the build process completed properly.

   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.

sudo make install

Finally, update the system's shared library cache.

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.

gnuradio-config-info --version
   gnuradio-config-info --prefix
   gnuradio-config-info --enabled-components

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.

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.
   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.
export PYTHONPATH=/usr/local/lib/python2.7/dist-packages

当没有连接板子的时候,运行含有uhd usrp的模块会出现:
RuntimeError: LookupError: KeyError: No devices found for ----->
Empty Device Address

连接上板子之后,会出现正常的运行结果。








你可能感兴趣的:(USRP)