Home

Better Android Support!

One of the harder things about GNU Radio on a new system is building the dependencies. That was a large part of my task when getting GNU Radio for Android working. All of the required dependencies needed to build rebuilt using the Android toolchain, which meant that for each dependency, I had to figure out how to set up and call the NDK properly. That was hard, and good thing that there were quite a few hints on the Internet for various programs like Boost and LibUSB. For a while now, I've had information on how to build all of the dependencies for Android on our Android support page. This includes a page dedicated to building the basic libraries and dependencies as well as a page discussing how to build VOLK, GNU Radio, GRAnd, and gr-osomosdr.

It seemed like very few people could follow this through and successfully rebuild all of these packages themselves. And that's fair because I had only ever done this on my machines which are both running the same version of Ubuntu Linux (15.10) and everything else. It's hard to say how any deviations from these versions might affect things. So to help with this issue, I just published two new tools to help people get started.

Tarball of Dependencies

The first tool, which should be the go-to for anyone wanting to get up and running immediately, is a tarball of all of the pre-built dependencies as well as all of the GNU Radio support packages. You just download this, untar/uncompress it (into /opt/grandroid, generally, since that's where I tell everyone to look for this stuff), and now you're ready to start building Android apps and linking to GNU Radio. Bam. Done. The GNU Radio team also has a GPG key for signing, so you can get the public key, download the signature for the tarball and verify your download.

The tarball contains a MANIFEST.txt file that describes what's been built and packaged into this tarball. As of writing this, it looks like:

Boost: 1.58.0
FFTW: 3.3.4
OpenSSL: 1.0.2
Thrift: 0.9.3
ZeroMQ: 3.2.4
LibUSB: v1.0.19-and5
RTL-SDR: b829664e85ae67a35c06f09ffbc16207f4001324
UHD: 4e64eb4888ecbe159af290482615b518ca835682
VOLK: 9b3c79afe34ea6a9dbf20e5c25afa7b5038119bd
gr-omsosdr: 8c01b772ef20bb718902a4e613554bd705010131
GNU Radio: b7870d6cc1b984e44044fa60240e4ad77c8ccd45

For versioned packages, that version is given. For the other packages, these are generally projects that we had to hack to get to work under Android, so these are the git refs for my android branches of these projects.

Do-It-Yourself Script

Some people are (justifiably) paranoid about taking pre-built binaries, even if they are signed. To help them, I've also published the script that I used to build the tarball of binaries. This basically takes the instructions that I made on the wiki pages and puts it into a much better package and slightly more robust way of building things yourself.

Speaking of paranoia, the script will ask you to enter your admin password because it will run sudo to create the directory ($PREFIX). If you look at the script, you see these three lines:

sudo mkdir -p ${PREFIX}
sudo chown $USER:$USER -R ${PREFIX}
sudo -K # invalidates credentials for anyone paranoid

It creates the directory $PREFIX, assigns it over to the user that called this script, and then uses the -K to invalidate the sudo credentials so it won't be able to do anything else as the superuser after this.

The script is only tested on Ubuntu 15.10 (64-bit).

Available GNU Radio Components

When we build GNU Radio, we turn off a lot of extraneous components that aren't necessary or even useful on Android, like GRC or the QT and WX widgets. What is built includes:

  • gnuradio-runtime
  • gr-blocks
  • gr-fft
  • gr-filter
  • gr-analog
  • gr-digital
  • gr-channels
  • gr-zeromq
  • gr-uhd
  • gr-ctrlport (with Thrift support)
  • Static libraries for each component

And also VOLK and gr-osmosdr separately. The GRAnd package provides audio sources and sinks for use under Android.

The one final GNU Radio component that I feel should be added here is gr-fec. However, right now, that requires GSL, which we have not yet built for Android.

Performance Monitor Android App

With our continuing roll-out of support and features for GNU Radio on Android, we are looking to handle all command-and-control between the app and the flowgraph through ControlPort. While I've had the ControlPort server side working on GNU Radio apps for a while, we didn't have the mechanism in place for client-side ControlPort apps, which will be necessary for getting and setting parameters in the radio. I've now added two new projects to help us with this.

The first project is GrControlPort -- this is an Android library (not an application) that is meant to provide a simple abstraction layer for using ControlPort in Java. This is very similar to our Python-based RPCConnection class that we use to make getting and setting knobs easier in that language. You use this library to make the connection to the ControlPort app and then use the returned object to get and set the knobs of the radio. There's an abstracted class to make the user code agnostic to the backend service, like Thrift. The README file explains more about how to use this, and it includes a simple Java class that shows the basic modes of getting and setting knobs of a flowgraph.

https://github.com/trondeau/GrControlPort

The second project is GrPerfMon, which is an Android app that uses GrControlPort to manage the ControlPort connection. This app reads the "work time" Performance Counter and displays this info as a percent of the total time for all blocks in a flowgraph. This is very similar in nature to our gr-perf-monitorx application we use on a desktop. You give it the hostname/IP address and port number of the running flowgraph along with the update interval (defaults to 1 second) and connect. When connected, it will show a bar graph of the percentages for each block. The code is on Github here:

https://github.com/trondeau/GrPerfMon

Because ControlPort is handled over a TCP/IP connection, the flowgraph and the app don't have to run on the same device, although part of the motivation for this work is to provide the experience and knowledge to make this the default communications between an Android flowgraph and app layer. But more on that to come. For right now, the image below shows me profiling from a Nexus 7 tablet a flowgraph running on my desktop machine:


GNU Radio for Android

I have been slowly pushing out information here and there on my work on Android. I've been able to show it off at various conferences and workshops that I've attended over the past few months. It gets a lot of very positive feedback, and we know there are many, many exciting things we as a community of developers and wireless experts can do with this kind of a system.

It's time to start really pushing this project. I spent so much time getting things to work under the hood that I've completely lost track of any of the cool applications that I wanted to work on with it! But the more people that get access to this and know how to work with it, the more interesting the application space and possibilities will become. Because of that, I had been waiting for two things to finish before writing this post. First, I wanted to be able to use a bus-powered Ettus Research USRP with and Android device. And second, I wanted the process documented from the start of building the dependencies to the end of a working (if overly simple) app. Both of those are done.

To help get things started, I've created an Android support page on the gnuradio.org wiki:

  • http://gnuradio.org/redmine/projects/gnuradio/wiki/Android

This page is designed to walk a developer through all of the stages from building the dependencies to GNU Radio itself, GRAnd, UHD, RTL-SDR, and gr-omsosdr. This should be pretty much copy-and-paste to get everything built and ready. The final part was finished just today: a walk-through for how to build a basic Android application that launches a GNU Radio flowgraph. This is done using Android Studio, which is the latest development environment for building Android apps. The project can be downloaded from it's Github page to provide a template to set up your own project and verify a working installation:

  • https://github.com/trondeau/GrTemplate

Hopefully, we will continue to evolve the process to make setup and building apps easier in the future. The next step is walking through and providing the annoying boilerplate stuff for hardware access so you can start using USRPs and RTL-SDRs with your devices. But for right now, I want to make sure people who are excited about this stuff have a way to get in and start playing.

List of what we support on Android

So where do we stand with our GNU Radio support on Android?

  • GNU Radio components:
    • Runtime, VOLK, Blocks, FFT, Filter, Analog, Digital, UHD
    • ControlPort
  • Extras
    • gr-osmosdr including RTL-SDR and UHD support
      • HackRF support should be trivial but not done, yet
    • gr-grand: GRAnd (GNU Radio for Android) to support Android-specific I/O and capabilities such as:
      • audio input and output
      • shared buffers between app and flowgraph
      • sensors (e.g., accelerometer and luminosity)
  • Tested hardware
    • RTL-SDRs
    • USRP B200 and B210 (the latter required external power on a Nexus 7)
  • Android Version
    • Android Lollipop 5.0 or greater. Tested on 5.1.1
      • some complex support in previous versions is lacking in the ndk; we think we can get around it, just not out-of-the-box.