Soapy HackRF Full Duplex

Two HackRFs, one radio. Simple enough idea, but getting the timing right was rather more interesting.

By Tom Cully

Soapy HackRF Full Duplex

The HackRF One is a nice little SDR, but it has one fairly significant limitation: it's half-duplex. You can transmit or receive, but not both at the same time.

So it occurred to me: they're relatively inexpensive, so why not use two, and SoapyHackRFDuplex happened.

https://github.com/tomdionysus/SoapyHackRFDuplex

It's a SoapySDR module which combines two physical HackRF One boards into a single virtual full-duplex radio. One receives, one transmits, and applications see a single device with independently configurable RX and TX channels.

Now, the interesting bit isn't simply getting two USB devices running simultaneously. It's synchronisation. Both HackRFs need to share a clock reference, and their sample streams need a common timeline. Happily, the units can use an optional 10MHz reference module, and have CLK_IN and CLK_OUT exposed as SMA - if one of the HackRF has a 10MHz module, you can connect the second with a short pigtail so they share a hardware clock reference. Then, it was just a matter of creating a calibration process which establishes the relative sample offset between the two radios.

This also allows proper timed transmission through the SoapySDR API. An application can schedule a transmission against a receive timestamp, rather than relying on host-side timing and hoping for the best.

I've tested this on real hardware, including a four-hour timed-transmission soak in which over a million bursts were received at precisely their requested sample positions.

A few other things worth mentioning:

  • Works with stock HackRF firmware and stock libhackrf. No firmware modifications required.
  • Standard SoapySDR interface, so it works with GNU Radio, SoapyRemote, Python and other compatible applications.
  • Independently configurable receive and transmit frequencies, gains and sample rates.
  • Supports timed TX and RX, with sample-level scheduling against the shared timeline.
  • Includes hardware diagnostics and an acceptance test utility.
  • Debian packages available for amd64 and arm64, including the Raspberry Pi 5.

The Pi 5 handles full duplex up to 16 Msps. Getting to 20 Msps requires a host with sufficient USB bandwidth, which I haven't as yet tried.

The project is GPL-3.0, and the source, documentation, build instructions and Debian packages are all available.

As usual, I'd appreciate testing, feedback, bug reports and suggestions. Particularly interested in hearing from anyone running this on hardware other than the Pi 5.