Gnuradio + UHD + OpenBTS 软件无线电平台搭建

环境

ubuntu 16.04 (14.04)

ubuntu 18 版本在后面会在装 OpenBTS 时因为 python-software-properties 依赖的问题卡住

换源并更新软件源

/etc/apt/sources.list 路径下

11

推荐使用清华的源,旁边也有自动选择最快的服务器的选项

如果是在终端下进行换源则别忘了更新

sudo apt-get update

Gnuradio

GNURadio 安装包下载地址 https://www.gnuradio.org/releases/gnuradio/

选择 tar.gz 格式的安装包,这里我选用的是 Gnuradio3.7.9 可用 wget 下载

1、安装各种依赖库(可能不限于下面这些库)

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 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-wxgtk2.8 git-core libqt4-dev python-numpy ccache python-opengl libgsl0-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 libzmq1 libzmq-dev python-requests python-sphinx libcomedi-dev python-sip \pkg-config libxrender-dev python-sip-dev \libqt4-opengl-dev
1
2
3
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install python-wxgtk2.8

2、进入安装包下载目录,并将安装包解压到 /usr/local/ 目录下(root 模式)

1
2
3
4
5
6
7
8
9
10
tar -zxvf gnuradio.3.7.9.tar.gz -C /usr/local
cd /usr/local/gnuradio-3.7.9/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
#安装完毕输入
sudo gnuradio-companion #启动Gnuradio

3、如果想省事的话,可以直接

1
sudo apt-get install gnuradio

UHD 安装

UHD 我使用的是 release_003_009_005 ,可能因为 uhd 在3.10 左右的版本做的一个改动会导致在编译 OpenBTS ./build.sh B210 时无法进行下去

1、仅当需要连接真实 USRP 硬件设备时,才需要安装 UHD 固件

2、从 Ettus Research 官网下载适合的 UHD release版本

http://github.com/EttusResearch/UHD/tags

3、安装一些库

1
sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-mako doxygen python-docutils cmake build-essential

4、将下载好的 UHD release 放到某个路径 下面

1
2
3
4
5
6
7
cd <path>/host
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldcnfig

5、安装完成,下载 UHD 固件,可以使用自带的脚本下载对应的固件

1
2
cd /usr/local/lib/uhd/utils
sudo ./uhd_images_downloader.py

若出现 ImportError: No module named requests

这时安装 requests

1
pip install requests

若显示 pip 尚未安装,则西安安装 pip,再安装 requests

1
2
sudo apt install python-pip
pip install requests

安装完毕接着执行

1
2
3
4
5
sudo ./uhd_images_downloader.py
...
...
#提示如下
Images successfully installed to:/usr/local/share/uhd/images

连接真实 USRP 硬件后, 在终端键入 uhd_find_devices 会显示当前链接的 USRP 的参数,说名 UHD 安装成功

3

OpenBTS 安装

1、安装依赖

1
sudo apt-get install software-properties-common python-software-properties git

2、下载源码

1
2
3
4
5
6
mkdir openbts && cd openbts
git clong https://github.com/RangeNetworks/dev.git
cd dev
./clone.sh
./switchto.sh master #选择分支
./build.sh B210 #编译

3、./build.sh B210 可能会遇到一些问题

libzmq5 unable to install

​ *原因:OpenBTS对Ubuntu 16.04的支持导致某些依赖版本较高

​ *解决方法:把 build.sh 中的 libzmq5 改成 libzmq3,重新执行 ./build.sh B210

openbts boost/config.hpp: No such file or directory

​ *解决方法:sudo apt-get install libboost-dev

‘class uhd::rx_Streamer’ has no member named ‘issue_stream_cmd’, ‘class uhd::tx_Streamer’ has no member named ‘recv_async_msg’

​ *解决方法:安装Ettus Ubuntu PPA中的libuhd-dev libuhd003 uhd-host

1
2
3
sudo add-apt-repository ppa:ettusresearch/uhd
sudo apt-get update
sudo apt-get install libuhd-dev libuhd003 uhd-host

/usr/bin/ld: cannot find -lboost_system

解决方法:sudo ldconfig
备用方法:sudo apt-get install libboost-system1.54-dev

4、安装

1
2
cd BUILDS
sudo dpkg -i [编译成功时间]/*.deb
1
2
3
a.建议先安装依赖deb包(liba53, libcoredumper),接下来安装应用deb包(range-asterisk, sipauthserve, smqueue, openbts),最后安装配置deb包(range-asterisk-config, range-configs)
b.若配置deb包的配置文件与已安装应用配置文件冲突,选择配置deb包的文件
c.如遇依赖问题,无法安装某些deb包,使用 sudo apt-get -f install

5|、启动/停止 OpenBTS

1
2
3
4
sudo start/stop sipauthserve
sudo start/stop smqueue
sudo start/stop openbts
sudo start/stop asterisk

12

发现 ubuntu 不再支持 upstart 的启动管理方式了

于是用 systemctl 启动

13

发现缺少 .service 文件

openbts_systemd_scripts

解压后将其中 systemd 中的四个 .service 文件复制到 /etc/systemd/system/

然后 openbts-cli.shopenbts-start.shopenbts-stop.sh 三个文件分别为客户端,启动服务,停止服务的执行脚本

10

可以看后四项服务的 PID 则说明服务已启动

6、OpenBTS 控制终端

1
2
3
cd /OpenBTS
#sudo ./OpenBTS
sudo ./OpenBTSCLI #OpenBTSCLI 需要 OpenBTS 先行启动

注意事项

-必须采用 su 用户才可以 open USB 之后再运行 uhd_usrp_probe 成功烧写固件和 FPGA

-OpenBTS及asterisk等应用默认开机启动,若系统安装其他GSM相关应用,如gr-gsm,注意sudo stop openbts,避连接B210时冲突

-若uhd_usrp_probe或sudo ./OpenBTSCLI提示无设备,拔插再试

-本实验中使用的 B210 的 USB 接口是3.0,所以虚拟机 USB 兼容性设为 3.0

1

-若在开放注册的时候出现下图警告,则需要调整增益,将 RxGain 降低

9

设备连接以及固件烧录过程如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
hengyud@ubuntu:/OpenBTS$ sudo -i
root@ubuntu:~# uhd_find_devices
linux; GNU C++ version 5.4.0 20160609; Boost_105800; UHD_003.009.005-0-unknown

--------------------------------------------------
-- UHD Device 0
--------------------------------------------------
Device Address:
type: b200
name: MyB210
serial: 30F7D88
product: B210


root@ubuntu:~# uhd_usrp_probe
linux; GNU C++ version 5.4.0 20160609; Boost_105800; UHD_003.009.005-0-unknown

-- Detected Device: B210
-- Loading FPGA image: /usr/local/share/uhd/images/usrp_b210_fpga.bin... done
-- Operating over USB 3.
-- Detecting internal GPSDO.... No GPSDO found
-- Initialize CODEC control...
-- Initialize Radio control...
-- Performing register loopback test... pass
-- Performing register loopback test... pass
-- Performing CODEC loopback test... pass
-- Performing CODEC loopback test... pass
-- Asking for clock rate 16.000000 MHz...
-- Actually got clock rate 16.000000 MHz.
-- Performing timer loopback test... pass
-- Performing timer loopback test... pass
-- Setting master clock rate selection to 'automatic'.
_____________________________________________________
/
| Device: B-Series Device
| _____________________________________________________
| /
| | Mboard: B210
| | revision: 4
| | product: 2
| | serial: 30F7D88
| | name: MyB210
| | FW Version: 8.0
| | FPGA Version: 13.0
| |
| | Time sources: none, internal, external, gpsdo
| | Clock sources: internal, external, gpsdo
| | Sensors: ref_locked
| | _____________________________________________________
| | /
| | | RX DSP: 0
| | | Freq range: -8.000 to 8.000 MHz
| | _____________________________________________________
| | /
| | | RX DSP: 1
| | | Freq range: -8.000 to 8.000 MHz
| | _____________________________________________________
| | /
| | | RX Dboard: A
| | | _____________________________________________________
| | | /
| | | | RX Frontend: A
| | | | Name: FE-RX2
| | | | Antennas: TX/RX, RX2
| | | | Sensors: temp, rssi, lo_locked
| | | | Freq range: 50.000 to 6000.000 MHz
| | | | Gain range PGA: 0.0 to 76.0 step 1.0 dB
| | | | Bandwidth range: 200000.0 to 56000000.0 step 0.0 Hz
| | | | Connection Type: IQ
| | | | Uses LO offset: No
| | | _____________________________________________________
| | | /
| | | | RX Frontend: B
| | | | Name: FE-RX1
| | | | Antennas: TX/RX, RX2
| | | | Sensors: temp, rssi, lo_locked
| | | | Freq range: 50.000 to 6000.000 MHz
| | | | Gain range PGA: 0.0 to 76.0 step 1.0 dB
| | | | Bandwidth range: 200000.0 to 56000000.0 step 0.0 Hz
| | | | Connection Type: IQ
| | | | Uses LO offset: No
| | | _____________________________________________________
| | | /
| | | | RX Codec: A
| | | | Name: B210 RX dual ADC
| | | | Gain Elements: None
| | _____________________________________________________
| | /
| | | TX DSP: 0
| | | Freq range: -8.000 to 8.000 MHz
| | _____________________________________________________
| | /
| | | TX DSP: 1
| | | Freq range: -8.000 to 8.000 MHz
| | _____________________________________________________
| | /
| | | TX Dboard: A
| | | _____________________________________________________
| | | /
| | | | TX Frontend: A
| | | | Name: FE-TX2
| | | | Antennas: TX/RX
| | | | Sensors: temp, lo_locked
| | | | Freq range: 50.000 to 6000.000 MHz
| | | | Gain range PGA: 0.0 to 89.8 step 0.2 dB
| | | | Bandwidth range: 200000.0 to 56000000.0 step 0.0 Hz
| | | | Connection Type: IQ
| | | | Uses LO offset: No
| | | _____________________________________________________
| | | /
| | | | TX Frontend: B
| | | | Name: FE-TX1
| | | | Antennas: TX/RX
| | | | Sensors: temp, lo_locked
| | | | Freq range: 50.000 to 6000.000 MHz
| | | | Gain range PGA: 0.0 to 89.8 step 0.2 dB
| | | | Bandwidth range: 200000.0 to 56000000.0 step 0.0 Hz
| | | | Connection Type: IQ
| | | | Uses LO offset: No
| | | _____________________________________________________
| | | /
| | | | TX Codec: A
| | | | Name: B210 TX dual DAC
| | | | Gain Elements: None
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
hengyud@ubuntu:/OpenBTS$ sudo ./OpenBTS
ALERT 43213:43213 2019-05-12T00:37:07.6 OpenBTS.cpp:595:main: OpenBTS (re)starting, ver 5.0-master build date/time 2019-04-28T22:47:15
ALERT 43213:43213 2019-05-12T00:37:07.6 OpenBTS.cpp:596:main: OpenBTS reading config file /etc/OpenBTS/OpenBTS.db
1557646627.677025 140203525388096:

OpenBTS
Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
Copyright 2010 Kestrel Signal Processing, Inc.
Copyright 2011, 2012, 2013, 2014 Range Networks, Inc.
Release 5.0-master+646bb6e79f CommonLibs:76b71d509b P formal build date 2019-04-28T22:41:36
"OpenBTS" is a registered trademark of Range Networks, Inc.

Contributors:
Range Networks, Inc.:
David Burgess, Harvind Samra, Donald Kirker, Doug Brown,
Pat Thompson, Kurtis Heimerl, Michael Iedema, Dave Gotwisner
Kestrel Signal Processing, Inc.:
David Burgess, Harvind Samra, Raffi Sevlian, Roshan Baliga
GNU Radio:
Johnathan Corgan
Others:
Anne Kwong, Jacob Appelbaum, Joshua Lackey, Alon Levy
Alexander Chemeris, Alberto Escudero-Pascual
Incorporated L/GPL libraries and components:
libortp, LGPL, 2.1 Copyright 2001 Simon MORLAT simon.morlat@linphone.org
libusb, LGPL 2.1, various copyright holders, www.libusb.org
libzmq, LGPL 3:
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2011 Botond Ballo
Copyright (c) 2007-2009 iMatix Corporation
Incorporated BSD/MIT-style libraries and components:
A5/1 Pedagogical Implementation, Simplified BSD License, Copyright 1998-1999 Marc Briceno, Ian Goldberg, and David Wagner
JsonBox, Copyright 2011 Anhero Inc.
Google Core Dumper, BSD 3-Clause License, Copyright (c) 2005-2007, Google Inc.
Incorporated public domain libraries and components:
sqlite3, released to public domain 15 Sept 2001, www.sqlite.org


This program comes with ABSOLUTELY NO WARRANTY.

Use of this software may be subject to other legal restrictions,
including patent licensing and radio spectrum licensing.
All users of this software are expected to comply with applicable
regulations and laws. See the LEGAL file in the source code for
more information.

Note to US Government Users:
The OpenBTS software applications and associated documentation are "Commercial
Item(s)," as that term is defined at 48 C.F.R. Section 2.101, consisting of
"Commercial Computer Software" and "Commercial Computer Software Documentation,"
as such terms are used in 48 C.F.R. 12.212 or 48 C.F.R. 227.7202, as
applicable. Consistent with 48 C.F.R. 12.212 or 48 C.F.R. Sections 227.7202-1
through 227.7202-4, as applicable, the Commercial Computer Software and
Commercial Computer Software Documentation are being licensed to U.S. Government
end users (a) only as Commercial Items and (b) with only those rights as are
granted to all other end users pursuant to the terms and conditions of
Range Networks' software licenses and master customer agreement.


1557646627.703102 140203525388096:
Starting the system...
ALERT 43213:43220 2019-05-12T00:37:12.7 OpenBTS.cpp:174:startTransceiver: starting transceiver ./transceiver with 1 ARFCNs
linux; GNU C++ version 5.4.0 20160609; Boost_105800; UHD_003.009.005-0-unknown

Using internal frequency reference
-- Detected Device: B210
-- Operating over USB 2.
-- Initialize CODEC control...
-- Initialize Radio control...
-- Performing register loopback test... pass
-- Performing register loopback test... pass
-- Performing CODEC loopback test... pass
-- Performing CODEC loopback test... pass
-- Asking for clock rate 16.000000 MHz...
-- Actually got clock rate 16.000000 MHz.
-- Performing timer loopback test... pass
-- Performing timer loopback test... pass
-- Setting master clock rate selection to 'automatic'.
-- Asking for clock rate 32.000000 MHz...
-- Actually got clock rate 32.000000 MHz.
-- Performing timer loopback test... pass
-- Performing timer loopback test... pass
-- Asking for clock rate 26.000000 MHz...
-- Actually got clock rate 26.000000 MHz.
-- Performing timer loopback test... pass
-- Performing timer loopback test... pass
1557646638.143648 140203525388096:
system ready

1557646638.143858 140203525388096:
use the OpenBTSCLI utility to access CLI

1557646638.144045 140203525388096: OpenBTSCLI network socket support for tcp:49300

OpenBTS>

OpenBTS操作指南