This repository contains the firmware for the STM32-based dynamometer project. It
targets the STM32H743IITx microcontroller and uses FreeRTOS for real-time task
management. The project is built with CMake + Ninja and the Arm GNU toolchain
(arm-none-eabi-gcc); code is generated from the .ioc with STM32CubeMX.
Include all submodules when cloning:
git clone --recurse-submodules <repository-url>If you forgot the flag, initialize the submodules afterwards:
git submodule update --init --recursiveYou only need these to build:
| Tool | Purpose | Install (Fedora) | Install (Ubuntu/Debian) |
|---|---|---|---|
| Arm GNU toolchain | Compiler/linker | sudo dnf install arm-none-eabi-gcc-cs arm-none-eabi-newlib |
sudo apt install gcc-arm-none-eabi |
| CMake (≥ 3.22) | Build system | sudo dnf install cmake |
sudo apt install cmake |
| Ninja | Build backend | sudo dnf install ninja-build |
sudo apt install ninja-build |
Additional, only if you need them:
- STM32CubeMX — to regenerate code after editing
stm32_dyno_firmware_v2.ioc(download). Not in apt/dnf; the download requires a free ST (myST) account. - A flashing tool — to program the board. The open-source options
(
stlink,openocd,dfu-util,stm32flash) install from apt/dnf with no account; STM32CubeProgrammer is not available via apt/dnf and requires a free ST account to download. See Flashing the Firmware.
The same commands work on Linux, macOS and Windows:
cmake --preset Debug # configure (use Release for the release build)
cmake --build --preset Debug # build
rm -rf build # cleanPresets (Debug, Release) are defined in CMakePresets.json; the Arm toolchain
file is cmake/gcc-arm-none-eabi.cmake.
Build output is written to build/<CONFIG>/:
stm32_dyno_firmware_v2.elfstm32_dyno_firmware_v2.hexstm32_dyno_firmware_v2.binstm32_dyno_firmware_v2.map
Requires only Docker — no host toolchain. The Dockerfile pins the Arm GNU
toolchain, CMake and Ninja, and CI builds inside this same image:
./Scripts/build-docker.sh # Release (Linux/macOS/Git-Bash)
./Scripts/build-docker.sh Debug.\Scripts\build-docker.ps1 # Release (Windows/PowerShell)
.\Scripts\build-docker.ps1 -Config DebugThe repo is bind-mounted, so output lands in build-docker/<CONFIG>/ on the host
— a separate tree from a native build's build/<CONFIG>/, so the two can coexist.
(On SELinux hosts the shell script adds the required :z mount option
automatically; on Windows, Docker Desktop must be in Linux container mode, which
is the default.)
The toolchain in the .ioc is set to CMake. After editing the design in
STM32CubeMX, click Generate Code to refresh the HAL/driver sources and
cmake/stm32cubemx/CMakeLists.txt. Your edits in the top-level CMakeLists.txt
(and inside USER CODE BEGIN/END blocks) are preserved.
To regenerate headlessly from the command line, drive STM32CubeMX with a script:
printf 'config load %s/stm32_dyno_firmware_v2.ioc\nproject generate\nexit\n' "$PWD" > /tmp/gen.txt
/path/to/STM32CubeMX -q /tmp/gen.txtBuild once, then flash the generated binary — no rebuild needed. Three methods (SWD via ST-Link, USB DFU, or UART) work on Linux and Windows; you pick the method and tool explicitly.
Both scripts default to the Release build, so the pair lines up with no arguments
(pass Debug / -Config Debug to build and flash the Debug image instead).
./Scripts/build-docker.sh # build → build-docker/Release/*.elf,*.bin
./Scripts/flash.sh swd --tool st-flash # flash that image (no rebuild).\Scripts\build-docker.ps1
.\Scripts\flash.ps1 -Method swd -Tool st-flashThe open-source tools (st-flash, openocd, dfu-util, stm32flash) install
from apt/dnf with no account; STM32CubeProgrammer is not in apt/dnf and needs
a free ST account. On Linux, USB access also needs a one-time udev-rule / group
setup.
See Scripts/README.md for the full guide: installing each
tool, choosing among multiple connected probes, device discovery, the CMake
flash targets, and Linux USB permissions.
.github/workflows/build.yml builds both Debug and Release with CMake on every
push/PR and uploads the resulting firmware as workflow artifacts.
- Ensure all submodules are initialized and updated before building.
- The build is IDE-independent. The project can still be opened in STM32CubeIDE 1.15+ via File → Import → Import CMake Project, but that is optional.