Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ configuration. It aims to be a general-purpose codeplug compiler: SSRF data
plus a profile compiles deterministically into a validated, radio-neutral
codeplug, and vendor CPS tools are replaceable export or programming
backends rather than the workflow. It targets analog radios CHIRP supports,
DMR radios qdmr supports (Baofeng DM-32, DM-1701, OpenGD77), the Retevis
MateTalk P4, and Benshi Bluetooth radios; `codeplugger radios` lists the
current set, and the [project site](https://codeplugger.chicagooffline.com/)
shows which of them have been programmed on hardware.
DMR radios qdmr supports (Baofeng DM-32, DM-1701, OpenGD77), radios running
RadioFoundry firmware, the Retevis MateTalk P4, and Benshi Bluetooth radios;
`codeplugger radios` lists the current set, and the
[project site](https://codeplugger.chicagooffline.com/) shows which of them
have been programmed on hardware.

Intent, guiding principles, current state, and the roadmap live in
[docs/plan.md](docs/plan.md). The site source is in `site/`.
Expand Down Expand Up @@ -110,7 +111,7 @@ flowchart LR
registry["Instance registry<br/>fleet radios, optional"]
resolve["codeplugger<br/>Resolve and validate against radio capabilities"]
resolved["Resolved codeplug<br/>radio-neutral, deterministic"]
backend["Programming backend<br/>gated write: dmrconf, p64tool, chirp-writer, benlink"]
backend["Programming backend<br/>gated write: dmrconf, radiofoundry-cps, p64tool, chirp-writer, benlink"]
exporter["Exporter<br/>CHIRP CSV / qdmr YAML / P4 TOML / benlink plan"]
cps["CPS tool<br/>CHIRP / vendor CPS"]
artifacts["Artifacts<br/>HTML reference + operation log"]
Expand All @@ -130,12 +131,15 @@ The diagram source is also available in [docs/workflow.mmd](docs/workflow.mmd).

## Documentation

- [docs/profiles.md](docs/profiles.md): the profile format, inheritance,
SSRF roots and overlays, exporter extensions (CHIRP scan skip, qdmr
settings and DMR APRS), and the instance registry.
- [docs/profiles.md](docs/profiles.md): the profile format, per-assignment
settings (receive-only channels, contacts, timeslots), RX groups and scan
lists, inheritance, SSRF roots and overlays, exporter extensions (CHIRP
scan skip, qdmr settings and DMR APRS), and the instance registry with
multiple DMR IDs.
- [docs/backends.md](docs/backends.md): each exporter and programming
backend, with the write gates it enforces: CHIRP CSV and `chirp-writer`,
qdmr YAML and `dmrconf`, P4 TOML and `p64tool`, benlink.
qdmr YAML and `dmrconf`, qdmr YAML and `radiofoundry-cps` for RadioFoundry
firmware, P4 TOML and `p64tool`, benlink.
- [docs/operations.md](docs/operations.md): HTML reference artifacts,
operation logs, and the registry-driven fleet dry run.
- [docs/architecture.md](docs/architecture.md): which repository owns which
Expand All @@ -148,7 +152,7 @@ The diagram source is also available in [docs/workflow.mmd](docs/workflow.mmd).
## Status

Profile resolution and validation, use-case fitting, the fleet dry run, the
four exporters and their gated write backends, and HTML/operation-log
four exporters, the five gated write backends, and HTML/operation-log
artifacts are working today. Which radios have had a codeplugger-generated
codeplug written to them and read back is recorded per radio on the
[project site](https://codeplugger.chicagooffline.com/); the benlink path has
Expand Down
187 changes: 156 additions & 31 deletions docs/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
A resolved codeplug leaves codeplugger one of two ways: as a file an external
CPS tool imports, or through a programming backend that drives the radio
itself. The GPL tools (`chirp-writer`, `dmrconf`, `p64tool`) are reached as
separate processes, never imports; `benlink` is Apache-2.0 and is imported.
Every write is gated: an explicit `confirm`, a backup taken before anything is
overwritten, and a read-back afterwards. `codeplugger program` wires these
gates for you; this page documents each path for when you need the pieces
directly.
separate processes, never imports; `benlink` is Apache-2.0 and is imported;
RadioFoundry's MIT-licensed CPS tools are run out of a checkout of that
project. Every write is gated: an explicit `confirm`, a backup taken before
anything is overwritten, and a read-back afterwards. `codeplugger program`
wires these gates for you; this page documents each path for when you need the
pieces directly.

| Radio family | Exporter | Backend | Write verified on hardware |
|---|---|---|---|
| Analog (CHIRP-supported) | CHIRP CSV | `chirp-writer` | FT-2800M, BF-1909 (driver round trip) |
| Baofeng DM-32 | qdmr YAML | `dmrconf` | yes |
| DM-1701, OpenGD77 | qdmr YAML | `dmrconf` | DM-1701 OEM, RT3S OpenGD77 |
| RadioFoundry (DM-1701, RT3S) | qdmr YAML | `dmrconf` | DM-1701 |
| RadioFoundry (DM-32UV) | qdmr YAML | none; RadioFoundry's `dm32_migrate.py` | no |
| RadioFoundry (DM-1701, RT3S, DM-32UV) | qdmr YAML | `radiofoundry-cps` | DM-1701, DM-32UV |
| Retevis MateTalk P4 | P4 TOML | `p64tool` | yes |
| Benshi (VR-N76, UV-Pro) | benlink plan | `benlink` | no |

Which backend a radio gets is decided by the blocks in its
`capabilities.json` (`chirp`, `benlink`, `radiofoundry_cps`, `dmrconf`,
`p64tool`), and `codeplugger radios` prints the answer for every radio. A
radio that carries both a `radiofoundry_cps` and a `dmrconf` block resolves to
`radiofoundry-cps`.

Per-radio status, with the evidence behind each badge, is on the
[project site](https://codeplugger.chicagooffline.com/) and in
[plan.md](plan.md).
Expand All @@ -42,9 +48,11 @@ Then import `output.csv` in CHIRP and upload from CHIRP to the radio.

Notes:

- CHIRP CSV export currently supports FM channels only.
- Any non-FM channel selected by the profile fails export with an explicit
error.
- CHIRP CSV export supports analog channels only: FM, NFM, and receive-only
AM. NFM is treated as a bandwidth of FM, so an NFM channel always exports
narrow, even when its SSRF record publishes a wide bandwidth.
- An AM channel that is transmit-permitted fails export, as does any other
mode (DMR, for example), each with an explicit error.
- Channel order in the CSV matches resolved profile order.
- Scan exclusion is set per assignment through `extensions.chirp`; see
[profiles.md](profiles.md#excluding-channels-from-scan-chirp).
Expand Down Expand Up @@ -114,6 +122,12 @@ The qdmr YAML exporter produces a codeplug for qdmr's `dmrconf` command-line
tool. Radio-wide settings and DMR APRS go through `extensions.qdmr` in the
profile; see [profiles.md](profiles.md#qdmr-settings-and-dmr-aprs-dm-32).

When an instance registry is supplied, every registered radio's DMR ID is
added as a private-call contact so other radios in the fleet show a name
instead of a number. That covers each entry in a radio's `dmr_ids` list as
well as its primary `dmr_id`: a secondary identity is named from its `name`,
falling back to its `key`.

The `dmrconf` backend wraps the external binary. Its write gates, in order:
`confirm=True`; a headless `dmrconf verify` against the radio key, because
dmrconf's own write-time check does not abort; `detect` must report the
Expand All @@ -136,29 +150,140 @@ was correct. Open-firmware radios reboot on dmrconf's closing control command
and vanish from USB for a few seconds, so the read-back is retried before it
is reported as a failure.

### RadioFoundry firmware
## qdmr YAML and `radiofoundry-cps`

[RadioFoundry](https://radiofoundry.org/) is MIT-licensed multi-mode firmware
that stores its codeplug in the OpenGD77 image layout and answers qdmr's
open-firmware CPS protocol, so a RadioFoundry radio is a separate radio id
(`*_radiofoundry`) with OpenGD77 limits, not a flag on the OEM entry. The STM32
radios (`baofeng_dm1701_radiofoundry`, `retevis_rt3s_radiofoundry`) enumerate
as USB `1FC9:0094` and take the ordinary `dmrconf` path under key `openuv380`;
`detect` reports `Open MD-UV380`, the same name as OpenGD77. The DM-32UV
(`baofeng_dm32_radiofoundry`) has no USB and keeps the image 7 MB into its data
flash, where qdmr's driver cannot write, so that entry carries no `dmrconf`
block: codeplugger exports qdmr YAML and RadioFoundry's own
`tools/dm32_migrate.py restore --yaml FILE` (or the browser Codeplug Editor)
writes it over the programming cable. `dmrconf verify --radio=opengd77` still
checks that YAML offline. P25, NXDN and Tier III channels are not representable
through this path; RadioFoundry carries them in a YAML block qdmr ignores.

**Hardware-verified 2026-11-30** on a DM-1701: a 278-channel, 30-zone write
through `codeplugger program --port /dev/cu.usbmodem21101 --confirm`, read
back and decoded to the same channels, zones and TG lists as an offline encode
of the sent YAML. The one decoded difference was contact `timeSlotOverride`
reading `None` where qdmr encodes `TS1`; RadioFoundry's qdmr-yaml spec says
that is how it reads a contact without an `openGD77` block.
for the Baofeng DM-1701, the Retevis RT3S and the Baofeng DM-32UV. It stores
its codeplug in the OpenGD77 image layout, so a RadioFoundry radio is a
separate radio id (`*_radiofoundry`) with OpenGD77 limits, not a flag on the
OEM entry, and it takes the same qdmr YAML export as the other DMR radios.
What differs is the transport. `codeplugger program` writes these radios with
the `radiofoundry-cps` backend, which drives RadioFoundry's own
`tools/cps_client.py` instead of letting `dmrconf` talk to the radio:

- The DM-32UV is only reachable this way. It has no USB of its own, and
RadioFoundry keeps the image 7 MB into the data flash (wire offset
`0x700000`), where qdmr's driver cannot address it. Before this backend the
entry was export-only.
- dmrconf's transport is unreliable against this firmware. The radio reboots
and drops off USB for several seconds when a session closes, so a cold read
fails with `Device not configured`.
- `cps_client verify` compares the radio against an image. dmrconf has no
equivalent, and its read-back is only an archive.

`dmrconf` is still required, for encoding only. Rendering YAML into an image
stays with qdmr's encoder, reached through RadioFoundry's
`tools/codeplug_port.py`, which puts back the TX contacts that encoder drops
from DMR channels. The backend imports that module from the checkout rather
than keeping a copy of it. Its optional group-list cleanup is switched off: it
mangles the block-style `groupLists` qdmr 0.15.1 exports and drops every list.

What it needs:

- A RadioFoundry checkout containing `tools/cps_client.py`, found through
`--rfoundry-root`, then `$RFOUNDRY_ROOT`, then a `RadioFoundry` directory
next to the codeplugger checkout. The checkout's `.venv/bin/python` is used
when it exists, since that is where its dependencies are installed.
- `dmrconf` on the path, or named with `--dmrconf`.
- `--port` for a radio on a programming cable, which means every DM-32UV.
Without it `cps_client` only finds a single USB `1FC9:0094` device, which is
how the DM-1701 and RT3S enumerate.

`--init-codeplug` belongs to the `dmrconf` backend and has no effect here.

```bash
uv run codeplugger program --radio baofeng_dm32_radiofoundry \
--profile path/to/profile.yml \
--rfoundry-root ../RadioFoundry \
--port /dev/cu.usbserial-2120 --confirm
```

The radio's `capabilities.json` says how to address it:

```json
"radiofoundry_cps": {
"dmrconf_radio_key": "openuv380",
"regions": "codeplug",
"offset": "0x700000"
}
```

| Field | Meaning |
|---|---|
| `dmrconf_radio_key` | qdmr radio key for the encode and decode legs only, never for transport. Required. |
| `regions` | Flash regions `cps_client` moves. The default, `codeplug`, covers channels, zones, contacts and group lists and leaves calibration and the radio's own settings alone. |
| `offset` | Base address of the image on the wire, as a hex string, when the firmware does not map it at zero. The DM-32UV needs `0x700000`. |
| `board` | Board id passed to `cps_client --board`. Omit it to let the client derive one from the radio type. |
| `model` | Substring the radio must report in `cps_client info` before a write. Set it only from a string read off real hardware; only the DM-1701 has one. |
| `block` | Bytes per CPS data request, 1 to 32. Omit it unless a cable cannot hold the default 32-byte block. |

The write gates, in order:

1. `confirm=True`, and a backup path that does not already exist.
2. `cps_client info` must answer, and the reported model must contain `model`
when the entry declares one. The identity read is retried, because the
link is not always awake on the first frame. A radio reporting radio type 6
skips the model check, because 6 is what the firmware sends for any board
that declares no type of its own (the DM-32UV is one), so it identifies
nothing.
3. A full read of the configured regions into the backup, retried across the
post-session reboot.
4. The export is encoded and flattened into the image the CPS wire wants.
5. The write. A serial fault mid-write is retried up to three times; a resumed
attempt only re-sends sectors that still differ. A refusal from the radio
is not retried.
6. A read-back into the read-back path, with the same retry as the backup.
7. `cps_client verify`, a byte-for-byte compare. If it disagrees, the
read-back is decoded with `dmrconf` and compared against the codeplug that
was sent, and only a mismatch there fails the write.

The fallback in step 7 exists because a byte compare flags good writes. On a
DM-1701 whose decoded read-back was identical to the YAML sent, the compare
still reported 8,634 differing bytes: 26 in the VFO A scratch area, which the
radio rewrites, and 8,608 of padding between image sections that is never
sent. The decoded compare checks channel, zone, contact and group-list counts
first; matching counts with differing YAML text still pass, and the output and
the operation log say which of the two it was.

**Hardware-verified 2026-12-01** on both radios that have been tried:

- DM-32UV (`eam_dm32_02`, over a USB-serial programming cable): 279 channels,
30 zones, 23 contacts and 5 group lists written at offset `0x700000`. The
pre-write backup and the read-back were both 1,179,648 bytes, and the
decoded read-back was identical to the codeplug sent.
- DM-1701: the same codeplug shape, with the decoded read-back identical to
the YAML sent line for line. This is the write the byte-compare figures
above come from.

Both ran RadioFoundry at git `62db1bae`. The RT3S entry has not been written
on this firmware. The DM-32's progress bar is not evidence either way: it sat
at 5% long after a read had finished on disk.

When a cabled radio answers nothing, `tools/dm32_cps_probe.py PORT` separates
the two directions of the link. It sends commands that change the radio's
display, so the screen shows whether host-to-radio works without needing a
reply. Run it with the RadioFoundry checkout's interpreter, which has
`pyserial`.

P25, NXDN and Tier III channels are not representable through this path;
RadioFoundry carries them in a YAML block qdmr ignores. `dmrconf verify
--radio=opengd77` checks the exported YAML offline, and RadioFoundry's manual
routes still accept the same file: `tools/dm32_migrate.py restore --yaml FILE`
over the programming cable, or the browser Codeplug Editor.

### Through `dmrconf` instead

The DM-1701 and RT3S entries also keep a `dmrconf` block (key `openuv380`),
because they enumerate as USB `1FC9:0094` and answer qdmr's open-firmware CPS
protocol, with `detect` reporting `Open MD-UV380` as OpenGD77 does. That path
is what first wrote a RadioFoundry radio, on 2026-11-30: a 278-channel,
30-zone write to a DM-1701 through `codeplugger program --port
/dev/cu.usbmodem21101 --confirm`, read back and decoded to the same channels,
zones and TG lists as an offline encode of the sent YAML. The one decoded
difference was contact `timeSlotOverride` reading `None` where qdmr encodes
`TS1`; RadioFoundry's qdmr-yaml spec says that is how it reads a contact
without an `openGD77` block. `codeplugger program` no longer takes this path
for these radios, but the `dmrconf` backend can still be driven directly.

## P4 TOML and `p64tool`

Expand Down
Loading
Loading