Dynamic Modules (dMOD) bootloader - A minimalistic embedded project for STM32 microcontrollers.
mkdir build
cd build
cmake ..
cmake --build .To build for Renode simulation (useful for automated testing without hardware):
mkdir build
cd build
cmake -DDMBOOT_EMULATION=ON ..
cmake --build .With emulation mode enabled, the workflow targets (install-firmware, connect, monitor-gdb) work similarly to hardware mode but use Renode instead of OpenOCD.
Why Renode? Renode provides excellent STM32F7 Discovery board emulation with complete peripheral support, accurate memory mapping, and full interrupt controller implementation. This enables proper firmware execution and log capture via monitor-gdb, making it ideal for CI testing and verification.
You can optionally embed binary files in ROM during the build:
cmake -DCMAKE_BUILD_TYPE=Debug \
-DTARGET=STM32F746xG \
-DSTARTUP_DMP_FILE=path/to/startup.dmp \
-DUSER_DATA_FILE=path/to/user_data.dat \
-S . -B build
cmake --build buildBuild Parameters:
STARTUP_DMP_FILE(optional) - Path to a startup package file (.dmp) that will be automatically loaded usingDmod_AddPackageBufferat bootUSER_DATA_FILE(optional) - Path to a user data file that will be embedded in ROM, with its address and size available via environment variablesUSER_DATA_ADDRandUSER_DATA_SIZEDMBOOT_EMULATION(optional) - Enable Renode simulation mode instead of hardware mode
Automatic Build-Time Embedding:
modules.dmp- Automatically created and embedded during build if modules are specified inmodules/modules.dmd. This file is loaded beforestartup.dmpat boot time. If no modules are defined, the file won't exist, which is not an error.
All parameters are optional. If not specified, the build will proceed with default settings.
The following targets work in both hardware mode (with OpenOCD) and Renode simulation mode. The workflow is identical regardless of the mode.
Install firmware on the target.
- Hardware mode: Flashes firmware to the microcontroller via OpenOCD
- Renode mode: Copies firmware to a known location for Renode to use
cmake --build . --target install-firmwareConnect to the target and start the debug server.
- Hardware mode: Starts OpenOCD server that allows debugging and monitoring
- Renode mode: Starts Renode with GDB server on port 3333
cmake --build . --target connectKeep this running in one terminal while using other debugging/monitoring tools.
Monitor logs from the firmware in real-time via OpenOCD. This target:
- Automatically builds the
dmlog_monitortool for the host architecture - Extracts the ring buffer address from the firmware's map file
- Runs
dmlog_monitorwith the correct configuration
Usage:
In one terminal, start OpenOCD:
cmake --build . --target connectIn another terminal, start the monitor:
cmake --build . --target monitorThe monitor will display logs from the firmware in real-time. Press Ctrl+C to exit.
Monitor logs from the firmware in real-time via GDB server. This target:
- Automatically builds the
dmlog_monitortool for the host architecture - Extracts the ring buffer address from the firmware's map file
- Runs
dmlog_monitorwith GDB backend configuration
This target works identically in both hardware and Renode modes, as it connects via the GDB protocol.
Usage:
In one terminal, start the debug server:
cmake --build . --target connectIn another terminal, start the monitor using GDB mode:
cmake --build . --target monitor-gdbThe monitor will connect to the GDB server at localhost:3333. Press Ctrl+C to exit.
Note: Both OpenOCD and Renode provide a GDB server on port 3333. The monitor-gdb target connects to this GDB server interface using the GDB Remote Serial Protocol, which is an alternative to using OpenOCD's telnet interface (port 4444) used by the monitor target. Both methods work equally well for monitoring logs.
Start GDB and connect to OpenOCD for debugging.
cmake --build . --target debug