Grafito CANStepper

Production firmware is not released yet. These are the two programming paths proven during bring-up; use them to load development or test images linked for flash address 0x08000000.

There are two ways in, and both need the main 24–48 V supply connected. USB-C does not power the board.

PathHardwareUse it for
USB-C DFU (ROM bootloader)A USB-C cableFlashing, with no extra hardware
SWDST-Link V2 (or clone)Debugging, live register access, flashing

Tool support

The STM32H5 is newer than some common open-source tools. Tested:

ToolResultWhy
dfu-util 0.11WorksTalks to the ROM bootloader (USB ID 0483:df11)
pyOCD + Keil STM32H5xx_DFP 2.3.1 packWorksSupports the H5's CPU access port (AP1)
st-flash 1.7.0FailsNo STM32H5 support
OpenOCD 0.11 / 0.12FailsCannot reach the H5 CPU on AP1

USB-C DFU

1. Linux: allow access without root

Add a udev rule for the ROM bootloader (and the ST-Link, if you use SWD too), then reload:

sudo tee /etc/udev/rules.d/49-stm32.rules >/dev/null <<'EOF'
# STM32 ROM bootloader (DFU)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0666"
# ST-Link V2
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"
EOF
sudo udevadm control --reload-rules && sudo udevadm trigger

2. Enter DFU mode

  1. Connect the main supply (24–48 V on CN1 or CN6) and plug in USB-C.
  2. Silence other boards on the CAN bus: reset them, put them in DFU too, or unplug the CAN cable. While another board is transmitting, this board may not enumerate (the ROM bootloader also listens on CAN and can lock onto it before USB).
  3. Hold BOOT, tap RESET, release BOOT.

The board enumerates as "STM Device in DFU Mode". Each board reports its own unique serial number, so a script can tell boards apart:

dfu-util -l

3. Flash

# -a 0 = internal flash; :leave starts the new image when done
dfu-util -a 0 -s 0x08000000:leave -D firmware.bin

With several boards in DFU mode at once, pick one by serial number with -S <serial>.

In DFU mode the ROM bootloader takes over pins PB13/PB14 (the encoder clock and data lines), so the encoder reads all zeros until the chip resets into your firmware.

Wiring

ST-LinkBoard pad
SWCLKSWCLK (CLK)
SWDIOSWDIO (DIO)
GNDGND
RSTNRST
3.3 VNot connected

Do not connect 3V3

The ST-Link cannot supply the board. Wired to 3V3, the chip browns out and shows up as chip ID 0x0000 with random disconnects. Power the board from its main input instead.

pyOCD

python3 -m venv ~/pyocd-venv && . ~/pyocd-venv/bin/activate
pip install pyocd
pyocd pack install stm32h503        # installs the Keil STM32H5xx_DFP pack
pyocd list --targets | grep -i h503 # note the exact target name it prints

pyocd list                          # the ST-Link should appear
pyocd flash -t <target> --base-address 0x08000000 firmware.bin
pyocd gdbserver -t <target>         # for debugging

Replace <target> with the STM32H503CB name from the list --targets output.

A correctly wired, powered board reports device ID 0x474. A brand-new board has blank flash with readout protection off.

If pyOCD reports "Get IDCODE error", the ST-Link itself is usually stuck: unplug and replug it.

On this page