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) <noreply@anthropic.com>
This commit is contained in:
Marcus Kida 2026-07-06 20:02:12 +02:00
parent 9c2b597397
commit c842068896
4 changed files with 48 additions and 17 deletions

View file

@ -7,7 +7,9 @@ single running list until the first versioned release.
## Unreleased ## 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 ## 0.1.0

View file

@ -1,28 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Build the OpenGD77 firmware for the Retevis RT-3S / TYT MD-UV380 in Docker. # Build the FreeTRX firmware in Docker. Nothing is installed on the host: the
# Nothing is installed on the host: the ARM toolchain lives only in the image, # ARM toolchain lives only in the image.
# and the build output lands in MDUV380_firmware/build/OpenMDUV380.bin.
# #
# 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 set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMAGE=opengd77-mduv380-builder 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)" echo "==> Building toolchain image ($IMAGE)"
docker build --platform linux/amd64 -t "$IMAGE" "$REPO_DIR/docker" 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 \ docker run --rm --platform linux/amd64 \
-v "$REPO_DIR":/work \ -v "$REPO_DIR":/work \
"$IMAGE" \ "$IMAGE" \
bash /work/docker/build.sh bash /work/docker/build.sh "$PLATFORM"
echo echo
echo "==> Firmware ready:" echo "==> Firmware ready:"
echo " $REPO_DIR/MDUV380_firmware/build/OpenMDUV380.bin" echo " $REPO_DIR/MDUV380_firmware/build/${OUT}.bin"
echo echo
echo "Flash it (with the radio in firmware-update mode) using:" echo "Flash it (with the radio in firmware-update mode) using:"
echo " ./MDUV380_firmware/tools/opengd77_stm32_firmware_loader.py \\" 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"

View file

@ -1,24 +1,35 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# In-container build script. Runs inside the toolchain image with the repo # In-container build script. Runs inside the toolchain image with the repo
# mounted at /work. Produces MDUV380_firmware/build/OpenMDUV380.bin # mounted at /work. Produces MDUV380_firmware/build/Open<PLATFORM>.bin.
# (the flashable OpenGD77 image for the MD-UV380 / Retevis RT-3S). #
# 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 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 cd /work/MDUV380_firmware
echo "==> Building for $PLATFORM"
echo "==> Preparing codec section (codec_cleaner -C)" echo "==> Preparing codec section (codec_cleaner -C)"
chmod +x tools/codec_cleaner.Linux chmod +x tools/codec_cleaner.Linux
( cd application/source/linkerdata && ../../../tools/codec_cleaner.Linux -C ) ( cd application/source/linkerdata && ../../../tools/codec_cleaner.Linux -C )
echo "==> Building firmware" echo "==> Building firmware"
# Clean build: obj/ lives on the host mount and would otherwise be reused across # 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 rm -rf build
mkdir -p build mkdir -p build
cd build cd build
make -f /work/docker/firmware.mk -j"$(nproc)" make -f /work/docker/firmware.mk PLATFORM="$PLATFORM" -j"$(nproc)"
echo echo
echo "==> Build complete:" echo "==> Build complete:"
ls -l /work/MDUV380_firmware/build/OpenMDUV380.bin ls -l "/work/MDUV380_firmware/build/${OUT}.bin"

View file

@ -15,14 +15,24 @@ CC := $(PREFIX)gcc
OBJCOPY := $(PREFIX)objcopy OBJCOPY := $(PREFIX)objcopy
SIZE := $(PREFIX)size SIZE := $(PREFIX)size
# ---- 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 TARGET := OpenMDUV380
endif
# ---- MCU / FPU ------------------------------------------------------------ # ---- MCU / FPU ------------------------------------------------------------
CPU := -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb CPU := -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
# ---- Preprocessor defines ------------------------------------------------- # ---- Preprocessor defines -------------------------------------------------
# NDEBUG + DEBUG mirrors the STM32CubeIDE "MDUV380_FW" release config exactly. # NDEBUG + DEBUG mirrors the STM32CubeIDE release configs exactly.
DEFS := -DUSE_HAL_DRIVER -DSTM32F405xx -DPLATFORM_MDUV380 -DNDEBUG -DDEBUG DEFS := -DUSE_HAL_DRIVER -DSTM32F405xx $(PLATFORM_DEFS) -DNDEBUG -DDEBUG
# Short git hash if available, otherwise UNKNOWN (matches the .cproject rule). # Short git hash if available, otherwise UNKNOWN (matches the .cproject rule).
GITVERSION := $(shell git -C .. rev-parse --short HEAD 2>/dev/null || echo UNKNOWN) GITVERSION := $(shell git -C .. rev-parse --short HEAD 2>/dev/null || echo UNKNOWN)