This page explains how to update your device firmware using STMicroelectronics STM32CubeProgrammer. Follow the steps carefully. Do not disconnect power or USB during flashing.
.hex file to a known location.:SYST:DFU 42.hexYou can flash the firmware from the command line using STM32CubeProgrammer's CLI tool. Ensure the device is in DFU mode first (see steps above).
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\
$env:Path += ";C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
Permanent (user) PATH:
setx PATH "$env:Path;C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" -c port=USB1 -w "C:\path\to\melexis_io_fw.hex" -v -g
C:\Tools\dfu-util\).
dfu-util --list
arm-none-eabi-objcopy -I ihex -O binary melexis_io_fw.hex melexis_io_fw.bin
srec_cat) to produce .bin.0x08000000 and reset when done:
dfu-util -a 0 -s 0x08000000:leave -D melexis_io_fw.bin
:leave if you do not want the board to reset automatically after programming.If you use EEPROM emulation in sectors 1–3 (0x08004000–0x0800FFFF), avoid erasing or writing those regions. Program only from 0x08010000 upward.
This is the recommended setup when you changed the linker script (FLASH origin at 0x08010000).
dfu-util -a 0 -s 0x08010000:leave -D melexis_io_fw.bin
:mass-erase. If multiple DFU devices are connected, you can select the STM32 DFU with -d 0483:df11.Trim the first 64 KB (sectors 0–3) so you only program the application part at 0x08010000.
Windows PowerShell snippet to create app_only.bin from full.bin:
$in = [System.IO.File]::OpenRead("full.bin")
$out = [System.IO.File]::Create("app_only.bin")
$in.Seek(0x10000, 'Begin') | Out-Null
$in.CopyTo($out)
$out.Close(); $in.Close()
# Flash only the app region
dfu-util -a 0 -s 0x08010000:leave -D .\app_only.bin
0x08000000 and still avoid sectors 1–3.dfu-util from your distribution:
sudo apt install dfu-util · Fedora: sudo dnf install dfu-util · Arch: sudo pacman -S dfu-utildfu-util --list
arm-none-eabi-objcopy -I ihex -O binary melexis_io_fw.hex melexis_io_fw.bin
dfu-util -a 0 -s 0x08000000:leave -D melexis_io_fw.bin
These steps mirror the Windows dfu-util flow; only installation differs. You may need sudo if udev permissions are not configured.
Adjust idProduct if your device reports a different PID than df11 (check with dfu-util --list).
# Create udev rule for STM32 DFU (VID 0483, PID df11)
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="df11", MODE="0666", TAG+="uaccess"' | sudo tee /etc/udev/rules.d/49-st-dfu.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
# Unplug and re-plug the device (or reset to DFU) to apply