FusionFoundry: Adding C4FM to the Baofeng DM-1701

FusionFoundry: Adding C4FM to the Baofeng DM-1701

Table of Contents

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

FusionFoundry is our fork of RadioFoundry, the free, MIT-licensed firmware for low-cost DMR radios. It adds C4FM, Yaesu’s System Fusion, to the Baofeng DM-1701. That’s a DMR handheld you can pick up second-hand for not much money, and Baofeng never meant it to go anywhere near Fusion.

As of this week it:

  • receives Fusion DN calls, with the caller’s callsign, the repeater they came through and the DG-ID
  • transmits DN that an MMDVM hotspot and a C4FM repeater both decode
  • filters by DG-ID, so you only hear the group you’ve set
  • looks up bridged DMR callers and shows their callsign and name
  • lists the last three stations heard on the home screen
  • controls WIRES-X/YSF rooms from the keypad: status, room list, search, connect, disconnect and favourites (so far tested with YSF only)

The RadioFoundry boot screen on the DM-1701: an orange hexagon logo with a handheld radio, the name RadioFoundry, a test callsign and an owner name

The standard RadioFoundry boot screen, which FusionFoundry builds on. All the screens in this post come from the firmware’s own UI simulator, which runs the real screen code on a computer and draws exactly what the radio’s 160 × 120 display shows.

Why a DMR radio can do C4FM at all

If you’ve read our posts on how DMR works and how C4FM works, you’ll have spotted that they’re closer than the marketing suggests:

DMRC4FM (DN mode)
Modulation4-level FSK4-level FSK
Symbol rate4,800 a second4,800 a second
Channel12.5 kHz12.5 kHz
Voice codecAMBE+2, 49 bits per 20 msthe same AMBE+2, 49 bits per 20 ms
Time slotsTwo (TDMA)None (continuous)
Frame30 ms bursts100 ms frames

The radio, the modulation and the voice codec are all the same. What differs is how the bits are arranged: the sync patterns, the headers, the error correction and where the voice sits in each frame. That’s all software.

The DM-1701 has three main chips: an STM32F405 processor, an HR_C6000 DMR chip and an AT1846S RF chip. Normally the HR_C6000 handles DMR’s framing itself. RadioFoundry had already worked out how to put it into a raw mode, where it just turns the signal into a stream of 4,800 symbols a second and hands them to the processor. With that in place, everything Fusion-specific can run on the STM32.

How a DMR handheld receives C4FM. The AT1846S RF chip tunes the signal and gives the FM discriminator. The HR_C6000 DMR chip, in a raw mode, turns it into 4,800 symbols a second with no DMR rules. The new FusionFoundry firmware on the STM32 finds the C4FM sync, decodes the FICH, callsigns and DG-ID, and builds frames. Voice goes through the radio’s own AMBE+2 vocoder, then to the speaker and screen. It works because DMR and C4FM are both 4-level FSK at 4,800 symbols a second, and C4FM’s DN mode uses the same AMBE+2 half-rate codec as DMR.

Measuring first, coding second

Yaesu does publish a standard for the air interface, but we deliberately didn’t write the code from it. Every value the code relies on was measured off air, or checked against a second, independent implementation.

The firmware already had a useful trick for this: a receive tap, which records the raw discriminator output before any decoding. We parked the radio a few metres from an MMDVM hotspot, keyed up some Fusion traffic, and recorded 15 seconds. A small script found the repeating 20-symbol frame sync blind, measured the levels and cut out 44 frames. Every step of the frame format was then checked against every one of those frames:

  • the FICH: the frame information channel that says what each frame is, protected by a CRC, Golay coding, a convolutional code and interleaving
  • the CSD: the callsigns in the header
  • the DCH: the data that travels alongside the voice
  • the voice: where each 49-bit AMBE+2 frame sits, and in what order. This was checked by ear. If the order’s wrong, you hear garbage.

Then the codec was run against test vectors from upstream RadioFoundry’s own Fusion work (pull request 833, written separately). Our encoder rebuilds every one of those frames bit for bit.

What you see on the radio

Home

Two home screens on a C4FM channel called Fusion Rpt. The first shows DG-ID 00 and the line 1W DN RX All. The second shows DG-ID 40, VW and RX 40. Both say No calls heard yet

Left: a C4FM channel open to every DG-ID. Right: one set to DG-ID 40, so only that group is heard.

A C4FM channel works like any other channel in the codeplug. You can set it from the radio’s own channel editor or from the web-based Codeplug Editor. Each channel has:

  • a TX DG-ID and an RX DG-ID (0–99). RX DG-ID 0 means “play everything”, which is how most Fusion repeaters and radios ship.
  • a voice mode: DN (half-rate voice plus data, the usual one) or VW (full-rate voice)

Your callsign and an optional 20-character message are set once in Settings → My radio. With no callsign set, the radio refuses to transmit on C4FM. Every Fusion transmission names its sender, and we’d rather the radio stopped you than sent something anonymous.

Receiving

Three receive screens. G4ABC on DG-ID 00 DN, C4FM via GB3FN, at minus 79 dBm. M0XYZ Pat, with DMR ID 2345052, C4FM via MW0AXD. 2E0AAA on DG-ID 12, with the warning Other DG-ID: not played

Left: a call through a repeater. Middle: a DMR user bridged into Fusion through a hotspot, with their name looked up from the radio’s DMR ID database. Right: a call on a different DG-ID, shown but kept quiet.

The middle one is a nice touch. When traffic is bridged from DMR into Fusion, the “callsign” that arrives is often just a DMR ID number. The radio already carries the DMR ID database, so it looks the number up and shows the real callsign and name.

Transmitting

Two transmit screens. Left: TALKING in red, M0XYZ, 0:01 of 3:00, Release PTT to stop. Right: NO TX, with Can’t transmit, No callsign in codeplug, Set callsign in editor

Left: transmitting, with the time-out timer counting. Right: what you get if you haven’t set a callsign.

A transmission is sent the way a Yaesu radio sends one. It starts with a 50 ms preamble, then a header with your callsign, then voice frames for as long as you hold PTT, then a terminator. It also sends the small radio-ID message Yaesu radios put in every call. That was added after early reports that Yaesu radios didn’t show our callsign without it.

VW: full-rate voice

VW now works, both receiving and transmitting. Getting there took a few goes.

Why IMBE?

DN uses the same half-rate AMBE+2 codec as DMR, so the DM-1701’s own vocoder handles it. VW is different: it carries full-rate voice at 7,200 bit/s, and Yaesu’s full-rate mode is compatible with the IMBE vocoder that P25 Phase 1 uses. The 144-bit frame and its error correction are the same.

FusionFoundry already had an IMBE decoder and encoder for its P25 mode, written in integer maths to run on the radio’s processor. So instead of writing a new codec, VW reuses that one:

  • No new codec in flash. The DM-1701 has only a few kilobytes of flash to spare, and a second full-rate codec wouldn’t fit.
  • One set of error correction. P25’s 144-bit frame coding was moved into a shared file, so P25 and C4FM use the same code and the same tests.
  • It’s already proven. The P25 voice path had been checked on air before VW used it.

The VW frame layout itself (where the five voice subframes sit in each C4FM frame, and the CSD3 message in the first one) came from upstream RadioFoundry’s Fusion pull request (833), which worked it out from an FT-5D’s VW transmissions. Our VW encoder matches that pull request’s test vectors bit for bit.

The experiments

  1. A memory block of its own. The first version gave the full-rate codec a fixed 4.5 KB block of RAM. On the DM-1701 that came out of the processor’s small fast-memory heap, and the radio went into a boot loop.
  2. Borrowing the vocoder’s memory. One over is either DN or VW, never both. So VW now borrows the DN vocoder’s working memory for the length of a VW over and hands it back afterwards; the vocoder rebuilds its state the next time it runs. With that change the radio boots, and the free heap is exactly what it was before VW (30,232 bytes).
  3. Loudness. Played at P25’s level, VW sounded quieter than DN. It’s now played a little louder than P25 (8/7, about +1.2 dB), set by ear against DN.
  4. When it can’t run. If a build can’t lend the memory, the radio doesn’t fail quietly. Home shows DN, the quick-settings tile is dimmed with “VW not available: DN only”, and PTT sends DN.

Set a channel to VW in the channel editor (the “C4FM mode” row), or switch it for now from the quick-settings tile.

WIRES-X/YSF from the keypad

Hold 9 on a C4FM channel and you get a WIRES-X/YSF screen, much like the DX button on a Yaesu radio:

RowWhat it does
1 Favouritesup to 10 rooms, saved in the codeplug
2 Recentthe last 5 rooms you linked to
3 Roomsthe node’s room list, 20 a page
4 Searchfind rooms by name
5 Connecttype a 5-digit room number
6 Disconnectunlink
7 Refreshask the node for its status

Four WIRES-X/YSF screens. Top left: the WIRES-X menu showing node 10234 N0CALL-ND, not linked, with Favourites, Recent, Rooms, Search and Connect to room. Top right: Rooms 1-20 of 25, starting 40000 UK-HUB. Bottom left: the menu again, now linked to 40001 ROOM 01. Bottom right: Favourites with two rooms

Top: the WIRES-X/YSF menu, then the node’s room list with how many stations are in each. Bottom: linked to a room, and two rooms saved as favourites. The node and rooms are the simulator’s test data.

Each action is one short burst of about half a second. Nothing is sent until you press a key.

Only YSF has been tested so far. The room commands are confirmed working against YSF rooms through an MMDVM hotspot running the latest WPSD, whose YSFGateway answers them. Real WIRES-X, through a Yaesu node, hasn’t been tried yet.

There’s no published standard for these commands. The formats came from our own byte-by-byte WIRES-X write-up and from reading a hotspot’s logs. The trickiest bug made a good lesson. DX and Connect worked first time, but room list and search just vanished: no reply, and not even a line in the gateway’s log. It turned out that WPSD’s YSFGateway reads every command’s parameters from byte 5 and skips byte 4. Without a space character in byte 4, the parameters are off by one and the gateway quietly drops the command. Add the space, and the list appears.

Built from scratch

FusionFoundry’s C4FM code is a new implementation, written for the Baofeng DM-1701 (v1) rather than copied from anywhere. It didn’t come out of nowhere, though:

  • It follows on from MMDVM. Much of what amateurs know about how Fusion looks on air comes from Jonathan Naylor, G4KLX, and his open-source MMDVM modem and MMDVMHost software, which put C4FM into almost every hotspot and plenty of repeaters. It’s also why an MMDVM hotspot was our test partner: if MMDVM decodes us, a big part of the Fusion world can.
  • Our own SDR work came first. Before the DM-1701, the author had already written digital modes for the bladeRF SDR and had C4FM working on SDRs like the bladeRF and HackRF. Our qradiolink post has more on that work.
  • Claude helped port it. Claude helped carry that earlier SDR code across to a very different home: a small STM32 processor, a DMR chip in raw mode, and no operating system.

Where AI really earned its keep was testing. Claude was very handy at building test cases and test harnesses: encoders and decoders that have to round-trip, the frames captured off air kept as fixed test vectors, and a simulated radio for the screens. The SDR code had run fine on the bladeRF and HackRF, but it didn’t work on the DM-1701 at first. Those tests turned up the bugs the author had introduced in the earlier attempts to bring it across. With the tests passing, the code went on air, where the hotspot and the repeater had the final say.

The spec also records where each value stands: known, measured or open. Nothing marked “open” is presented as fact.

What isn’t done yet

  • A real Yaesu radio hasn’t yet confirmed that it shows our callsign. If you’ve got an FT-5D, FT-3D or FTM-series radio and fancy helping, get in touch.
  • Real WIRES-X through a Yaesu node (an HRI-200 or DR-2X) is untested. So far only YSF has been tested and confirmed working, through an MMDVM hotspot running the latest WPSD.
  • Group Monitor (GM) and DSQ aren’t written.
  • Deviation: the nominal outer deviation is ±1,800 Hz, but the hotspot and repeater only decoded us reliably at a setting of 2,400. What actually goes on air for a given setting still needs measuring with proper test gear.

Can I try it?

Not yet. FusionFoundry hasn’t been published. The plan is to offer the WIRES-X/YSF work to upstream RadioFoundry on top of their own Fusion pull request (833), rather than run a separate fork for ever, so the work ends up somewhere everyone can use it.

When it is out, a few things carry over from RadioFoundry:

  • No codec is included. DMR and Fusion DN both need DVSI’s proprietary AMBE+2 vocoder. RadioFoundry’s tools take it from Baofeng’s own firmware file, which you download yourself, and check it by SHA-256 on your machine. Without it, the radio runs FM only.
  • It’s experimental. Back up your codeplug and keep the stock firmware.
  • Check your transmit frequency against a counter or service monitor. Accuracy depends on each radio’s factory calibration.
  • Your licence applies. In the UK, use C4FM on 144–146 MHz and 430–440 MHz, in the digital voice parts of the band plan.
Share :

Related Posts

Quansheng UV-K5: Flashing the CEC Firmware for CW

Quansheng UV-K5: Flashing the CEC Firmware for CW

In the last UV-K5 post we used the IJV firmware to get the radio on SSB. This time it’s CW. The CEC firmware by phdlee adds proper Morse modes to the £25 Quansheng UV-K5: you can key it from the radio’s own buttons or plug in a straight key or paddle.

Read More
2 m CW on a £25 Handheld: The NR7Y Firmware for the UV-K5 and UV-K1

2 m CW on a £25 Handheld: The NR7Y Firmware for the UV-K5 and UV-K1

Last month we flashed the CEC firmware and sent Morse from a £25 Quansheng UV-K5. There’s a catch, though. CEC only runs on the original UV-K5, and most radios sold today are the newer UV-K5 v3 or UV-K1.

Read More
How C4FM, System Fusion and WIRES-X Actually Work

How C4FM, System Fusion and WIRES-X Actually Work

D-STAR’s opposite number, taken apart one layer at a time.

Read More