User Tools

Site Tools


Sidebar

Go Back

Refresh

You are not allowed to add pages

Direct Link

library:gnuradio:installation

Install GNURadio On Ubuntu 20.04


两种安装方案:

  • 安装编译好的二进制版本。
  • 下载源代码,编译,安装。

1. Install Released Builds GnuRadio Packages

For Ubuntu, the latest builds (both released and pulled from master branch) are maintained as PPAs on launchpad. Be sure to uninstall any previously installed versions of gnuradio first.

1.1 设置最新发行版本路径

$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases

其他版本

其他版本

- To access the latest from the master branch (currently pre 3.9 release), add the gnuradio/gnuradio-master ppa (removing other gnuradio ppas if already configured)

$ sudo add-apt-repository ppa:gnuradio/gnuradio-master

- To access the 3.7 released version (legacy), add the gnuradio/gnuradio-releases-3.7 ppa (removing other gnuradio ppas if already configured)

$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.7

1.2 更新和安装

$ sudo apt-get update
$ sudo apt install gnuradio

参考:https://wiki.gnuradio.org/index.php/InstallingGR

或先下载,后安装

$ apt-get update
$ apt-get download gnuradio                                  # Download package
$ sudo apt-get -f -y install
$ sudo dpkg -i gnuradio_3.8.2.0-0~gnuradio~focal-2_amd64.deb # Install package, package name may be different.

1.3 Modtool on Ubuntu ( Only for Ubuntu 18 or earlier)

NOTE: On released builds for Ubuntu 18 (bionic), there is an issue using gr_modtool after GNU Radio has been installed from the PPA. This is due to byte-compiled code that remains in the modtool templates after installation. To workaround this issue:

$ cd /usr/share/gnuradio/modtool/templates/gr-newmod
$ sudo py3clean .

This issue does not appear for Ubuntu 19 and later packages

Check Ubuntu version

$ cat /proc/version
inux version 5.4.0-42-generic (buildd@lgw01-amd64-038) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020

# linux内核版本号 : 5.4.0-42
# gcc编译器版本号 : 9.3.0
# Ubuntu 版本号   : 9.3.0-10ubuntu2

1.4 Run GNURadio

$ gnuradio-companion

2. 编译安装GNURadio

2.1 删除已安装的GNURadio旧版本(首次安装跳过)

sudo apt-get autoremove gnuradio

2.2 Installing Dependencies

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 python3-gi python3-gi-cairo gobject-introspection gir1.2-gtk-3.0
sudo apt install pybind11-dev python3-matplotlib libsndfile1-dev

2.3 Installing Volk

VOLK(Vector Optimized Library of Kernels)已从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
sudo ldconfig

2.4 Installing GNU Radio

安装pip3

sudo apt install python3-pip

安装pygccxml

pip3 install pygccxml

下载安装GNURadio代码

cd
git clone https://github.com/gnuradio/gnuradio.git
cd gnuradio
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
make

Note: In the following command, it is very possible that not all tests pass. Generally any error is a sign of a missing dependency such as the Python interface to ZMQ or NumPy or SciPy, none of which are required for building GNU Radio but are required for testing.

  make test
  sudo make install

Again, if you're running Linux, then always remember to do the following command after installing any library:

  sudo ldconfig

可能出现的问题及解决方法

  • Unordered List Item缺少Python包
User set python executable /usr/bin/python3
Python checking for numpy - found
Python checking for pygccxml - not found
......

处理

sudo apt install python3-pip
pip3 install pygccxml
  • VOLK required but not found
cd build
git pull --recurse-submodules=on
git submodule update --init

2.5 Setting Envirments

A. Determine the GNU Radio install prefix

If you don't know or remember your installation prefix, perform the following step:

  on a terminal screen, enter gnuradio-config-info --prefix

then use that prefix in place of {your-prefix} in the following commands.

B. Finding the Python library

Using a terminal, enter the following command, substituting the prefix you found above in place of {your-prefix}:

find {your-prefix} -name gnuradio | grep “packages”

Put the appropriate paths it found into the export commands below. Note that the paths are separated by colons : export PYTHONPATH={your-prefix}/lib/{Py-version}/dist-packages:{your-prefix}/lib/{Py-version}/site-packages:$PYTHONPATH

C. Setting PYTHONPATH

- For almost all Debian / Ubuntu (and derivative) systems, and most other 32-bit Unix/Linux systems, the paths will look like this:

export PYTHONPATH={your-prefix}/lib/{Py-version}/dist-packages:{your-prefix}/lib/{Py-version}/site-packages:$PYTHONPATH

- For other 64-bit systems, the paths will look like this:

export PYTHONPATH={your-prefix}/lib64/{Py-version}/site-packages:$PYTHONPATH

example:

export PYTHONPATH={/usr/local/lib/python3/dist-packages:/usr/local/lib/python3/site-packages:$PYTHONPATH

D. Setting LD_LIBRARY_PATH

- For almost all Debian / Ubuntu (and derivative) systems, and most other 32-bit Unix/Linux systems, use:

export LD_LIBRARY_PATH={your-prefix}/lib:$LD_LIBRARY_PATH

- For other 64-bit systems, use:

export LD_LIBRARY_PATH={your-prefix}/lib64:$LD_LIBRARY_PATH

Example:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

E. Store the commands in a Bash start-up file

Once you have determined the correct two export commands to use, open your text editor and put them in your ~/.bash_aliases or ~/.bashrc or ~/.profile file. Save the file. On your terminal enter exit. Then start a new terminal. As an example, your entries might be:

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

F. 运行GNURadio

gnuradio-companion

启动GNURadio GUI。

2.6 安装 RTL2832U驱动

1) 安装依赖包libusb-1.0-0.dev

sudo apt-get install libusb-1.0-0.dev

2) 安装驱动

cd
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
sudo make install
sudo ldconfig
sudo cp ../rtl-sdr.rules /etc/udev/rules.d/

3) 删除内核中的冲突模块 添加文件 /etc/modprobe.d/no-rtl.conf 移除dvb相关驱动,文件内容:

  blacklist dvb_usb_rtl28xxu
  blacklist rtl2832
  blacklist rtl2830

4) 重启Ubuntu,插入RTL-SDR接收机 5)测试

sdr@ubuntu:~$ sudo rtl_test -t
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7
 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0
 49.6 
[R82XX] PLL not locked!
Sampling at 2048000 S/s.
No E4000 tuner found, aborting.

RTL-SDR工作正常。

2.7 在GNURadio中添加Osmocom功能块

方法1(已在vmware中验证)

sudo apt install librtlsdr-dev
sudo apt-get install gr-osmosdr

方法2(未验证)

sudo apt install librtlsdr-dev
cd
git clone git://git.osmocom.org/gr-osmosdr
cd gr-osmosdr
git checkout gr3.8

mkdir build
cd build/
cmake ../

make 
sudo make install
sudo ldconfig

启动GUI(命令 gnuradio-companion),在右侧模块列表中确认存在[OsmoSDR]模块分组,及模块分组内存在 osmocom Sink/osmocom Source/RTL-SDR Source等模块

× 问题
1) 在GUI中没有RTL输入模块
检查用户环境(.profile),是否正确设置

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

具体路径按实际安装路径。

3. Installation Script Example

3.1 For Ubuntu 18.04

An easy way to install GNU Radio 3.8 on many Ubuntu systems is to use the following commands (note that this skips the setup for UHD hardware):

  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 python3-pip python3-gi-cairo
  pip3 install git+https://github.com/pyqtgraph/pyqtgraph@develop
  pip3 install numpy scipy
  echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc
  echo 'export LD_LIBRARY_PATH=/user/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
  echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.profile
  echo 'export LD_LIBRARY_PATH=/user/local/lib:$LD_LIBRARY_PATH' >> ~/.profile
  cd ~/
  git clone --recursive https://github.com/gnuradio/gnuradio
  cd gnuradio
  git checkout maint-3.8
  mkdir build
  cd build
  git pull --recurse-submodules=on
  git submodule update --init
  cmake -DENABLE_GR_UHD=OFF ..
  make -j $(nproc --all)
  sudo make install
  sudo ldconfig

Once this is done, reboot your computer and GNU Radio should be all set for you.

4. RTL-SDR

4.1 下载,编译和安装 RTL2832U Osmocom 驱动

安装依赖包libusb-1.0-0.dev
sudo apt-get install libusb-1.0-0.dev

安装驱动

cd
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
sudo make install
sudo ldconfig
sudo cp ../rtl-sdr.rules /etc/udev/rules.d/

删除内核中的冲突模块
sudo rmmod dvb_usb_rtl28xxu rtl2832

测试驱动
sudo rmmod dvb_usb_rtl28xxu rtl2832

重启 Ubuntu,插入RTL-SDR
测试

sudo rtl_test -t

 " 来测试 librtlsdr 库是否安装成功。如果出现以下内容,则表明安装成功,否则需要重新编译、安装。

cd

git clone git:git.osmocom.org/gr-osmosdr cd gr-osmosdr/ mkdir build cd build/ cmake ../ Found 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001 Using device 0: Generic RTL2832U OEM Found Rafael Micro R820T tuner Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 [R82XX] PLL not locked! Sampling at 2048000 S/s. No E4000 tuner found, aborting. Found 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001 Using device 0: Generic RTL2832U OEM Kernel driver is active, or device is claimed by second instance of librtlsdr. In the first case, please either detach or blacklist the kernel module (dvb_usb_rtl28xxu), or enable automatic detaching at compile time. usb_claim_interface error -6 Failed to open rtlsdr device #0. 驱动错误: sdr@ubuntu:~$ sudo rtl_test [sudo] password for sdr: Found 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001 Using device 0: Generic RTL2832U OEM Kernel driver is active, or device is claimed by second instance of librtlsdr. In the first case, please either detach or blacklist the kernel module (dvb_usb_rtl28xxu), or enable automatic detaching at compile time. usb_claim_interface error -6 Failed to open rtlsdr device #0. 解决方法:
1) 添加文件 /etc/modprobe.d/no-rtl.conf 移除dvb相关驱动,文件内容: <code> blacklist dvb_usb_rtl28xxu blacklist rtl2832 blacklist rtl2830 </code> 2) 重启 3) 测试 sdr@ubuntu:~$ sudo rtl_test -t Found 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001 Using device 0: Generic RTL2832U OEM Found Rafael Micro R820T tuner Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 [R82XX] PLL not locked! Sampling at 2048000 S/s. No E4000 tuner found, aborting. 在文件中写入: blacklist dvb_usb_rtl28xxu blacklist rtl2832 blacklist rtl2830 二、编译、安装 osmocom GNU Radio Blocks 注意: 在编译 osmocom GNU Radio Blocks(下文简称为 block) 之前,需要确保关于 RTL-SDR 的所有的依赖项都已安装(就是 librtlsdr 库)。 编译 osmocom GNU Radio Blocks 需要依赖首先安装最新的 gnuradio(如果是编译 master 分支,gnuradio 版本需 >= v3.7;如果编译 gr3.6 分支,gnuradio 版本需为 3.6.5 )。 在从 git 上下载和编译新版本的 block 之前,如果已经安装了其它版本需要首先运行 “make uninstall”来卸载该版本。 git clone git:
git.osmocom.org/gr-osmosdr

cd gr-osmosdr/
mkdir build
cd build/
cmake ../  

make 
sudo make install
sudo ldconfig


To be able to open the device without root permissions add yourself to the "dialout" group or do a "chmod 666 /dev/ttyUSB0" after pluggin in.
rtl_test
sdr@xinsi-HP-ZBook-15:/dev$ rtl_test

Found 1 device(s):

0:  , , SN: 

Using device 0: Generic RTL2832U OEM usb_open error -3 Please fix the device permissions, e.g. by installing the udev rules file rtl-sdr.rules Failed to open rtlsdr device #0.

sudo usermod -G plugdev sdr

sdr@xinsi-HP-ZBook-15:~$ rtl_test Found 1 device(s):

0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM Found Rafael Micro R820T tuner Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 [R82XX] PLL not locked! Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode…

安装:

安装gnuradio

sudo apt-get install gnuradio

添加rtl-sdr的源(懒得编译了)

sudo add-apt-repository ppa:dobey/osmosdr-dailies sudo apt-get update sudo apt-get install rtl-sdr

添加qgrx(一个不错的rtl-sdr GUI前端)的源 (详见http://gqrx.dk/)

sudo add-apt-repository ppa:gqrx/releases sudo apt-get install gqrx

5. Q&A

5.1 MPIR

pip3 install gmpy

sudo apt-get install texinfo
sudo apt install yasm

git clone git://github.com/wbhart/mpir.git mpir
cd mpir
autogen.sh
./configure --enable-gmpcompat --with-yasm=/usr/bin/yasm
make
make check
sudo make install
sudo ldconfig
library/gnuradio/installation.txt · Last modified: 2022/05/02 00:32 (external edit)