Your stepper, seen as a smart servo: Zephyr RTOS firmware that turns a stepper motor and an STM32 board into a joint that answers as a DYNAMIXEL XM430-W350.
Zephyr RTOS 4.5 · DYNAMIXEL Protocol 2.0 · 20 kHz current control · MCUboot · Tested on a PC
Documentation · PDF manual · Getting started · Hardware and wiring
Doppelstep is open-source Zephyr RTOS firmware for the STMicroelectronics B-G431B-ESC1
motor-control board. It drives a two-phase stepper motor with closed-loop microstepping
current control and answers on the bus as a DYNAMIXEL XM430-W350 (model 1020) in
position, extended position and velocity mode. Software written for the servo, such as the
DynamixelSDK under the ROS 2 dynamixel_hardware_interface of an OpenMANIPULATOR-X robot arm,
drives it without changes. The same firmware runs on a PC with a
physical model of the motor, so protocol, motion and protection are tested on every change
before they reach the hardware.
A second board is in development: the Stepper Motor FOC Closed-Loop Driver of Awesome-SMT-Machine, with two full H-bridges (TI DRV8412) and an MA730 magnetic encoder that measures the position of the joint (Supported boards).
| Servo emulation | The complete Control Table of an XM430-W350, checked as the real servo checks it; position, extended position and velocity mode; Sync/Bulk and Fast Sync/Bulk Read, Bus Watchdog, Reboot, Factory Reset; EEPROM area in flash |
| Motor control | Stepper-C: current loop at 20 kHz in a zero-latency interrupt, motion profiles at 1 kHz, 16 microsteps per full step |
| Protection | Comparators switch the gates off through the timer break input within 0.5 µs; overcurrent, bus voltage and leg faults inside the 20 kHz interrupt; a self-test of the bridge and the wiring before the first Torque Enable; temperature and watchdog |
| Zephyr drivers | A power_stage driver class with one backend per MCU family, the motor behind Zephyr's stepper / stepper_ctrl APIs, the servo as a child node of its UART, an out-of-tree board; layer rules checked in CI |
| Firmware update | MCUboot with an RSA-2048 signature check; serial recovery over the DYNAMIXEL bus itself |
| Simulation | The plant model of Stepper-Lab with power stage values from ngspice, on the PC (native_sim) or on the board |
| Bench GUI | Motion with live plots and CSV recording, the whole Control Table, the SIL test scenarios on the board with an HTML report, firmware update |
Measured with the CI build of this version:
| Board | B-G431B-ESC1: STM32G431CB, Cortex-M4F, 170 MHz, 128 KiB flash, 32 KiB RAM |
| Application | 73 808 B flash of the 87 712 B slot, 17 768 B RAM (simulated motor: 75 780 B); full-bridge board 76 676 B, 18 152 B RAM |
| Bootloader | MCUboot, 37 148 B flash |
| Tests per CI run | 258: 211 ztest cases in 13 configurations, 37 SIL and integration tests, 10 fixed-point motion tests (plus 45 host tests of the GUI) |
Comparison, pinouts and how to add a board: Supported boards.
| Board | Power stage | Encoder | Status |
|---|---|---|---|
STMicroelectronics B-G431B-ESC1 (b_g431b_esc1) |
Three half-bridges, shared-leg topology | None | Checked with a real motor at 12 V and 24 V |
Stepper Motor FOC Closed-Loop Driver of Awesome-SMT-Machine (sfs_doppelstep_full_bridge) |
TI DRV8412, two full H-bridges | MA730 on SPI2 | Built and tested in CI; the run on the board is next |
The second board comes from the open-source pick-and-place machine of Ziyang Zhong and Ziming Xian: Ziming Xian designed the PCB, Ziyang Zhong did the software bring-up. It carries an STM32G431CBU6, a DRV8412, an MA730 magnetic encoder, WS2812B LEDs and a CAN transceiver on a 4-layer PCB on the back of a NEMA 17 motor. It is not the final hardware of Doppelstep, but a good starting point: the same MCU as the B-G431B-ESC1, plus an encoder on the motor shaft. Doppelstep uses its DRV8412, current sensing, encoder, one status LED and USART3 for the DYNAMIXEL bus; the CAN bus is not used. The authors welcome fabricating the board for early-stage validation. Do not use it for commercial purposes, a company demo included, without discussing it with both of them first. The requirements for a dedicated Doppelstep PCB are collected in Hardware development.
| Drop-in for the host | The host sees an XM430-W350, not a stepper. An integration test drives the firmware with the official DynamixelSDK, the library under the ROS 2 driver, in the control loop of ros2_control: Sync Read and Sync Write at 100 Hz. DYNAMIXEL emulation |
| Real-time motor control | Closed-loop microstepping current control in a 20 kHz zero-latency interrupt; a fault switches the outputs off inside that interrupt. Architecture |
| Tested before hardware | The same firmware runs on a PC with the motor model of Stepper-Lab and power stage values from ngspice: 258 automated tests on every CI run. Simulated motor |
| Real Zephyr engineering | Own driver class for the power stage, the motor behind Zephyr's stepper / stepper_ctrl APIs, an out-of-tree board, devicetree bindings, layer rules enforced in CI. Porting to a new MCU family |
| Field update over the servo bus | MCUboot serial recovery with an RSA-2048 signature; the bench GUI verifies the uploaded image by its hash. Firmware update |
| Reproducible anywhere | Pinned versions, a Docker image published for CI and GitHub Codespaces, a Dev Container, and the same VS Code tasks on Windows and Linux. Development environment |
Doppelstep 0.4.0 drives a real motor and works with DYNAMIXEL Wizard 2.0: checked on the B-G431B-ESC1 with a 17HS19-2004S1 at 12 V and 24 V. The second board (DRV8412, MA730 encoder) is built and tested in CI; its run on hardware is next. Before that, every change runs on the PC against the simulated motor. Changes per release are in CHANGELOG.md; the open items are listed in Status and known limits.
- XM430-W350 emulation over Protocol 2.0, mapped onto the motor
- Checked with DYNAMIXEL Wizard 2.0 at the factory 57600 bps: scan, Dashboard in position, extended position and velocity mode, Limit Settings, Control Table (screenshots)
- Factory values of the Control Table from the devicetree of the board and motor; firmware version from git in Model Information
- Closed-loop microstepping current control with protection in the interrupt
- Protection of the bridge and the motor: hardware comparators, self-test before the first Torque Enable, current offset and bus voltage checks
- SIL and integration tests on
native_sim, CI in a published environment image - MCUboot with serial recovery over the bus; bench GUI
- Documentation website and PDF manual
- Dead time of the power stage: 1200 ns, from an ngspice sweep with the MB1419 gate circuit
- Effective dead time and current at rest measured on the board without a current probe: 1.05 µs at 24 V, 1.4 µs at 12 V; ripple below the ADC resolution (Measurements with MCUViewer)
- Dead time measured on the board with an oscilloscope (bring-up step 1)
- Checked on the board with the simulated motor: all 20 GUI test scenarios, fast loop 37 µs of 50 µs, watchdog, firmware update over the bus
- Checked with a real motor (17HS19-2004S1, 12 V and 24 V): all 20 GUI test scenarios in three runs, hardware comparators, 2 minutes of moves at 1.5 A
- Self-test on the board: no supply, open coil, no motor, coil on the wrong legs, swapped coils (test record)
- Rest of the hardware checklist with the motor: vibration at rest (check 16)
- Lost steps reported, with an encoder (Overload Error; simulated encoder in the SIL tests)
- PWM Limit applied (a duty limit in Stepper-C)
- Position regulator with an encoder (Position P Gain); Velocity PI and Position I/D not applied
- Temperature sensor (power stage NTC) and overheating trip
- Single-wire TTL bus shared with real DYNAMIXEL servos
- Second board with two full H-bridges (TI DRV8412, docs): power stage backend, MA730 encoder and WS2812B status LED drivers built in CI, measured Present Position, lost steps and position regulator from the encoder (docs); the run on hardware to follow
No hardware needed. In the browser:
bash scripts/run-tests.sh # firmware on native_sim + 32 SIL and integration testsOr on your PC, with Docker and Git:
git clone https://github.com/SystemFromScratch/sfs-doppelstep.git doppelstep
cd doppelstep
docker compose build # toolchain image
docker compose run --rm zephyr bash scripts/west-init.sh # Zephyr and the libraries
docker compose run --rm zephyr bash scripts/run-tests.sh # firmware + SIL and integration testsThen run the simulated servo and move it from the PC, the way a robot controller would:
docker compose run --rm zephyr west build -b native_sim/native/64 -s app -d build-native
docker compose run --rm -p 5555:5555 zephyr python3 tools/sim/run_native.py run --tcp 5555
python tools/sim/dxl_smoke_test.py --tcp localhost:5555 # second terminalEvery release carries the
board images, built and tested by the release pipeline: …-merged.hex (MCUboot and the
application) for the first flashing through the ST-LINK, the signed …-app.signed.bin for an
update over the bus with the GUI, the same pair with the simulated motor (…-sim-motor.*), the
PDF manual and SHA256SUMS. The images are signed with the public development key of
MCUboot: for a product, build from source with your own key
(Firmware update).
| Target | Command |
|---|---|
| Board, real motor | west build -p always --sysbuild -b b_g431b_esc1 -s app -d build |
| Full-bridge board (DRV8412) | west build -p always --sysbuild -b sfs_doppelstep_full_bridge -s app -d build-fb |
| Board, simulated motor | the same, plus -- -DEXTRA_DTC_OVERLAY_FILE=sim.overlay |
PC (native_sim) |
west build -b native_sim/native/64 -s app -d build-native |
| Flash MCUboot and the signed application | west flash -d build -r openocd |
Run west in the container (docker compose run --rm zephyr …), in the Dev Container or in
a codespace; the VS Code tasks do the same on Windows and Linux. Before a real motor turns,
wire it as shown in
Hardware and bring-up
and follow its bring-up checklist.
app/ Zephyr application: threads, queues, register mapping, board overlays
drivers/ power_stage/ (STM32, simulation), motor/ (Stepper-C), x430/ (servo),
ma730/ (encoder), ws2812/ (status LED)
include/, dts/ public driver APIs, devicetree bindings
boards/ out-of-tree boards: B-G431B-ESC1, full-bridge board (DRV8412)
modules/ build glue of Stepper-C, the X430 emulator and Stepper-Lab
tests/ ztest suites, pytest SIL and integration tests
tools/ bench GUI, native_sim launcher, documentation tools
scripts/ CI, tests, layer check, release packaging, host GDB servers
docs/ documentation website and PDF manual sources
west.yml pinned Zephyr and libraries
CHANGELOG.md changes of every release
The website at systemfromscratch.github.io/sfs-doppelstep covers the idea and the technology stack, the hardware with the motor wiring, the DYNAMIXEL emulation, configuration, architecture, the simulated motor, firmware update, porting, the development environment, tests and the bench GUI. The same content is available as a printable PDF manual.
python -m pip install -r requirements.txt
mkdocs serve # live preview
python tools/docs/build_manual.py # PDF manual
python tools/docs/diagrams.py # regenerate the diagramsAnton Vynohradov — Embedded Systems Engineer, Secure Product Architect, founder of SystemFromScratch®: secure embedded systems and compliance-ready engineering, from concept to certification-ready product. systemfromscratch.com · GitHub · LinkedIn · ORCID · contact@systemfromscratch.com
Need firmware like this for your product, Zephyr drivers, a bootloader or CRA readiness? Get in touch.
Many thanks to Ziyang Zhong (baoqi-zhong) and Ziming Xian (ZimingXian), the authors of Awesome-SMT-Machine. Ziming Xian designed the Stepper Motor FOC Closed-Loop Driver and Ziyang Zhong brought up its software. Thanks to both of them for publishing it with its schematic, for agreeing that Doppelstep references their project, and for their support and advice. Their board gave Doppelstep a closed-loop platform with an encoder from the start. Have a look at their pick-and-place machine as well.
Issues and pull requests are welcome, measurements from a real B-G431B-ESC1 especially. A
change must keep the builds free of warnings, pass the layer check and all tests
(scripts/ci.sh) and keep the documentation in sync. See CONTRIBUTING.md;
security issues: SECURITY.md.
Copyright © 2026 Anton Vynohradov. Licensed under the Apache License 2.0. Zephyr RTOS, MCUboot, the libraries and the tools Doppelstep uses come under their own licenses (License).
SystemFromScratch® is a registered trademark. The Apache License 2.0 grants no rights to use the SystemFromScratch® name or logo; they may not be used to endorse or promote products derived from Doppelstep without prior written permission. DYNAMIXEL and ROBOTIS are trademarks of ROBOTIS Co., Ltd.; STM32 is a registered trademark of STMicroelectronics International N.V. Doppelstep is not affiliated with or endorsed by them.
- Documentation and PDF manual
- Stepper-C, DXL2-C, Stepper-Lab and the DYNAMIXEL X430 Control Table Emulator (no documentation website yet)
- Zephyr RTOS and MCUboot
- DYNAMIXEL Protocol 2.0 and the XM430-W350 Control Table