Project

General

Profile

SDR PHY » History » Version 25

fixeria, 08/10/2018 08:31 PM

1 2 fixeria
h1. SDR (Software Defined Radio) hardware
2
3 17 fixeria
{{>toc}}
4
5 2 fixeria
Unlike the obsolete [[Phones|Calypso based phones]], "SDR (Software Defined Radio)":https://en.wikipedia.org/wiki/Software-defined_radio has many advantages, providing much more freedom for the implementation of mobile side [[Software|GSM protocol stack]]. This page describes all steps required for running the higher layer (L2&3) applications (e.g. [[mobile]] or [[ccch_scan]]) on SDR hardware.
6
7
h2. SDR PHY vs Calypso
8
9
h3. What's so special about SDR?
10
11
* General purpose hardware
12
** i.e. not limited to any particular technology and/or protocol stack,
13
** could be used as PHY for GSM, LTE, IEE802.11, GPS, Bluetooth, etc.
14
* Becomes cheap and available for everyone
15
** e.g. RTL-SDR, LimeSDR-Mini
16
* Becomes even smaller than a credit card
17
** e.g. XTRX
18
* Open Source friendly
19
** GNU Radio, GQRX, OpenBTS, OsmoTRX, srsLTE, etc.
20
** some drivers, firmware and PCB schematics are available
21
22
h3. Advantages over Calypso
23
24 11 ipse
* No need to rely on a 'black box' DSP
25 2 fixeria
* No hardware availability problem
26
* No reverse engineering required
27
* No freq. band limitations
28
29
h3. Disadvantages
30
31
* Low output power
32
* General purpose hardware
33
** No screen, no keyboard,
34
** No built-in SIM reader,
35
** No built-in audio
36
** etc.
37
38
h3. What is it for?
39
40
* Another hardware platform for [[OsmocomBB]]
41
* 100% Open Source GSM L1 implementation
42
** GSM TS 05.02 scheduling
43
** GSM TS 05.03 channel coding
44
** GSM TS 05.04 (de)modulation
45
** GSM TS 05.10 synchronization
46
47
h2. Supported SDR hardware
48
49 25 fixeria
At the moment only USRP hardware is supported via UHD driver. This limitation caused by the requirement of the stream tags support.
50 2 fixeria
51
The current implementation is known to work on the following devices:
52
53 1 fixeria
* USRP B2X0, including 'mini'
54
* Fairwaves [[UmTRX:]]
55 25 fixeria
56
Note: *LimeSDR is not (yet?) supported* exactly because the stream tags are not supported by _gr-limesdr_.
57 2 fixeria
58
h2. Software installation
59
60 5 fixeria
!graph_trxcon.png!
61
62 2 fixeria
The signal processing part is based on [[GR-GSM:]] (https://github.com/ptrkrysik/gr-gsm) project, which is represented by a set of "GNU Radio":https://www.gnuradio.org/ blocks for GSM. So, first of all you need to install "GNU Radio":https://www.gnuradio.org/ with compiled-in "UHD driver":http://files.ettus.com/manual/ support.
63
64
h3. 1. "UHD driver":http://files.ettus.com/manual/
65
66
Follow the "Installing and/or Building UHD" section of official project documentation. After the installation, make sure that your device is recognized properly:
67
68
<pre>
69
$ uhd_find_devices
70
$ uhd_usrp_probe
71
</pre>
72
73
h3. 2. "GNU Radio":https://www.gnuradio.org/
74
75
Despite "GNU Radio":https://www.gnuradio.org/ is available as a binary package on some distributions, we recommend to build the latest release version from source. Please follow the corresponding "building guide":https://wiki.gnuradio.org/index.php/BuildGuide.
76
77
During the build configuration process, make sure you have the following components:
78
79
* python-support
80
* gr-digital
81
* gr-filter
82
* gr-blocks
83
* gr-uhd
84
85
For binary or already installed builds, use the following command to get build info:
86
87
<pre>
88
$ gnuradio-config-info --enabled-components
89
</pre>
90
91
h3. 3. [[GR-GSM:]] with transceiver
92
93 6 fixeria
!graph_trx.png!
94
95 2 fixeria
For now, the transmitter implementation lives in separate branches. This manual compilation from source is required. "General building process":https://github.com/ptrkrysik/gr-gsm/wiki/Manual-compilation-and-installation and dependences are described in the "project's wiki":https://github.com/ptrkrysik/gr-gsm/wiki/.
96
97
<pre>
98
# Get the source code
99
$ git clone git://git.osmocom.org/gr-gsm
100
$ cd gr-gsm/
101
$ git checkout fixeria/trx
102
103
# Configure and compile
104
$ mkdir build
105
$ cd build
106
$ cmake ..
107
$ make
108
109
# Install
110
$ sudo make install
111
$ sudo ldconfig
112
</pre>
113
114 12 fixeria
The transceiver logic is represented by the following flow graph:
115 8 fixeria
116
!grc_trx.png!
117
118 2 fixeria
h3. 4. [[OsmocomBB:]]
119
120
You need to compile OsmocomBB with the [[TRX_Interface|TRX interface]] support. Please refer the corresponding [[TRX_Interface|wiki page]].
121
122
h2. Running
123
124 4 fixeria
First of all, please see [[SDR_PHY#Project-status|known limitations]].
125 2 fixeria
126
h3. Hardware preparation
127
128
You need to have two antennas connected: one for RX, another for TX. Both antennas should be chosen for a proper frequency band, otherwise the distance will be limited. Also, it's strongly recommended to use a band-pass filter for TX in order to *avoid interference*.
129
130
_Note: There is a bug of USRP B2X0 hardware, which affects the burst transmission quality. It appears when both transmission and reception are performed of the same side of device. To mitigate this, please use an attenuator or antenna with some resistance between the active pin and ground._
131
132
Finally, connect your SDR hardware and make sure it's working. 
133
134
h3. Transceiver
135
136
Check available configuration options:
137
138
<pre>
139
$ grgsm_trx --help
140
141
...
142
143
  TRX interface specific
144
   -i --remote-addr  Set remote address (default 127.0.0.1)
145
   -p --base-port    Set base port number (default 5700)
146
147
  Radio interface specific
148
   -a --device-args  Set device arguments
149
   -s --sample-rate  Set sample rate
150
   -g --rx-gain      Set RX gain (default 30)
151
   -G --tx-gain      Set TX gain (default 10)
152
      --rx-antenna   Set RX antenna (default RX2)
153
      --tx-antenna   Set TX antenna (default TX/RX)
154
      --ppm          Set frequency correction (default 0)
155
</pre>
156
157
If you already have another transceiver runing, e.g. [[OsmoTRX:]], choose a different TRX base port. Keep in mind that a single transceiver process occupies six UDP ports at the same time.
158
159
Choose proper RX / TX antennas and corresponding gain values depending on your device. TX gain requires more attention and should be set depending on your environment and antennas used. Feel free to use a spectrum browser, such as GQRX or osmocom_fft, for measuring the proper values.
160
161
PPM value is typically measured at runtime, so no need to specify it manually.
162
163
<pre>
164
$ grgsm_trx --rx-gain 30 --tx-gain 80
165
linux; GNU C++ version 4.8.5; Boost_105500; UHD_003.010.002.000-0-122bfae1
166
167
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
168
This is free software: you are free to change and redistribute it.
169
There is NO WARRANTY, to the extent permitted by law.
170
171
[i] Init Radio interface
172
-- Detected Device: B200
173
-- Operating over USB 3.
174
-- Initialize CODEC control...
175
-- Initialize Radio control...
176
-- Performing register loopback test... pass
177
-- Performing CODEC loopback test... pass
178
-- Setting master clock rate selection to 'automatic'.
179
-- Asking for clock rate 16.000000 MHz... 
180
-- Actually got clock rate 16.000000 MHz.
181
-- Performing timer loopback test... pass
182
-- Setting master clock rate selection to 'manual'.
183
-- Asking for clock rate 26.000000 MHz... 
184
-- Actually got clock rate 26.000000 MHz.
185
-- Performing timer loopback test... pass
186
-- Asking for clock rate 26.000000 MHz... OK
187
[i] Init CTRL interface
188
[i] Init complete
189
</pre>
190
191
At this step transceiver is ready.
192
193
h3. The trxcon application
194
195
As we don't use Calypso-based phones, the [[osmocon]] application is useless here. Instead, you need to run another application called trxcon. You should use the same TRX base port as specified to transceiver.
196
197
<pre>
198
$ cd osmocom-bb/src/
199
$ host/trxcon/trxcon
200
201
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
202
This is free software: you are free to change and redistribute it.
203
There is NO WARRANTY, to the extent permitted by law.
204
205
<0001> l1ctl_link.c:235 Init L1CTL link (/tmp/osmocom_l2)
206
<0003> trx_if.c:646 Init transceiver interface
207
<0005> sched_trx.c:112 Init scheduler
208
<0000> trxcon.c:277 Init complete
209
</pre>
210
211
See help details.
212
213
h3. L2&3 applications
214
215
At this step you should be able to run the higher layer applications.
216
217
For example, run [[ccch_scan]]:
218
219
<pre>
220
$ cd osmocom-bb/src/
221
$ cd host/layer23/src/misc/
222
$ ./ccch_scan -i 127.0.0.1 -a <ARFCN>
223
</pre>
224
225
It should synchronize with a BTS on specified ARFCN, and start decoding BCCH messages.
226
227 22 fixeria
h2. Docker images
228
229
It's possible to run the software in Docker containers. This way is recommended for beginners.
230
231
_Note:_ at the moment, there is a build script for GR-GSM TRX only.
232
233
The build script for [[GR-GSM:]] (i.e. Dockerfile) is shipped as a part of a separate project called "docker-playground".
234
It's based on "base/archlinux" image, which provides the recent versions of both UHD and GNU Radio without tons of
235
dependencies such as Xorg, GTK, fonts, etc.
236
237
h3. Building Docker image
238
239
You need to clone the "docker-playground" repository first:
240
241
<pre>
242
$ git clone git://git.osmocom.org/docker-playground/
243
</pre>
244
245
Then make sure you have stable Internet connection and enough disk space, and start building:
246
247
<pre>
248
$ cd docker-playground/
249
$ cd gr-gsm-master/
250
$ make build
251
</pre>
252
253
It will take a while...
254
255
As soon as the building process is finished, you should see the new images:
256
257
<pre>
258
$ docker image ls
259
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
260 23 fixeria
user/gr-gsm-master        latest              c5912ee7d6ae        About an hour ago   2.09GB
261 1 fixeria
base/archlinux            latest              7477438791e3        28 hours ago        689MB
262 23 fixeria
</pre>
263
264
Please note that *this container requires privileged access* to the host USB devices (USRPs).
265
266
h3. Running Docker image
267
268
Read the above part about running first.
269
270
As soon as you build the image, feel free to start it:
271
272
<pre>
273
$ cd docker-playground/
274
$ cd gr-gsm-master/
275
$ make run
276
</pre>
277
278
The last command will drop you into a bash shell. As there are no build scripts for the higher layer applications of [[OsmocomBB:]], the following part assumes that you are running [[OsmocomBB:]] on the host side.
279
280
By default, Docker should create a network interface for interacting with containers:
281
282
<pre>
283
$ ip addr
284
# ...
285
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
286
    link/ether 02:42:13:85:c2:c9 brd ff:ff:ff:ff:ff:ff
287
    inet 172.17.0.1/16 scope global docker0
288
       valid_lft forever preferred_lft forever
289
</pre>
290
291
In this example, the host has 172.17.0.1 assigned. Remember this address.
292
293 24 fixeria
_Note:_ make sure your firewall doesn't block the connections with Docker's interface.
294
295 23 fixeria
The container itself should also have it's own address. You can check it:
296
297
<pre>
298
[root@f7e86148c1c2 tmp]# pacman -S net-tools
299
[root@f7e86148c1c2 tmp]# ifconfig
300
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
301
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 0.0.0.0
302
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
303
        RX packets 40  bytes 139097 (135.8 KiB)
304
        RX errors 0  dropped 0  overruns 0  frame 0
305
        TX packets 32  bytes 2752 (2.6 KiB)
306
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
307
308
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
309
        inet 127.0.0.1  netmask 255.0.0.0
310
        loop  txqueuelen 1  (Local Loopback)
311
        RX packets 0  bytes 0 (0.0 B)
312
        RX errors 0  dropped 0  overruns 0  frame 0
313
        TX packets 0  bytes 0 (0.0 B)
314
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
315
</pre>
316
317
Now, make sure your hardware is available within the container:
318
319
<pre>
320
[root@f7e86148c1c2 tmp]# uhd_find_devices
321
# Device list will appear here
322
</pre>
323
324
And finally, start the transceiver:
325
326
<pre>
327
# You need to use IP address of the host
328
[root@f7e86148c1c2 tmp]# grgsm_trx --remote-addr 172.17.0.1
329
</pre>
330
331
and trxcon on the host side:
332
333 1 fixeria
<pre>
334 24 fixeria
$ cd osmocom-bb/src/host/trxcon/trxcon/
335
336
# You need to use IP address of the host
337
$ ./trxcon --trx-ip 172.17.0.2
338 1 fixeria
</pre>
339 24 fixeria
340
That's it!
341 22 fixeria
342 2 fixeria
h2. Related pages
343
344
* [[TRX Interface]]
345 10 fixeria
346
{{child_pages(TRX_Interface)}}
347 2 fixeria
348
h2. Project status
349
350
Known limitations (not implemented):
351
352 14 fixeria
* Automatic PHY delay measurement
353 2 fixeria
* AGC (Automatic Gain Control)
354
* Power measurement
355
356
Work in progress:
357 1 fixeria
358 16 fixeria
* Docker scripts (Dockerfiles)
359 2 fixeria
* GAPK based audio back-end
360 1 fixeria
* TCH/H implementation
361 16 fixeria
* Frequency Hopping
362 2 fixeria
363
Future plans:
364
365
* Extend supported hardware list (Soapy?)
366
* PC/SC physical SIM interface
367
* AMR (Adaptive Multi-Rate)
368
369
h2. Further reading / watching
370
371
https://media.ccc.de/v/34c3-8952-running_gsm_mobile_phone_on_sdr
372 15 fixeria
https://www.youtube.com/watch?v=nmqzr2-yF04
Add picture from clipboard (Maximum size: 48.8 MB)