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+  
pybombs recipes add 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 jessie main contrib non-free
deb jessie rpi
#deb 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:

  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 responses to “Compiling GnuRadio on a Raspberry Pi”

  1. Emmanuel Avatar

    Thanks man this post is amazing!! I was struggling with the correct install of GNUradio, thanks a lot…

  2. Emmanuel Avatar

    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

  3. luke Avatar

    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.

  4. Imen Avatar

    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

  5. Lance Avatar

    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]?

  6. ay Avatar

    I am running gnu radio on rasberry pi zero. Its running fine but I run fm radio example by ettus research. Gnu Radio uploads the firmware and then shows these errors bellow:


    Preferences file: /home/pi/.grc
    Block paths:

    Loading: “/home/pi/Desktop/Lab_4.grc”
    >>> Done

    Showing: “/home/pi/Desktop/Lab_4.grc”

    Generating: “/home/pi/Desktop/”

    Executing: “/home/pi/Desktop/”

    linux; GNU C++ version 4.9.1; Boost_105500; UHD_003.007.003-0-unknown

    Using Volk machine: generic_orc
    — Loading firmware image: /usr/share/uhd/images/usrp_b200_fw.hex… done
    — Loading FPGA image: /usr/share/uhd/images/usrp_b210_fpga.bin… done
    — Operating over USB 2.
    — Detecting internal GPSDO…. No GPSDO found
    — Initialize CODEC control…
    — Initialize Radio control…
    — Performing register loopback test… pass
    — Performing register loopback test… pass
    — Performing CODEC loopback test… pass
    — Performing CODEC loopback test… pass
    — Asking for clock rate 32.000000 MHz
    — Actually got clock rate 32.000000 MHz
    — Performing timer loopback test… pass
    — Performing timer loopback test… pass
    VOLK: Error allocating memory (posix_memalign: 22)
    VOLK: Error allocating memory (posix_memalign: 22)
    VOLK: Error allocating memory (posix_memalign: 22)
    ..the above line repeats many time and then
    >>> Done

    CAN you tell me whats the problem