The Problem
Software-defined radio (SDR) platforms require tight integration between firmware, FPGA gateware, host drivers, and hardware designs. Most SDR repos scatter these layers across separate projects with inconsistent build systems, making it difficult to reproduce a working radio from source or contribute changes that span the stack.
What This Does
This repository is the official HackRF source tree—a low-cost, open-source SDR platform. It contains five self-contained projects: firmware/ (278 files, C and Python for the LPC43xx MCU and FPGA), host/ (27 files, C libraries and CLI tools like hackrf_transfer.c), hardware/ (121 files, KiCad schematics and board layouts), ci-scripts/ (10 files, Jenkins and test harnesses), and tools/ (6 files, utilities). The docs/ folder (89 files) holds Sphinx-based documentation covering both hardware and software.
The firmware is the largest component—126 code files spanning MCU firmware, FPGA gateware (Python-generated Verilog), and a CPLD debug interface. The host stack provides a userspace library (libhackrf) and command-line tools for streaming IQ samples.
How It Is Wired
Execution starts in one of three places depending on the target: firmware/ builds via CMake (firmware/CMakeLists.txt), the host tools compile from host/hackrf-tools/src/hackrf_transfer.c, and CI orchestration begins at Jenkinsfile or .github/workflows/build.yml. The firmware's USB command interface routes through firmware/common/usb.c, which carries 11 unresolved TODO markers and is a central hub for device control. The FPGA gateware in firmware/fpga/ uses Python scripts to generate Verilog, with interface/ modules (spi, sgpio, max586x) handling chip-level communication.
The import graph shows 41 internal Python modules with only 5 edges—the firmware's FPGA tooling is largely self-contained. The most connected modules (firmware/fpga/interface/__init__ and firmware/fpga/util/__init__) are pure aggregators with no inbound dependencies, so changing them is low-risk. The hardware design files in hardware/ are not code and have no runtime wiring.
How To Use It
Setup: Build the host tools from source. The repo uses CMake for firmware and a Makefile-based flow for host tools. A Dockerfile (based on ubuntu:22.04) provides a build environment.
git clone https://github.com/moses-y/hackrf
cd hackrf/host
mkdir build && cd build
cmake .. && make
Configuration: No runtime configuration files are required. Firmware flashing uses hackrf_spiflash from the host tools.
Running it: The primary CLI is hackrf_transfer, which streams IQ samples to/from the device:
hackrf_transfer -r capture.iq -f 915 -s 8000000
This captures 8 MS/s at 915 MHz to capture.iq.
Real-World Use
A typical application: spectrum monitoring. Capture a wideband sweep, process it offline, and detect signals of interest.
hackrf_transfer -r sweep.iq -f 2400 -s 20000000 -n 50000000
# Process sweep.iq with GNU Radio or numpy
Code Health & Issues
Static analysis (not manual review) found 52 issues: 23 high, 26 medium, 3 low. Key findings:
- High – Deep nesting (29 occurrences) in
firmware/fpga/interface/spi.pyandfirmware/common/clock_gen.c, with max indentation depth of 8. - High – Duplicated 6-line blocks (1,424 repetitions across 200 files), notably in
ci-scripts/hackrf_pro_test.pyandfirmware/common/adc.c. - High – Oversized files:
firmware/common/rad1o/ubuntu18.cat 3,300 lines;host/hackrf-tools/src/hackrf_transfer.csimilarly large. - Med – Files opened without context managers in
firmware/tools/dump_cgu.pyandfirmware/tools/edit-font.py; broad exception handling in CI scripts; high branching density infirmware/common/picoprintf.c. - Low – TODO/FIXME markers: 3 in CI scripts, 11 in
firmware/common/usb.c.
SDLC observations: CI exists (Jenkins + GitHub Actions), tests are present (15 files), and a license is included. However, the Docker base image (ubuntu:22.04) is unpinned, GitHub Actions use mutable tags (lukka/get-cmake@latest), no dependency update bot is configured, and no vulnerability scanning gates PRs.
The Bottom Line
This is the reference implementation of a widely-used SDR platform—the hardware and firmware are battle-tested across thousands of deployed units. The codebase shows its age in file size and nesting, but the architecture is sound and well-documented. Use it if you need to extend HackRF firmware, build custom FPGA gateware, or integrate the host API into your own tooling.