Installing dfu-util

This guide explains how to install dfu-util, the utility for programming the flash memory on Particle devices like the Core, Photon, P1 (with USB) and Electron over USB.

It can be used to program both Device OS and application firmware, and save and restore configurations.

If you are using Windows, you can use the Windows CLI Installer to automatically install dfu-util and the CLI rather than using these instructions.

Activating DFU mode (blinking yellow)

In order to use dfu-util, your Particle device must be in DFU mode (blinking yellow).

If your device is in a particularly odd and confused state, sometimes you may need to unplug the power, hold down the SETUP/MODE button, and then plug in USB power. Release SETUP/MODE when blinking yellow.

Select computer operating system:

Using dfu-util

A good command to test dfu-util is the -l (list) command. For a Photon, it returns something like this:

$ dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Deducing device DFU version from functional descriptor length
Found DFU: [2b04:d006] ver=0200, devnum=18, cfg=1, intf=0, path="253-1.1.6", alt=1, name="@DCT Flash   /0x00000000/01*016Kg", serial="00000000010C"
Found DFU: [2b04:d006] ver=0200, devnum=18, cfg=1, intf=0, path="253-1.1.6", alt=0, name="@Internal Flash   /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg", serial="00000000010C"

And for an Electron:

$ dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Deducing device DFU version from functional descriptor length
Found DFU: [2b04:d00a] ver=0200, devnum=18, cfg=1, intf=0, path="253-1.1.6", alt=1, name="@DCT Flash   /0x00000000/01*016Kg", serial="00000000010C"
Found DFU: [2b04:d00a] ver=0200, devnum=18, cfg=1, intf=0, path="253-1.1.6", alt=0, name="@Internal Flash   /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg", serial="00000000010C"

They're nearly identical but you can tell by their USB IDs:

  • [2b04:d000] Core
  • [2b04:d006] Photon
  • [2b04:d008] P1
  • [2b04:d00a] Electron

Updating Device OS versions with dfu-util

Normally it's easier to use the Particle CLI, which calls dfu-util to do the actual work. For example, for the Photon you might use:

particle flash --usb system-part1-0.5.3-photon.bin
particle flash --usb system-part2-0.5.3-photon.bin

This internally will use dfu-util with options like:

dfu-util -d 2b04:d006 -a 0 -s 0x08020000 -D system-part1-0.4.9-photon.bin
dfu-util -d 2b04:d006 -a 0 -s 0x08060000:leave -D system-part2-0.4.9-photon.bin

Note the addresses are different for the Electron; you should refer to the release notes to find the addresses to use for your device and Device OS version.

You will often see this warning in the output from dfu-util. It's normal:

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!

Saving and restoring device private keys

Saving your device private and public keys is useful if you're going to completely erase the configuration. If you don't do this, new keys can be generated but you'll need to update the cloud using particle keys doctor.

Saving keys. Replace d006 with the appropriate value, such as d00a for an Electron:

dfu-util -d 2b04:d006 -a 1 -s 34:1600 -U keys.bin

Restoring keys:

dfu-util -d 2b04:d006 -a 1 -s 34 -D keys.bin