Skip to main content

Taking the Raspberry Pi 2 for a Test Drive with GNU Radio

title

Installing GNU Radio and receiving aircraft radar with a USB TV tuner

The Raspberry Pi has been put to countless creative uses, with it's low cost and easy to use GPIO, coupled with a passionate and inventive community, giving birth to applications that have ranged from simple fun, to inspired and even profound.

However, the single-core Raspberry Pi couldn't be everything to everyone and a common wish was for just a little more horsepower, for those applications that really need it. A great example being software-defined radio (SDR), where components usually implemented in hardware are instead implemented in software. Resulting in flexibility, but at the cost of being computationally intensive.

The Raspberry Pi 2 Model B, with it's quad-core processor and 1GB RAM, weighs in at around six times the performance of its predecessor and should far better accommodate SDR applications.

title

Installing GNU Radio

The GNU Radio SDR toolkit is a fairly substantial codebase and with some equally heavyweight dependencies. Thankfully, Raspbian packages are available — not in the current “wheezy” release , but in the “jessie” testing release. The MicroSD card that came supplied with the Pi 2 was based on wheezy, but adding a line to the Apt configuration was all that was needed to get jessie packages.

Edit /etc/apt/sources.list and add the line:

deb http://archive.raspbian.org/raspbian jessie main

Update the Apt cache:

$ sudo apt-get update

Install GNU Radio runtime and development files:

$ sudo apt-get install gnuradio gnuradio-dev

title

Setting up RTL-SDR

title

It still never ceases to amaze me what can be done with a humble USB TV tuner dongle that can be picked up for around £10 plus open source SDR software. Above can be seen the Pi 2 with such a tuner plugged in to one of the USB ports, and the supplied antenna attached. For more information on the wonder that is rtl-sdr, see the post I wrote about this back in 2012.

Since we're re-purposing a TV tuner that is supported by the Linux kernel and which would otherwise be claimed by it and for TV reception, we need to first stop the kernel from doing so.

Edit the file /etc/modprobe.d/raspi-blacklist.conf and add the line:

blacklist dvb_usb_rtl28xxu

Install the rtl-sdr software and GNU Radio support:

$ sudo apt-get install rtl-sdr gr-osmosdr

In order to access the device as a non-root user we need to set up a new udev rule, but first we need to ascertain the USB ID. Ensure that the tuner is plugged in and type:

$ lsusb

This gave me:

Bus 001 Device 004: ID 0bda:2832 Realtek Semiconductor Corp. RTL2832U DVB-T

Next we create the file /etc/udev/rules.d/20.rtlsdr.rules, with the line:

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

We could restart udev at this point, but since we also blacklisted a kernel module it's probably just easiest to reboot.

A simple test

title

To get a simple spectrum display we can run the FFT application which is provided as part of the gr-osmocom software.

$ osmocom_fft

If we then check the CPU load we can see that we have plenty of capacity to spare, with just one core at around 70% utilisation.

title

gr-air-modes

Around 2 ½ years ago I wrote about how you could use rtl-sdr hardware together with the GNU Radio-based gr-air-modes software, to receive position and heading information from aircraft Mode-S transponders. At the time I used a laptop, and did try using a Raspberry Pi Model B also, but this didn't have quite enough processing power and resulted in buffer underruns.

In order to build gr-air-modes a few additional dependencies are required.

$ sudo apt-get install cmake libboost-dev sqlite pyqt4-dev-tools liblog4cpp5-dev swig

With these installed the sources can be cloned from GitHub:

$ git clone https://github.com/bistromath/gr-air-modes.git

To then build and install:

$ cd gr-air-modes
$ mkdir build
$ cd build
$ cmake ../
$ make
$ sudo make install
$ sudo ldconfig

We can then run the application with:

$ modes_rx -s osmocom

And with only a tiny antenna and a good number of miles from the nearest airport, I still managed to get no shortage of output!

title

Not to mention, once again with plenty of headroom to spare.

title

Conclusion

The Pi 2 provides a marked improvement on the first generation hardware, with four cores instead of one and each of these being a more recent and more powerful version of the ARM architecture. A performance improvement that will be welcomed by many and not least of all those with SDR applications in mind.

See also the post on running a GSM network on the Raspberry Pi 2 with UmTRX.

Andrew Back

BUY A Pi2

Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.
DesignSpark Electrical Logolinkedin