From c84206889614e29d003649ae06168cd67a51cf56 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Mon, 6 Jul 2026 20:02:12 +0200 Subject: [PATCH] Build: parameterize by platform, add DM-1701 (RT-84) target ./build-firmware.sh DM1701 builds OpenDM1701.bin with PLATFORM_RT84_DM1701 + PLATFORM_VARIANT_DM1701 (vs PLATFORM_MDUV380). Same firmware source, same GCC 14 toolchain and codec placement. Not officially tested on DM-1701 hardware yet. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 4 +++- build-firmware.sh | 24 ++++++++++++++++-------- docker/build.sh | 21 ++++++++++++++++----- docker/firmware.mk | 16 +++++++++++++--- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73c8c17..c14475c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ single running list until the first versioned release. ## Unreleased -_Nothing yet._ +- **DM-1701 build support** — the Docker build is now parameterized by platform; + `./build-firmware.sh DM1701` produces `OpenDM1701.bin` (Baofeng DM-1701 / + Retevis RT-84). Not officially tested yet. ## 0.1.0 diff --git a/build-firmware.sh b/build-firmware.sh index c8fe8b9..4bac525 100755 --- a/build-firmware.sh +++ b/build-firmware.sh @@ -1,28 +1,36 @@ #!/usr/bin/env bash # -# Build the OpenGD77 firmware for the Retevis RT-3S / TYT MD-UV380 in Docker. -# Nothing is installed on the host: the ARM toolchain lives only in the image, -# and the build output lands in MDUV380_firmware/build/OpenMDUV380.bin. +# Build the FreeTRX firmware in Docker. Nothing is installed on the host: the +# ARM toolchain lives only in the image. # -# Usage: ./build-firmware.sh +# Usage: ./build-firmware.sh [MDUV380|DM1701] (default: MDUV380) +# MDUV380 -> TYT MD-UV380 / Retevis RT-3S -> MDUV380_firmware/build/OpenMDUV380.bin +# DM1701 -> Baofeng DM-1701 / Retevis RT-84 -> MDUV380_firmware/build/OpenDM1701.bin set -euo pipefail REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" IMAGE=opengd77-mduv380-builder +PLATFORM="${1:-MDUV380}" +case "$PLATFORM" in + MDUV380) OUT="OpenMDUV380"; MODEL="MD-UV380" ;; + DM1701) OUT="OpenDM1701"; MODEL="DM-1701" ;; + *) echo "Unknown platform '$PLATFORM' (use MDUV380 or DM1701)"; exit 1 ;; +esac + echo "==> Building toolchain image ($IMAGE)" docker build --platform linux/amd64 -t "$IMAGE" "$REPO_DIR/docker" -echo "==> Running build in container" +echo "==> Running build in container ($PLATFORM)" docker run --rm --platform linux/amd64 \ -v "$REPO_DIR":/work \ "$IMAGE" \ - bash /work/docker/build.sh + bash /work/docker/build.sh "$PLATFORM" echo echo "==> Firmware ready:" -echo " $REPO_DIR/MDUV380_firmware/build/OpenMDUV380.bin" +echo " $REPO_DIR/MDUV380_firmware/build/${OUT}.bin" echo echo "Flash it (with the radio in firmware-update mode) using:" echo " ./MDUV380_firmware/tools/opengd77_stm32_firmware_loader.py \\" -echo " -m MD-UV380 -f MDUV380_firmware/build/OpenMDUV380.bin" +echo " -m ${MODEL} -f MDUV380_firmware/build/${OUT}.bin" diff --git a/docker/build.sh b/docker/build.sh index 951d9c5..99730a0 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -1,24 +1,35 @@ #!/usr/bin/env bash # # In-container build script. Runs inside the toolchain image with the repo -# mounted at /work. Produces MDUV380_firmware/build/OpenMDUV380.bin -# (the flashable OpenGD77 image for the MD-UV380 / Retevis RT-3S). +# mounted at /work. Produces MDUV380_firmware/build/Open.bin. +# +# Usage: build.sh [MDUV380|DM1701] (default: MDUV380) +# MDUV380 -> TYT MD-UV380 / Retevis RT-3S -> OpenMDUV380.bin +# DM1701 -> Baofeng DM-1701 / Retevis RT-84 -> OpenDM1701.bin set -euo pipefail +PLATFORM="${1:-MDUV380}" +case "$PLATFORM" in + MDUV380) OUT="OpenMDUV380" ;; + DM1701) OUT="OpenDM1701" ;; + *) echo "Unknown platform '$PLATFORM' (use MDUV380 or DM1701)"; exit 1 ;; +esac + cd /work/MDUV380_firmware +echo "==> Building for $PLATFORM" echo "==> Preparing codec section (codec_cleaner -C)" chmod +x tools/codec_cleaner.Linux ( cd application/source/linkerdata && ../../../tools/codec_cleaner.Linux -C ) echo "==> Building firmware" # Clean build: obj/ lives on the host mount and would otherwise be reused across -# toolchain changes, silently relinking stale .o files (e.g. an old GCC build). +# toolchain/platform changes, silently relinking stale .o files. rm -rf build mkdir -p build cd build -make -f /work/docker/firmware.mk -j"$(nproc)" +make -f /work/docker/firmware.mk PLATFORM="$PLATFORM" -j"$(nproc)" echo echo "==> Build complete:" -ls -l /work/MDUV380_firmware/build/OpenMDUV380.bin +ls -l "/work/MDUV380_firmware/build/${OUT}.bin" diff --git a/docker/firmware.mk b/docker/firmware.mk index b2ac72c..9f90930 100644 --- a/docker/firmware.mk +++ b/docker/firmware.mk @@ -15,14 +15,24 @@ CC := $(PREFIX)gcc OBJCOPY := $(PREFIX)objcopy SIZE := $(PREFIX)size -TARGET := OpenMDUV380 +# ---- Platform selection --------------------------------------------------- +# PLATFORM=MDUV380 (default) -> TYT MD-UV380 / Retevis RT-3S +# PLATFORM=DM1701 -> Baofeng DM-1701 / Retevis RT-84 +PLATFORM ?= MDUV380 +ifeq ($(PLATFORM),DM1701) +PLATFORM_DEFS := -DPLATFORM_RT84_DM1701 -DPLATFORM_VARIANT_DM1701 +TARGET := OpenDM1701 +else +PLATFORM_DEFS := -DPLATFORM_MDUV380 +TARGET := OpenMDUV380 +endif # ---- MCU / FPU ------------------------------------------------------------ CPU := -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb # ---- Preprocessor defines ------------------------------------------------- -# NDEBUG + DEBUG mirrors the STM32CubeIDE "MDUV380_FW" release config exactly. -DEFS := -DUSE_HAL_DRIVER -DSTM32F405xx -DPLATFORM_MDUV380 -DNDEBUG -DDEBUG +# NDEBUG + DEBUG mirrors the STM32CubeIDE release configs exactly. +DEFS := -DUSE_HAL_DRIVER -DSTM32F405xx $(PLATFORM_DEFS) -DNDEBUG -DDEBUG # Short git hash if available, otherwise UNKNOWN (matches the .cproject rule). GITVERSION := $(shell git -C .. rev-parse --short HEAD 2>/dev/null || echo UNKNOWN)