Skip to content

Installation on RaspberryPi 3

superuser5 edited this page Jan 21, 2020 · 8 revisions

Prerequisites

What will we need

We would need Raspberry Pi 3 or Raspberry Pi Zero W 1.1, which has 64-bit ARMv7 processor. Please note that gr-gsm cannot be installed on Raspberry Pi 1 (we tested Model B), since it has ARMv6 processor. Some GNU Radio components are not supported on ARMv6 architecture.

On RPi we will install Debian based Linux operating system Raspbian Jessie (we used version from 2016-03-18).

Update software on Raspberry Pi

First we need to change default password with the command passwd. After that we need to install new updates:

sudo apt-get update
sudo apt-get upgrade

Expand space on a SD card and set-up the device

Next step is to expand space on a SD card. We invoke the tool to do that with sudo raspi-config. In menu we select Expand space. We also need to set timezone, in which country we will use Wi-fi, keyboard settings (under Internationalisation Options). Do not change language settings! If system language is not English, some strange errors in Python start to appear.

Now we need to reboot the machine with sudo reboot.

Update firmware on Raspberry Pi

Right after that we need to update Raspberry firmware with command sudo rpi-update. When this is finished, we need to stop the machine with sudo shutdown -h now and physically plug off the power. After some seconds we power it up again.

Secure the device

Now it is good time to setup firewall, enable NTP client, change hostname... maybe we also want to set up VNC console. We assume you are able to secure the device, for some quick steps, you can see this guide (in slovenian, english translation via Google Translate is also available)).

Do not skip this step, security is important.

Increase swap space

Sometimes you will need more memory for compiling. You can "add" new memory with increasing swap space. Open the configuration file:

sudo nano /etc/dphys-swapfile

... and look for default value in Raspbian, which is: CONF_SWAPSIZE=100

Change it to: CONF_SWAPSIZE=1024 After that you need to stop and start the service that manages the swapfile on Rasbian:

sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

Now can then verify the amount of memory and swap space by issuing the following command: free -m

Install screen

Since compiling can take a long time, it may also be a good idea to install screen: sudo apt-get install screen.

Installation of software needed for gr-gsm

Install Kalibrate

First, we will install Kalibrate:

sudo apt-get install libtool autoconf automake libfftw3-dev librtlsdr0 librtlsdr-dev libusb-1.0-0 libusb-1.0-0-dev
git clone https://github.com/asdil12/kalibrate-rtl.git
cd kalibrate-rtl
git checkout arm_memory
./bootstrap
./configure
make
sudo make install

Set access to USB devices

Plug in the RTL-SDR device and check it's ID with lsusb command. You will see something like this:

Bus 001 Device 004: ID **0bda:2832** Realtek Semiconductor Corp. RTL2832U DVB-T
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In our case ID of the RTL.SDR device is 0bda:2832. Now we open a rules file:

sudo nano /etc/udev/rules.d/20.rtlsdr.rules

...and add this line to it:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2832", GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"

If you are using several RTL-SDR devices, you can add several lines to this file.

Now we need to reboot our Raspberry Pi: sudo reboot

Calibrate RTL-SDR device

Now we can invoke the command to calibrate our RTL-SDR device for GSM frequency band (actually to compute the average absolute error in PPM):

kal -s GSM900

We get the result similar to this:

Found 1 device(s):
  0:  Generic RTL2832U

Using device 0: Generic RTL2832U
Found Rafael Micro R820T tuner
Exact sample rate is: 270833.002142 Hz
kal: Scanning for GSM-900 base stations.
GSM-900:
	chan: 1 (935.2MHz - 33.430kHz)	power: 55085.23
	chan: 3 (935.6MHz - 34.130kHz)	power: 63242.36
	chan: 5 (936.0MHz - 33.970kHz)	power: 41270.82
...
...
	chan: 112 (957.4MHz - 32.934kHz)	power: 498930.07
	chan: 116 (958.2MHz - 31.859kHz)	power: 88039.44
	chan: 124 (959.8MHz - 32.429kHz)	power: 247404.23

The strongest signal in our case is on channel 112. So we run calibration on this channel:

kal -c 112

... and get the result like this:

Found 1 device(s):
  0:  Generic RTL2832U

Using device 0: Generic RTL2832U
Found Rafael Micro R820T tuner
Exact sample rate is: 270833.002142 Hz
kal: Calculating clock frequency offset.
Using GSM-900 channel 112 (957.4MHz)
average		[min, max]	(range, stddev)
- 34.368kHz		[-34376, -34357]	(20, 4.697051)
overruns: 0
not found: 0
average absolute error: 35.897 ppm

So our average absolute error is 36 PPM (35.897 PPM).

Install GNU Radio

Now we need to install GNU Radio, which is quite simple:

sudo apt-get install gnuradio gnuradio-dev gnu // In fact, there's no such package named "gnu", so just install gnuradio gnuradio-dev

Install libosmocore

We need to compile libosmocore...

sudo apt-get install cmake
sudo apt-get install build-essential libtool shtool autoconf automake git-core pkg-config make gcc
sudo apt-get install libpcsclite-dev libtalloc-dev gnutls-dev libsctp-dev
git clone git://git.osmocom.org/libosmocore.git
cd libosmocore/
autoreconf -i
./configure
make
sudo make install
sudo ldconfig -i
cd

...and install some other things

sudo apt-get install swig python-docutils
sudo apt-get install gr-osmosdr rtl-sdr
sudo apt-get install libboost-dev
sudo apt-get install osmo-sdr libosmosdr-dev
sudo apt-get install libusb-1.0.0 libusb-dev
sudo apt-get install libboost-all-dev libcppunit-dev swig doxygen liblog4cpp5-dev python-scipy

Install gr-gsm

Now we are ready for the final step:

git clone https://github.com/ptrkrysik/gr-gsm.git
cd gr-gsm
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig

Finally, we create the ~/.gnuradio/config.conf config file with nano ~/.gnuradio/config.conf. We add this two lines to it (in that GNU Radio can find custom blocks of gr-gsm):

[grc]
local_blocks_path=/usr/local/share/gnuradio/grc/blocks

Usage

Now we can run GSM scanner with:

grgsm_scanner -p 36

Please note, that we used parameter -p 36 - it is our average absolute error in PPM.

We can also use GSM Live Monitor (grgsm_livemon), but we need a GUI or VNC console.