FusionFoundry: Adding D-STAR to the Baofeng DM-1701

FusionFoundry: Adding D-STAR to the Baofeng DM-1701

Table of Contents

In the last post we taught a Baofeng DM-1701 (v1) DMR handheld to speak Yaesu System Fusion. That turned out to be the easy one. C4FM and DMR are close cousins, so the radio’s chips could do most of the work.

D-STAR is Icom’s mode, and it’s a different animal. This post is about getting it onto the same radio, in the same FusionFoundry fork of the open-source RadioFoundry firmware.

If you want the background on the mode itself first, read our How D-STAR works explainer.

Whose code is it?

Credit where it’s due. The D-STAR code itself was written for upstream RadioFoundry by Brian Henderson, in pull request 809. It was written clean room from the JARL D-STAR standard, and it was built for the DM-32UV, whose HR_C7000 chip has flat FM audio paths that suit D-STAR well. That code has already been used on air with Icom radios on the DM-32UV.

The DM-1701 doesn’t have those paths. FusionFoundry’s part was to bring it across to the DM-1701: a new way in and out of the radio for D-STAR’s signal, finding the RAM for it, and testing the result. As with the C4FM work, Claude helped with the port and, most of all, with the test harnesses.

Why D-STAR is harder than C4FM

C4FM worked on the DM-1701 because it shares so much with DMR. D-STAR shares almost nothing:

DMRC4FM (DN)D-STAR
Modulation4-level FSK4-level FSKGMSK, 2 levels
Rate4,800 symbols/s4,800 symbols/s4,800 bit/s
Pulse shaperoot raised cosineroot raised cosineGaussian
Voice codecAMBE+2 half-rateAMBE+2 half-rateAMBE 3600x2400 (the older AMBE)

Two problems fall out of that table.

  1. The modulation. The HR_C6000 is a 4-level FSK chip. It has no GMSK modem, and no setting turns one on.
  2. The voice codec. D-STAR uses the original AMBE codec, not AMBE+2. The radio’s vocoder only speaks AMBE+2, so for D-STAR it’s no help at all.

The signal path

How the DM-1701 receives and sends D-STAR. Receive: the AT1846S RF chip gives the FM discriminator; the HR_C6000 passes a flat FM copy with its filters off; a new GMSK demodulator on the STM32 recovers 4,800 bit/s and the D-STAR frames; a software AMBE 2400 decoder turns them into speech, because the chip’s own vocoder only does AMBE+2. Transmit: a software AMBE 2400 encoder makes voice frames; the framer sends each bit as a symbol, 1 as +3 and 0 as -3; the HR_C6000’s DMR 4,800 symbol/s pipe sends them as two levels at plus or minus 1,200 Hz; the AT1846S puts them on air. The pulse shape is DMR’s root raised cosine rather than D-STAR’s Gaussian.

The trick is the same one C4FM used: stop treating the DMR chip as a DMR chip.

Receiving. The HR_C6000 can hand the processor a copy of the FM discriminator audio, from 0 to 3,400 Hz with every receive filter switched off. That’s raw enough for a GMSK demodulator. The demodulator runs on the STM32: it removes any DC offset from frequency error, finds the bit clock from the zero crossings, and decides each bit in the middle. From there the D-STAR framing takes over: the radio header with its callsigns, the voice frames and the slow data.

Transmitting. Here’s the neat part. D-STAR’s GMSK is 2-level at 4,800 bit/s. The HR_C6000 already has a pipe that sends 4,800 symbols a second for DMR. Use only its outer two levels, a 1 as +3 and a 0 as −3, and it sends a 2-level signal at ±1,200 Hz deviation. That’s D-STAR’s deviation.

It isn’t quite real GMSK. The chip shapes each symbol with DMR’s root raised cosine pulse, not D-STAR’s Gaussian one. A D-STAR receiver will see a little more overlap between neighbouring bits than it would from an Icom radio. Our own demodulator decodes it cleanly, and it’s good enough to make contacts, but it’s one reason this isn’t a match for a real D-STAR radio (more on that below).

A software AMBE codec

The voice codec was the bigger job, and it’s Brian’s work in the upstream code: an AMBE 3600x2400 encoder and decoder in software, in integer maths, small enough for a 168 MHz processor with no hardware help. The decoder is based on the ISC-licensed mbelib. The encoder was tuned against Icom radios, which showed that a real DVSI encoder doesn’t make the same choices mbelib would guess. There’s also a speech leveller so loud voices don’t hit the decoder’s ceiling on the other end.

On the DM-1701 the codec has to share the radio with everything else, which brings us to RAM.

Finding the RAM

The DM-1701’s STM32F405 has 192 KB of RAM and it was already nearly full. Three things make room:

  • The codec borrows the DMR vocoder’s memory. D-STAR and DMR never run at the same time, so the codec uses the vocoder’s working block while a D-STAR channel is in use. This is the same trick C4FM’s VW mode uses.
  • One mode area. D-STAR’s engine and C4FM’s engine share one block of memory. Only one of them runs at a time.
  • The IP gateway is left out. FusionFoundry’s DM-1701 build drops the USB network and its services to make room for C4FM and D-STAR.

If the memory still can’t be found, the radio says so instead of failing quietly:

Two Home screens. Left: No callsign set, Can’t transmit, Set it: hash then My call. Right: a D-STAR channel showing No calls heard yet and No RAM for voice

Left: like C4FM, D-STAR refuses to transmit without your callsign. Right: what you’d see if the codec couldn’t get its memory.

Using it

A D-STAR channel lives in the codeplug like any other, with the kind DV. You set your callsign and a short message once for the whole radio, and each channel has its UR (who you’re calling) and, if you’re working through a repeater, the repeater’s callsign.

Two Home screens on a D-STAR channel called 3 County DMR. Left: sending to CQCQCQ, 1W DV Direct. Right: sending to CQCQCQ via Q1RPT module B

Left: simplex, calling CQ. Right: the same channel set to go via a repeater. The module letter goes in the eighth place of the repeater’s callsign, as D-STAR expects.

Press # on Home for the D-STAR page. Each row sets UR for you, the job you’d otherwise do by typing callsigns:

Four screens. The D-STAR menu: Heard M0XYZ/5100 Hello from the park; 1 Send to CQCQCQ, 2 Call CQ, 3 Call last caller M0XYZ, 4 Echo test, 5 Link reflector. Typing REF030 into a callsign box. Home showing Link REF030 C with Link: press PTT once. Home showing Echo test with Echo: talk, then listen

Top left: the menu. Top right: typing a reflector. Bottom left: ready to link to REF030 C. Bottom right: ready for an echo test.

  • Call CQ and Call last caller set UR for now, until you change channel or press Back on Home.
  • Echo test: the next over asks the gateway to play you back, so you can hear how you sound.
  • Link reflector takes the reflector the way people write it (REF030C, REF030CL and REF30C all work) and builds the eight-character link command itself. Unlink and Gateway info are rows 6 and 7. A one-letter command always goes in the eighth place of UR, however it was typed.
  • Echo, link, unlink and info go out with one over, then UR goes back to the channel’s.
  • Rows 8, 9 and 0 set My call, the four-character suffix and the message.

Receiving and transmitting

Three screens. Receive: M0XYZ /5100, UR CQCQCQ, Q1RPT B to Q1RPT G, Hello from the park, at minus 83 dBm. Home with M0XYZ/5100 heard 12s ago saying Hello from the park. Transmit: TALKING to CQCQCQ via Q1RPT B to Q1RPT G, from Q1ABC, 0:01 of 3:00

Left: a call coming in, with the caller’s callsign and suffix, the route through the repeater and their slow-data message. Middle: Home remembers who you last heard. Right: transmitting through a repeater.

On receive the radio shows the caller, their four-character suffix, who they were calling, the repeater route and the 20-character message from the slow data. On transmit it sends a preamble long enough for the radio to settle after key-up, the header, then voice frames with your message in the slow data, then D-STAR’s end pattern.

Testing it

The upstream code arrived with its tests, and they were the safety net for the port:

  • Test vectors for the header coding, the framing and the slow data, from an independent reference written from the standard.
  • Headers recorded off air from an IC-9700 and an ID-51. Our header coder has to build exactly the same bits from the same fields. That catches the kind of mistake a home-made reference would share with the code it tests.
  • The modem on the host. The DM-1701’s route, DMR-shaped symbols in, goes through the GMSK demodulator on the computer before it ever goes near the radio.
  • A host test of the whole radio core, switching between DMR, D-STAR, C4FM and FM.

As with the C4FM work, AI was most useful here, building harnesses and replaying captures until the bugs had nowhere to hide.

A fair warning about the audio

It works, and you can make QSOs with it, but the audio quality isn’t great. D-STAR has been squeezed onto a radio that was never built for it: GMSK sent through a DMR chip with the wrong pulse shape, and the voice codec running in software on a small processor instead of a proper AMBE chip. That shows in how it sounds.

Have a listen and judge for yourself. First the DM-1701, then an Icom ID-52 for comparison:

The DM-1701 on D-STAR (about 10 seconds).
An Icom ID-52 on D-STAR, from the ID-52’s own voice recorder (about 8 seconds).

Treat it as a fun experiment and a way to try D-STAR on a radio you already own. If D-STAR is going to be your main mode, you’re much better off with a proper D-STAR radio.

What isn’t done yet

  • Audio quality. See the warning above. There’s room to improve the codec and the transmit pulse shape.
  • Deviation still needs measuring off air with proper test gear.
  • D-STAR’s fast data (DD mode) isn’t written. This is DV voice with slow data only.

Can I try it?

Not yet. FusionFoundry hasn’t been published. As with C4FM, the plan is to offer the DM-1701 route back to upstream RadioFoundry on top of Brian’s D-STAR pull request, so it ends up where everyone can use it.

Licence note: in the UK, D-STAR belongs in the digital voice parts of the band plan, the same as C4FM and DMR. If you link to a reflector, you’re on the air through every gateway connected to it, so identify as you would anywhere else.

Share :

Related Posts

Introduction to DMR Radio

Introduction to DMR Radio

An Introduction to DMR (Digital Mobile Radio) Digital Mobile Radio (DMR) has become one of the most widely used digital voice modes in amateur radio. It blends traditional RF with modern networking, allowing operators to communicate locally or across the world with relatively modest equipment.

Read More
FusionFoundry: Adding C4FM to the Baofeng DM-1701

FusionFoundry: Adding C4FM to the Baofeng DM-1701

In the last post we looked at other people’s firmware hacks. This one’s our own.

Read More
Quansheng UV-K5: SSB on a Budget with Double Sideband

Quansheng UV-K5: SSB on a Budget with Double Sideband

The Quansheng UV-K5 is a dual-band 2m/70cm handheld that sells for about £25. On its own that makes it a decent cheap FM handie. What makes it special is the community firmware. Because the radio can be reflashed over the programming cable, people have rewritten its software to add a spectrum display, AM and SSB receive, wide frequency coverage, and transmit on “SSB”.

Read More