Commit graph

54 commits

Author SHA1 Message Date
Marcus Kida
0867742901 Fix DMR hang: call AMBE codec via C function pointers, not inline asm
The radio hard-froze (needs battery pull) the instant it processed an incoming
DMR frame — repeater reply, or noise on a DMR channel. FM and DMR TX-without-a-
listening-repeater were fine. Cause: codec_interface.c invoked the AMBE codec
through hand-written inline assembler with no operands and no clobber list,
branching (BL) to an absolute address. That code's correctness depends entirely
on a specific compiler's register allocation; modern GNU toolchains (both ARM
GCC 10 and 14) miscompile it, corrupting state on the first codec call.

Port the official R20260504 (git ebd7100) rework: replace all five inline-asm
calls (2x decode, 2x encode, 1x ECC) with C function-pointer calls. Each call
reproduces the exact register/stack layout the assembler set up (AAPCS: args
1-4 -> r0-r3, args 5+ -> stack) and sets the Thumb bit on the target address.
Also drop the trailing semicolons from the AMBE_* address macros in codec.h so
they can be used in C expressions.

Builds cleanly with the GCC 14.2 Docker toolchain (no STM32CubeIDE needed) and
DMR RX/TX now works on the radio.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 11:14:06 +02:00
Marcus Kida
0d8a293199 Dockerize build fixes: GCC 14 toolchain, clean build, flash helper
Bring the headless Docker build closer to the official OpenGD77 build and
add a flashing helper.

docker/Dockerfile
  - Replace Ubuntu's stock gcc-arm-none-eabi (GCC 10.3.1) with the Arm GNU
    Toolchain 14.2.rel1 (GCC 14). The official firmware is built with GCC 14
    (gnu-tools-for-stm32 14.3); GCC 10 produced a firmware that hard-faults on
    the DMR path. Guard the image build to fail if the compiler is not GCC 14.
  - git config --system safe.directory '*' so the build stamps a real GitID
    instead of #UNKNOWN.

docker/build.sh
  - rm -rf build before compiling. obj/ lives on the host mount and was being
    reused across toolchain changes, silently relinking stale .o files (an
    earlier rebuild produced a byte-identical GCC-10 image because of this).

docker/firmware.mk
  - Add -DNDEBUG to exactly mirror the STM32CubeIDE "MDUV380_FW" release config
    (which defines both NDEBUG and DEBUG).

flash.sh
  - Helper to flash via opengd77_stm32_firmware_loader.py with model, secondary
    language (auto-builds the .gla files) and the DMR codec donor.

.gitignore
  - Ignore generated *.gla files and the host-side languages_builder binary.

Note: the GCC 14 rebuild did NOT resolve the DMR-receive hang; that fault is in
the firmware source revision (this tree is a snapshot; the known-good build is
commit ebd7100, not present here) and is out of scope of these build changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 10:29:48 +02:00
Marcus Kida
6714da6e00 Dockerize build 2026-07-06 08:48:59 +02:00
Marcus Kida
01467e5913 Initial Commit 2026-07-06 08:45:33 +02:00