SDR/HackRF One: Mac Setup and Basics

HackRFOne-web

The HackRF One is a very nice software-defined radio (SDR). Though a good bit more expensive than other SDR hardware, it is very well made and Michael Ossmann of Great Scott Gadgets has put together an extensive set of free video tutorials. Of course, those only help if you have everything set up correctly to begin with.

It appears that most SDR work is done through Linux, which makes sense: SDR is classic hardware/software hacking. But for a Mac user, I found it somewhat difficult to get started. This short tutorial will hopefully help kickstart that process for you!

1. INSTALL MACPORTS
If you don’t already have it installed, you’ll need MacPorts, which is a very easy and helpful tool for installing software. Follow their instructions for getting it set up, then head back here.

Want to use something else like Homebrew? I did too, but you’ll regret it. MacPorts is the only option that has everything we need to install, so for the sake of your sanity, I suggest using it. I started with Homebrew and ended up manually deleting everything (a pain) and starting over.

2. INSTALL GNU RADIO COMPANION
Using MacPorts, install GNU Radio Companion, a graphical tool for interacting with the HackRF One.

GNURadioCompanion-web

In the Terminal, type the following command:

This may take quite a while (like 30 minutes, perhaps more), so be patient! More information and other install options can be found on the gnuradio.org website.

3. TEST YOUR PROGRESS
To test if the installation was successful, try importing the gnuradio module into a Python script. In the Terminal, type python  to get an interactive shell, then:

If you don’t get an error, you’ve installed gnuradio properly!

4. TEST GNURADIO COMPANION
Now that we know gnuradio works, let’s try its GUI application gnuradio Companion. Type the following command into the Terminal:

This should launch the application in a GUI window (like above). Don’t worry if you get lots of errors in the Terminal, that’s normal. If the GUI starts without any fatal errors, you’re good to go.

5. DIDN’T WORK?
If you got an error box that says “Cannot import gnuradio”, that’s ok! I spent 3 hours tracking down a solution so you don’t have to.

In your Finder, edit your user’s .bash_profile  and/or .bashrc  files. If you don’t know how to see hidden files on your computer, just type the following in the Terminal:

Look for lines with something like this and add a # in front of the line to comment it out:

Save the file (if you’re in the Terminal text editor, hit Control+X, then Y and return to save). You might need to quit Terminal for the changes to take effect. Then run step 4 again: hopefully it works!

6. INSTALL HACKRF SOFTWARE AND TEST CONNECTION
Additionally, we need to install software for the HackRF One. Again in the Terminal, use MacPorts to install:

Then, plug your HackRF One board into your computer’s USB port. In the Terminal, type the following command to check if the board is connected:

You should get a string of data that lists the board’s firmware version, serial number, etc.

7. INSTALL OSMOSDR
Ok, one more set of tools. This plugs everything together, and lets our HackRF One connect to gnuradio Companion. Run both of these commands:

This one may also take a long while – it will install a lot of other libraries that are required. If you don’t get any errors, you should be ok.

8. INSTALL GQRX (optional)
If you want something more intuitive to play with your new SDR device, GQRX is a good option and one of the few available for Mac. Lots of help from this tutorial for this step.

GQRX

To install:

To test that everything works, open GQRX:

It will launch as a full GUI application with some very nice filters and other options built-in. If you get some scary warnings when starting for the first time, just ignore them 😉.

THAT’S IT!
You made it! Play with GQRX and tune into some weird stations. Follow along with the HackRF One video tutorials and build some cool modules. If you run into trouble or have questions, post them in the comments.

Did you find this post helpful or interesting? A small donation goes a long way towards helping produce this content. If you can't, please share what you've done with others!
Donate via Flattr

29 Replies to “SDR/HackRF One: Mac Setup and Basics”

  1. Hi,
    I followed you installation handout,
    a good addition will be how to install the line tools first for xcode: xcode-select --install

    But I have a problem too, that I didn’t find how to solve it. Here is my terminal log file. Osx is El Captan.
    Can you help me?

    ---> Computing dependencies for gnuradio
    ---> Dependencies to be installed: doxygen fftw-3-single fftw-3 graphviz fontconfig freetype gd2 jpeg tiff xpm xorg-libXext xorg-libX11 xorg-kbproto xorg-libXau xorg-xproto xorg-libXdmcp xorg-libxcb xorg-libpthread-stubs xorg-xcb-proto xorg-xextproto xorg-libXt xorg-libsm xorg-libice gts glib2 libffi pcre libnetpbm libLASi pango Xft2 xrender xorg-renderproto cairo libpixman xorg-xcb-util gobject-introspection libtool py27-mako py27-beaker py27-setuptools py27-markupsafe harfbuzz graphite2 urw-fonts webp xorg-libXaw xorg-libXmu gsl jack db60 libsamplerate libsndfile flac libogg libvorbis libxslt libsdl xorg-libXrandr xorg-randrproto log4cpp pkgconfig portaudio py27-cheetah py27-lxml py27-matplotlib py27-cairo py27-cycler py27-six py27-dateutil py27-tz py27-numpy libgcc cctools llvm-3.7 libcxx llvm_select gmp isl ld64 ld64-latest libmpc mpfr py27-cython cython_select py27-nose nosetests_select py27-parsing py27-pyobjc-cocoa py27-pyobjc py27-py2app py27-macholib py27-modulegraph py27-altgraph py27-tornado py27-backports-ssl_match_hostname py27-backports py27-backports_abc py27-certifi py27-singledispatch qhull py27-opengl py27-Pillow lcms2 openjpeg jbigkit py27-tkinter tk tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-opengl-accelerate py27-pygtk atk gtk2 gdk-pixbuf2 jasper shared-mime-info hicolor-icon-theme xorg-libXcomposite xorg-compositeproto xorg-libXfixes xorg-fixesproto xorg-libXcursor xorg-libXdamage xorg-damageproto xorg-libXi xorg-inputproto xorg-libXinerama xorg-xineramaproto libglade2 py27-gobject py27-pyqt4 dbus-python27 dbus dbus-glib py27-sip qt4-mac libmng py27-pyqwt qwt52 py27-scipy swig-python swig py27-sphinx py27-alabaster py27-babel py27-docutils py27-roman py27-imagesize py27-jinja2 py27-pygments py27-snowballstemmer sphinx_select py27-wxpython-3.0 wxPython-3.0 wxWidgets-common wxWidgets_select qwtplot3d uhd gzip libusb py27-requests volk orc xmlto coreutils docbook-xml docbook-xml-4.1.2 docbook-xml-4.2 xmlcatmgr docbook-xml-4.3 docbook-xml-4.4 docbook-xml-4.5 docbook-xml-5.0 docbook-xsl findutils fop getopt libpaper
    ---> Configuring doxygen
    Error: org.macports.configure for port doxygen returned: configure failure: command execution failed
    Error: Failed to install doxygen
    Please see the log file for port doxygen for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_doxygen/doxygen/main.log
    Error: The following dependencies were not installed: doxygen fftw-3-single fftw-3 graphviz fontconfig freetype gd2 jpeg tiff xpm xorg-libXext xorg-libX11 xorg-kbproto xorg-libXau xorg-xproto xorg-libXdmcp xorg-libxcb xorg-libpthread-stubs xorg-xcb-proto xorg-xextproto xorg-libXt xorg-libsm xorg-libice gts glib2 libffi pcre libnetpbm libLASi pango Xft2 xrender xorg-renderproto cairo libpixman xorg-xcb-util gobject-introspection libtool py27-mako py27-beaker py27-setuptools py27-markupsafe harfbuzz graphite2 urw-fonts webp xorg-libXaw xorg-libXmu gsl jack db60 libsamplerate libsndfile flac libogg libvorbis libxslt libsdl xorg-libXrandr xorg-randrproto log4cpp pkgconfig portaudio py27-cheetah py27-lxml py27-matplotlib py27-cairo py27-cycler py27-six py27-dateutil py27-tz py27-numpy libgcc cctools llvm-3.7 libcxx llvm_select gmp isl ld64 ld64-latest libmpc mpfr py27-cython cython_select py27-nose nosetests_select py27-parsing py27-pyobjc-cocoa py27-pyobjc py27-py2app py27-macholib py27-modulegraph py27-altgraph py27-tornado py27-backports-ssl_match_hostname py27-backports py27-backports_abc py27-certifi py27-singledispatch qhull py27-opengl py27-Pillow lcms2 openjpeg jbigkit py27-tkinter tk tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-opengl-accelerate py27-pygtk atk gtk2 gdk-pixbuf2 jasper shared-mime-info hicolor-icon-theme xorg-libXcomposite xorg-compositeproto xorg-libXfixes xorg-fixesproto xorg-libXcursor xorg-libXdamage xorg-damageproto xorg-libXi xorg-inputproto xorg-libXinerama xorg-xineramaproto libglade2 py27-gobject py27-pyqt4 dbus-python27 dbus dbus-glib py27-sip qt4-mac libmng py27-pyqwt qwt52 py27-scipy swig-python swig py27-sphinx py27-alabaster py27-babel py27-docutils py27-roman py27-imagesize py27-jinja2 py27-pygments py27-snowballstemmer sphinx_select py27-wxpython-3.0 wxPython-3.0 wxWidgets-common wxWidgets_select qwtplot3d uhd gzip libusb py27-requests volk orc xmlto coreutils docbook-xml docbook-xml-4.1.2 docbook-xml-4.2 xmlcatmgr docbook-xml-4.3 docbook-xml-4.4 docbook-xml-4.5 docbook-xml-5.0 docbook-xsl findutils fop getopt libpaper
    To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
    Error: Processing of port gnuradio failed

  2. It looks like the install got hung up installed doxygen, which is a dependency for gnuradio. I’d try to manually install doxygen (using the command sudo port install doxygen, or from the source code) and see if you can get that to work. With it properly installed, you should then be able to install gnuradio.

  3. i was able to install gnuradio after installing doxygen individually. but now when I try to run “gnuradio-companion”, python keeps closing/crashing.

    the error message is like this

    ——————————————————————————————–
    $ gnuradio-companion

    ** (process:51425): WARNING **: Trying to register gtype ‘GMountMountFlags’ as enum when in fact it is of type ‘GFlags’

    ** (process:51425): WARNING **: Trying to register gtype ‘GDriveStartFlags’ as enum when in fact it is of type ‘GFlags’

    ** (process:51425): WARNING **: Trying to register gtype ‘GSocketMsgFlags’ as enum when in fact it is of type ‘GFlags’
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
    warnings.warn(str(e), _gtk.Warning)
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnuradio/grc/gui/Actions.py:32: GtkWarning: gdk_keymap_get_for_display: assertion ‘GDK_IS_DISPLAY (display)’ failed
    _keymap = gtk.gdk.keymap_get_default()
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnuradio/grc/gui/Colors.py:24: GtkWarning: gdk_screen_get_system_colormap: assertion ‘GDK_IS_SCREEN (screen)’ failed
    _COLORMAP = gtk.gdk.colormap_get_system() #create all of the colors
    Unable to import Colors
    Floating point exception: 8
    —————————————————-

    also tried to import it into the pthon interpreter but it says the class is not found.

  4. I had similar problems myself. I ended up uninstalling everything and starting over a few times. Can’t say what will do it for your particular case, but that would be a good place to start. Sorry I don’t have a magic-bullet fix!

  5. Thank you for your blogpost, but I had no luck following it.
    The only result starting gnuradio-companion – after many tries – is:

    mozart:~ framlin$ gnuradio-companion
    Traceback (most recent call last):
    File “/opt/local/bin/gnuradio-companion”, line 29, in
    from gnuradio.grc.main import main
    ImportError: No module named main

    Do you have any ideas, whats going wrong? Seems to be any Python issue, doesn’t it?

  6. Aehm, I do not have a .bash_profile.
    I only have a .profile.

    Should I create one? What should I add to the .bash_profile?

  7. Hmm, the step that deals with the .bash_profile file is to comment out (ie: remove) a line. Are you sure you don’t have the file in your user’s home folder? If you find it, you do need to complete that step. If not, the fact that it is missing might be causing the issue (though I’m not really sure how to fix it, I’m afraid!).

  8. yes, I am sure ;)

    But, i have NO PYTHONPATH.

    framlin$ echo $PYTHONPATH

    that means there is an EMPTY-output.
    May this cause the problem? Should one have a value within $PYTHONPATH?

  9. I solved the problem of python where I get an error of importing gnuradio. In macports you should first select your python.

    $ port select python

    Results:
    none (active)
    python26-apple
    python27
    python27-apple

    Than select the proper python, in my case it was “python27”. Not the “python27-apple”. With $”port select python python 27″ the results are:

    none
    python26-apple
    python27 (active)
    python27-apple

    After that I was able to load the package gnuradio into python.

  10. Thanks Joe – I haven’t tried this recently, but when I attempted to install everything by Homebrew, it broke at the final steps and I had to start over. Did it work for you all the way through?

  11. I followed the instructions here, but had a few problems. First, installing gnuradio failed at the point where the system was installing doxygen. I resolved that by installing doxygen manually, as someone suggested. However, after the installation of gnuradio appeared to complete successfully on my next attempt, I encountered a new problem when I typed “import gnuradio” at the Python prompt:

    >>> import gnuradio
    Traceback (most recent call last):
    File “”, line 1, in
    ImportError: No module named gnuradio

    At the Terminal prompt, I typed “which python”, and I got “/usr/bin/python”. I typed “type gnuradio” and got “-bash: type: gnuradio: not found”. Back in Python, I typed “import sys” and then “sys.path” and got a series of paths that were all different from the location where I later found the gnuradio folder. The only gnuradio folder my system can find is located at “/opt/local/share”. I would also note that, at the Terminal prompt, when I typed “port select python”, it resulted in:

    “Available versions for python:
    none (active)
    python26-apple
    python27
    python27-apple”

    I typed “port select python27”, and I got: “Warning: Unable to get active selected version: The specified group ‘python27’ does not exist.
    Error: The ‘list’ command failed: The specified group ‘python27’ does not exist.” I then tried the same command for the other two listed available versions for python, and in all cases, I the same error occurred.

    Any advice on how I should proceed would be greatly appreciated.

  12. Yikes, not sure I can help. But one thing at a time:

    First, running type gnuradio in the Terminal will give you that error – gnuradio is not a command line command.

    Second, did you update the .bash_profile file as in Step 5? If not, that could well be the problem.

    Finally, when I type in gnuradio.__file__ (which tells me where it’s installed), I see /usr/local/lib/python2.7/site-packages/gnuradio. Then, when I look in the sys.path list, I see that /usr/local/lib/python2.7/site-packages is listed. So, if you don’t see that location yourself, you could try adding it to your PYTHONPATH.

    Hope that works!

  13. Hi there. Thanks for the post. I tried it and got the same result as Jay. I.e.:
    ** (process:51425): WARNING **: Trying to register gtype ‘GMountMountFlags’ as enum when in fact it is of type ‘GFlags’

    ** (process:51425): WARNING **: Trying to register gtype ‘GDriveStartFlags’ as enum when in fact it is of type ‘GFlags’

    ** (process:51425): WARNING **: Trying to register gtype ‘GSocketMsgFlags’ as enum when in fact it is of type ‘GFlags

    I would like to uninstall everything, but am such a newb that I don’t know how. Can anyone help?
    Thanks.

  14. Hi to everyone, I installed xcode, macports then gnuradio. When i tried to import it said something like “can’t import”, I choose the python27 then the import command didn’t return any errors. When I tried to run gnuradio-companion from the terminal…ops…
    ** (process:30507): WARNING **: Trying to register gtype ‘GMountMountFlags’ as enum when in fact it is of type ‘GFlags’

    ** (process:30507): WARNING **: Trying to register gtype ‘GDriveStartFlags’ as enum when in fact it is of type ‘GFlags’

    ** (process:30507): WARNING **: Trying to register gtype ‘GSocketMsgFlags’ as enum when in fact it is of type ‘GFlags’

    (process:30507): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback ‘C’ locale.
    Traceback (most recent call last):
    File “/opt/local/bin/gnuradio-companion”, line 97, in
    check_gtk()
    File “/opt/local/bin/gnuradio-companion”, line 64, in check_gtk
    die(err, “Failed to initialize GTK. If you are running over ssh, ”
    File “/opt/local/bin/gnuradio-companion”, line 42, in die
    import gtk
    File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py”, line 69, in
    _init()
    File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py”, line 57, in _init
    warnings.warn(str(e), _gtk.Warning)
    gtk.GtkWarning: could not open display

    Some ideas?

  15. I looked into the gnuradio.org install guide for mac:

    Prerequisite: X11.app, recommended via XQuartz
    Running almost any GNU Radio graphical interface (GUI) will require downloading and installing X11/XQuartz first.

    Works perfect right now!!!

  16. Im very new at this and could use some help. I have a Hackrf on the way. Trying to setup the software. Your page has been the easiest to get this far but I’m stuck now. It seems to have installed ok at the beginning but I can’t get past the testing. What am I missing?
    Thanks for your help.

    Jeffreys-MacBook-Pro:~ jeffreystitt$ gnuradio
    -bash: gnuradio: command not found
    Jeffreys-MacBook-Pro:~ jeffreystitt$ import gnuradio
    -bash: import: command not found
    Jeffreys-MacBook-Pro:~ jeffreystitt$ gnuradio-companion
    ** (process:83590): WARNING **: Trying to register gtype ‘GMountMountFlags’ as enum when in fact it is of type ‘GFlags’
    ** (process:83590): WARNING **: Trying to register gtype ‘GDriveStartFlags’ as enum when in fact it is of type ‘GFlags’
    ** (process:83590): WARNING **: Trying to register gtype ‘GSocketMsgFlags’ as enum when in fact it is of type ‘GFlags’
    Traceback (most recent call last):
    File “/opt/local/bin/gnuradio-companion”, line 97, in
    check_gtk()
    File “/opt/local/bin/gnuradio-companion”, line 64, in check_gtk
    die(err, “Failed to initialize GTK. If you are running over ssh, ”
    File “/opt/local/bin/gnuradio-companion”, line 42, in die
    import gtk
    File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py”, line 69, in
    _init()
    File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py”, line 57, in _init
    warnings.warn(str(e), _gtk.Warning)
    gtk.GtkWarning: could not open display

  17. update for me. Looking at the other comments I decided to uninstall gnu radio.
    I then installed the 11Xquartz
    installed gnu radio thru that.
    If I go to python no problem but if I try to import gnuradio it doesn’t work.
    If I go to gnuradio-companion it gives some warning errors but then it opens the GUI screen to start.
    Im still waiting on my hardware to arrive and see what happens.
    I still can not select any python port
    Any info would be greatly appreciated
    Thanks Jeffrey

  18. @Jeffrey – see Step 5 for the import error. I found that you really have to do everything perfectly in order, otherwise it doesn’t seem to work. You may have to uninstall and start over, knowing what steps you’ll need.

  19. Hi Jeff. I made all the step above in my mac (macOS Sierra), the gnuradio-companion works perfectly, the hackerf_info works fine too but I can’t find the Osmocom Source block in the gnu, I installed the gr-osmosdr and gr-fosphor as described but no block. Any ideas?

  20. I have tried a couple of times. I uninstall gnuradio. Reinstall step by step and when I look for the bash_profile in terminal window it blank. The only thing working is gnuradio-companion. it opens ok.

    Last login: Wed May 24 11:05:38 on ttys000
    Jeffreys-MacBook-Pro:~ jeffreystitt$ port select python
    Available versions for python:
    none (active)
    python26-apple
    python27
    python27-apple
    Jeffreys-MacBook-Pro:~ jeffreystitt$ port select python python27
    Selecting ‘python27’ for ‘python’ failed: could not create new link “/opt/local/bin/python” pointing to “/opt/local/bin/python2.7”: permission denied
    Jeffreys-MacBook-Pro:~ jeffreystitt$

    Sorry for all the questions but I’m new and I’m very interested in this to work.
    So even though it opens gnuradio-companion it still is not going to function correct?
    Thanks again for your help.

  21. @Jeffrey – you need to use sudo in front of the command (ie sudo port select python python27) and enter your password. Only root users can make changes like that.

  22. @Arturo – sorry, no idea! Did you try a restart? (Dumb, I know, but maybe?) Otherwise, you might have to ask on a gnuradio-companion or HackRF forum.

  23. Thanks much for this set of instructions. Without it, I’m not sure where we’d get started.

    A few comments from my experience —

    – The Python ‘import gnuradio’ didn’t work first time around. I didn’t have the .bash files mentioned so I thought I was stuck. I tried an uninstall, a ‘sudo port python select python python27’ and a reattempt at the install. This did the trick. So perhaps the python version needs to be set *before* the port utility does the installation.

    – The gnuradio-companion is a command-line executable. I got stuck because I thought it ran in the python interpreter.

Leave a Reply

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