Compiling GnuRadio on a Raspberry Pi

The best bet for most people looking to install GnuRadio on a Raspberry Pi, is to simply do:

$ sudo apt-get install gnuradio gnuradio-dev

…and you are done. Unfortunately, it is not so simple to actually compile the latest version on a Raspberry Pi. While the Pi has gotten faster with the 2 & 3, it is still pretty slow and does not have that much memory, so it takes a long time. If you are good with cross compiler, you can compile on your desktop and ship it your Pi. You are on your own to figure out how to do this… please let me know if you do!

It is not too bad to compile GnuRadio using PyBombs on the Pi. There are a few gotchas though.

The first step is to setup get PyBombs installed. Follow the instructions here. Basically it is:

sudo pip install PyBOMBS
pybombs recipes add gr-recipes git+https://github.com/gnuradio/gr-recipes.git  
pybombs recipes add gr-etcetera git+https://github.com/gnuradio/gr-etcetera.git

Now that you have PyBombs installed, it is time to do some configuration. The first problem you have to work around is that the version of GCC installed from the Raspbian Repo is compiled for the Rasp Pi v1 chip, which has an older ARM processor. This forces some some older C Flags during compile and mess up the GnuRadio build, once it is time to compile Volk. Double check this by doing ‘gcc -v’ on the Pi and looking for:

--with-arch=armv6 --with-fpu=vfp --with-float=hard

The work around is to use the GCC build from the standard Debian repo. I didn’t figure this out on my own. There is a good blog post here. However, before you do this, make sure you have some of the dependancies for GnuRadio installed:

sudo apt-get install libssl-dev libtiff5-dev

To switch to Repos with the ARM7 code,  I edited `/etc/apt/sources.list` and it now looks like:

deb http://mirrors.acm.jhu.edu/debian/ jessie main contrib non-free
deb http://mirrordirector.raspbian.org/raspbian/ jessie rpi
#deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

If you end up getting weird dependency errors, you can comment out the new lines and enable to old way.

After making that edit, update the package list and install a better ver of GCC:

sudo apt-get update
sudo apt-get install debian-archive-keyring
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install gcc-4.9 gcc-4.9-base libgcc-4.9-dev libgcc1 gcc

After all that, there is still one more step before you can install GnuRadio. The PyBombs recipe for GnuRadio needs to have some C flags added. Edit the `~/.pybombs/recipes/gr-recipes/gnuradio.lwr` file and change config_opt:

vars:
  config_opt: " -DENABLE_DOXYGEN=$builddocs -DCMAKE_ASM_FLAGS='-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7' -DCMAKE_C_FLAGS='-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7'"

I also had to remove some of the old Deb packages from the Raspbian repo:

sudo apt-get remove libqtgui4 libqtcore4 libqt4-xmlpatterns libqt4-xml libqt4-network libqt4-dbus

There is one other thing you have to do… increase the swap size otherwise the Pi will run out of memory with such a large compile. You will probably want to turn this back to the default value after you are done compiling. Follow the directions here.

OK, sweet! Now the now it is time to run `pybombs install gnuradio`. On a Raspbery Pi 2, it took about 24 hours. It might not be a bad idea to run `screen` so thing don’t stop if you get disconnected.

6 thoughts on “Compiling GnuRadio on a Raspberry Pi”

  1. Hi, sorry I’m here again I did every step on your and everything was fine until “pybombs install gnuradio” I have this error :

    /home/pi/src/gnuradio/volk/kernels/volk/asm/neon/volk_32f_x2_dot_prod_32f_neonasm_opts.s: Assembler messages:
    /home/pi/src/gnuradio/volk/kernels/volk/asm/neon/volk_32f_x2_dot_prod_32f_neonasm_opts.s:46: Error: selected processor does not support ARM mode `sbfx r11,r1,#2,#1′
    volk/lib/CMakeFiles/volk_obj.dir/build.make:1359: recipe for target ‘volk/lib/CMakeFiles/volk_obj.dir/__/kernels/volk/asm/neon/volk_32f_x2_dot_prod_32f_neonasm_opts.s.o’ failed
    make[2]: *** [volk/lib/CMakeFiles/volk_obj.dir/__/kernels/volk/asm/neon/volk_32f_x2_dot_prod_32f_neonasm_opts.s.o] Error 1
    CMakeFiles/Makefile2:201: recipe for target ‘volk/lib/CMakeFiles/volk_obj.dir/all’ failed
    make[1]: *** [volk/lib/CMakeFiles/volk_obj.dir/all] Error 2
    Makefile:147: recipe for target ‘all’ failed
    make: *** [all] Error 2

    can you help me? Thanks

  2. Sorry – I just saw this. Try doing a ‘gcc -v’
    You may have the older version of gcc running. I think that is what causes that error.

  3. Good morning thanks a lot for this post I did every step but in the last one when “pybombs install gnuradio” I had this message :
    “PyBombs.PackageManager – ERROR- Package gnuradio requires source-build, but no prefix is specified. Aborting”

    Please help me

    When I do “gcc-v” it shows me that I run with arm7

  4. Once all those steps have been done, and it was done correctly, why can’t that person just post the binary instead of making everyone else go through the same agony. Just put the binary out there and say “This is a binary for a Raspberry Pi [whatever] running Raspbian [so-and-so]?

  5. thanks for this post. one commenter asked about just installing a binary instead of going through the pain. indeed, raspbian has gnuradio 3.7.5, but to install something like ‘gr-gsm’ one need 3.7.8 or later. I tried ‘pybombs’ before seeing your post, and it was not successful, even after increasing swap space. I just didn’t know about the compiler issue. So *thanks!*

Leave a Reply

Your email address will not be published. Required fields are marked *