8000 GitHub - nsnw/uv-k5-minimal: Minimal firmware for the Quansheng UV-K5 · GitHub
[go: up one dir, main page]

Skip to content

About

Minimal firmware for the Quansheng UV-K5

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

uv-k5-minimal

A small, from-scratch receive-only firmware for the Quansheng UV-K5 (DP32G030 MCU, BK4819 transceiver), at about 11 KB. The low-level drivers come from the open UV-K5 firmware projects (see Credits); everything above them is new (mostly written by Claude: see Yes, an AI wrote this) and kept deliberately small, so you can read and change the whole thing. It's meant as a clean starting point for your own firmware: uv-k5-aprs (APRSK5) grew out of it.

Warning

  • Back up your EEPROM first (k5 backup eeprom.bin while the stock firmware is running). This firmware keeps its settings at 0x0000, over the start of the stock channel memory. Factory calibration (0x1E00–0x1FFF) is only read.
  • It never transmits. PTT is a monitor button.
  • Tested on one UV-K5 (DP32G030, BK4819, bootloader 2.00.06). Other variants haven't been tried.

What it does

  • Single VFO, 18–630 MHz and 840–1300 MHz (the BK4819's tuning range)
  • FM / AM / USB, 25 / 12.5 / 6.25 kHz filters
  • Squelch 0–9 using the radio's factory calibration
  • RSSI in dBm with a bar graph, battery voltage, a modulation icon
  • Settings saved to EEPROM 3 s after the last change
  • A debug console on the programming cable (38400 8N1): read and write BK4819 registers, tune, and watch interrupts, which is handy for experiments

Keys

Key Action
0–9 Type a frequency. The first 3 digits are MHz: 1 4 5 5 = 145.5 MHz. Entry finishes after 5 decimal digits, or on MENU.
* while typing Place the decimal point yourself: 1 2 9 6 * 5 = 1296.5 MHz, 2 7 * 1 8 5 = 27.185 MHz
MENU Confirm typed frequency, otherwise cycle the tuning step
EXIT Delete the last typed character (hold to cancel)
UP / DOWN Tune one step (hold to repeat)
* Cycle FM → AM → USB
F Cycle filter 25k → 12.5k → 6.25k
Side 1 / Side 2 Squelch down / up
PTT Monitor: open the squelch while held

The volume knob is analogue, so there is no software volume.

Building

Needs Docker (Colima, Rancher Desktop or Docker Desktop all work).

./build.sh                         # uses the current docker context
DOCKER_CONTEXT=colima ./build.sh   # or pick one
./build.sh clean

Output goes to build/:

  • k5-minimal.packed.bin: flash this with any UV-K5 flasher (web flashers, k5prog, uvtools)
  • k5-minimal.bin: raw image
  • k5-minimal.elf and .map: for debugging

With a native arm-none-eabi-gcc and python3 -m pip install crcmod, plain make works too. The version number is set in the Makefile.

Flashing and other tools

The k5 command-line tool flashes firmware, backs up the EEPROM and talks to the debug console. See tools/README.md:

python3 -m venv .venv && .venv/bin/pip install -e tools
.venv/bin/k5 backup eeprom.bin   # with the stock firmware running
.venv/bin/k5 flash               # bootloader mode: hold PTT while switching on
.venv/bin/k5 console             # talk to the running firmware

Layout

startup/   reset vector, .data/.bss init         (upstream)
bsp/       DP32G030 register headers              (upstream)
driver/    BK4819, LCD, keypad, EEPROM, SPI, I2C   (upstream, trimmed)
src/
  main.c      boot + 10 ms tick loop
  board.c     pin muxing, backlight, audio amp, PTT  (upstream sequence)
  radio.c     BK4819 receive setup and squelch handling
  app.c       key handling and screen
  input.c     key debounce / long-press / repeat
  gfx.c       text and big-digit drawing
  icons.c     status line icons
  battery.c   battery voltage
  console.c   debug console on the programming cable
  settings.c  EEPROM settings (own layout)
  font.c      font tables                          (upstream)
tools/       the k5 command-line tool, firmware packer

Hardware notes

  • The MCU runs at 48 MHz with 60 KB of flash available to the firmware and 16 KB of RAM.
  • The BK4819 demodulates on-chip. Demodulated audio goes straight to the speaker amplifier, and the MCU's ADC is only wired to battery voltage and current. So software decoding of audio-band data (APRS, ACARS, …) needs either the BK4819's built-in FSK modem or a hardware mod.
  • Below 280 MHz the BK4819 routes through the VHF LNA, above it through the UHF LNA (BK4819_PickRXFilterPathBasedOnFrequency).

Yes, an AI wrote this

Most of this firmware was written by Claude (Anthropic's AI) working in Claude Code, with me (Andy, VE6LY) choosing what it should do, testing every build on a real radio and on the air, and deciding what stayed. The design calls and the bugs found the hard way are mine; most of the typing isn't.

If you're about to open an issue or post a comment complaining that it's AI-written: don't bother. That kind of complaint will be mocked and then ignored as tedious bullshit. Bug reports, fixes and good ideas are welcome, whoever or whatever wrote them.

Credits

This firmware stands on the work of the UV-K5 firmware community. The drivers, start-up code, register definitions and firmware packer come from these Apache-2.0 projects; NOTICE lists exactly what was taken.

  • DualTachyon: the open re-implementation of the UV-K5 firmware that made all of this possible (uv-k5-firmware)
  • OneOfEleven, egzumer and armel (F4HWN): the custom firmware forks (OneOfEleven, egzumer, armel)
  • sq5bpf: k5prog, which documented the bootloader and EEPROM protocol the k5 tool speaks
  • ARM: CMSIS 5 headers (Apache-2.0), in external/CMSIS/

References

There's no public datasheet for the DP32G030 or a complete one for the BK4819; the upstream firmware sources (credited above) are the best documentation of both, and the driver headers here keep their register notes.

See also

  • uv-k5-aprs (APRSK5): an APRS station firmware built on this one, with receive, beacon, digipeater, messaging and a KISS TNC.

Licence

Apache License 2.0: see LICENSE and NOTICE. Copyright 2026 Andy Smith, VE6LY.

About

Minimal firmware for the Quansheng UV-K5

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0