.\" This manpage has been automatically generated by docbook2man
.\" from a DocBook document. This tool can be found at:
.\"
.\" Please send any bug reports, improvements, comments, patches,
.\" etc. to Steve Cheng .
.TH "DFU-TOOL" "1" "26 February,2015" "" ""
.SH NAME
dfu-tool \- Device Firmware Upgrade Tool
.SH SYNOPSIS
\fBdfu-tool\fR [ \fB--verbose\fR ] [ \fB--version\fR ] [ \fB--force\fR ] [ \fB--device=VID:PID\fR ] [ \fB--transfer-size=BYTES\fR ]
.SH "DESCRIPTION"
.PP
This manual page documents briefly the \fBdfu-tool\fR command.
.PP
\fBdfu-tool\fR allows a user to write various kinds of
firmware onto devices supporting the USB Device Firmware Upgrade protocol.
This tool can be used to switch the device from the normal runtime mode
to `DFU mode' which allows the user to read and write firmware.
Either the whole device can be written in one operation, or individual
`targets' can be specified with the alternative name or number.
.PP
\fBdfu-tool\fR uses the libdfu shared
library to perform actions.
All synchronous actions can be safely cancelled and on failure will return
errors with both a type and a full textual description.
libdfu supports DFU 1.0, DFU 1.1 and the ST DfuSe vendor extension, and
handles many device `quirks' necessary for the real-world implementations
of DFU\&.
.PP
Additionally \fBdfu-tool\fR can be used to convert firmware
from various different formats, or to modify details about the elements,
images and metadata contained inside the firmware file.
For example, you can easily convert DFU 1.1 firmware into the
vendor-specific DfuSe format, convert a Intel HEX file into a raw file
padded to a specific size, or add new copyright and licensing information
to an existing file.
Fields such as the vendor and product IDs can be changed, and the firmware
elements can be encrypted and decrypted using various different methods.
Merging two DfuSe files together is also possible, although specifying
different alt-setting numbers before merging is a good idea to avoid
confusion.
.PP
Although \fBdfu-tool\fR tries to provide a large number of
easy-to-use commands, it may only be possible to do certain operations
using the libdfu library directly.
This is easier than it sounds, as the library is built with GObject
Introspection support making it usable in many languages such as C,
Javascript and Python.
Furthermore, using the library is a good idea if you want to perform
multiple operations on large firmware files, for instance,
converting from an Intel HEX file, padding to a certain size, setting
vendor and adding licensing information and then saving to a remote
location.
.SH "OPTIONS"
.PP
This program follows the usual GNU command line syntax,
with long options starting with two dashes (-).
A summary of options is included below.
.TP
\fB --help \fR
Show summary of all the commands available for use.
.TP
\fB --version \fR
Show the version of \fBdfu-tool\fR installed.
.TP
\fB --verbose \fR
Show extra debugging information.
.TP
\fB --device=VID:PID \fR
If multiple DFU-capable devices are attached you can specify the
specific vendor and product ID of the DFU device you want to query.
.TP
\fB --transfer-size=BYTES \fR
Manually override the size of each USB transfer, which you may want
for unreliable hardware or when the device lies about the maximum
packet size it accepts.
.TP
\fB --force \fR
Force the operation, disregarding warnings or sanity checks like
file CRC and checksums.
This is useful if you really know what you are doing, or in the
specialised case of fuzz-testing libdfu.
.SH "DEVICE COMMANDS"
.PP
These commands are used to interface with DFU-capable devices.
.TP
\fB list \fR
This command lists currently attached DFU capable devices.
Some devices do not support the official DFU runtime
mode and thus do not support auto-discovery using this command.
For those devices, putting the device into DFU mode manually (e.g. by
holding a button down when rebooting the device) will make it show
up here.
.TP
\fB detach \fR
This command detaches the currently attached DFU capable device into
a special programming mode.
Whilst the device is in this special DFU mode it
can not be used as a normal device.
For example, a printer will not accept documents when in DFU mode.
.TP
\fB attach \fR
This command attaches a DFU capable device back to runtime so it can
be used as a normal device.
Some devices do not support attaching, and need to be manually
disconnected and connected before changing modes.
.TP
\fB watch \fR
This command watches DFU devices being hotplugged and can be used to
verify libdfu matches up the runtime and DFU modes
when attaching and detaching.
Use \fBCTRL+C\fR to make this command quit.
.TP
\fB read FILENAME \fR
This command uploads all the firmware from device into a file.
If the device has multiple partitions exported as different alternative
sections then they will all be read into a multi-image DfuSe-format
file.
If you just want the contents of one partition, \fBread-alt\fR
is the command you want.
.TP
\fB read-alt FILENAME DEVICE-ALT-NAME|DEVICE-ALT-ID \fR
This command uploads firmware from one partition into a file.
You can specify the partition by either the ALT-ID or ALT-NAME if set.
e.g. \fBdfu-tool read-alt backup.dfu SRAM\fR
.TP
\fB write \fR
This command downloads firmware from a file into all possible
partitions of a device.
If you only want to write one partition, \fBwrite-alt\fR
is the command you want.
.TP
\fB write-alt FILENAME DEVICE-ALT-NAME|DEVICE-ALT-ID [IMAGE-ALT-NAME|IMAGE-ALT-ID] \fR
This command downloads firmware from the file into one partition.
You can specify the partition by either the ALT-ID or ALT-NAME if set.
e.g. \fBdfu-tool write-alt sram.dfu SRAM __SRAM\fR
.SH "FIRMWARE COMMANDS"
.PP
These commands are used to read and modify existing firmware files.
.TP
\fB dump FILENAME \fR
This command dumps all know details about a firmware file.
The complete memory map is shown, along with any metadata or vendor
information about the firmware file.
.TP
\fB convert FORMAT FILE-IN FILE-OUT [SIZE] \fR
This command converts the firmware from one format to another, optionally
padding to a certain size.
Possible values for the destination \fBFORMAT\fR include:
raw, ihex,
dfu and dfuse\&.
The \fBFILE-IN\fR and \fBFILE-OUT\fR values can
be the same if the source file is to be overwritten.
Although padding increases the file size with no apparent advantages
it can be used to support devices that do not store the runtime image
size and where validation of the written firmware is required.
e.g. \fBdfu-tool convert dfu firmware.hex firmware.dfu 8000\fR
.TP
\fB encrypt FILENAME-IN FILENAME-OUT TYPE KEY \fR
This command encrypts firmware data.
Only the image contents are actually modified, the DFU footer and
DfuSe header are left unaltered.
Possible values for the destination \fBTYPE\fR include:
xtea and nop\&.
If the \fBKEY\fR is not of the required length it is used
as an input to a hash function which can produce a key of the
required size.
e.g. \fBdfu-tool encrypt firmware.dfu firmware.xdfu xtea deadbeef\fR
.TP
\fB decrypt FILENAME-IN FILENAME-OUT TYPE KEY \fR
This command decrypts firmware data.
Only the image contents are actually modified, the DFU footer and
DfuSe header are left unaltered.
Possible values for the destination \fBTYPE\fR include:
xtea and nop\&.
If the \fBKEY\fR is not of the required length it is used
as an input to a hash function which can produce a key of the
required size.
e.g. \fBdfu-tool decrypt firmware.xdfu firmware.dfu xtea deadbeef\fR
.TP
\fB merge FILE-OUT FILE1 FILE2 [FILE3...] \fR
This command merges multiple firmware files into one file.
Although you can merge files with the same ALT-ID or ALT-NAME this
probably isn't what you want to do.
e.g. \fBdfu-tool merge combined.dfu lib.dfu app.dfu\fR
.TP
\fB set-alt-setting FILE ALT-ID \fR
This command modifies the alternative number on firmware file.
e.g. \fBdfu-tool set-alt-setting firmware.dfu 1\fR
.TP
\fB set-alt-setting-name \fR
This command modifies the alternative name on firmware file.
e.g. \fBdfu-tool set-alt-setting-name firmware.dfu SRAM\fR
.TP
\fB set-metadata FILE KEY VALUE \fR
This command adds or modifies existing metadata on a firmware file.
NOTE: There is only very limited metadata storage space in DFU files,
so keys and values should be kept as short as possible.
In particular, the License value should be
specified in SPDX format.
e.g. \fBdfu-tool set-metadata firmware.dfu Licence GPL-2.0+\fR
.TP
\fB set-vendor FILE VID \fR
This command sets vendor ID on a firmware file that will be used to
match specific devices.
Values of ffff will match any device vendor.
e.g. \fBdfu-tool set-vendor firmware.dfu 273f\fR
.TP
\fB set-product FILE PID \fR
This command sets the product ID on a firmware file that will be used to
match specific devices.
Values of ffff will match any device product.
e.g. \fBdfu-tool set-product firmware.dfu 1004\fR
.TP
\fB set-release FILE RELEASE \fR
This command sets the release version on firmware file that will be used to
match specific devices.
Values of ffff will match any device release.
e.g. \fBdfu-tool set-release firmware.dfu ffff\fR
.SH "AUTHOR"
.PP
This manual page was written by Richard Hughes \&.