Teaching qradiolink to Speak D-STAR and Fusion

Teaching qradiolink to Speak D-STAR and Fusion

Table of Contents

How a laptop, a bladeRF and a lot of HackRF recordings got two digital voice modes on the air.

There’s a particular kind of frustration that only radio people know. The software says everything is fine. The logs say bytes are flowing. The waterfall shows a nice fat signal. And the repeater a few miles away hears… nothing.

This is the story of getting D-STAR (Icom’s digital voice mode) and C4FM / System Fusion (Yaesu’s) working from qradiolink, an open-source software-defined radio (SDR) application, running on a MacBook and transmitting through a bladeRF SDR. Neither mode was possible from that setup before. Both now work, and getting there taught me more about what actually goes out of an antenna than years of reading datasheets.

How to read this post. The story is written for anyone. Sections in grey boxes marked ⚙ Under the bonnet are the technical detail — framing, modulation, the bugs and their fixes. Skip them freely; the story still makes sense without them.


Meet the kit

qradiolink is a free, open-source radio program by Adrian Musceac, YO8RZZ. It’s built on GNU Radio, the open-source signal-processing toolkit, with a Qt interface, and it does in software the jobs a conventional radio does with hardware: filtering, modulation, demodulation and voice coding.

It already covers a lot of ground. There’s analogue FM, AM, SSB and CW, digital voice using Codec2 and Opus, DMR and M17, and it can even send video and IP data over the air. It also does “radio over IP”, linking stations through a Mumble voice server. It works with many SDRs, including the bladeRF, HackRF, LimeSDR, PlutoSDR and Ettus USRP, and it’s released under the GPL v3 licence, so anyone can read the code, change it and share the changes.

What it couldn’t do was D-STAR or C4FM. The D-STAR and C4FM support in this post is my own work on a local copy of the code. It isn’t part of an official qradiolink release yet, so you won’t find it in the download links at the end.

bladeRF

The bladeRF is made by Nuand in San Francisco. Mine is the original bladeRF x40: a board about the size of a postcard that plugs into the computer over USB 3.0 and covers 300 MHz to 3.8 GHz. It’s full duplex, so it can transmit and receive at the same time, with up to 28 MHz of bandwidth from a 12-bit Lime Microsystems LMS6002D transceiver chip and an Altera Cyclone IV FPGA on board.

To the computer, a bladeRF is a very fast pipe for numbers. qradiolink works out exactly what the signal should look like and streams it as a million or more samples a second, and the bladeRF turns those numbers into a real radio signal, here on 70 cm.

HackRF One

The HackRF One comes from Great Scott Gadgets, designed by Michael Ossmann as open-source hardware. It covers a huge range, 1 MHz to 6 GHz, at up to 20 million samples a second. It’s half duplex (it can transmit or receive, but not both at once) and uses 8-bit samples, so it’s less refined than the bladeRF, but it’s affordable, popular and very capable. We’ve looked at it before in our HackRF post.

In this story the HackRF never transmits. It sits beside the laptop as a test receiver, recording everything the bladeRF sends as raw samples, so they can be decoded and measured on the computer afterwards. It turned out to be the most useful tool of the lot.

The bladeRF SDR board: the transmitter that put D-STAR and Fusion on the air
bladeRF x40. Photo: Nuand.
HackRF One: the receive-only listener used to record and decode every test transmission
HackRF One. Photo: SparkFun Electronics, CC BY 2.0, via Wikimedia Commons.

The cast

PartWhat it does
qradiolinkOpen-source SDR transceiver app (GNU Radio + Qt). Does the voice coding, framing and modulation in software.
bladeRFThe SDR that actually transmits — a box that turns a stream of numbers into radio waves.
MacBook (Intel i5)Runs qradiolink, supplies the microphone.
MB6DSThe local gateway: a D-STAR system and an MMDVM hotspot for Fusion, both linked to the internet.
HackRF OneA second SDR, used purely as a listener to record exactly what the bladeRF was putting on air. The hero of this story.
Icom IC-9700 / ID-50Real D-STAR radios, used to check what “correct” looks like.

What happens when you press the PTT

Both modes follow the same broad recipe: your voice is squeezed into a tiny digital stream by a vocoder, wrapped into frames with headers and error correction, turned into a wobbling radio frequency by a modulator, and sent out of the bladeRF.

flowchart TB
    subgraph L["In the laptop — qradiolink"]
        direction LR
        A[🎤 MacBook mic<br/>8 kHz audio] --> B[Volume and<br/>clipping] --> C[Vocoder<br/>AMBE / AMBE+2] --> D[Framing<br/>headers, FEC, sync] --> E[Modulator<br/>GMSK or 4-level FSK]
    end
    subgraph R["On air and beyond"]
        direction LR
        F[bladeRF<br/>431–434 MHz] -. radio .-> G[MB6DS<br/>gateway / hotspot] --> H[(Internet<br/>reflector / XLX)] --> I[Other D-STAR and<br/>Fusion radios]
    end
    L --> R

Every box in that chain had at least one problem. Some were in qradiolink, some in the Mac, and one turned out to be in the hotspot itself.


Part 1 — D-STAR

The symptom

The first transmissions looked perfect from the laptop’s side. qradiolink’s debug log reported the header being built, voice frames queued, the modulator pulling every byte. The repeater’s log, though, showed this:

Radio header decoded - My:          /      Your:          Flags: 00 00 00

It had heard something that looked like the start of a D-STAR transmission — but the header, which carries your callsign and routing, was gibberish.

⚙ Under the bonnet — what a D-STAR transmission looks like

D-STAR voice uses GMSK at 4800 bit/s: a smooth two-tone FM signal (±1.2 kHz deviation, Gaussian filter BT = 0.5). One frequency means a 0, the other a 1, and the Gaussian filter rounds off the transitions to keep the signal narrow.

Binary FSK: the carrier frequency shifts with each data bit

Frequency-shift keying: data (top), carrier, and the modulated signal. Image: Ktims, CC BY-SA 3.0, via Wikimedia Commons.

A transmission is laid out like this:

flowchart LR
    P["Bit-sync preamble<br/>1010… (128 bytes)"] --> S["Frame sync<br/>15 bits"]
    S --> H["Radio header<br/>41 bytes → 660 bits<br/>(FEC, interleave, scramble)"]
    H --> V["Voice frames × N<br/>9 B AMBE + 3 B slow data<br/>every 20 ms"]
    V --> E["End pattern"]

The 41-byte header (flags, RPT2, RPT1, UR, MY callsign + suffix, CRC-CCITT) is protected with a rate-½, K = 3 convolutional code, interleaved and scrambled before it goes on air — so a single wrong bit in the modulation scrambles the whole thing, which is exactly what “blank header, flags 00 00 00” means.

Voice frames come in superframes of 21. The first carries a data-sync pattern (55 2D 16); the other 20 carry 3 bytes each of scrambled slow data, which repeats the header and carries a short text message.

The detective work

The logs had told me all they could. So I put the HackRF next to the laptop in receive-only mode, recorded the bladeRF’s transmissions as raw radio samples, and wrote a small decoder (in Python, following the same algorithm the MMDVM repeater firmware uses) to see exactly what was on air. For comparison I recorded the real MB6DS repeater too.

That recording found two problems that no log could have shown.

flowchart TD
    A["Repeater: blank header"] --> B{"Record with HackRF<br/>and decode offline"}
    B --> C["At 4 MS/s: only fragments<br/>of preamble on air"]
    C --> D["Fix 1: sample rate<br/>4 MS/s → 1 MS/s"]
    D --> E["Continuous signal —<br/>header decodes, but…"]
    E --> F["Real repeater decodes as INVERTED<br/>relative to qradiolink"]
    F --> G["Fix 2: flip TX polarity"]
    G --> H["✅ MB6DS: header decoded,<br/>BER 0.0%"]

Problem one: the laptop couldn’t keep up. qradiolink was running the bladeRF at 4 million samples per second. The MacBook’s i5 couldn’t feed it fast enough, so the radio was transmitting in short bursts with gaps between — on air, only scraps of the preamble came out. Dropping to 1 million samples per second gave a clean, continuous signal.

Problem two: the signal was upside down. With a clean recording, my decoder could read qradiolink’s header perfectly — but it read the real repeater’s signal with the opposite polarity. qradiolink was sending “high tone” for 0 and “low tone” for 1. Real Icom radios do the opposite. Flip it, and:

Radio header decoded - My: MW0AXD  /BLRF  Your: CQCQCQ  Rpt1: MB6DS  B  Rpt2: MB6DS  G  Flags: 40 00 00
AMBE for MW0AXD    Frames: 4.7s, Silence: 0.0%, BER: 0.0%

A perfect header and zero bit errors. 🎉

⚙ Under the bonnet — the other D-STAR fixes

  • Polarity (gr_mod_dstar.cpp): the symbol map is now bit 0 → −1, bit 1 → +1, so a 1 is the higher frequency, as measured off a real repeater. qradiolink inherited the MMDVM convention, which is inverted relative to what’s on air.
  • Repeater flag: flag1 = 0x40 whenever RPT1/RPT2 aren’t DIRECT, so the gateway knows the call is meant to go via it.
  • Slow data: alternate superframes now carry the 41-byte header in 5-byte blocks (type 0x5n, padded with 0x66) and a 20-character text message, all scrambled with 70 4F 93 — as real radios do. Late-joining receivers can then still get your callsign.
  • Longer preamble: 128 bytes of 0xAA rather than 64, because the bladeRF’s TX stream only starts at PTT and the first few milliseconds can be lost while it settles.
  • LO leakage: SDRs leak a little of their local oscillator at the tuned frequency. A 100 kHz tx_carrier_offset moves that spur off-channel.

Then the audio went quiet

D-STAR was decoding, but on the next day’s tests my voice sometimes came through and sometimes didn’t. Three separate culprits turned up, each sneakier than the last.

  1. macOS took the microphone away. Rebuilding qradiolink removed the app’s code signature. macOS ties microphone permission to that signature, so it silently fed the “new” app near-silence instead of asking permission. Re-signing the app after each build fixed it.
  2. The microphone loop ran slightly slow. It handled one 40 ms block of audio per pass and then slept for 39 ms — plus the processing time, a touch over real time. The result was 24 audio blocks a second instead of 25, which starved D-STAR of about 5% of its voice frames. Every time it ran dry the bladeRF briefly stopped transmitting and the receiver lost sync.
  3. Loud audio “wrapped around”. Turning the volume up past full scale made samples flip from maximum positive to maximum negative — a harsh crackle rather than a gentle clip.

⚙ Under the bonnet — the audio fixes

flowchart TB
    subgraph B4["Before"]
        direction LR
        M1[macOS mic<br/>25 blocks/s] --> L1[One block per pass<br/>then sleep 39 ms] --> T1[Encoder gets ~24 blocks/s<br/>runs dry: gaps on air]
    end
    subgraph AF["After"]
        direction LR
        M2[macOS mic<br/>25 blocks/s] --> L2[Drain every waiting<br/>block, then sleep] --> T2[Encoder gets 25 blocks/s<br/>idle: keep newest block only]
    end
    B4 --> AF
  • src/audio/audioreader.cpp: drain every complete buffer per pass; when not transmitting, keep only the newest buffer. Before the second fix, a couple of idle minutes built up 6–9 seconds of old audio, which was all sent at the next PTT.
  • src/radiocontroller.cpp: the volume multiply now clamps to ±32767 instead of letting a 16-bit integer wrap.
  • After any rebuild: codesign --force --deep --sign - qradiolink.app.

Part 2 — C4FM / System Fusion

With D-STAR working, Fusion should have been easy — same app, same radio, same lessons. It wasn’t.

A different kind of signal

Where D-STAR uses two tones, C4FM uses four. Each symbol carries two bits, so twice the data fits in the same channel — at the cost of needing a cleaner signal to tell the levels apart.

⚙ Under the bonnet — C4FM framing

C4FM is 4-level FSK at 4800 symbols/s (9600 bit/s), root-raised-cosine filtered (α = 0.2), with deviations of ±1800 Hz and ±600 Hz. Each pair of bits picks a level: 01 → +3, 00 → +1, 10 → −1, 11 → −3.

Four-level FSK: each pair of bits picks one of four carrier frequencies

Four-level FSK: each pair of bits (top) picks one of four levels, and each level shifts the carrier (middle) to its own frequency (bottom): +3 is highest, −3 lowest, with the outer pair three times as far from the carrier as the inner pair (±1800 vs ±600 Hz). Simplified: the frequencies are exaggerated, and the real signal glides between them because of the filtering. Image: drawn for this post.

Every frame lasts 100 ms: 120 bytes, or 480 symbols.

flowchart LR
    S["Sync<br/>D4 71 C9 63 4D<br/>40 bits"] --> F["FICH<br/>200 bits<br/>Golay + convolutional + interleave"]
    F --> P["Payload — V/D mode 2<br/>5 × (DCH 40 bits + VCH 104 bits)"]
  • FICH (frame information channel) tells the receiver what kind of frame this is: header, voice or terminator; the data type; and the frame number (0–6, cycling). If the FICH doesn’t decode, MMDVMHost drops the frame silently — remember that.
  • DCH carries the callsign and text, one 10-character field per frame number.
  • VCH carries one 49-bit AMBE+2 voice frame (20 ms). The first 27 bits are sent three times over for robustness; the receiver’s bit-error-rate figure is literally how often those three copies disagree.

Silence, in both polarities

Pressing PTT in C4FM mode produced… nothing at the hotspot. Not a garbled header, not an error — nothing at all, even with debug logging turned up to the maximum. Flipping polarity (I added a setting for that) changed nothing.

So, back to the HackRF. This time I took the bits off the air and fed them through MMDVMHost’s own decoding code — the same code that runs on the hotspot:

96 of 96 frames: FICH decoded
FN=1 DCH OK 'MW0AXD    '
voice repetition errors: 0 of 12,690

Every frame perfect. qradiolink’s Fusion transmission was, bit for bit, exactly what a Yaesu radio would send. The problem had to be on the receiving side.

Narrowing it down

flowchart TB
    subgraph S1["1 · Is the transmitter right?"]
        direction LR
        A[Hotspot logs nothing] --> B[HackRF + MMDVMHost code:<br/>96/96 frames valid ✅]
    end
    subgraph S2["2 · Rule things out"]
        direction LR
        C[bladeRF 250 Hz low<br/>tune +250 Hz ✅] --> D[Move hotspot closer<br/>still nothing] --> E[Hotspot decodes D-STAR ✅<br/>so it is C4FM-specific]
    end
    subgraph S3["3 · Find it"]
        direction LR
        F[Modem trace:<br/>no RX YSF at all] --> G[Hotspot sends ±1370 Hz<br/>we send standard ±1800] --> H[Hotspot YSF settings<br/>back to default] --> I[✅ received RF from<br/>MW0AXD, BER 4.5%]
    end
    S1 --> S2 --> S3

Along the way:

  • Frequency. Measuring both transmitters in the same HackRF recording (so the HackRF’s own error cancels out) showed the bladeRF sitting 250 Hz low. Tuning qradiolink to 431.062750 MHz brought the two within 16 Hz. D-STAR shrugs off that kind of error, but C4FM’s inner levels are only 600 Hz from the centre, so it matters more.
  • Deviation. I trimmed qradiolink’s C4FM deviation, which measured about 11% hot, to the exact standard ±1800/±600 Hz.
  • The real culprit. The hotspot is an MMDVM_HS_Hat (firmware 1.6.1), built around the ADF7021 radio chip. That chip demodulates C4FM in hardware using fixed decision thresholds, and on this board the receive side turned out to be tied to the hotspot’s YSF level settings. Its YSFTXLevel had been set to 30, which is why it transmitted at only about 75% of standard deviation — and, it seems, why it couldn’t recognise a signal at the standard level. Putting its YSF settings back to the defaults fixed it on the next over.

Measured C4FM deviation levels, hotspot vs qradiolink The four C4FM levels measured off air, from the same HackRF recording. The hotspot (orange) was transmitting well inside the standard; qradiolink (blue, before the deviation trim) slightly outside it. Dashed lines: the standard ±600 / ±1800 Hz.

⚙ Under the bonnet — the C4FM changes

  • Preamble: 240 bytes of 0x77 (200 ms of alternating +3/−3 symbols) before the header frame, as MMDVM sends, so the receiver can lock while the bladeRF stream settles.
  • Deviation (gr_mod_c4fm.cpp): FM sensitivity factor 0.85 → 0.765, giving exactly ±1800/±600 Hz.
  • Polarity settings: “Invert TX polarity” checkboxes for C4FM and D-STAR on the Mode settings 2 tab (c4fm_tx_invert, dstar_tx_invert). Both should be off: normal polarity is correct for both modes.
  • Hotspot debugging tip: [Modem] Trace=1 in MMDVMHost logs every frame between host and modem. RX YSF Data means the modem heard you; seeing only TX … lines means it didn’t. Turn it off afterwards, because it fills the SD card.

What I learned

  1. Logs tell you what the software intended. Only a recording tells you what actually went out of the antenna. A cheap receive-only SDR and a few hundred lines of Python found every major bug here.
  2. Measure against something real. Polarity and frequency mistakes only showed up when I compared against a real repeater and a real hotspot in the same recording.
  3. Small timing errors matter. 24 versus 25 audio blocks per second sounds trivial. It was the difference between clean audio and dropouts.
  4. Sometimes it’s the other end. After a day of suspecting my own transmitter, the last C4FM problem was a single setting on the hotspot.

What’s next

  • Bring the C4FM bit-error rate down from 4.5% (a clean link should be under 2%) — probably by fine-tuning deviation against this hotspot.
  • Clear up the slightly muffled D-STAR audio: a proper headset microphone and correct gain staging should do it.
  • End-to-end testing across the XLX reflector, with Fusion going in and D-STAR coming out through the transcoder.

73 de MW0AXD


Image credits

Share :

Related Posts

FT8 & FT4 for Beginners -- Setup and Your First Digital QSO

FT8 & FT4 for Beginners -- Setup and Your First Digital QSO

Introduction FT8 and FT4 are among the most popular digital modes in amateur radio. Designed for weak-signal communication, they allow operators to make contacts even when signals are barely audible. These modes are ideal for worldwide communication using modest antennas and relatively low power.

Read More
Testing NXDN Digital Voice

Testing NXDN Digital Voice

Testing NXDN Digital Voice With the new AnyTone D890UV now on the market, and an unofficial firmware update doing the rounds, operators finally have an affordable, consumer-friendly way to test out the NXDN protocol. AnyTone is still awaiting its official NXDN membership status — so consider this experimental for now — but in the meantime there’s nothing stopping us from getting NXDN running on our hotspots and XLX servers and having a proper play.

Read More
DMR, WPSD & DMRGateway

DMR, WPSD & DMRGateway

Introduction to WPSD and DMRGateway If you’ve been running a DMR hotspot for a while, you’ve probably run into the frustrating choice between networks.

Read More